From: Christian Mauderer <oss@c-mauderer.de>
To: Jacek Anaszewski <jacek.anaszewski@gmail.com>,
linux-leds@vger.kernel.org, devicetree@vger.kernel.org,
Pavel Machek <pavel@ucw.cz>
Cc: Dan Murphy <dmurphy@ti.com>, Rob Herring <robh+dt@kernel.org>,
Mark Rutland <mark.rutland@arm.com>
Subject: Re: [PATCH v3 2/2] leds: spi-byte: add single byte SPI LED driver
Date: Sun, 5 May 2019 22:14:59 +0200 [thread overview]
Message-ID: <3017c83c-3931-aa90-8bbb-b60263500a9d@c-mauderer.de> (raw)
In-Reply-To: <a473e4ec-10f7-6261-1fc3-8164677ac36b@gmail.com>
On 05/05/2019 22:09, Jacek Anaszewski wrote:
> Christian,
>
> Thank you for the update. One thing left after switching
> to devm API. Please refer below to the remove op.
>
> On 5/5/19 10:00 PM, oss@c-mauderer.de wrote:
>> From: Christian Mauderer <oss@c-mauderer.de>
>>
>> This driver adds support for simple SPI based LED controller which use
>> only one byte for setting the brightness.
>>
>> Signed-off-by: Christian Mauderer <oss@c-mauderer.de>
>> ---
>>
>> Changes compared to v2:
>> - use "if (ret)" instead of "if (ret != 0)"
>> - don't initialize ldev-fields with zero
>> - use devm_led_classdev_register instead of led_classdev_register
>> - check for error instead of good case with the last if in spi_byte_probe
>>
>> Changes compared to v1:
>> - rename ubnt-spi to leds-spi-byte
>> - rework probe to get all parameters before allocating anything ->
>> error checks
>> all collected together and initializing all fields of the device
>> structure is
>> more obvious
>> - fix some unsteady indentations during variable declaration
>> - rework comment with protocol explanation
>> - handle case of off_bright > max_bright
>> - fix spelling in commit message
>> - mutex_destroy in remove
>> - change label to use either use the given one without a prefix or a
>> default one
>>
>>
>> drivers/leds/Kconfig | 12 ++++
>> drivers/leds/Makefile | 1 +
>> drivers/leds/leds-spi-byte.c | 134 +++++++++++++++++++++++++++++++++++
>> 3 files changed, 147 insertions(+)
>> create mode 100644 drivers/leds/leds-spi-byte.c
>
> [...]
>> +
>> +static int spi_byte_remove(struct spi_device *spi)
>> +{
>> + struct spi_byte_led *led = spi_get_drvdata(spi);
>> +
>> + led_classdev_unregister(&led->ldev);
>
> This is now not needed - devm, means "device managed", i.e.
> all resources claimed with it will be automatically reclaimed
> on device destruction.
>
Thanks for the hint. I've read that the devm functions are some "free
automatically" functions. But I haven't drawn the conclusion that I have
to remove this function. Seems I still need to learn a lot about the
Linux API.
I'll wait for further feedback over night and then remove it in a v4
tomorrow. Otherwise I'll spam the list with lots of new versions.
>> + mutex_destroy(&led->mutex);
>> +
>> + return 0;
>> +}
>> +
>> +static const struct of_device_id spi_byte_dt_ids[] = {
>> + { .compatible = "leds-spi-byte", },
>> + {},
>> +};
>> +
>> +MODULE_DEVICE_TABLE(of, spi_byte_dt_ids);
>> +
>> +static struct spi_driver spi_byte_driver = {
>> + .probe = spi_byte_probe,
>> + .remove = spi_byte_remove,
>> + .driver = {
>> + .name = KBUILD_MODNAME,
>> + .of_match_table = spi_byte_dt_ids,
>> + },
>> +};
>> +
>> +module_spi_driver(spi_byte_driver);
>> +
>> +MODULE_AUTHOR("Christian Mauderer <oss@c-mauderer.de>");
>> +MODULE_DESCRIPTION("single byte SPI LED driver");
>> +MODULE_LICENSE("GPL v2");
>> +MODULE_ALIAS("spi:leds-spi-byte");
>>
>
next prev parent reply other threads:[~2019-05-05 20:15 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-05 20:00 [PATCH v3 1/2] dt-bindings: leds: Add binding for spi-byte LED oss
2019-05-05 20:00 ` [PATCH v3 2/2] leds: spi-byte: add single byte SPI LED driver oss
2019-05-05 20:09 ` Jacek Anaszewski
2019-05-05 20:14 ` Christian Mauderer [this message]
2019-05-06 12:05 ` Dan Murphy
2019-05-06 12:59 ` Christian Mauderer
2019-05-06 14:58 ` Dan Murphy
2019-05-06 15:15 ` Pavel Machek
2019-05-06 15:29 ` Christian Mauderer
2019-05-06 17:40 ` Dan Murphy
2019-05-06 19:12 ` Christian Mauderer
2019-05-06 15:19 ` Christian Mauderer
2019-05-06 15:37 ` Dan Murphy
2019-05-06 15:42 ` Christian Mauderer
2019-05-06 16:21 ` [PATCH v3 1/2] dt-bindings: leds: Add binding for spi-byte LED Rob Herring
2019-05-06 16:28 ` Pavel Machek
2019-05-06 17:44 ` Rob Herring
2019-05-06 19:21 ` Christian Mauderer
2019-05-06 20:25 ` Pavel Machek
2019-05-07 9:52 ` Christian Mauderer
2019-05-10 19:50 ` Christian Mauderer
2019-05-10 20:42 ` Jacek Anaszewski
2019-05-11 6:56 ` Christian Mauderer
2019-05-11 9:11 ` Jacek Anaszewski
2019-05-06 17:03 ` Christian Mauderer
2019-05-06 17:59 ` Rob Herring
2019-05-06 19:28 ` Christian Mauderer
2019-05-06 19:06 ` Jacek Anaszewski
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=3017c83c-3931-aa90-8bbb-b60263500a9d@c-mauderer.de \
--to=oss@c-mauderer.de \
--cc=devicetree@vger.kernel.org \
--cc=dmurphy@ti.com \
--cc=jacek.anaszewski@gmail.com \
--cc=linux-leds@vger.kernel.org \
--cc=mark.rutland@arm.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).