diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index 26f03a14a478..eb26a5add57c 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -462,7 +462,7 @@ static void i2c_device_shutdown(struct device *dev) static void i2c_client_dev_release(struct device *dev) { - kfree(to_i2c_client(dev)); + i2c_unregister_device(to_i2c_client(dev)); } static ssize_t @@ -1527,7 +1527,6 @@ void i2c_del_adapter(struct i2c_adapter *adap) dev_dbg(&adap->dev, "Removing %s at 0x%x\n", client->name, client->addr); list_del(&client->detected); - i2c_unregister_device(client); } mutex_unlock(&adap->userspace_clients_lock); diff --git a/drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c b/drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c index 63db04fe12d3..7facf4568e95 100644 --- a/drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c +++ b/drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c @@ -623,9 +623,9 @@ void pvr2_i2c_core_init(struct pvr2_hdw *hdw) hdw->i2c_adap.dev.parent = &hdw->usb_dev->dev; hdw->i2c_adap.algo = &hdw->i2c_algo; hdw->i2c_adap.algo_data = hdw; - hdw->i2c_linked = !0; i2c_set_adapdata(&hdw->i2c_adap, &hdw->v4l2_dev); - i2c_add_adapter(&hdw->i2c_adap); + if (!i2c_add_adapter(&hdw->i2c_adap)) + hdw->i2c_linked = !0; if (hdw->i2c_func[0x18] == i2c_24xxx_ir) { /* Probe for a different type of IR receiver on this device. This is really the only way to differentiate diff --git a/drivers/media/v4l2-core/v4l2-i2c.c b/drivers/media/v4l2-core/v4l2-i2c.c index b4acca75644b..b059c95cad4a 100644 --- a/drivers/media/v4l2-core/v4l2-i2c.c +++ b/drivers/media/v4l2-core/v4l2-i2c.c @@ -108,10 +108,10 @@ struct v4l2_subdev error: /* * If we have a client but no subdev, then something went wrong and - * we must unregister the client. + * we must release the client. */ if (!IS_ERR(client) && !sd) - i2c_unregister_device(client); + i2c_client_dev_release(client); return sd; } EXPORT_SYMBOL_GPL(v4l2_i2c_new_subdev_board);