From: Matthias Brugger <matthias.bgg@gmail.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Gene Chen <gene_chen@richtek.com>,
linux-leds@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org
Cc: Pavel Machek <pavel@ucw.cz>
Subject: Re: [PATCH v1 1/1] leds: mt6360: Get rid of custom led_init_default_state_get()
Date: Wed, 3 Aug 2022 13:44:08 +0200 [thread overview]
Message-ID: <cb74e4d0-8170-0837-fa43-d269a8db4d90@gmail.com> (raw)
In-Reply-To: <20220802212532.7091-1-andriy.shevchenko@linux.intel.com>
On 02/08/2022 23:25, Andy Shevchenko wrote:
> LED core provides a helper to parse default state from firmware node.
> Use it instead of custom implementation.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>
> ---
> drivers/leds/flash/leds-mt6360.c | 38 +++++---------------------------
> 1 file changed, 6 insertions(+), 32 deletions(-)
>
> diff --git a/drivers/leds/flash/leds-mt6360.c b/drivers/leds/flash/leds-mt6360.c
> index e1066a52d2d2..1af6c5898343 100644
> --- a/drivers/leds/flash/leds-mt6360.c
> +++ b/drivers/leds/flash/leds-mt6360.c
> @@ -71,10 +71,6 @@ enum {
> #define MT6360_STRBTO_STEPUS 32000
> #define MT6360_STRBTO_MAXUS 2432000
>
> -#define STATE_OFF 0
> -#define STATE_KEEP 1
> -#define STATE_ON 2
> -
> struct mt6360_led {
> union {
> struct led_classdev isnk;
> @@ -84,7 +80,7 @@ struct mt6360_led {
> struct v4l2_flash *v4l2_flash;
> struct mt6360_priv *priv;
> u32 led_no;
> - u32 default_state;
> + enum led_default_state default_state;
> };
>
> struct mt6360_priv {
> @@ -405,10 +401,10 @@ static int mt6360_isnk_init_default_state(struct mt6360_led *led)
> level = LED_OFF;
>
> switch (led->default_state) {
> - case STATE_ON:
> + case LEDS_DEFSTATE_ON:
> led->isnk.brightness = led->isnk.max_brightness;
> break;
> - case STATE_KEEP:
> + case LEDS_DEFSTATE_KEEP:
> led->isnk.brightness = min(level, led->isnk.max_brightness);
> break;
> default:
> @@ -443,10 +439,10 @@ static int mt6360_flash_init_default_state(struct mt6360_led *led)
> level = LED_OFF;
>
> switch (led->default_state) {
> - case STATE_ON:
> + case LEDS_DEFSTATE_ON:
> flash->led_cdev.brightness = flash->led_cdev.max_brightness;
> break;
> - case STATE_KEEP:
> + case LEDS_DEFSTATE_KEEP:
> flash->led_cdev.brightness =
> min(level, flash->led_cdev.max_brightness);
> break;
> @@ -760,25 +756,6 @@ static int mt6360_init_flash_properties(struct mt6360_led *led,
> return 0;
> }
>
> -static int mt6360_init_common_properties(struct mt6360_led *led,
> - struct led_init_data *init_data)
> -{
> - const char *const states[] = { "off", "keep", "on" };
> - const char *str;
> - int ret;
> -
> - if (!fwnode_property_read_string(init_data->fwnode,
> - "default-state", &str)) {
> - ret = match_string(states, ARRAY_SIZE(states), str);
> - if (ret < 0)
> - ret = STATE_OFF;
> -
> - led->default_state = ret;
> - }
> -
> - return 0;
> -}
> -
> static void mt6360_v4l2_flash_release(struct mt6360_priv *priv)
> {
> int i;
> @@ -852,10 +829,7 @@ static int mt6360_led_probe(struct platform_device *pdev)
>
> led->led_no = reg;
> led->priv = priv;
> -
> - ret = mt6360_init_common_properties(led, &init_data);
> - if (ret)
> - goto out_flash_release;
> + led->default_state = led_init_default_state_get(child);
>
> if (reg == MT6360_VIRTUAL_MULTICOLOR ||
> reg <= MT6360_LED_ISNKML)
prev parent reply other threads:[~2022-08-03 11:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-02 21:25 [PATCH v1 1/1] leds: mt6360: Get rid of custom led_init_default_state_get() Andy Shevchenko
2022-08-02 23:32 ` kernel test robot
2022-08-02 23:43 ` kernel test robot
2022-08-03 11:44 ` Matthias Brugger [this message]
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=cb74e4d0-8170-0837-fa43-d269a8db4d90@gmail.com \
--to=matthias.bgg@gmail.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=gene_chen@richtek.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.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).