diff --git a/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c b/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c index d2a0c4f8c03e..b0d8912690a2 100644 --- a/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c +++ b/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c @@ -105,7 +105,6 @@ struct tc9563_pwrctrl { struct tc9563_pwrctrl_cfg ep_cfg; struct gpio_desc *reset_gpio; struct i2c_adapter *adapter; - struct i2c_client *client; struct regmap *regmap; }; @@ -504,6 +503,7 @@ static int tc9563_pwrctrl_probe(struct platform_device *pdev) enum tc9563_pwrctrl_ports port; struct tc9563_pwrctrl *tc9563; struct device_node *i2c_node; + struct i2c_client *client; int ret, addr; tc9563 = devm_kzalloc(dev, sizeof(*tc9563), GFP_KERNEL); @@ -520,15 +520,14 @@ static int tc9563_pwrctrl_probe(struct platform_device *pdev) if (!tc9563->adapter) return dev_err_probe(dev, -EPROBE_DEFER, "Failed to find I2C adapter\n"); - tc9563->client = i2c_new_dummy_device(tc9563->adapter, addr); - if (IS_ERR(tc9563->client)) { + client = devm_i2c_new_dummy_device(dev, tc9563->adapter, addr); + if (IS_ERR(client)) { dev_err(dev, "Failed to create I2C client\n"); - i2c_put_adapter(tc9563->adapter); - return PTR_ERR(tc9563->client); + ret = PTR_ERR(client); + goto remove_i2c; } - tc9563->regmap = devm_regmap_init_i2c(tc9563->client, - &tc9563_regmap_config); + tc9563->regmap = devm_regmap_init_i2c(client, &tc9563_regmap_config); if (IS_ERR(tc9563->regmap)) { ret = dev_err_probe(dev, PTR_ERR(tc9563->regmap), "Failed to allocate register map\n"); @@ -606,7 +605,6 @@ static int tc9563_pwrctrl_probe(struct platform_device *pdev) power_off: tc9563_pwrctrl_power_off(&tc9563->pwrctrl); remove_i2c: - i2c_unregister_device(tc9563->client); i2c_put_adapter(tc9563->adapter); return ret; } @@ -618,7 +616,6 @@ static void tc9563_pwrctrl_remove(struct platform_device *pdev) struct tc9563_pwrctrl, pwrctrl); tc9563_pwrctrl_power_off(&tc9563->pwrctrl); - i2c_unregister_device(tc9563->client); i2c_put_adapter(tc9563->adapter); }