linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] iio: accel: adxl345: Add ACPI HID table
@ 2022-02-15  4:20 Kai-Heng Feng
  2022-02-15  8:27 ` Andy Shevchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Kai-Heng Feng @ 2022-02-15  4:20 UTC (permalink / raw)
  To: lars, Michael.Hennerich, jic23
  Cc: andy.shevchenko, Kai-Heng Feng, linux-iio, linux-kernel

x86 boards may use ACPI HID "ADS0345" for adxl345 device.

Analog replied:
"ADS034X is not a valid PNP ID. ADS0345 would be.
I'm not aware that this ID is already taken.
Feel free to submit a mainline Linux input mailing list patch."

So add an ACPI match table for that accordingly.

Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
---
v3:
 - Convert the driver from input to iio.

v2:
 - Drop ACPI_PTR()
 - Drop redundant empty line and comma
 - Add info from vendor

 drivers/iio/accel/adxl345_i2c.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/iio/accel/adxl345_i2c.c b/drivers/iio/accel/adxl345_i2c.c
index a431cba216e69..1d57050c775de 100644
--- a/drivers/iio/accel/adxl345_i2c.c
+++ b/drivers/iio/accel/adxl345_i2c.c
@@ -41,6 +41,7 @@ static int adxl345_i2c_probe(struct i2c_client *client,
 static const struct i2c_device_id adxl345_i2c_id[] = {
 	{ "adxl345", ADXL345 },
 	{ "adxl375", ADXL375 },
+	{ "ADS0345:00", ADXL345 },
 	{ }
 };
 
@@ -54,10 +55,17 @@ static const struct of_device_id adxl345_of_match[] = {
 
 MODULE_DEVICE_TABLE(of, adxl345_of_match);
 
+static const struct acpi_device_id adxl345_acpi_match[] = {
+	{ "ADS0345" },
+	{ }
+};
+MODULE_DEVICE_TABLE(acpi, adxl345_acpi_match);
+
 static struct i2c_driver adxl345_i2c_driver = {
 	.driver = {
 		.name	= "adxl345_i2c",
 		.of_match_table = adxl345_of_match,
+		.acpi_match_table = adxl345_acpi_match,
 	},
 	.probe		= adxl345_i2c_probe,
 	.id_table	= adxl345_i2c_id,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] iio: accel: adxl345: Add ACPI HID table
  2022-02-15  4:20 [PATCH v3] iio: accel: adxl345: Add ACPI HID table Kai-Heng Feng
@ 2022-02-15  8:27 ` Andy Shevchenko
  2022-02-15 11:30   ` Kai-Heng Feng
  0 siblings, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2022-02-15  8:27 UTC (permalink / raw)
  To: Kai-Heng Feng
  Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	linux-iio, Linux Kernel Mailing List

On Tue, Feb 15, 2022 at 6:20 AM Kai-Heng Feng
<kai.heng.feng@canonical.com> wrote:
>
> x86 boards may use ACPI HID "ADS0345" for adxl345 device.
>
> Analog replied:
> "ADS034X is not a valid PNP ID. ADS0345 would be.
> I'm not aware that this ID is already taken.
> Feel free to submit a mainline Linux input mailing list patch."
>
> So add an ACPI match table for that accordingly.

Thank you for the update, my comments below.

...

> @@ -41,6 +41,7 @@ static int adxl345_i2c_probe(struct i2c_client *client,
>  static const struct i2c_device_id adxl345_i2c_id[] = {
>         { "adxl345", ADXL345 },
>         { "adxl375", ADXL375 },

> +       { "ADS0345:00", ADXL345 },
>         { }
>  };
>

This is wrong. First of all, on the left side you put the device
instance name (which must not be in the ID tables, since the device
instance name is "ID + instance number"). Second, the motivation of
this is not clear, if the device is enumerated by ACPI, why do you
care about board code?

Just don't add anything to this table.

The rest is good, but consider doing the same for _spi part of the driver.

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] iio: accel: adxl345: Add ACPI HID table
  2022-02-15  8:27 ` Andy Shevchenko
@ 2022-02-15 11:30   ` Kai-Heng Feng
  2022-02-15 15:31     ` Andy Shevchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Kai-Heng Feng @ 2022-02-15 11:30 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	linux-iio, Linux Kernel Mailing List

On Tue, Feb 15, 2022 at 4:28 PM Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
>
> On Tue, Feb 15, 2022 at 6:20 AM Kai-Heng Feng
> <kai.heng.feng@canonical.com> wrote:
> >
> > x86 boards may use ACPI HID "ADS0345" for adxl345 device.
> >
> > Analog replied:
> > "ADS034X is not a valid PNP ID. ADS0345 would be.
> > I'm not aware that this ID is already taken.
> > Feel free to submit a mainline Linux input mailing list patch."
> >
> > So add an ACPI match table for that accordingly.
>
> Thank you for the update, my comments below.
>
> ...
>
> > @@ -41,6 +41,7 @@ static int adxl345_i2c_probe(struct i2c_client *client,
> >  static const struct i2c_device_id adxl345_i2c_id[] = {
> >         { "adxl345", ADXL345 },
> >         { "adxl375", ADXL375 },
>
> > +       { "ADS0345:00", ADXL345 },
> >         { }
> >  };
> >
>
> This is wrong. First of all, on the left side you put the device
> instance name (which must not be in the ID tables, since the device
> instance name is "ID + instance number"). Second, the motivation of
> this is not clear, if the device is enumerated by ACPI, why do you
> care about board code?

I was uncertain on this at first, but later I saw some drivers use
this form (*:00) too, so I just followed through.

The intention is to accommodate adxl345_i2c_probe() without any modification.


>
> Just don't add anything to this table.

Got it.

>
> The rest is good, but consider doing the same for _spi part of the driver.

OK, will do.

Kai-Heng

>
> --
> With Best Regards,
> Andy Shevchenko

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] iio: accel: adxl345: Add ACPI HID table
  2022-02-15 11:30   ` Kai-Heng Feng
@ 2022-02-15 15:31     ` Andy Shevchenko
  0 siblings, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2022-02-15 15:31 UTC (permalink / raw)
  To: Kai-Heng Feng
  Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	linux-iio, Linux Kernel Mailing List

On Tue, Feb 15, 2022 at 1:30 PM Kai-Heng Feng
<kai.heng.feng@canonical.com> wrote:
> On Tue, Feb 15, 2022 at 4:28 PM Andy Shevchenko
> <andy.shevchenko@gmail.com> wrote:
> > On Tue, Feb 15, 2022 at 6:20 AM Kai-Heng Feng
> > <kai.heng.feng@canonical.com> wrote:

...

> > > +       { "ADS0345:00", ADXL345 },
> >
> > This is wrong. First of all, on the left side you put the device
> > instance name (which must not be in the ID tables, since the device
> > instance name is "ID + instance number"). Second, the motivation of
> > this is not clear, if the device is enumerated by ACPI, why do you
> > care about board code?
>
> I was uncertain on this at first, but later I saw some drivers use
> this form (*:00) too, so I just followed through.

Those "drivers" are actually so called board files, i.o.w. hard coded
pieces of what firmware(s) missed. That's why they are using device
instance name(s) instead of the device IDs.

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-02-15 15:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-15  4:20 [PATCH v3] iio: accel: adxl345: Add ACPI HID table Kai-Heng Feng
2022-02-15  8:27 ` Andy Shevchenko
2022-02-15 11:30   ` Kai-Heng Feng
2022-02-15 15:31     ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).