@@ -181,6 +181,8 @@ struct ssif_addr_info {
181
181
struct device * dev ;
182
182
struct i2c_client * client ;
183
183
184
+ struct i2c_client * added_client ;
185
+
184
186
struct mutex clients_mutex ;
185
187
struct list_head clients ;
186
188
@@ -1641,15 +1643,7 @@ static int ssif_probe(struct i2c_client *client, const struct i2c_device_id *id)
1641
1643
1642
1644
out :
1643
1645
if (rv ) {
1644
- /*
1645
- * Note that if addr_info->client is assigned, we
1646
- * leave it. The i2c client hangs around even if we
1647
- * return a failure here, and the failure here is not
1648
- * propagated back to the i2c code. This seems to be
1649
- * design intent, strange as it may be. But if we
1650
- * don't leave it, ssif_platform_remove will not remove
1651
- * the client like it should.
1652
- */
1646
+ addr_info -> client = NULL ;
1653
1647
dev_err (& client -> dev , "Unable to start IPMI SSIF: %d\n" , rv );
1654
1648
kfree (ssif_info );
1655
1649
}
@@ -1669,7 +1663,8 @@ static int ssif_adapter_handler(struct device *adev, void *opaque)
1669
1663
if (adev -> type != & i2c_adapter_type )
1670
1664
return 0 ;
1671
1665
1672
- i2c_new_device (to_i2c_adapter (adev ), & addr_info -> binfo );
1666
+ addr_info -> added_client = i2c_new_device (to_i2c_adapter (adev ),
1667
+ & addr_info -> binfo );
1673
1668
1674
1669
if (!addr_info -> adapter_name )
1675
1670
return 1 ; /* Only try the first I2C adapter by default. */
@@ -1842,7 +1837,7 @@ static int ssif_platform_remove(struct platform_device *dev)
1842
1837
return 0 ;
1843
1838
1844
1839
mutex_lock (& ssif_infos_mutex );
1845
- i2c_unregister_device (addr_info -> client );
1840
+ i2c_unregister_device (addr_info -> added_client );
1846
1841
1847
1842
list_del (& addr_info -> link );
1848
1843
kfree (addr_info );
0 commit comments