Commit 0fba999f authored by Antti Palosaari's avatar Antti Palosaari Committed by Mauro Carvalho Chehab

[media] dvb_usb_v2: I2C adapter cleanup changes

Signed-off-by: default avatarAntti Palosaari <crope@iki.fi>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 77f54517
...@@ -70,10 +70,12 @@ int dvb_usbv2_download_firmware(struct dvb_usb_device *d) ...@@ -70,10 +70,12 @@ int dvb_usbv2_download_firmware(struct dvb_usb_device *d)
int dvb_usbv2_i2c_init(struct dvb_usb_device *d) int dvb_usbv2_i2c_init(struct dvb_usb_device *d)
{ {
int ret = 0; int ret;
if (!d->props.i2c_algo) if (!d->props.i2c_algo) {
return 0; ret = 0;
goto err;
}
strlcpy(d->i2c_adap.name, d->name, sizeof(d->i2c_adap.name)); strlcpy(d->i2c_adap.name, d->name, sizeof(d->i2c_adap.name));
d->i2c_adap.algo = d->props.i2c_algo; d->i2c_adap.algo = d->props.i2c_algo;
...@@ -83,11 +85,16 @@ int dvb_usbv2_i2c_init(struct dvb_usb_device *d) ...@@ -83,11 +85,16 @@ int dvb_usbv2_i2c_init(struct dvb_usb_device *d)
i2c_set_adapdata(&d->i2c_adap, d); i2c_set_adapdata(&d->i2c_adap, d);
ret = i2c_add_adapter(&d->i2c_adap); ret = i2c_add_adapter(&d->i2c_adap);
if (ret < 0) if (ret < 0) {
pr_err("%s: could not add i2c adapter\n", KBUILD_MODNAME); pr_err("%s: i2c_add_adapter() failed\n", KBUILD_MODNAME);
goto err;
}
d->state |= DVB_USB_STATE_I2C; d->state |= DVB_USB_STATE_I2C;
return 0;
err:
pr_debug("%s: failed=%d\n", __func__, ret);
return ret; return ret;
} }
...@@ -95,7 +102,9 @@ int dvb_usbv2_i2c_exit(struct dvb_usb_device *d) ...@@ -95,7 +102,9 @@ int dvb_usbv2_i2c_exit(struct dvb_usb_device *d)
{ {
if (d->state & DVB_USB_STATE_I2C) if (d->state & DVB_USB_STATE_I2C)
i2c_del_adapter(&d->i2c_adap); i2c_del_adapter(&d->i2c_adap);
d->state &= ~DVB_USB_STATE_I2C; d->state &= ~DVB_USB_STATE_I2C;
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment