@@ -184,6 +184,8 @@ struct ssif_addr_info {
184
184
struct device * dev ;
185
185
struct i2c_client * client ;
186
186
187
+ struct i2c_client * added_client ;
188
+
187
189
struct mutex clients_mutex ;
188
190
struct list_head clients ;
189
191
@@ -1710,15 +1712,7 @@ static int ssif_probe(struct i2c_client *client, const struct i2c_device_id *id)
1710
1712
1711
1713
out :
1712
1714
if (rv ) {
1713
- /*
1714
- * Note that if addr_info->client is assigned, we
1715
- * leave it. The i2c client hangs around even if we
1716
- * return a failure here, and the failure here is not
1717
- * propagated back to the i2c code. This seems to be
1718
- * design intent, strange as it may be. But if we
1719
- * don't leave it, ssif_platform_remove will not remove
1720
- * the client like it should.
1721
- */
1715
+ addr_info -> client = NULL ;
1722
1716
dev_err (& client -> dev , "Unable to start IPMI SSIF: %d\n" , rv );
1723
1717
kfree (ssif_info );
1724
1718
}
@@ -1737,7 +1731,8 @@ static int ssif_adapter_handler(struct device *adev, void *opaque)
1737
1731
if (adev -> type != & i2c_adapter_type )
1738
1732
return 0 ;
1739
1733
1740
- i2c_new_device (to_i2c_adapter (adev ), & addr_info -> binfo );
1734
+ addr_info -> added_client = i2c_new_device (to_i2c_adapter (adev ),
1735
+ & addr_info -> binfo );
1741
1736
1742
1737
if (!addr_info -> adapter_name )
1743
1738
return 1 ; /* Only try the first I2C adapter by default. */
@@ -2018,8 +2013,8 @@ static int ssif_platform_remove(struct platform_device *dev)
2018
2013
return 0 ;
2019
2014
2020
2015
mutex_lock (& ssif_infos_mutex );
2021
- if (addr_info -> client )
2022
- i2c_unregister_device (addr_info -> client );
2016
+ if (addr_info -> added_client )
2017
+ i2c_unregister_device (addr_info -> added_client );
2023
2018
2024
2019
list_del (& addr_info -> link );
2025
2020
kfree (addr_info );
0 commit comments