diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2017-10-31 16:21:35 +0200 |
---|---|---|
committer | Wolfram Sang <wsa@the-dreams.de> | 2017-11-02 00:00:28 +0100 |
commit | 7b43dd19c9b13a3f5478b9d88a49a5495399ad29 (patch) | |
tree | 64b4756358fa79889cd33ea170300faaff3bfcd2 /drivers | |
parent | da24b8240fe6afdeef388a2ef1da662b25675a5a (diff) | |
download | op-kernel-dev-7b43dd19c9b13a3f5478b9d88a49a5495399ad29.zip op-kernel-dev-7b43dd19c9b13a3f5478b9d88a49a5495399ad29.tar.gz |
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>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/i2c/i2c-core-base.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index 7b08f34..706164b 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); */ void i2c_unregister_device(struct i2c_client *client) { + if (!client) + return; if (client->dev.of_node) of_node_clear_flag(client->dev.of_node, OF_POPULATED); if (ACPI_COMPANION(&client->dev)) @@ -1436,8 +1438,7 @@ static int __unregister_client(struct device *dev, void *dummy) static int __unregister_dummy(struct device *dev, void *dummy) { struct i2c_client *client = i2c_verify_client(dev); - if (client) - i2c_unregister_device(client); + i2c_unregister_device(client); return 0; } |