aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2017-10-31 10:21:35 -0400
committerWolfram Sang <wsa@the-dreams.de>2017-11-01 19:00:28 -0400
commit7b43dd19c9b13a3f5478b9d88a49a5495399ad29 (patch)
tree64b4756358fa79889cd33ea170300faaff3bfcd2
parentda24b8240fe6afdeef388a2ef1da662b25675a5a (diff)
i2c: Make i2c_unregister_device() NULL-aware
It's a common pattern to be NULL-aware when freeing resources. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
-rw-r--r--drivers/i2c/i2c-core-base.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index 7b08f3446bfc..706164b4c5be 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -819,6 +819,8 @@ EXPORT_SYMBOL_GPL(i2c_new_device);
819 */ 819 */
820void i2c_unregister_device(struct i2c_client *client) 820void i2c_unregister_device(struct i2c_client *client)
821{ 821{
822 if (!client)
823 return;
822 if (client->dev.of_node) 824 if (client->dev.of_node)
823 of_node_clear_flag(client->dev.of_node, OF_POPULATED); 825 of_node_clear_flag(client->dev.of_node, OF_POPULATED);
824 if (ACPI_COMPANION(&client->dev)) 826 if (ACPI_COMPANION(&client->dev))
@@ -1436,8 +1438,7 @@ static int __unregister_client(struct device *dev, void *dummy)
1436static int __unregister_dummy(struct device *dev, void *dummy) 1438static int __unregister_dummy(struct device *dev, void *dummy)
1437{ 1439{
1438 struct i2c_client *client = i2c_verify_client(dev); 1440 struct i2c_client *client = i2c_verify_client(dev);
1439 if (client) 1441 i2c_unregister_device(client);
1440 i2c_unregister_device(client);
1441 return 0; 1442 return 0;
1442} 1443}
1443 1444