Skip to content

Commit

Permalink
[media] dvb_usb_v2: I2C adapter cleanup changes
Browse files Browse the repository at this point in the history
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Antti Palosaari authored and Mauro Carvalho Chehab committed Aug 4, 2012
1 parent 77f5451 commit 0fba999
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions drivers/media/dvb/dvb-usb/dvb_usb_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 ret = 0;
int ret;

if (!d->props.i2c_algo)
return 0;
if (!d->props.i2c_algo) {
ret = 0;
goto err;
}

strlcpy(d->i2c_adap.name, d->name, sizeof(d->i2c_adap.name));
d->i2c_adap.algo = d->props.i2c_algo;
Expand All @@ -83,19 +85,26 @@ int dvb_usbv2_i2c_init(struct dvb_usb_device *d)
i2c_set_adapdata(&d->i2c_adap, d);

ret = i2c_add_adapter(&d->i2c_adap);
if (ret < 0)
pr_err("%s: could not add i2c adapter\n", KBUILD_MODNAME);
if (ret < 0) {
pr_err("%s: i2c_add_adapter() failed\n", KBUILD_MODNAME);
goto err;
}

d->state |= DVB_USB_STATE_I2C;

return 0;
err:
pr_debug("%s: failed=%d\n", __func__, ret);
return ret;
}

int dvb_usbv2_i2c_exit(struct dvb_usb_device *d)
{
if (d->state & DVB_USB_STATE_I2C)
i2c_del_adapter(&d->i2c_adap);

d->state &= ~DVB_USB_STATE_I2C;

return 0;
}

Expand Down

0 comments on commit 0fba999

Please sign in to comment.