From: Jacek Anaszewski <jacek.anaszewski@gmail.com>
To: Dan Murphy <dmurphy@ti.com>, pavel@ucw.cz
Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 4/5] leds: flash: Add devm_* functions to the flash class
Date: Tue, 1 Oct 2019 23:10:01 +0200 [thread overview]
Message-ID: <ab274710-2d6a-7a2a-6261-bfdff5ade466@gmail.com> (raw)
In-Reply-To: <218b33ac-506b-2014-d37f-3da2da323388@gmail.com>
Moreover, checkpatch.pl complains about whitespaces
in two places of this patch.
On 10/1/19 11:06 PM, Jacek Anaszewski wrote:
> Dan,
>
> Thank you for the patch. One funny omission caught my
> eye here and in led-class.c when making visual comparison.
> Please refer below.
>
> On 10/1/19 8:04 PM, Dan Murphy wrote:
>> Add the missing device managed API for registration and
>> unregistration for the LED flash class.
>>
>> Signed-off-by: Dan Murphy <dmurphy@ti.com>
>> ---
>> drivers/leds/led-class-flash.c | 50 +++++++++++++++++++++++++++++++++
>> include/linux/led-class-flash.h | 14 +++++++++
>> 2 files changed, 64 insertions(+)
>>
>> diff --git a/drivers/leds/led-class-flash.c b/drivers/leds/led-class-flash.c
>> index 60c3de5c6b9f..c2b4fd02a1bc 100644
>> --- a/drivers/leds/led-class-flash.c
>> +++ b/drivers/leds/led-class-flash.c
>> @@ -327,6 +327,56 @@ void led_classdev_flash_unregister(struct led_classdev_flash *fled_cdev)
>> }
>> EXPORT_SYMBOL_GPL(led_classdev_flash_unregister);
>>
>> +static void devm_led_classdev_flash_release(struct device *dev, void *res)
>> +{
>> + led_classdev_flash_unregister(*(struct led_classdev_flash **)res);
>> +}
>> +
>> +int devm_led_classdev_flash_register_ext(struct device *parent,
>> + struct led_classdev_flash *fled_cdev,
>> + struct led_init_data *init_data)
>> +{
>> + struct led_classdev_flash **dr;
>> + int ret;
>> +
>> + dr = devres_alloc(devm_led_classdev_flash_release, sizeof(*dr),
>> + GFP_KERNEL);
>> + if (!dr)
>> + return -ENOMEM;
>> +
>> + ret = led_classdev_flash_register_ext(parent, fled_cdev, init_data);
>> + if (ret) {
>> + devres_free(dr);
>> + return ret;
>> + }
>> +
>> + *dr = fled_cdev;
>> + devres_add(parent, dr);
>> +
>> + return 0;
>> +}
>> +EXPORT_SYMBOL_GPL(devm_led_classdev_flash_register_ext);
>> +
>> +static int devm_led_classdev_flash_match(struct device *dev,
>> + void *res, void *data)
>> +{
>> + struct fled_cdev **p = res;
>
> We don't have struct fled_cdev. This name is used for variables
> of struct led_clssdev_flash type in drivers.
>
> We don't get even compiler warning here because this is cast
> from void pointer.
>
> Funny thing is that you seem to have followed similar flaw in
> devm_led_classdev_match() where struct led_cdev has been
> introduced.
>
> We need to fix both cases.
>
>> +
>> + if (WARN_ON(!p || !*p))
>> + return 0;
>> +
>> + return *p == data;
>> +}
>> +
>> +void devm_led_classdev_flash_unregister(struct device *dev,
>> + struct led_classdev_flash *fled_cdev)
>> +{
>> + WARN_ON(devres_release(dev,
>> + devm_led_classdev_flash_release,
>> + devm_led_classdev_flash_match, fled_cdev));
>> +}
>> +EXPORT_SYMBOL_GPL(devm_led_classdev_flash_unregister);
>> +
>> static void led_clamp_align(struct led_flash_setting *s)
>> {
>> u32 v, offset;
>> diff --git a/include/linux/led-class-flash.h b/include/linux/led-class-flash.h
>> index 1bd83159fa4c..21a3358a1731 100644
>> --- a/include/linux/led-class-flash.h
>> +++ b/include/linux/led-class-flash.h
>> @@ -113,6 +113,20 @@ static inline int led_classdev_flash_register(struct device *parent,
>> */
>> void led_classdev_flash_unregister(struct led_classdev_flash *fled_cdev);
>>
>> +int devm_led_classdev_flash_register_ext(struct device *parent,
>> + struct led_classdev_flash *fled_cdev,
>> + struct led_init_data *init_data);
>> +
>> +
>> +static inline int devm_led_classdev_flash_register(struct device *parent,
>> + struct led_classdev_flash *fled_cdev)
>> +{
>> + return devm_led_classdev_flash_register_ext(parent, fled_cdev, NULL);
>> +}
>> +
>> +void devm_led_classdev_flash_unregister(struct device *parent,
>> + struct led_classdev_flash *fled_cdev);
>> +
>> /**
>> * led_set_flash_strobe - setup flash strobe
>> * @fled_cdev: the flash LED to set strobe on
>>
>
--
Best regards,
Jacek Anaszewski
next prev parent reply other threads:[~2019-10-01 21:10 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-01 18:04 [PATCH 1/5] leds: Kconfig: Be consistent with the usage of "LED" Dan Murphy
2019-10-01 18:04 ` [PATCH 2/5] leds: flash: Convert non extended registration to inline Dan Murphy
2019-10-01 18:04 ` [PATCH 3/5] leds: flash: Remove extern from the header file Dan Murphy
2019-10-01 20:57 ` Jacek Anaszewski
2019-10-02 11:56 ` Dan Murphy
2019-10-02 19:53 ` Jacek Anaszewski
2019-10-01 18:04 ` [PATCH 4/5] leds: flash: Add devm_* functions to the flash class Dan Murphy
2019-10-01 21:06 ` Jacek Anaszewski
2019-10-01 21:10 ` Jacek Anaszewski [this message]
2019-10-02 12:04 ` Dan Murphy
2019-10-02 19:55 ` Jacek Anaszewski
2019-10-01 18:04 ` [PATCH 5/5] leds: lm3601x: Convert class registration to device managed Dan Murphy
2019-10-01 19:39 ` Jacek Anaszewski
2019-10-01 20:11 ` Dan Murphy
2019-10-01 21:16 ` [PATCH 1/5] leds: Kconfig: Be consistent with the usage of "LED" Jacek Anaszewski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ab274710-2d6a-7a2a-6261-bfdff5ade466@gmail.com \
--to=jacek.anaszewski@gmail.com \
--cc=dmurphy@ti.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=pavel@ucw.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).