mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Jean-François Lessard" <jefflessard3@gmail.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: "Andy Shevchenko" <andy@kernel.org>,
	"Rob Herring" <robh@kernel.org>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	"Geert Uytterhoeven" <geert@linux-m68k.org>,
	devicetree@vger.kernel.org, linux-leds@vger.kernel.org,
	linux-kernel@vger.kernel.org, "Andreas Färber" <afaerber@suse.de>,
	"Boris Gjenero" <boris.gjenero@gmail.com>,
	"Christian Hewitt" <christianshewitt@gmail.com>,
	"Heiner Kallweit" <hkallweit1@gmail.com>,
	"Paolo Sabatino" <paolo.sabatino@gmail.com>,
	"Martin Blumenstingl" <martin.blumenstingl@googlemail.com>
Subject: Re: [PATCH v3 3/4] auxdisplay: Add TM16xx 7-segment LED matrix display controllers driver
Date: Fri, 22 Aug 2025 09:50:08 -0400	[thread overview]
Message-ID: <13102F25-B59B-46CA-B0DC-F6F5724E4974@gmail.com> (raw)
In-Reply-To: <CAHp75VcpJzMUtrN2kBhWs90G3n6_NWTBhw3MX2WpuhsDt7zmjQ@mail.gmail.com>

Le 22 août 2025 02 h 08 min 42 s HAE, Andy Shevchenko <andy.shevchenko@gmail.com> a écrit :
>On Fri, Aug 22, 2025 at 5:20 AM Jean-François Lessard
><jefflessard3@gmail.com> wrote:
>> Le 21 août 2025 16 h 19 min 23 s HAE, Andy Shevchenko <andy.shevchenko@gmail.com> a écrit :
>> >On Thu, Aug 21, 2025 at 10:04 PM Jean-François Lessard
>> ><jefflessard3@gmail.com> wrote:
>> >> Le 21 août 2025 04 h 08 min 51 s HAE, Andy Shevchenko <andy.shevchenko@gmail.com> a écrit :
>> >> >On Wed, Aug 20, 2025 at 7:32 PM Jean-François Lessard
>> >> ><jefflessard3@gmail.com> wrote:
>
>...
>
>> >> >> +#define TM16XX_DRIVER_NAME "tm16xx"
>
>> >> The TM16XX_DRIVER_NAME macro is standard practice for consistent string usage
>> >> in registration and module macros.
>> >> If helpful, I can add a leading /* module name */ header comment.
>> >
>> >Instead of an unneeded comment it seems better to use explicit string
>> >literal in all cases (two?).
>>
>> I'm surprised by this preference since driver name macros are very common
>> practice, but I'll use explicit string literals to align on this preference.
>
>Usually we put a macro to something which (theoretically) might
>change. The driver name is part of an ABI and I prefer it to be
>explicit as we do not break an ABI. Once introduced it can't be
>modified or removed. Also it's better to see clearly exactly at the
>place in use in the code the name as it's easier to (git) grep for
>something similar. With a macro I would need to grep at least twice to
>see the users.
>

Well received. I'll use explicit string literals.

>...
>
>> >> >> +       keypad->state = devm_bitmap_zalloc(display->dev, nbits, GFP_KERNEL);
>> >> >> +       keypad->last_state = devm_bitmap_zalloc(display->dev, nbits, GFP_KERNEL);
>> >> >> +       keypad->changes = devm_bitmap_zalloc(display->dev, nbits, GFP_KERNEL);
>> >> >> +       if (!keypad->state || !keypad->last_state || !keypad->changes) {
>> >> >> +               ret = -ENOMEM;
>> >
>> >> >> +               goto free_keypad;
>> >
>> >(Hit send too early that time...) This goto is bad. It means
>> >misunderstanding of the devm concept. See below.
>>
>> I can assure I understand the devm paradigm. The keypad probe is optional,
>> failure doesn't fail the main driver probe but only generates a warning. The
>> cleanup code prevents memory from staying allocated until device removal
>> in this specific optional failure case. However, if you insist, I'll remove the
>> cleanup and let devm handle it normally.
>
>Assume you have a separate feature, let's say keypad driver for some
>complex HW, like this one, and you have even a separate (library)
>driver for it. Then you want to introduce some kind of library
>functions to probe and remove the only keypad part, here are two
>options:
>- follow the library pattern with plain (non-devm) k*alloc() in probe
>and kfree in remove
>- use driver pattern with devm
>
>If you choose the second one, it will be weird to call devm_kfree().
>The rule of thumb the devm_$FREE_MY_RESOURSE() *must* be *well*
>justified. Because it's exceptional. Losing 1kb memory or so is not
>enough to justify.
>

Understood. I'll remove the cleanup gotos for this scenario given that
devm is generally preferred and that losing 1kb memory or so is not
enough to justify.

>> >> >> +       }
>> >> >> +
>> >> >> +       input = devm_input_allocate_device(display->dev);
>
>> >> >> +free_bitmaps:
>> >> >> +       devm_kfree(display->dev, keypad->state);
>> >> >> +       devm_kfree(display->dev, keypad->last_state);
>> >> >> +       devm_kfree(display->dev, keypad->changes);
>> >> >> +free_keypad:
>> >> >> +       devm_kfree(display->dev, keypad);
>> >> >> +       return ret;
>> >
>> >No way. We don't do that, If required it signals about exceptional
>> >case (0.01% probability) or misunderstanding of devm:
>> >- managed resources are managed by core, no need to call for free
>> >- using managed resources in the contexts when object lifetime is
>> >short is incorrect, needs to be switched to the plain alloc (nowadays
>> >with __free() from cleanup.h to have RAII enabled)
>> >
>> >Choose one of these and fix the code accordingly.
>>
>> Same as above.
>

...

>> >I stopped here, I believe it's enough for now (and I would wait for
>> >the smaller changes per patch, perhaps 2 DT bindings patch + common
>> >part (basic functionality) + spi driver + i2c driver + keyboard,
>> >something like 6+ patches).

I know it's a lot to review ~1800 lines at once and that the split into multiple
files will require a review anyway, but feel free to share additional feedback
on any other obvious issues you may observe, so I can fix these for v4.

Thanks again for your time and thorough feedback,
Jean-François Lessard

  reply	other threads:[~2025-08-22 13:50 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-20 16:31 [PATCH v3 0/4] " Jean-François Lessard
2025-08-20 16:31 ` [PATCH v3 1/4] dt-bindings: vendor-prefixes: Add fdhisi, titanmec, princeton, winrise, wxicore Jean-François Lessard
2025-08-20 20:08   ` Conor Dooley
2025-08-21 19:35     ` Jean-François Lessard
2025-08-21 20:13       ` Conor Dooley
2025-08-22  2:35         ` Jean-François Lessard
2025-08-20 16:31 ` [PATCH v3 2/4] dt-bindings: auxdisplay: add Titan Micro Electronics TM16xx Jean-François Lessard
2025-08-21  7:48   ` Krzysztof Kozlowski
2025-08-21 15:16     ` Jean-François Lessard
2025-08-22  6:44       ` Krzysztof Kozlowski
2025-08-22 13:32         ` Jean-François Lessard
2025-08-20 16:31 ` [PATCH v3 3/4] auxdisplay: Add TM16xx 7-segment LED matrix display controllers driver Jean-François Lessard
2025-08-21  7:43   ` Krzysztof Kozlowski
2025-08-21 16:42     ` Jean-François Lessard
2025-08-21  8:08   ` Andy Shevchenko
2025-08-21 19:04     ` Jean-François Lessard
2025-08-21 20:19       ` Andy Shevchenko
2025-08-22  2:20         ` Jean-François Lessard
2025-08-22  6:08           ` Andy Shevchenko
2025-08-22 13:50             ` Jean-François Lessard [this message]
2025-08-27  5:32   ` kernel test robot
2025-08-20 16:31 ` [PATCH v3 4/4] MAINTAINERS: Add entry for TM16xx driver Jean-François Lessard
2025-08-20 19:08   ` Andy Shevchenko
2025-08-20 19:51     ` Conor Dooley
2025-08-20 20:29       ` Andy Shevchenko
2025-08-21 17:40         ` Conor Dooley
2025-08-21 19:33           ` Andy Shevchenko
2025-08-21 19:35             ` Andy Shevchenko
2025-08-21 20:11               ` Conor Dooley
2025-08-21 20:23                 ` Andy Shevchenko

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=13102F25-B59B-46CA-B0DC-F6F5724E4974@gmail.com \
    --to=jefflessard3@gmail.com \
    --cc=afaerber@suse.de \
    --cc=andy.shevchenko@gmail.com \
    --cc=andy@kernel.org \
    --cc=boris.gjenero@gmail.com \
    --cc=christianshewitt@gmail.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=geert@linux-m68k.org \
    --cc=hkallweit1@gmail.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=martin.blumenstingl@googlemail.com \
    --cc=paolo.sabatino@gmail.com \
    --cc=robh@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®