diff mbox series

iio: adc: ti-adc081c: Partial revert of removal of ACPI IDs

Message ID 20211003162417.427260-1-jic23@kernel.org (mailing list archive)
State Superseded
Headers show
Series iio: adc: ti-adc081c: Partial revert of removal of ACPI IDs | expand

Commit Message

Jonathan Cameron Oct. 3, 2021, 4:24 p.m. UTC
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

Unfortuanately a non standards compliant ACPI ID is known to be
in the wild on some AAEON boards.

Partly revert the removal of these IDs so that ADC081C will again
work + add a comment to that affect for future reference.

Reported-by: Kunyang Fan <Kunyang_Fan@aaeon.com.tw>
Fixes: c458b7ca3fd0 ("iio:adc:ti-adc081c: Drop ACPI ids that seem very unlikely to be official.")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
---
Kunyang Fan,

I left this for a while in the hope that you might be able to
provide more details on where this ID is used + whether there are
other similar IDs in use by AAEON firmwares.

That information would still be extremely useful given the vague
nature of the comment I have added will give us no real information
on whether we can drop this in the distant future.

Also, please test this patch to make sure I've put back everything
necessary.

drivers/iio/adc/ti-adc081c.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

Comments

Andy Shevchenko Oct. 3, 2021, 4:28 p.m. UTC | #1
On Sun, Oct 3, 2021 at 7:20 PM Jonathan Cameron <jic23@kernel.org> wrote:
>
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
> Unfortuanately a non standards compliant ACPI ID is known to be

Unfortunately

> in the wild on some AAEON boards.
>
> Partly revert the removal of these IDs so that ADC081C will again
> work + add a comment to that affect for future reference.

affect?! Okay, you are native speaker.

...

> +#include <linux/acpi.h>

> +       if (ACPI_COMPANION(&client->dev)) {
> +               const struct acpi_device_id *ad_id;
> +
> +               ad_id = acpi_match_device(client->dev.driver->acpi_match_table,
> +                                         &client->dev);
> +               if (!ad_id)
> +                       return -ENODEV;
> +               model = &adcxx1c_models[ad_id->driver_data];
> +       } else {
> +               model = &adcxx1c_models[id->driver_data];
> +       }

Can we please use device_get_match_data() instead (with corresponding
property.h inclusion instead of acpi.h)?
This may require adding driver_data to OF IDs.
Jonathan Cameron Oct. 4, 2021, 7:25 p.m. UTC | #2
On Sun, 3 Oct 2021 19:28:06 +0300
Andy Shevchenko <andy.shevchenko@gmail.com> wrote:

> On Sun, Oct 3, 2021 at 7:20 PM Jonathan Cameron <jic23@kernel.org> wrote:
> >
> > From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> >
> > Unfortuanately a non standards compliant ACPI ID is known to be  
> 
> Unfortunately

One day I'll actually remember to spell check my patch descriptions.
Sorry!

> 
> > in the wild on some AAEON boards.
> >
> > Partly revert the removal of these IDs so that ADC081C will again
> > work + add a comment to that affect for future reference.  
> 
> affect?! Okay, you are native speaker.

Doesn't make me competent at writing my native language :)

> 
> ...
> 
> > +#include <linux/acpi.h>  
> 
> > +       if (ACPI_COMPANION(&client->dev)) {
> > +               const struct acpi_device_id *ad_id;
> > +
> > +               ad_id = acpi_match_device(client->dev.driver->acpi_match_table,
> > +                                         &client->dev);
> > +               if (!ad_id)
> > +                       return -ENODEV;
> > +               model = &adcxx1c_models[ad_id->driver_data];
> > +       } else {
> > +               model = &adcxx1c_models[id->driver_data];
> > +       }  
> 
> Can we please use device_get_match_data() instead (with corresponding
> property.h inclusion instead of acpi.h)?
> This may require adding driver_data to OF IDs.
> 

Sure. I was going for minimal change + most revert like, but fair enough
we'll clean that up whilst here.

Jonathan
Kunyang Fan(范坤揚) Nov. 30, 2021, 4:22 a.m. UTC | #3
Hi Andy,

This patch would affect the ADC function on AAEON x86 products: https://www.aaeon.com/en/p/developer-board-intel-11th-up-xtreme-i11, we need the ACPI ID to enable ADC device ADC081C

Thanks,

Kunyang

-----Original Message-----
From: Andy Shevchenko <andy.shevchenko@gmail.com>
Sent: Monday, October 4, 2021 12:28 AM
To: Jonathan Cameron <jic23@kernel.org>
Cc: linux-iio <linux-iio@vger.kernel.org>; Jonathan Cameron <Jonathan.Cameron@huawei.com>; Kunyang Fan <Kunyang_Fan@aaeon.com.tw>
Subject: Re: [PATCH] iio: adc: ti-adc081c: Partial revert of removal of ACPI IDs

On Sun, Oct 3, 2021 at 7:20 PM Jonathan Cameron <jic23@kernel.org> wrote:
>
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
> Unfortuanately a non standards compliant ACPI ID is known to be

Unfortunately

> in the wild on some AAEON boards.
>
> Partly revert the removal of these IDs so that ADC081C will again work
> + add a comment to that affect for future reference.

affect?! Okay, you are native speaker.

...

> +#include <linux/acpi.h>

> +       if (ACPI_COMPANION(&client->dev)) {
> +               const struct acpi_device_id *ad_id;
> +
> +               ad_id = acpi_match_device(client->dev.driver->acpi_match_table,
> +                                         &client->dev);
> +               if (!ad_id)
> +                       return -ENODEV;
> +               model = &adcxx1c_models[ad_id->driver_data];
> +       } else {
> +               model = &adcxx1c_models[id->driver_data];
> +       }

Can we please use device_get_match_data() instead (with corresponding property.h inclusion instead of acpi.h)?
This may require adding driver_data to OF IDs.

--
With Best Regards,
Andy Shevchenko
<p></p>
===================================================================================================================================
This email and any attachments to it contain confidential information and are intended solely for the use of the individual to whom it is addressed.If you are not the intended recipient or receive it accidentally, please immediately notify the sender by e-mail and delete the message and any attachments from your computer system, and destroy all hard copies. If any, please be advised that any unauthorized disclosure, copying, distribution or any action taken or omitted in reliance on this, is illegal and prohibited. Furthermore, any views or opinions expressed are solely those of the author and do not represent those of ASUSTeK. Thank you for your cooperation.
===================================================================================================================================
Andy Shevchenko Nov. 30, 2021, 9:44 a.m. UTC | #4
On Tue, Nov 30, 2021 at 6:22 AM Kunyang Fan(范坤揚) <Kunyang_Fan@asus.com> wrote:
>
> Hi Andy,
>
> This patch would affect the ADC function on AAEON x86 products: https://www.aaeon.com/en/p/developer-board-intel-11th-up-xtreme-i11, we need the ACPI ID to enable ADC device ADC081C

AFAIU Jonathan did that patch (and it's applied, right?) exactly for
that reason, but the main issue here is the process inside AAEON
company regarding ACPI IDs, can that be fixed please?
Jonathan Cameron Nov. 30, 2021, 10:10 a.m. UTC | #5
On Tue, 30 Nov 2021 11:44:17 +0200
Andy Shevchenko <andy.shevchenko@gmail.com> wrote:

> On Tue, Nov 30, 2021 at 6:22 AM Kunyang Fan(范坤揚) <Kunyang_Fan@asus.com> wrote:
> >
> > Hi Andy,
> >
> > This patch would affect the ADC function on AAEON x86 products: https://www.aaeon.com/en/p/developer-board-intel-11th-up-xtreme-i11, we need the ACPI ID to enable ADC device ADC081C  
> 
> AFAIU Jonathan did that patch (and it's applied, right?) exactly for
> that reason, but the main issue here is the process inside AAEON
> company regarding ACPI IDs, can that be fixed please?
> 

I need to do a v2 with changes as you suggested, so not in yet.

Jonathan
Kunyang Fan(范坤揚) Nov. 30, 2021, 10:16 a.m. UTC | #6
Hi Andy,

Yes, this patch can resolve the ADC device "ADC081C021CIMKX" not found issue on our x86 devices. Currently, this patch is still not in the latest kernel 5.16.0-rc3.

Best regard,

Kunyang

-----Original Message-----
From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
Sent: Tuesday, November 30, 2021 6:11 PM
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Kunyang Fan(范坤揚) <Kunyang_Fan@asus.com>; Jonathan Cameron <jic23@kernel.org>; linux-iio <linux-iio@vger.kernel.org>; Kunyang Fan <Kunyang_Fan@aaeon.com.tw>; Jacob Wu(吳文傑) <Jacob_Wu@asus.com>
Subject: Re: [PATCH] iio: adc: ti-adc081c: Partial revert of removal of ACPI IDs

On Tue, 30 Nov 2021 11:44:17 +0200
Andy Shevchenko <andy.shevchenko@gmail.com> wrote:

> On Tue, Nov 30, 2021 at 6:22 AM Kunyang Fan(范坤揚) <Kunyang_Fan@asus.com> wrote:
> >
> > Hi Andy,
> >
> > This patch would affect the ADC function on AAEON x86 products:
> > https://www.aaeon.com/en/p/developer-board-intel-11th-up-xtreme-i11,
> > we need the ACPI ID to enable ADC device ADC081C
>
> AFAIU Jonathan did that patch (and it's applied, right?) exactly for
> that reason, but the main issue here is the process inside AAEON
> company regarding ACPI IDs, can that be fixed please?
>

I need to do a v2 with changes as you suggested, so not in yet.

Jonathan

<p></p>

===================================================================================================================================
This email and any attachments to it contain confidential information and are intended solely for the use of the individual to whom it is addressed.If you are not the intended recipient or receive it accidentally, please immediately notify the sender by e-mail and delete the message and any attachments from your computer system, and destroy all hard copies. If any, please be advised that any unauthorized disclosure, copying, distribution or any action taken or omitted in reliance on this, is illegal and prohibited. Furthermore, any views or opinions expressed are solely those of the author and do not represent those of ASUSTeK. Thank you for your cooperation.
===================================================================================================================================
diff mbox series

Patch

diff --git a/drivers/iio/adc/ti-adc081c.c b/drivers/iio/adc/ti-adc081c.c
index 16fc608db36a..0872a4897609 100644
--- a/drivers/iio/adc/ti-adc081c.c
+++ b/drivers/iio/adc/ti-adc081c.c
@@ -15,6 +15,7 @@ 
  * bits of value registers are reserved.
  */
 
+#include <linux/acpi.h>
 #include <linux/err.h>
 #include <linux/i2c.h>
 #include <linux/module.h>
@@ -162,7 +163,17 @@  static int adc081c_probe(struct i2c_client *client,
 	if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_WORD_DATA))
 		return -EOPNOTSUPP;
 
-	model = &adcxx1c_models[id->driver_data];
+	if (ACPI_COMPANION(&client->dev)) {
+		const struct acpi_device_id *ad_id;
+
+		ad_id = acpi_match_device(client->dev.driver->acpi_match_table,
+					  &client->dev);
+		if (!ad_id)
+			return -ENODEV;
+		model = &adcxx1c_models[ad_id->driver_data];
+	} else {
+		model = &adcxx1c_models[id->driver_data];
+	}
 
 	iio = devm_iio_device_alloc(&client->dev, sizeof(*adc));
 	if (!iio)
@@ -210,6 +221,13 @@  static const struct i2c_device_id adc081c_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, adc081c_id);
 
+static const struct acpi_device_id adc081c_acpi_match[] = {
+	/* Used on some AAEON boards */
+	{ "ADC081C", ADC081C },
+	{ }
+};
+MODULE_DEVICE_TABLE(acpi, adc081c_acpi_match);
+
 static const struct of_device_id adc081c_of_match[] = {
 	{ .compatible = "ti,adc081c" },
 	{ .compatible = "ti,adc101c" },
@@ -222,6 +240,7 @@  static struct i2c_driver adc081c_driver = {
 	.driver = {
 		.name = "adc081c",
 		.of_match_table = adc081c_of_match,
+		.acpi_match_table = adc081c_acpi_match,
 	},
 	.probe = adc081c_probe,
 	.id_table = adc081c_id,