From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Kate Hsuan <hpa@redhat.com>
Cc: "Pavel Machek" <pavel@ucw.cz>, "Lee Jones" <lee@kernel.org>,
linux-leds@vger.kernel.org, platform-driver-x86@vger.kernel.org,
"Hans de Goede" <hdegoede@redhat.com>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"André Apitzsch" <git@apitzsch.eu>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 2/2] leds: rgb: leds-ktd202x: Get device properties through fwnode to support ACPI
Date: Tue, 12 Mar 2024 01:04:31 +0200 [thread overview]
Message-ID: <Ze-N_y5Tbjc93aRp@surfacebook.localdomain> (raw)
In-Reply-To: <20240306025801.8814-3-hpa@redhat.com>
Wed, Mar 06, 2024 at 10:58:01AM +0800, Kate Hsuan kirjoitti:
> This LED controller also installed on a Xiaomi pad2 and it is a x86
> platform. The original driver is based on device tree and can't be
> used for this ACPI based system. This patch migrated the driver to
> use fwnode to access the properties. Moreover, the fwnode API
> supports device tree so this work won't effect the original
> implementations.
...
> + fwnode_for_each_available_child_node(np, child) {
Please, rename np to fwnode to avoid confusion.
> + num_channels++;
> + }
...
> - for_each_available_child_of_node(np, child) {
> + fwnode_for_each_available_child_node(np, child) {
> u32 mono_color;
> u32 reg;
> int ret;
>
> - ret = of_property_read_u32(child, "reg", ®);
> + ret = fwnode_property_read_u32(child, "reg", ®);
> if (ret != 0 || reg >= chip->num_leds) {
> dev_err(chip->dev, "invalid 'reg' of %pOFn\n", child);
Must be %pfw now.
> - of_node_put(child);
> + fwnode_handle_put(child);
> return -EINVAL;
Side note: This shouldn't shadow error code when ret != 0.
> }
...
> - ret = of_property_read_u32(child, "color", &mono_color);
> + ret = fwnode_property_read_u32(child, "color", &mono_color);
> if (ret < 0 && ret != -EINVAL) {
> dev_err(chip->dev, "failed to parse 'color' of %pOF\n", child);
Must be %pfw now.
> - of_node_put(child);
> + fwnode_handle_put(child);
> return ret;
> }
...
> - ret = of_property_read_u32(np, "reg", ®);
> + ret = fwnode_property_read_u32(np, "reg", ®);
> if (ret != 0 || reg >= chip->num_leds) {
> dev_err(chip->dev, "invalid 'reg' of %pOFn\n", np);
Must be %pfw now.
> return -EINVAL;
> /* Color property is optional in single color case */
> - ret = of_property_read_u32(np, "color", &color);
> + ret = fwnode_property_read_u32(np, "color", &color);
> if (ret < 0 && ret != -EINVAL) {
> dev_err(chip->dev, "failed to parse 'color' of %pOF\n", np);
Must be %pfw now.
> return ret;
> }
...
> + struct fwnode_handle *child, *np;
Do not use np for sturct fwnode_handle. It will be quite confusing.
...
> - chip->num_leds = (int)(unsigned long)of_device_get_match_data(chip->dev);
> + count = device_get_child_node_count(dev);
>
Redundant blank line.
> - count = of_get_available_child_count(np);
> if (!count || count > chip->num_leds)
> return -EINVAL;
...
> + chip->num_leds = (unsigned long)i2c_get_match_data(client);
No warnings during compilation?
...
> +static const struct i2c_device_id ktd202x_id[] = {
> + {"ktd2026", KTD2026_NUM_LEDS},
> + {"ktd2027", KTD2027_NUM_LEDS},
> + {},
N ocomma for the terminator entry.
> +};
> +MODULE_DEVICE_TABLE(i2c, ktd202x_id);
...
> +#ifndef CONFIG_ACPI
Please, no. Drop them.
> static const struct of_device_id ktd202x_match_table[] = {
> { .compatible = "kinetic,ktd2026", .data = (void *)KTD2026_NUM_LEDS },
> { .compatible = "kinetic,ktd2027", .data = (void *)KTD2027_NUM_LEDS },
> {},
> };
> MODULE_DEVICE_TABLE(of, ktd202x_match_table);
> +#endif
>
> static struct i2c_driver ktd202x_driver = {
> .driver = {
> .name = "leds-ktd202x",
> +#ifndef CONFIG_ACPI
> .of_match_table = ktd202x_match_table,
> +#endif
This is quite unusual besides being ugly.
> },
> .probe = ktd202x_probe,
> .remove = ktd202x_remove,
> .shutdown = ktd202x_shutdown,
> + .id_table = ktd202x_id,
> };
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2024-03-11 23:05 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-06 2:57 [PATCH v4 0/2] KTD2026 indicator LED for X86 Xiaomi Pad2 Kate Hsuan
2024-03-06 2:58 ` [PATCH v4 1/2] platform: x86-android-tablets: other: Add swnode for Xiaomi pad2 indicator LED Kate Hsuan
2024-03-11 22:42 ` Andy Shevchenko
2024-03-12 10:35 ` Ilpo Järvinen
2024-03-13 7:44 ` Kate Hsuan
2024-03-06 2:58 ` [PATCH v4 2/2] leds: rgb: leds-ktd202x: Get device properties through fwnode to support ACPI Kate Hsuan
2024-03-11 12:03 ` Ilpo Järvinen
2024-03-11 18:48 ` André Apitzsch
2024-03-11 23:04 ` Andy Shevchenko [this message]
2024-03-22 5:44 ` Kate Hsuan
2024-03-22 16:01 ` Andy Shevchenko
2024-03-24 14:48 ` Kate Hsuan
2024-03-11 12:05 ` [PATCH v4 0/2] KTD2026 indicator LED for X86 Xiaomi Pad2 Ilpo Järvinen
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=Ze-N_y5Tbjc93aRp@surfacebook.localdomain \
--to=andy.shevchenko@gmail.com \
--cc=git@apitzsch.eu \
--cc=hdegoede@redhat.com \
--cc=hpa@redhat.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=lee@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=pavel@ucw.cz \
--cc=platform-driver-x86@vger.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
all inboxes | Powered by JetHome®