From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Robin van der Gracht <robin@protonic.nl>
Cc: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>,
Raul E Rangel <rrangel@chromium.org>,
Wolfram Sang <wsa@kernel.org>,
linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org,
linux-usb@vger.kernel.org, Miguel Ojeda <ojeda@kernel.org>,
Heikki Krogerus <heikki.krogerus@linux.intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: Re: [PATCH v1 2/3] auxdisplay: ht16k33: Make use of device_get_match_data()
Date: Wed, 22 Feb 2023 19:01:40 +0200 [thread overview]
Message-ID: <Y/ZKdN4nuHcL4DgE@smile.fi.intel.com> (raw)
In-Reply-To: <0235f0fed989a8b027db720663699f5d@protonic.nl>
On Wed, Feb 22, 2023 at 05:46:00PM +0100, Robin van der Gracht wrote:
> On 2023-02-21 18:48, Andy Shevchenko wrote:
> > On Tue, Feb 21, 2023 at 05:10:00PM +0100, Robin van der Gracht wrote:
> > > On 2023-02-21 14:40, Andy Shevchenko wrote:
> > > > On Tue, Feb 21, 2023 at 03:33:06PM +0200, Andy Shevchenko wrote:
...
> > > > > - id = i2c_of_match_device(dev->driver->of_match_table, client);
> > > > > - if (id)
> > > > > - priv->type = (uintptr_t)id->data;
> > > > > + priv->type = (uintptr_t)device_get_match_data(dev);
> > > >
> > > > Looking closer the I²C ID table should provide DISP_MATRIX to keep
> > > > default and
> > > > this needs to be not dropped.
^^^^^ (1)
> > > > So, the question is what to do with unknown type then, return -EINVAL
> > > > from probe()?
> > >
> > > If you leave out your addition of the DISP_UNKNOWN type, the default
> > > type
> > > will be DISP_MATRIX if no match is found, which is as it is now.
> > >
> > > In that case the following change should suffice:
> > >
> > > @@ -713,7 +715,6 @@ static int ht16k33_seg_probe(struct device *dev,
> > > struct
> > > ht16k33_priv *priv,
> > > static int ht16k33_probe(struct i2c_client *client)
> > > {
> > > struct device *dev = &client->dev;
> > > - const struct of_device_id *id;
> > > struct ht16k33_priv *priv;
> > > uint32_t dft_brightness;
> > > int err;
> > > @@ -728,9 +729,8 @@ static int ht16k33_probe(struct i2c_client
> > > *client)
> > > return -ENOMEM;
> > >
> > > priv->client = client;
> > > - id = i2c_of_match_device(dev->driver->of_match_table, client);
> > > - if (id)
> > > - priv->type = (uintptr_t)id->data;
> > > + priv->type = (uintptr_t)device_get_match_data(dev);
> > > +
> > > i2c_set_clientdata(client, priv);
> > >
> > > err = ht16k33_initialize(priv);
> > >
> > > Or do you think falling back to DISP_MATRIX if no match is found is
> > > wrong?
> >
> > First of all, the I²C ID table should actually use DISP_MATRIX.
> >
> > Second, there are two points:
> >
> > - It would be nice to check if the OF ID table doesn't provide a setting
> > (shouldn't we try I²C ID table and then, if still nothing, bail out?)
> >
> > - The I²C ID table can be extended in the future with another entry
> > which
> > may want to have different default
>
> For my understanding, please correct me if I'm wrong;
>
> For all methods of instantiation during ht16k33 probe, i2c_of_match_device()
> matches the compatible strings in the OF ID table due to a call to
> i2c_of_match_device_sysfs().
>
> device_get_match_data() only matches the compatible strings in the OF ID
> table for devicetree instantiation because of_match_device() won't match
> is there is no actual of_node.
That's half-true. On ACPI based platforms we may have no of_node and match
against OF ID table.
> So with only device_get_match_data() and a non devicetree instantiation,
> priv->type will always be (uintptr_t)NULL = 0 = DISP_MATRIX.
Yes.
> Which effectively breaks i.e. user-space instantiation for other display
> types which now do work due to i2c_of_match_device().
> (so my suggestion above is not sufficient).
>
> Are you proposing extending and searching the I2C ID table to work around
> that?
See (1) above. This is the downside I have noticed after sending this series.
So, the I²C ID table match has to be restored, but the above mentioned issues
with existing table are not gone, hence they need to be addressed in the next
version.
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2023-02-22 17:02 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-21 13:33 [PATCH v1 0/3] i2c: stop using i2c_of_match_device() Andy Shevchenko
2023-02-21 13:33 ` [PATCH v1 1/3] usb: typec: stusb160x: Make use of device_get_match_data() Andy Shevchenko
2023-02-21 13:53 ` Heikki Krogerus
2023-02-21 13:33 ` [PATCH v1 2/3] auxdisplay: ht16k33: " Andy Shevchenko
2023-02-21 13:40 ` Andy Shevchenko
2023-02-21 16:10 ` Robin van der Gracht
2023-02-21 17:48 ` Andy Shevchenko
2023-02-22 16:46 ` Robin van der Gracht
2023-02-22 17:01 ` Andy Shevchenko [this message]
2023-02-22 17:20 ` Andy Shevchenko
2023-02-22 18:46 ` Krzysztof Kozlowski
2023-02-22 19:11 ` Andy Shevchenko
2023-02-23 9:55 ` Geert Uytterhoeven
2023-02-23 11:53 ` Andy Shevchenko
2023-02-23 8:19 ` Robin van der Gracht
2023-02-21 13:33 ` [PATCH v1 3/3] i2c: Unexport i2c_of_match_device() Andy Shevchenko
2023-02-23 13:50 ` [PATCH v1 0/3] i2c: stop using i2c_of_match_device() 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=Y/ZKdN4nuHcL4DgE@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=ojeda@kernel.org \
--cc=rmk+kernel@armlinux.org.uk \
--cc=robin@protonic.nl \
--cc=rrangel@chromium.org \
--cc=wsa@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