diff mbox series

[v1,01/15] i2c: Make i2c_unregister_device() NULL-aware

Message ID 20171031142149.32512-1-andriy.shevchenko@linux.intel.com
State Accepted
Headers show
Series [v1,01/15] i2c: Make i2c_unregister_device() NULL-aware | expand

Commit Message

Andy Shevchenko Oct. 31, 2017, 2:21 p.m. UTC
It's a common pattern to be NULL-aware when freeing resources.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/i2c/i2c-core-base.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Wolfram Sang Nov. 1, 2017, 11:04 p.m. UTC | #1
On Tue, Oct 31, 2017 at 04:21:35PM +0200, Andy Shevchenko wrote:
> It's a common pattern to be NULL-aware when freeing resources.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Applied to for-next, thanks!
diff mbox series

Patch

diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index 56e46581b84b..6735c9365430 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -808,6 +808,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))
@@ -1417,8 +1419,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;
 }