Commit 7b43dd19 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Wolfram Sang

i2c: Make i2c_unregister_device() NULL-aware

It's a common pattern to be NULL-aware when freeing resources.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
parent da24b824
...@@ -819,6 +819,8 @@ EXPORT_SYMBOL_GPL(i2c_new_device); ...@@ -819,6 +819,8 @@ EXPORT_SYMBOL_GPL(i2c_new_device);
*/ */
void i2c_unregister_device(struct i2c_client *client) void i2c_unregister_device(struct i2c_client *client)
{ {
if (!client)
return;
if (client->dev.of_node) if (client->dev.of_node)
of_node_clear_flag(client->dev.of_node, OF_POPULATED); of_node_clear_flag(client->dev.of_node, OF_POPULATED);
if (ACPI_COMPANION(&client->dev)) if (ACPI_COMPANION(&client->dev))
...@@ -1436,8 +1438,7 @@ static int __unregister_client(struct device *dev, void *dummy) ...@@ -1436,8 +1438,7 @@ static int __unregister_client(struct device *dev, void *dummy)
static int __unregister_dummy(struct device *dev, void *dummy) static int __unregister_dummy(struct device *dev, void *dummy)
{ {
struct i2c_client *client = i2c_verify_client(dev); struct i2c_client *client = i2c_verify_client(dev);
if (client) i2c_unregister_device(client);
i2c_unregister_device(client);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment