From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
To: Kyle Swenson <kyle.swenson@est.tech>,
pavel@ucw.cz, robh+dt@kernel.org, krzk+dt@kernel.org
Cc: linux-leds@vger.kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH 1/2] leds: aw21024: Add support for Awinic's AW21024
Date: Wed, 18 May 2022 10:30:15 +0200 [thread overview]
Message-ID: <bfb0f17f-4e78-65ad-898c-b6c07b04db38@linaro.org> (raw)
In-Reply-To: <YoPrLbGBnSuYgEzF@p620>
On 17/05/2022 20:36, Kyle Swenson wrote:
>>> +static const struct of_device_id of_aw21024_leds_match[] = {
>>> + { .compatible = "awinic,aw21024", },
>>> + {},
>>> +};
>>> +MODULE_DEVICE_TABLE(of, of_aw21024_leds_match);
>>> +
>>> +static struct i2c_driver aw21024_driver = {
>>> + .driver = {
>>> + .name = "aw21024",
>>> + .of_match_table = of_match_ptr(of_aw21024_leds_match),
>>
>> of_match_ptr causes this being unused. kbuild robot probably pointed
>> this out... if not - of_match_ptr goes with maybe_unused. You need both
>> or none, depending on intended usage.
>>
> Ah, yes, the kbuild robot did point this out to me, and I had planned on
> fixing by adding 'depends on OF' to the Kconfig. Perhaps that isn't
> correct or complete (or even relevant)?
>
> I'll do some investigating and determine if I need to use of_match_ptr
> or not and I'll fix it either by removing it or adding maybe_unused in
> the next version.
Your has i2c_device_id so it could bind without OF, however obviously
aw21024_probe_dt() will do nothing and return 0.
Therefore it is up to you if you want to add dependency on OF. If you
add, please add it with "|| COMPILE_TEST".
Then in both cases you need to handle the case of building (not running)
a driver without OF: using maybe_unused+of_match_ptr() or nothing (thus
always referencing of_device_id). Which one to choose matters less.
Using it causes the code to be smaller for !OF case, which might matter
for some distros which build everything as module. Not using it allows
to match the driver on ACPI systems, although I am not sure if this is
relevant.
I don't have recommendation on that - just be sure there are no warnings.
Best regards,
Krzysztof
prev parent reply other threads:[~2022-05-18 8:30 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-13 19:04 [PATCH 1/2] leds: aw21024: Add support for Awinic's AW21024 Kyle Swenson
2022-05-13 19:04 ` [PATCH 2/2] dt-bindings: leds: Add aw21024 binding Kyle Swenson
2022-05-13 20:48 ` Rob Herring
2022-05-17 9:08 ` Krzysztof Kozlowski
2022-05-17 18:31 ` Kyle Swenson
2022-05-18 8:17 ` Krzysztof Kozlowski
2022-05-18 21:18 ` Kyle Swenson
2022-05-19 8:04 ` Krzysztof Kozlowski
2022-05-16 10:21 ` [PATCH 1/2] leds: aw21024: Add support for Awinic's AW21024 kernel test robot
2022-05-16 10:42 ` kernel test robot
2022-05-16 12:34 ` kernel test robot
2022-05-17 9:11 ` Krzysztof Kozlowski
2022-05-17 18:36 ` Kyle Swenson
2022-05-18 8:30 ` Krzysztof Kozlowski [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=bfb0f17f-4e78-65ad-898c-b6c07b04db38@linaro.org \
--to=krzysztof.kozlowski@linaro.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=kyle.swenson@est.tech \
--cc=linux-leds@vger.kernel.org \
--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).