Re: [PATCH v2 1/2] drivers: core: platform: Add platform_get_match_data() helper

From: Jonathan Cameron

Date: Sat Nov 28 2026 - 13:39:04 EST


On Sat, 28 Nov 2026 10:04:48 +0100
Fabio Forni <development@xxxxxxxxxx> wrote:

> Hello Jonathan,
>
> On 28/11/26 01:27, Jonathan Cameron wrote:
> > On Sat, 28 Nov 2026 00:22:09 +0100
> > Fabio Forni via B4 Relay <devnull+development.redaril.me@xxxxxxxxxx> wrote:
> >
> >> From: Fabio Forni <development@xxxxxxxxxx>
> >>
> >> device_get_match_data() retrieves driver data through the device's
> >> fwnode. However, software nodes don't implement
> >> fwnode->device_get_match_data(), so for a platform device that is
> >> dynamically instantiated, device_get_match_data() is of no use.
> >> platform_get_device_id() can be used instead, but this doesn't make the
> >> driver code abstract enough.
> >>
> >> Add the platform_get_match_data() helper, so that driver data can be
> >> retrieved from platform_device's fwnode *or* device_id as a fallback.
> > I'd have added a reference to similar cases like i2c_get_match_data()
> > or spi_get_device_match_data()
>
> Good idea, I'll do that in v3. I'll wait a few days to let others add comments.
>
> > and perhaps have followed the naming in there for the return variable.
> > Both call it match.
>
> Alright. I think you want me to return NULL instead of -ENODATA as well?
> The other helpers do so.

I hadn't particularly noted that difference but yes, consistency on that
would help reduce mistakes.

Jonathan