public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Sui Jingfeng <sui.jingfeng@linux.dev>
Cc: dri-devel@lists.freedesktop.org, linux-acpi@vger.kernel.org,
	linux-kernel@vger.kernel.org, Daniel Scally <djrscally@gmail.com>,
	Heikki Krogerus <heikki.krogerus@linux.intel.com>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>
Subject: Re: [PATCH v2] software node: Implement device_get_match_data fwnode callback
Date: Tue, 23 Apr 2024 16:28:25 +0300	[thread overview]
Message-ID: <Zie3ebHOEpWHj1qV@smile.fi.intel.com> (raw)
In-Reply-To: <20240422164658.217037-1-sui.jingfeng@linux.dev>

On Tue, Apr 23, 2024 at 12:46:58AM +0800, Sui Jingfeng wrote:
> Because the software node backend of the fwnode API framework lacks an
> implementation for the .device_get_match_data function callback. This
> makes it difficult to use(and/or test) a few drivers that originates

Missing space before opening parenthesis.

> from DT world on the non-DT platform.
> 
> Implement the .device_get_match_data fwnode callback, device drivers or
> platform setup codes are expected to provide a string property, named as
> "compatible", the value of this software node string property is used to
> match against the compatible entries in the of_device_id table.

Yep and again, how is this related? If you want to test a driver originating
from DT, you would probably want to have a DT (overlay) to be provided.

> This also helps to keep the three backends of the fwnode API aligned as
> much as possible, which is a fundamential step to make device driver
> OF-independent truely possible.
> 
> Fixes: ffb42e64561e ("drm/tiny/repaper: Make driver OF-independent")
> Fixes: 5703d6ae9573 ("drm/tiny/st7735r: Make driver OF-independent")

How is it a fix?

> Closes: https://lore.kernel.org/lkml/20230223203713.hcse3mkbq3m6sogb@skbuf/

Yes, and then Reported-by, which is missing here.

> Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Cc: Daniel Scally <djrscally@gmail.com>
> Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> Cc: Sakari Ailus <sakari.ailus@linux.intel.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: "Rafael J. Wysocki" <rafael@kernel.org>

Please, move these after the cutter '---' line (note you may have that line in
your local repo).

...

> +static const void *
> +software_node_get_match_data(const struct fwnode_handle *fwnode,
> +			     const struct device *dev)
> +{
> +	struct swnode *swnode = to_swnode(fwnode);
> +	const struct of_device_id *matches = dev->driver->of_match_table;
> +	const char *val = NULL;
> +	int ret;

> +	ret = property_entry_read_string_array(swnode->node->properties,
> +					       "compatible", &val, 1);

And if there are more than one compatible provided?

> +	if (ret < 0 || !val)
> +		return NULL;

> +	while (matches && matches->compatible[0]) {

First part of the conditional is invariant to the loop. Can be simply

	matches = dev->driver->of_match_table;
	if (!matches)
		return NULL;

	while (...)

> +		if (!strcmp(matches->compatible, val))
> +			return matches->data;
> +
> +		matches++;
> +	}
> +
> +	return NULL;
> +}

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2024-04-23 13:28 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-22 16:46 [PATCH v2] software node: Implement device_get_match_data fwnode callback Sui Jingfeng
2024-04-23 13:28 ` Andy Shevchenko [this message]
2024-04-23 16:49   ` Sui Jingfeng
2024-04-23 21:37     ` Dmitry Baryshkov
2024-04-24  5:09       ` Sui Jingfeng
2024-04-24  8:39         ` Dmitry Baryshkov
2024-04-24 10:51           ` Sui Jingfeng
2024-04-24 12:21           ` Sui Jingfeng
2024-04-24 13:10       ` Andy Shevchenko
2024-04-24 13:34         ` Dmitry Baryshkov
2024-04-24 14:52           ` Andy Shevchenko
2024-04-24 16:34             ` Dmitry Baryshkov
2024-04-24 16:44               ` Andy Shevchenko
2024-04-24 19:32                 ` Dmitry Baryshkov
2024-04-25 13:42                 ` Sui Jingfeng
2024-04-25 13:49                   ` Andy Shevchenko
2024-04-24 18:19               ` Sui Jingfeng

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=Zie3ebHOEpWHj1qV@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=djrscally@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=sui.jingfeng@linux.dev \
    /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