gpio: sim: driver improvements
cover gpio: sim: driver improvements
From: Bartosz Golaszewski <[email protected]>
Andy had some suggestions in his review of the gpio-virtuser that also apply to gpio-sim so let's use them.
Bartosz Golaszewski (3):
gpio: sim: use device_match_name() instead of strcmp(dev_name(...
gpio: sim: drop kernel.h include
gpio: sim: use devm_mutex_init()
drivers/gpio/gpio-sim.c | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-)
Signature · 1 line
2.40.1
PATCH 1/3 gpio: sim: use device_match_name() instead of strcmp(dev_name(...
From: Bartosz Golaszewski <[email protected]>
Use the dedicated helper for comparing device names against strings. While at it: reshuffle the code a bit for less indentation.
--- drivers/gpio/gpio-sim.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
drivers/gpio/gpio-sim.c +11 -11
@@ -581,19 +581,19 @@ static int gpio_sim_bus_notifier_call(struct notifier_block *nb,snprintf (devname,sizeof (devname),"gpio-sim.%u" , simdev->id); -if (strcmp (dev_name (dev), devname) ==0 ) { -if (action ==BUS_NOTIFY_BOUND_DRIVER ) - simdev->driver_bound = true; -else if (action ==BUS_NOTIFY_DRIVER_NOT_BOUND ) - simdev->driver_bound = false; -else -return NOTIFY_DONE ; +if (!device_match_name (dev, devname)) +return NOTIFY_DONE ; -complete (&simdev->probe_completion); -return NOTIFY_OK ; - } +if (action ==BUS_NOTIFY_BOUND_DRIVER ) + simdev->driver_bound = true; +else if (action ==BUS_NOTIFY_DRIVER_NOT_BOUND ) + simdev->driver_bound = false; +else +return NOTIFY_DONE ; -return NOTIFY_DONE ; +complete (&simdev->probe_completion); + +return NOTIFY_OK ; }static struct gpio_sim_device *to_gpio_sim_device (struct config_item *item)
Signature · 1 line
2.40.1
PATCH 2/3 gpio: sim: drop kernel.h include
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
We included kernel.h for ARRAY_SIZE() which has since been moved into its own header. Use it instead.
--- drivers/gpio/gpio-sim.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-sim.c +1 -1
@@ -7,6 +7,7 @@#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt +#include <linux/array_size.h> #include <linux/bitmap.h> #include <linux/cleanup.h> #include <linux/completion.h>
@@ -20,7 +21,6 @@#include <linux/interrupt.h> #include <linux/irq.h> #include <linux/irq_sim.h> -#include <linux/kernel.h> #include <linux/list.h> #include <linux/lockdep.h> #include <linux/minmax.h>
Signature · 1 line
2.40.1
PATCH 3/3 gpio: sim: use devm_mutex_init()
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
Drop the hand-coded devres action callback for destroying the mutex in favor of devm_mutex_init().
--- drivers/gpio/gpio-sim.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)
drivers/gpio/gpio-sim.c +1 -10
@@ -308,13 +308,6 @@ static ssize_t gpio_sim_sysfs_pull_store(struct device *dev,return len; } -static void gpio_sim_mutex_destroy (void *data) -{ -struct mutex *lock = data; - -mutex_destroy (lock); -} -static void gpio_sim_put_device (void *data) {struct device *dev = data;
@@ -458,9 +451,7 @@ static int gpio_sim_add_bank(struct fwnode_handle *swnode, struct device *dev)if (ret)return ret; -mutex_init (&chip->lock); - ret =devm_add_action_or_reset (dev, gpio_sim_mutex_destroy, - &chip->lock); + ret =devm_mutex_init (dev, &chip->lock);if (ret)return ret;
Signature · 1 line
2.40.1
Re: [PATCH 3/3] gpio: sim: use devm_mutex_init()
Quoted 5 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
Drop the hand-coded devres action callback for destroying the mutex in favor of
devm_mutex_init().
All three LGTM,
Thanks!
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH 3/3] gpio: sim: use devm_mutex_init()
Quoted 9 lines · Andy Shevchenko
Quoted 5 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
Drop the hand-coded devres action callback for destroying the mutex in favor of
devm_mutex_init().All three LGTM,
Can you leave your tags under the cover letter in such cases? This will make b4 pick it up for all patches automatically.
Thanks,
Bart
Quoted 3 lines
Reviewed-by Andy Shevchenko <[email protected]>Thanks!
Re: [PATCH 3/3] gpio: sim: use devm_mutex_init()
Mon, Jun 10, 2024 at 05:31:44PM +0200, Bartosz Golaszewski kirjoitti:
Quoted 6 lines · Andy Shevchenko
Quoted 5 lines · Bartosz Golaszewski
Quoted 3 lines
From: Bartosz Golaszewski <[email protected]>
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Drop the hand-coded devres action callback for destroying the mutex in favor of
devm_mutex_init().All three LGTM,
Can you leave your tags under the cover letter in such cases? This will make b4 pick it up for all patches automatically.
For some reason I was thinking there is no cover letter. But okay, done now.
Quoted 2 lines
Quoted 2 lines
Reviewed-by Andy Shevchenko <[email protected]>Thanks!
Signature · 2 lines
With Best Regards, Andy Shevchenko
Mon, Jun 10, 2024 at 04:05:45PM +0200, Bartosz Golaszewski kirjoitti:
Quoted 4 lines
From: Bartosz Golaszewski <[email protected]>
Andy had some suggestions in his review of the gpio-virtuser that also apply to gpio-sim so let's use them.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Bartosz Golaszewski
AppliedFrom: Bartosz Golaszewski <[email protected]>
Quoted 11 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
Andy had some suggestions in his review of the gpio-virtuser that also apply to gpio-sim so let's use them.
Bartosz Golaszewski (3):
gpio: sim: usedevice_match_name()instead of strcmp(dev_name(...
gpio: sim: dropkernel.hinclude
gpio: sim: usedevm_mutex_init()[...]
Applied, thanks!
[1/3] gpio: sim: use device_match_name() instead of strcmp(dev_name(...
commit: 8a05de23adabc4d982dfdeabc184a267f7a50491
[2/3] gpio: sim: drop kernel.h include
commit: b5f5cbee764e2faffe5241445830a5e43084f3a0
[3/3] gpio: sim: use devm_mutex_init()
commit: 413427153921ac8263d3a516bfbdaa42fa058085Best regards,
Signature · 1 line
Bartosz Golaszewski <[email protected]>