From: Lee Jones <lee@kernel.org>
To: "Thomas Weißschuh" <linux@weissschuh.net>
Cc: "Thomas Weißschuh" <thomas@weissschuh.net>,
"Pavel Machek" <pavel@ucw.cz>,
"Benson Leung" <bleung@chromium.org>,
"Guenter Roeck" <groeck@chromium.org>,
linux-leds@vger.kernel.org, chrome-platform@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] leds: cros_ec: Implement review comments from Lee
Date: Thu, 20 Jun 2024 10:31:14 +0100 [thread overview]
Message-ID: <20240620093114.GH3029315@google.com> (raw)
In-Reply-To: <20240614-cros_ec-led-review-v1-1-946f2549fac2@weissschuh.net>
Definitely not seen a commit message like that before
> Implement review comments from Lee as requested in [0] for
> "leds: Add ChromeOS EC driver".
>
> Changes:
> * Inline DRV_NAME string constant.
> * Use dev_err() instead of dev_warn() to report errors.
> * Rename cros_ec_led_probe_led() to cros_ec_led_probe_one().
> * Make loop variable "int" where they belong.
> * Move "Unknown LED" comment to where it belongs.
> * Register trigger during _probe().
> * Use module_platform_driver() and drop all the custom boilerplate.
If you're fixing many things, then I would expect to receive many
patches. One patch for functional change please. If you can reasonably
group fixes of similar elk, then please do. However one patch that does
a bunch of different things is a no-go from me, sorry.
> [0] https://lore.kernel.org/lkml/20240614093445.GF3029315@google.com/T/#m8750abdef6a968ace765645189170814196c9ce9
>
> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
> ---
> drivers/leds/leds-cros_ec.c | 50 +++++++++++++--------------------------------
> 1 file changed, 14 insertions(+), 36 deletions(-)
>
> diff --git a/drivers/leds/leds-cros_ec.c b/drivers/leds/leds-cros_ec.c
> index 7bb21a587713..275522b81ea5 100644
> --- a/drivers/leds/leds-cros_ec.c
> +++ b/drivers/leds/leds-cros_ec.c
> @@ -14,8 +14,6 @@
> #include <linux/platform_data/cros_ec_commands.h>
> #include <linux/platform_data/cros_ec_proto.h>
>
> -#define DRV_NAME "cros-ec-led"
> -
> static const char * const cros_ec_led_functions[] = {
> [EC_LED_ID_BATTERY_LED] = LED_FUNCTION_CHARGING,
> [EC_LED_ID_POWER_LED] = LED_FUNCTION_POWER,
> @@ -152,7 +150,7 @@ static int cros_ec_led_count_subleds(struct device *dev,
>
> if (common_range != range) {
> /* The multicolor LED API expects a uniform max_brightness */
> - dev_warn(dev, "Inconsistent LED brightness values\n");
> + dev_err(dev, "Inconsistent LED brightness values\n");
> return -EINVAL;
> }
> }
> @@ -176,22 +174,21 @@ static const char *cros_ec_led_get_color_name(struct led_classdev_mc *led_mc_cde
> return led_get_color_name(color);
> }
>
> -static int cros_ec_led_probe_led(struct device *dev, struct cros_ec_device *cros_ec,
> +static int cros_ec_led_probe_one(struct device *dev, struct cros_ec_device *cros_ec,
> enum ec_led_id id)
> {
> union cros_ec_led_cmd_data arg = {};
> struct cros_ec_led_priv *priv;
> struct led_classdev *led_cdev;
> struct mc_subled *subleds;
> - int ret, num_subleds;
> - size_t i, subled;
> + int i, ret, num_subleds;
> + size_t subled;
>
> arg.req.led_id = id;
> arg.req.flags = EC_LED_FLAGS_QUERY;
> ret = cros_ec_led_send_cmd(cros_ec, &arg);
> - /* Unknown LED, skip */
> if (ret == -EINVAL)
> - return 0;
> + return 0; /* Unknown LED, skip */
> if (ret == -EOPNOTSUPP)
> return -ENODEV;
> if (ret < 0)
> @@ -247,11 +244,14 @@ static int cros_ec_led_probe(struct platform_device *pdev)
> struct device *dev = &pdev->dev;
> struct cros_ec_dev *ec_dev = dev_get_drvdata(dev->parent);
> struct cros_ec_device *cros_ec = ec_dev->ec_dev;
> - int ret = 0;
> - size_t i;
> + int i, ret = 0;
> +
> + ret = devm_led_trigger_register(dev, &cros_ec_led_trigger);
> + if (ret)
> + return ret;
>
> for (i = 0; i < EC_LED_ID_COUNT; i++) {
> - ret = cros_ec_led_probe_led(dev, cros_ec, i);
> + ret = cros_ec_led_probe_one(dev, cros_ec, i);
> if (ret)
> break;
> }
> @@ -260,38 +260,16 @@ static int cros_ec_led_probe(struct platform_device *pdev)
> }
>
> static const struct platform_device_id cros_ec_led_id[] = {
> - { DRV_NAME, 0 },
> + { "cros-ec-led", 0 },
> {}
> };
>
> static struct platform_driver cros_ec_led_driver = {
> - .driver.name = DRV_NAME,
> + .driver.name = "cros-ec-led",
> .probe = cros_ec_led_probe,
> .id_table = cros_ec_led_id,
> };
> -
> -static int __init cros_ec_led_init(void)
> -{
> - int ret;
> -
> - ret = led_trigger_register(&cros_ec_led_trigger);
> - if (ret)
> - return ret;
> -
> - ret = platform_driver_register(&cros_ec_led_driver);
> - if (ret)
> - led_trigger_unregister(&cros_ec_led_trigger);
> -
> - return ret;
> -};
> -module_init(cros_ec_led_init);
> -
> -static void __exit cros_ec_led_exit(void)
> -{
> - platform_driver_unregister(&cros_ec_led_driver);
> - led_trigger_unregister(&cros_ec_led_trigger);
> -};
> -module_exit(cros_ec_led_exit);
> +module_platform_driver(cros_ec_led_driver);
>
> MODULE_DEVICE_TABLE(platform, cros_ec_led_id);
> MODULE_DESCRIPTION("ChromeOS EC LED Driver");
>
> ---
> base-commit: b6774dd948171c478c7aa19318b1d7ae9cf6d7a4
> change-id: 20240614-cros_ec-led-review-ec93abc65933
>
> Best regards,
> --
> Thomas Weißschuh <linux@weissschuh.net>
>
--
Lee Jones [李琼斯]
next prev parent reply other threads:[~2024-06-20 9:31 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-14 10:04 [PATCH] leds: cros_ec: Implement review comments from Lee Thomas Weißschuh
2024-06-20 9:31 ` Lee Jones [this message]
2024-06-20 10:12 ` Thomas Weißschuh
2024-06-20 12:27 ` Lee Jones
2024-06-20 14:38 ` Thomas Weißschuh
2024-06-20 17:15 ` Lee Jones
2024-06-20 19:02 ` Thomas Weißschuh
2024-06-21 10:40 ` Lee Jones
2024-06-21 10:44 ` Thomas Weißschuh
2024-06-20 17:13 ` (subset) " Lee Jones
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=20240620093114.GH3029315@google.com \
--to=lee@kernel.org \
--cc=bleung@chromium.org \
--cc=chrome-platform@lists.linux.dev \
--cc=groeck@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=linux@weissschuh.net \
--cc=pavel@ucw.cz \
--cc=thomas@weissschuh.net \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.