gpiolib: Follow usual pattern for gpiod_remove_lookup_table() call
PATCH 1/3 gpiolib: Follow usual pattern for gpiod_remove_lookup_table() call
The usual pattern for the remove calls, like gpiod_remove_lookup_table(), is to be NULL-aware, i.o.w. become a no-op whenever parameter is NULL. Update gpiod_remove_lookup_table() call to follow this pattern.
--- drivers/gpio/gpiolib.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpio/gpiolib.c +4 -0
@@ -3460,6 +3460,10 @@ EXPORT_SYMBOL_GPL(gpiod_add_lookup_table);*/ void gpiod_remove_lookup_table (struct gpiod_lookup_table *table) { +/* Nothing to remove */ +if (!table) +return ; +mutex_lock (&gpio_lookup_lock);list_del (&table->list);
Signature · 1 line
2.29.2
PATCH 2/3 i2c: i801: Drop duplicate NULL check in i801_del_mux()
Since gpiod_remove_lookup_table() is NULL-aware, no need to have this check in the caller. Drop duplicate NULL check.
--- drivers/i2c/busses/i2c-i801.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/i2c/busses/i2c-i801.c +1 -2
@@ -1487,8 +1487,7 @@ static void i801_del_mux(struct i801_priv *priv) {if (priv->mux_pdev)platform_device_unregister (priv->mux_pdev); -if (priv->lookup) -gpiod_remove_lookup_table (priv->lookup); +gpiod_remove_lookup_table (priv->lookup); }static unsigned int i801_get_adapter_class (struct i801_priv *priv)
Signature · 1 line
2.29.2
Re: [PATCH v1 2/3] i2c: i801: Drop duplicate NULL check in i801_del_mux()
Quoted 13 lines · Andy Shevchenko
Since
gpiod_remove_lookup_table()is NULL-aware, no need to have this check in the caller. Drop duplicate NULL check.Signed-off-by Andy Shevchenko <[email protected]>--- drivers/i2c/busses/i2c-i801.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/i2c/busses/i2c-i801.c +0
-0
drivers/i2c/busses/i2c-i801.c static void i801_del_mux(struct i801_priv *priv) · line 1493
Quoted 9 lines
drivers/i2c/busses/i2c-i801.c +1
-2@@ -1487,8 +1487,7 @@ static void i801_del_mux(struct i801_priv *priv) {if (priv->mux_pdev)platform_device_unregister (priv->mux_pdev); -if (priv->lookup) -gpiod_remove_lookup_table (priv->lookup); +gpiod_remove_lookup_table (priv->lookup); }static unsigned int i801_get_adapter_class (struct i801_priv *priv)
Signature · 2 lines
Jean Delvare SUSE L3 Support
PATCH 3/3 i2c: i801: Refactor mux code since platform_device_unregister() is NULL aware
In reply to Andy Shevchenkoplatform_device_unregister() is NULL-aware and thus doesn't required a duplication check in i801_del_mux(). Besides that it's also error pointer aware, and we may drop unneeded assignment in i801_add_mux() followed by conversion to PTR_ERR_OR_ZERO() for the returned value.
--- drivers/i2c/busses/i2c-i801.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/i2c/busses/i2c-i801.c +3 -7
@@ -1433,7 +1433,7 @@ static int i801_add_mux(struct i801_priv *priv)const struct i801_mux_config *mux_config;struct i2c_mux_gpio_platform_data gpio_data;struct gpiod_lookup_table *lookup; -int err, i; +int i;if (!priv->mux_drvdata)return 0 ;
@@ -1473,20 +1473,16 @@ static int i801_add_mux(struct i801_priv *priv)PLATFORM_DEVID_NONE , &gpio_data, sizeof(struct i2c_mux_gpio_platform_data));if (IS_ERR (priv->mux_pdev)) { - err =PTR_ERR (priv->mux_pdev);gpiod_remove_lookup_table (lookup); - priv->mux_pdev =NULL ;dev_err (dev,"Failed to register i2c-mux-gpio device\n" ); -return err; } -return 0 ; +return PTR_ERR_OR_ZERO (priv->mux_pdev); }static void i801_del_mux (struct i801_priv *priv) { -if (priv->mux_pdev) -platform_device_unregister (priv->mux_pdev); +platform_device_unregister (priv->mux_pdev);gpiod_remove_lookup_table (priv->lookup); }
Signature · 1 line
2.29.2
Re: [PATCH v1 3/3] i2c: i801: Refactor mux code since platform_device_unregister() is NULL aware
Quoted 36 lines · Andy Shevchenko
platform_device_unregister()is NULL-aware and thus doesn't required a duplication check ini801_del_mux(). Besides that it's also error pointer aware, and we may drop unneeded assignment ini801_add_mux()followed by conversion toPTR_ERR_OR_ZERO()for the returned value.Signed-off-by Andy Shevchenko <[email protected]>--- drivers/i2c/busses/i2c-i801.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)drivers/i2c/busses/i2c-i801.c +2
-5@@ -1433,7 +1433,7 @@ static int i801_add_mux(struct i801_priv *priv)const struct i801_mux_config *mux_config;struct i2c_mux_gpio_platform_data gpio_data;struct gpiod_lookup_table *lookup; -int err, i; +int i;if (!priv->mux_drvdata)return 0 ;@@ -1473,20 +1473,16 @@ static int i801_add_mux(struct i801_priv *priv)PLATFORM_DEVID_NONE , &gpio_data, sizeof(struct i2c_mux_gpio_platform_data));if (IS_ERR (priv->mux_pdev)) { - err =PTR_ERR (priv->mux_pdev);gpiod_remove_lookup_table (lookup); - priv->mux_pdev =NULL ;dev_err (dev,"Failed to register i2c-mux-gpio device\n" ); -return err; } -return 0 ; +return PTR_ERR_OR_ZERO (priv->mux_pdev);
drivers/i2c/busses/i2c-i801.c static int i801_add_mux(struct i801_priv *priv) · line 1488
Quoted 10 lines
drivers/i2c/busses/i2c-i801.c +1
-2}static void i801_del_mux (struct i801_priv *priv) { -if (priv->mux_pdev) -platform_device_unregister (priv->mux_pdev); +platform_device_unregister (priv->mux_pdev);gpiod_remove_lookup_table (priv->lookup); }
Signature · 2 lines
Jean Delvare SUSE L3 Support
Bartosz Golaszewski
AppliedQuoted 26 lines · Andy Shevchenko
The usual pattern for the remove calls, like
gpiod_remove_lookup_table(), is to be NULL-aware, i.o.w. become a no-op whenever parameter is NULL. Updategpiod_remove_lookup_table()call to follow this pattern.Signed-off-by Andy Shevchenko <[email protected]>--- drivers/gpio/gpiolib.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/gpio/gpiolib.c +4
-1@@ -3460,6 +3460,10 @@ EXPORT_SYMBOL_GPL(gpiod_add_lookup_table);*/ void gpiod_remove_lookup_table (struct gpiod_lookup_table *table) { +/* Nothing to remove */ +if (!table) +return ; +mutex_lock (&gpio_lookup_lock);list_del (&table->list); --
Quoted 2 lines
2.29.2
Applied, thanks!
Bart
Quoted 26 lines · Bartosz Golaszewski
Quoted 24 lines · Andy Shevchenko
The usual pattern for the remove calls, like
gpiod_remove_lookup_table(), is to be NULL-aware, i.o.w. become a no-op whenever parameter is NULL. Updategpiod_remove_lookup_table()call to follow this pattern.Signed-off-by Andy Shevchenko <[email protected]>--- drivers/gpio/gpiolib.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/gpio/gpiolib.c +4
-0@@ -3460,6 +3460,10 @@ EXPORT_SYMBOL_GPL(gpiod_add_lookup_table);*/ void gpiod_remove_lookup_table (struct gpiod_lookup_table *table) { +/* Nothing to remove */ +if (!table) +return ; +mutex_lock (&gpio_lookup_lock);
Quoted 6 lines
Quoted 4 lines
drivers/gpio/gpiolib.c +0
-1list_del (&table->list); --2.29.2
Applied, thanks!
Thanks. Though I think it can be also applied to I²C tree since dependency? Any tags / immutable branch for Wolfram?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Bartosz Golaszewski
Acked-byQuoted 35 lines · Andy Shevchenko
Quoted 26 lines · Bartosz Golaszewski
Quoted 24 lines · Andy Shevchenko
The usual pattern for the remove calls, like
gpiod_remove_lookup_table(), is to be NULL-aware, i.o.w. become a no-op whenever parameter is NULL. Updategpiod_remove_lookup_table()call to follow this pattern.Signed-off-by Andy Shevchenko <[email protected]>--- drivers/gpio/gpiolib.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/gpio/gpiolib.c +4
-0@@ -3460,6 +3460,10 @@ EXPORT_SYMBOL_GPL(gpiod_add_lookup_table);*/ void gpiod_remove_lookup_table (struct gpiod_lookup_table *table) { +/* Nothing to remove */ +if (!table) +return ; +mutex_lock (&gpio_lookup_lock);Quoted 6 lines
Quoted 4 lines
drivers/gpio/gpiolib.c +0
-1list_del (&table->list); --2.29.2
Applied, thanks!
Quoted 8 lines
Thanks. Though I think it can be also applied to I涎 tree since dependency? Any tags / immutable branch for Wolfram?
--
With Best Regards,
Andy Shevchenko
Oops I assumed this is independent. In that case:
Wolfram, please take it through the i2c tree.
Bartosz
Quoted 14 lines · Andy Shevchenko
The usual pattern for the remove calls, like
gpiod_remove_lookup_table(), is to be NULL-aware, i.o.w. become a no-op whenever parameter is NULL. Updategpiod_remove_lookup_table()call to follow this pattern.Signed-off-by Andy Shevchenko <[email protected]>--- drivers/gpio/gpiolib.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/gpio/gpiolib.c +0
-0
drivers/gpio/gpiolib.c EXPORT_SYMBOL_GPL(gpiod_add_lookup_table); · line 3469
Quoted 10 lines
drivers/gpio/gpiolib.c +4
-0@@ -3460,6 +3460,10 @@ EXPORT_SYMBOL_GPL(gpiod_add_lookup_table);*/ void gpiod_remove_lookup_table (struct gpiod_lookup_table *table) { +/* Nothing to remove */ +if (!table) +return ; +mutex_lock (&gpio_lookup_lock);list_del (&table->list);
Signature · 2 lines
Jean Delvare SUSE L3 Support