public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Peter Rosin <peda@axentia.se>
Cc: Javier Martinez Canillas <javierm@redhat.com>,
	"linux-i2c@vger.kernel.org" <linux-i2c@vger.kernel.org>,
	Wolfram Sang <wsa@the-dreams.de>
Subject: Re: [PATCH v1 2/5] i2c: mux: pca954x: Make use of device properties
Date: Fri, 6 Mar 2020 17:07:03 +0200	[thread overview]
Message-ID: <20200306150703.GO1748204@smile.fi.intel.com> (raw)
In-Reply-To: <db6c657b-6b9c-77f9-f990-90e47f48688e@axentia.se>

On Fri, Mar 06, 2020 at 03:57:50PM +0100, Peter Rosin wrote:
> On 2020-03-06 14:58, Andy Shevchenko wrote:
> > On Fri, Mar 06, 2020 at 12:48:14PM +0100, Peter Rosin wrote:
> >> On 2020-03-06 10:54, Andy Shevchenko wrote:
> >>> On Thu, Mar 05, 2020 at 09:05:56PM +0000, Peter Rosin wrote:
> >>>> On 2020-03-05 16:53, Andy Shevchenko wrote:
> >>>>> Device property API allows to gather device resources from different sources,
> >>>>> such as ACPI. Convert the drivers to unleash the power of device property API.
> >>>
> >>> ...
> >>>
> >>>>>  static const struct i2c_device_id pca954x_id[] = {
> >>>>> -	{ "pca9540", pca_9540 },
> >>>>> -	{ "pca9542", pca_9542 },
> >>>>> -	{ "pca9543", pca_9543 },
> >>>>> -	{ "pca9544", pca_9544 },
> >>>>> -	{ "pca9545", pca_9545 },
> >>>>> -	{ "pca9546", pca_9546 },
> >>>>> -	{ "pca9547", pca_9547 },
> >>>>> -	{ "pca9548", pca_9548 },
> >>>>> -	{ "pca9846", pca_9846 },
> >>>>> -	{ "pca9847", pca_9847 },
> >>>>> -	{ "pca9848", pca_9848 },
> >>>>> -	{ "pca9849", pca_9849 },
> >>>>> +	{ "pca9540", .driver_data = (kernel_ulong_t)&chips[pca_9540] },
> >>>>> +	{ "pca9542", .driver_data = (kernel_ulong_t)&chips[pca_9542] },
> >>>>> +	{ "pca9543", .driver_data = (kernel_ulong_t)&chips[pca_9543] },
> >>>>> +	{ "pca9544", .driver_data = (kernel_ulong_t)&chips[pca_9544] },
> >>>>> +	{ "pca9545", .driver_data = (kernel_ulong_t)&chips[pca_9545] },
> >>>>> +	{ "pca9546", .driver_data = (kernel_ulong_t)&chips[pca_9546] },
> >>>>> +	{ "pca9547", .driver_data = (kernel_ulong_t)&chips[pca_9547] },
> >>>>> +	{ "pca9548", .driver_data = (kernel_ulong_t)&chips[pca_9548] },
> >>>>> +	{ "pca9846", .driver_data = (kernel_ulong_t)&chips[pca_9846] },
> >>>>> +	{ "pca9847", .driver_data = (kernel_ulong_t)&chips[pca_9847] },
> >>>>> +	{ "pca9848", .driver_data = (kernel_ulong_t)&chips[pca_9848] },
> >>>>> +	{ "pca9849", .driver_data = (kernel_ulong_t)&chips[pca_9849] },
> >>>>
> >>>> It feels odd/wrong to specifically name .driver_data when .name is not there.
> >>>> None or both...
> >>>
> >>> I will add .name as well.
> >>>
> >>>>> +	data->chip = device_get_match_data(dev);
> >>>>>  	if (!data->chip)
> >>>>>  		data->chip = &chips[id->driver_data];
> >>>>
> >>>> These two lines no longer make any sence.
> >>>
> >>> Please elaborate.
> >>>
> >>> IIRC Javier explained once that I²C ID table is still good to have to allow
> >>> enumeration from user space.
> >>
> >> id->driver_data is no longer an integer index into chips[].
>>> So, for the I2C
> >> ID table case, either device_get_match_data returns the .driver_data as-is
> >> from the pca954x_id array,
>>> or it returns NULL (I don't know which it is).
> > No, you took it wrong. device_get_match_data() operates with ACPI/DT tables.
> 
> <rant-mode>
> 
> What do you mean wrong? 

I meant that A is wrong.

> I said that either A or B holds but did not know which
> (with these definitions):
> 
> A. device_get_match_data() digs in the i2c_device_id table and returns the
>    .driver_data of the matching entry.
> B. device_get_match_data() behaves as of_device_get_match_data() and does not
>    dig in the i2c_device_id table, and therefore returns NULL when the driver
>    is probed that way.
> 
> And that in either of these cases your patch made no sense.
> 
> At least that was what I tried to say, using less words...
> 
> And then, according to you, B holds. So, I was right: either A or B holds. BTW,
> I obviously meant the either/or construct to be in the exclusive sense where
> both cannot hold (but my statement is also correct in the inclusive-or sense).
> 
> I would only have been wrong if the correct description had been some third
> option, which I had not mentioned. But that was apparently not the case.

-- 
With Best Regards,
Andy Shevchenko

  reply	other threads:[~2020-03-06 15:07 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-05 15:53 [PATCH v1 1/5] i2c: mux: pca954x: Refactor pca954x_irq_handler() Andy Shevchenko
2020-03-05 15:53 ` [PATCH v1 2/5] i2c: mux: pca954x: Make use of device properties Andy Shevchenko
2020-03-05 21:05   ` Peter Rosin
2020-03-06  9:54     ` Andy Shevchenko
2020-03-06 11:48       ` Peter Rosin
2020-03-06 13:58         ` Andy Shevchenko
2020-03-06 14:57           ` Peter Rosin
2020-03-06 15:07             ` Andy Shevchenko [this message]
2020-03-05 15:53 ` [PATCH v1 3/5] i2c: mux: pca954x: Drop useless validation for optional GPIO descriptor Andy Shevchenko
2020-03-05 21:19   ` Peter Rosin
2020-03-06  9:56     ` Andy Shevchenko
2020-03-05 15:53 ` [PATCH v1 4/5] i2c: mux: pca954x: Move device_remove_file() out of pca954x_cleanup() Andy Shevchenko
2020-03-05 15:53 ` [PATCH v1 5/5] i2c: mux: pca954x: Convert license to SPDX identifier Andy Shevchenko
2020-03-05 21:34 ` [PATCH v1 1/5] i2c: mux: pca954x: Refactor pca954x_irq_handler() Peter Rosin
2020-03-06 10:02   ` Andy Shevchenko
2020-03-06 10:58     ` Peter Rosin
2020-03-16 16:08       ` 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=20200306150703.GO1748204@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=javierm@redhat.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=peda@axentia.se \
    --cc=wsa@the-dreams.de \
    /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