* [PATCH v1 1/1] pwm: core: use device_match_name() instead of strcmp(dev_name(...
@ 2024-10-24 15:19 Andy Shevchenko
2024-10-24 20:55 ` Uwe Kleine-König
0 siblings, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2024-10-24 15:19 UTC (permalink / raw)
To: Uwe Kleine-König, linux-pwm, linux-kernel
Cc: Uwe Kleine-König, Andy Shevchenko
Use the dedicated helper for comparing device names against strings.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/pwm/core.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index 634be56e204b..4399e793efaf 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -852,9 +852,7 @@ static struct pwm_chip *pwmchip_find_by_name(const char *name)
guard(mutex)(&pwm_lock);
idr_for_each_entry_ul(&pwm_chips, chip, tmp, id) {
- const char *chip_name = dev_name(pwmchip_parent(chip));
-
- if (chip_name && strcmp(chip_name, name) == 0)
+ if (device_match_name(pwmchip_parent(chip), name))
return chip;
}
--
2.43.0.rc1.1336.g36b5255a03ac
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v1 1/1] pwm: core: use device_match_name() instead of strcmp(dev_name(...
2024-10-24 15:19 [PATCH v1 1/1] pwm: core: use device_match_name() instead of strcmp(dev_name( Andy Shevchenko
@ 2024-10-24 20:55 ` Uwe Kleine-König
2024-10-25 13:04 ` Andy Shevchenko
0 siblings, 1 reply; 5+ messages in thread
From: Uwe Kleine-König @ 2024-10-24 20:55 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: linux-pwm, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 796 bytes --]
Hello Andy,
On Thu, Oct 24, 2024 at 06:19:05PM +0300, Andy Shevchenko wrote:
> diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
> index 634be56e204b..4399e793efaf 100644
> --- a/drivers/pwm/core.c
> +++ b/drivers/pwm/core.c
> @@ -852,9 +852,7 @@ static struct pwm_chip *pwmchip_find_by_name(const char *name)
> guard(mutex)(&pwm_lock);
>
> idr_for_each_entry_ul(&pwm_chips, chip, tmp, id) {
> - const char *chip_name = dev_name(pwmchip_parent(chip));
> -
> - if (chip_name && strcmp(chip_name, name) == 0)
> + if (device_match_name(pwmchip_parent(chip), name))
This theoretically changes behaviour in a few cases. For example if
dev_name(pwmchip_parent(chip)) is NULL the new code would crash. Can
this happen?
Best regards
Uwe
> return chip;
> }
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1 1/1] pwm: core: use device_match_name() instead of strcmp(dev_name(...
2024-10-24 20:55 ` Uwe Kleine-König
@ 2024-10-25 13:04 ` Andy Shevchenko
2024-10-25 14:17 ` Uwe Kleine-König
0 siblings, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2024-10-25 13:04 UTC (permalink / raw)
To: Uwe Kleine-König; +Cc: linux-pwm, linux-kernel
On Thu, Oct 24, 2024 at 10:55:36PM +0200, Uwe Kleine-König wrote:
> On Thu, Oct 24, 2024 at 06:19:05PM +0300, Andy Shevchenko wrote:
...
> > idr_for_each_entry_ul(&pwm_chips, chip, tmp, id) {
> > - const char *chip_name = dev_name(pwmchip_parent(chip));
> > -
> > - if (chip_name && strcmp(chip_name, name) == 0)
> > + if (device_match_name(pwmchip_parent(chip), name))
>
> This theoretically changes behaviour in a few cases. For example if
> dev_name(pwmchip_parent(chip)) is NULL the new code would crash. Can
> this happen?
Please, tell me how
(looking at the of device_add() and kobject_set_name_vargs() implementations)?
Btw, have you ever seen this check somewhere else? (I don't, but I haven't
covered full kernel sources, of course.)
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1 1/1] pwm: core: use device_match_name() instead of strcmp(dev_name(...
2024-10-25 13:04 ` Andy Shevchenko
@ 2024-10-25 14:17 ` Uwe Kleine-König
2024-10-25 14:23 ` Andy Shevchenko
0 siblings, 1 reply; 5+ messages in thread
From: Uwe Kleine-König @ 2024-10-25 14:17 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: linux-pwm, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1062 bytes --]
Hello Andy,
On Fri, Oct 25, 2024 at 04:04:19PM +0300, Andy Shevchenko wrote:
> On Thu, Oct 24, 2024 at 10:55:36PM +0200, Uwe Kleine-König wrote:
> > On Thu, Oct 24, 2024 at 06:19:05PM +0300, Andy Shevchenko wrote:
>
> ...
>
> > > idr_for_each_entry_ul(&pwm_chips, chip, tmp, id) {
> > > - const char *chip_name = dev_name(pwmchip_parent(chip));
> > > -
> > > - if (chip_name && strcmp(chip_name, name) == 0)
> > > + if (device_match_name(pwmchip_parent(chip), name))
> >
> > This theoretically changes behaviour in a few cases. For example if
> > dev_name(pwmchip_parent(chip)) is NULL the new code would crash. Can
> > this happen?
>
> Please, tell me how
> (looking at the of device_add() and kobject_set_name_vargs() implementations)?
This is unfair, I intended to let you do the work and you just give it
back to me :-)
... a bit later ...
ok, willing to merge if you update the commit log to mention that the
theoretical changes (no check for NULL, more lax check (trailing \n))
don't matter.
Best regards
Uwe
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1 1/1] pwm: core: use device_match_name() instead of strcmp(dev_name(...
2024-10-25 14:17 ` Uwe Kleine-König
@ 2024-10-25 14:23 ` Andy Shevchenko
0 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2024-10-25 14:23 UTC (permalink / raw)
To: Uwe Kleine-König; +Cc: linux-pwm, linux-kernel
On Fri, Oct 25, 2024 at 04:17:04PM +0200, Uwe Kleine-König wrote:
> On Fri, Oct 25, 2024 at 04:04:19PM +0300, Andy Shevchenko wrote:
> > On Thu, Oct 24, 2024 at 10:55:36PM +0200, Uwe Kleine-König wrote:
> > > On Thu, Oct 24, 2024 at 06:19:05PM +0300, Andy Shevchenko wrote:
...
> > > > idr_for_each_entry_ul(&pwm_chips, chip, tmp, id) {
> > > > - const char *chip_name = dev_name(pwmchip_parent(chip));
> > > > -
> > > > - if (chip_name && strcmp(chip_name, name) == 0)
> > > > + if (device_match_name(pwmchip_parent(chip), name))
> > >
> > > This theoretically changes behaviour in a few cases. For example if
> > > dev_name(pwmchip_parent(chip)) is NULL the new code would crash. Can
> > > this happen?
> >
> > Please, tell me how
> > (looking at the of device_add() and kobject_set_name_vargs() implementations)?
>
> This is unfair, I intended to let you do the work and you just give it
> back to me :-)
Unfair to ask me about this code as you should know better as the maintainer
than me why this code is there, no? :-)
> ... a bit later ...
>
> ok, willing to merge if you update the commit log to mention that the
> theoretical changes (no check for NULL, more lax check (trailing \n))
> don't matter.
Okay.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-10-25 14:23 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-24 15:19 [PATCH v1 1/1] pwm: core: use device_match_name() instead of strcmp(dev_name( Andy Shevchenko
2024-10-24 20:55 ` Uwe Kleine-König
2024-10-25 13:04 ` Andy Shevchenko
2024-10-25 14:17 ` Uwe Kleine-König
2024-10-25 14:23 ` Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox