From: Bjorn Andersson <bjorn.andersson@linaro.org>
To: Marek Beh?n <marek.behun@nic.cz>
Cc: linux-leds@vger.kernel.org, Pavel Machek <pavel@ucw.cz>,
Dan Murphy <dmurphy@ti.com>, Ond??ej Jirman <megous@megous.com>,
linux-kernel@vger.kernel.org, Rob Herring <robh+dt@kernel.org>,
devicetree@vger.kernel.org,
Linus Walleij <linus.walleij@linaro.org>
Subject: Re: [PATCH leds v1 06/10] leds: pm8058: use struct led_init_data when registering
Date: Wed, 16 Sep 2020 19:46:25 -0500 [thread overview]
Message-ID: <20200917004625.GJ1893@yoga> (raw)
In-Reply-To: <20200916231650.11484-7-marek.behun@nic.cz>
On Wed 16 Sep 18:16 CDT 2020, Marek Beh?n wrote:
> By using struct led_init_data when registering we do not need to parse
> `label` DT property nor `linux,default-trigger` property.
>
> Signed-off-by: Marek Behún <marek.behun@nic.cz>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
> ---
> drivers/leds/leds-pm8058.c | 38 +++++++++++++++++++-------------------
> 1 file changed, 19 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/leds/leds-pm8058.c b/drivers/leds/leds-pm8058.c
> index 7869ccdf70ce6..f6190e4af60fe 100644
> --- a/drivers/leds/leds-pm8058.c
> +++ b/drivers/leds/leds-pm8058.c
> @@ -87,36 +87,37 @@ static enum led_brightness pm8058_led_get(struct led_classdev *cled)
>
> static int pm8058_led_probe(struct platform_device *pdev)
> {
> + struct led_init_data init_data = {};
> + struct device *dev = &pdev->dev;
> + enum led_brightness maxbright;
> + struct device_node *np;
> struct pm8058_led *led;
> - struct device_node *np = pdev->dev.of_node;
> - int ret;
> struct regmap *map;
> const char *state;
> - enum led_brightness maxbright;
> + int ret;
>
> - led = devm_kzalloc(&pdev->dev, sizeof(*led), GFP_KERNEL);
> + led = devm_kzalloc(dev, sizeof(*led), GFP_KERNEL);
The pdev->dev -> dev and of_node changes are reasonable, but shouldn't
be part of this patch. It simply makes it hard to reason about he actual
change.
Please respin this with only the introduction of led_init_data.
Thanks,
Bjorn
> if (!led)
> return -ENOMEM;
>
> - led->ledtype = (u32)(unsigned long)of_device_get_match_data(&pdev->dev);
> + led->ledtype = (u32)(unsigned long)device_get_match_data(dev);
>
> - map = dev_get_regmap(pdev->dev.parent, NULL);
> + map = dev_get_regmap(dev->parent, NULL);
> if (!map) {
> - dev_err(&pdev->dev, "Parent regmap unavailable.\n");
> + dev_err(dev, "Parent regmap unavailable.\n");
> return -ENXIO;
> }
> led->map = map;
>
> + np = dev_of_node(dev);
> +
> ret = of_property_read_u32(np, "reg", &led->reg);
> if (ret) {
> - dev_err(&pdev->dev, "no register offset specified\n");
> + dev_err(dev, "no register offset specified\n");
> return -EINVAL;
> }
>
> /* Use label else node name */
> - led->cdev.name = of_get_property(np, "label", NULL) ? : np->name;
> - led->cdev.default_trigger =
> - of_get_property(np, "linux,default-trigger", NULL);
> led->cdev.brightness_set = pm8058_led_set;
> led->cdev.brightness_get = pm8058_led_get;
> if (led->ledtype == PM8058_LED_TYPE_COMMON)
> @@ -142,14 +143,13 @@ static int pm8058_led_probe(struct platform_device *pdev)
> led->ledtype == PM8058_LED_TYPE_FLASH)
> led->cdev.flags = LED_CORE_SUSPENDRESUME;
>
> - ret = devm_led_classdev_register(&pdev->dev, &led->cdev);
> - if (ret) {
> - dev_err(&pdev->dev, "unable to register led \"%s\"\n",
> - led->cdev.name);
> - return ret;
> - }
> + init_data.fwnode = of_fwnode_handle(np);
> +
> + ret = devm_led_classdev_register_ext(dev, &led->cdev, &init_data);
> + if (ret)
> + dev_err(dev, "Failed to register LED for node %pOF\n", np);
>
> - return 0;
> + return ret;
> }
>
> static const struct of_device_id pm8058_leds_id_table[] = {
> @@ -173,7 +173,7 @@ static struct platform_driver pm8058_led_driver = {
> .probe = pm8058_led_probe,
> .driver = {
> .name = "pm8058-leds",
> - .of_match_table = pm8058_leds_id_table,
> + .of_match_table = of_match_ptr(pm8058_leds_id_table),
> },
> };
> module_platform_driver(pm8058_led_driver);
> --
> 2.26.2
>
next prev parent reply other threads:[~2020-09-17 0:53 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-16 23:16 [PATCH leds v1 00/10] Start moving parsing of `linux,default-trigger` to LED core (a cleanup of LED drivers) Marek Behún
2020-09-16 23:16 ` [PATCH leds v1 01/10] leds: parse linux,default-trigger DT property in LED core Marek Behún
2020-09-16 23:16 ` [PATCH leds v1 02/10] leds: bcm6328, bcm6358: use struct led_init_data when registering Marek Behún
2020-09-16 23:16 ` [PATCH leds v1 03/10] leds: lm3697: " Marek Behún
2020-09-17 11:39 ` Dan Murphy
2020-09-17 15:24 ` Marek Behun
2020-09-16 23:16 ` [PATCH leds v1 04/10] leds: max77650: " Marek Behún
2020-09-17 10:09 ` Bartosz Golaszewski
2020-09-16 23:16 ` [PATCH leds v1 05/10] leds: mt6323: " Marek Behún
2020-09-16 23:16 ` [PATCH leds v1 06/10] leds: pm8058: " Marek Behún
2020-09-17 0:46 ` Bjorn Andersson [this message]
2020-09-17 15:24 ` Marek Behun
2020-09-16 23:16 ` [PATCH leds v1 07/10] leds: is31fl32xx: " Marek Behún
2020-09-17 15:23 ` Marek Behun
2020-09-16 23:16 ` [PATCH leds v1 08/10] leds: is31fl319x: " Marek Behún
2020-09-16 23:16 ` [PATCH leds v1 09/10] leds: lm36274: " Marek Behún
2020-09-17 15:28 ` Dan Murphy
2020-09-17 15:54 ` Marek Behun
2020-09-16 23:16 ` [PATCH leds v1 10/10] leds: ns2: refactor and use struct led_init_data Marek Behún
2020-09-18 13:02 ` Simon Guinot
2020-09-18 17:14 ` Marek Behun
2020-09-21 12:53 ` Simon Guinot
2020-09-21 13:02 ` Marek Behun
2020-09-21 14:03 ` Simon Guinot
2020-09-21 14:31 ` Marek Behun
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=20200917004625.GJ1893@yoga \
--to=bjorn.andersson@linaro.org \
--cc=devicetree@vger.kernel.org \
--cc=dmurphy@ti.com \
--cc=linus.walleij@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=marek.behun@nic.cz \
--cc=megous@megous.com \
--cc=pavel@ucw.cz \
--cc=robh+dt@kernel.org \
/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).