* [PATCH v1 1/3] iio: imu: inv_mpu6050: Drop wrong use of ACPI_PTR()
@ 2022-02-03 15:59 Andy Shevchenko
2022-02-03 15:59 ` [PATCH v1 2/3] iio: imu: inv_mpu6050: Check ACPI companion directly Andy Shevchenko
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Andy Shevchenko @ 2022-02-03 15:59 UTC (permalink / raw)
To: Andy Shevchenko, linux-iio, linux-kernel
Cc: Jonathan Cameron, Lars-Peter Clausen
ACPI_PTR() is more harmful than helpful. For example, in this case
if CONFIG_ACPI=n, the ID table left unused which is not what we want.
Instead of adding ifdeffery or attribute here and there, drop ACPI_PTR().
Fixes: 3b3870646642 ("iio: imu: inv_mpu6050: Mark acpi match table as maybe unused")
Fixes: fd64df16f40e ("iio: imu: inv_mpu6050: Add SPI support for MPU6000")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c | 7 +++----
drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c | 4 ++--
2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
index fe03707ec2d3..ccb06d9af760 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
@@ -3,11 +3,11 @@
* Copyright (C) 2012 Invensense, Inc.
*/
-#include <linux/acpi.h>
#include <linux/delay.h>
#include <linux/err.h>
#include <linux/i2c.h>
#include <linux/iio/iio.h>
+#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/of_device.h>
#include <linux/property.h>
@@ -249,11 +249,10 @@ static const struct of_device_id inv_of_match[] = {
};
MODULE_DEVICE_TABLE(of, inv_of_match);
-static const struct acpi_device_id __maybe_unused inv_acpi_match[] = {
+static const struct acpi_device_id inv_acpi_match[] = {
{"INVN6500", INV_MPU6500},
{ },
};
-
MODULE_DEVICE_TABLE(acpi, inv_acpi_match);
static struct i2c_driver inv_mpu_driver = {
@@ -262,7 +261,7 @@ static struct i2c_driver inv_mpu_driver = {
.id_table = inv_mpu_id,
.driver = {
.of_match_table = inv_of_match,
- .acpi_match_table = ACPI_PTR(inv_acpi_match),
+ .acpi_match_table = inv_acpi_match,
.name = "inv-mpu6050-i2c",
.pm = &inv_mpu_pmops,
},
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c
index 6800356b25fb..44b4f74b9256 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c
@@ -2,8 +2,8 @@
/*
* Copyright (C) 2015 Intel Corporation Inc.
*/
+#include <linux/mod_devicetable.h>
#include <linux/module.h>
-#include <linux/acpi.h>
#include <linux/of.h>
#include <linux/property.h>
#include <linux/spi/spi.h>
@@ -148,7 +148,7 @@ static struct spi_driver inv_mpu_driver = {
.id_table = inv_mpu_id,
.driver = {
.of_match_table = inv_of_match,
- .acpi_match_table = ACPI_PTR(inv_acpi_match),
+ .acpi_match_table = inv_acpi_match,
.name = "inv-mpu6000-spi",
.pm = &inv_mpu_pmops,
},
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v1 2/3] iio: imu: inv_mpu6050: Check ACPI companion directly
2022-02-03 15:59 [PATCH v1 1/3] iio: imu: inv_mpu6050: Drop wrong use of ACPI_PTR() Andy Shevchenko
@ 2022-02-03 15:59 ` Andy Shevchenko
2022-02-03 15:59 ` [PATCH v1 3/3] iio: imu: inv_mpu6050: Make use of device properties Andy Shevchenko
2022-02-05 16:45 ` [PATCH v1 1/3] iio: imu: inv_mpu6050: Drop wrong use of ACPI_PTR() Jonathan Cameron
2 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2022-02-03 15:59 UTC (permalink / raw)
To: Andy Shevchenko, linux-iio, linux-kernel
Cc: Jonathan Cameron, Lars-Peter Clausen
Instead of checking for ACPI handle followed by extracting a companion
device, do the latter first and use it for checks.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c
index f8f0cf716bc6..9b4298095d3f 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c
@@ -127,15 +127,14 @@ static int inv_mpu_process_acpi_config(struct i2c_client *client,
int inv_mpu_acpi_create_mux_client(struct i2c_client *client)
{
struct inv_mpu6050_state *st = iio_priv(dev_get_drvdata(&client->dev));
+ struct acpi_device *adev = ACPI_COMPANION(&client->dev);
st->mux_client = NULL;
- if (ACPI_HANDLE(&client->dev)) {
+ if (adev) {
struct i2c_board_info info;
struct i2c_client *mux_client;
- struct acpi_device *adev;
int ret = -1;
- adev = ACPI_COMPANION(&client->dev);
memset(&info, 0, sizeof(info));
dmi_check_system(inv_mpu_dev_list);
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v1 3/3] iio: imu: inv_mpu6050: Make use of device properties
2022-02-03 15:59 [PATCH v1 1/3] iio: imu: inv_mpu6050: Drop wrong use of ACPI_PTR() Andy Shevchenko
2022-02-03 15:59 ` [PATCH v1 2/3] iio: imu: inv_mpu6050: Check ACPI companion directly Andy Shevchenko
@ 2022-02-03 15:59 ` Andy Shevchenko
2022-02-05 16:45 ` [PATCH v1 1/3] iio: imu: inv_mpu6050: Drop wrong use of ACPI_PTR() Jonathan Cameron
2 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2022-02-03 15:59 UTC (permalink / raw)
To: Andy Shevchenko, linux-iio, linux-kernel
Cc: Jonathan Cameron, Lars-Peter Clausen
Convert the module to be property provider agnostic and allow
it to be used on non-OF platforms.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c | 8 ++++----
drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c | 1 -
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
index ccb06d9af760..55cffb5fa115 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
@@ -9,8 +9,8 @@
#include <linux/iio/iio.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
-#include <linux/of_device.h>
#include <linux/property.h>
+
#include "inv_mpu_iio.h"
static const struct regmap_config inv_mpu_regmap_config = {
@@ -51,7 +51,7 @@ static int inv_mpu_i2c_aux_setup(struct iio_dev *indio_dev)
{
struct inv_mpu6050_state *st = iio_priv(indio_dev);
struct device *dev = indio_dev->dev.parent;
- struct device_node *mux_node;
+ struct fwnode_handle *mux_node;
int ret;
/*
@@ -65,12 +65,12 @@ static int inv_mpu_i2c_aux_setup(struct iio_dev *indio_dev)
case INV_MPU9150:
case INV_MPU9250:
case INV_MPU9255:
- mux_node = of_get_child_by_name(dev->of_node, "i2c-gate");
+ mux_node = device_get_named_child_node(dev, "i2c-gate");
if (mux_node != NULL) {
st->magn_disabled = true;
dev_warn(dev, "disable internal use of magnetometer\n");
}
- of_node_put(mux_node);
+ fwnode_handle_put(mux_node);
break;
default:
break;
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c
index 44b4f74b9256..26a7c2521dc4 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c
@@ -4,7 +4,6 @@
*/
#include <linux/mod_devicetable.h>
#include <linux/module.h>
-#include <linux/of.h>
#include <linux/property.h>
#include <linux/spi/spi.h>
#include <linux/regmap.h>
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v1 1/3] iio: imu: inv_mpu6050: Drop wrong use of ACPI_PTR()
2022-02-03 15:59 [PATCH v1 1/3] iio: imu: inv_mpu6050: Drop wrong use of ACPI_PTR() Andy Shevchenko
2022-02-03 15:59 ` [PATCH v1 2/3] iio: imu: inv_mpu6050: Check ACPI companion directly Andy Shevchenko
2022-02-03 15:59 ` [PATCH v1 3/3] iio: imu: inv_mpu6050: Make use of device properties Andy Shevchenko
@ 2022-02-05 16:45 ` Jonathan Cameron
2022-02-05 18:45 ` Andy Shevchenko
2 siblings, 1 reply; 6+ messages in thread
From: Jonathan Cameron @ 2022-02-05 16:45 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: linux-iio, linux-kernel, Lars-Peter Clausen
On Thu, 3 Feb 2022 17:59:18 +0200
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
> ACPI_PTR() is more harmful than helpful. For example, in this case
> if CONFIG_ACPI=n, the ID table left unused which is not what we want.
>
> Instead of adding ifdeffery or attribute here and there, drop ACPI_PTR().
>
> Fixes: 3b3870646642 ("iio: imu: inv_mpu6050: Mark acpi match table as maybe unused")
> Fixes: fd64df16f40e ("iio: imu: inv_mpu6050: Add SPI support for MPU6000")
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Hi Andy,
Whilst I fully support tidying this up, what is 'fixing' as such?
Will get rid of an unused warning for the spi case but that sort
of things doesn't always get fixes tags. They tend to result
in backports and I wouldn't think it was worth backporting this
unless I'm missing something...
Jonathan
> ---
> drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c | 7 +++----
> drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c | 4 ++--
> 2 files changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
> index fe03707ec2d3..ccb06d9af760 100644
> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
> @@ -3,11 +3,11 @@
> * Copyright (C) 2012 Invensense, Inc.
> */
>
> -#include <linux/acpi.h>
> #include <linux/delay.h>
> #include <linux/err.h>
> #include <linux/i2c.h>
> #include <linux/iio/iio.h>
> +#include <linux/mod_devicetable.h>
> #include <linux/module.h>
> #include <linux/of_device.h>
> #include <linux/property.h>
> @@ -249,11 +249,10 @@ static const struct of_device_id inv_of_match[] = {
> };
> MODULE_DEVICE_TABLE(of, inv_of_match);
>
> -static const struct acpi_device_id __maybe_unused inv_acpi_match[] = {
> +static const struct acpi_device_id inv_acpi_match[] = {
> {"INVN6500", INV_MPU6500},
> { },
> };
> -
> MODULE_DEVICE_TABLE(acpi, inv_acpi_match);
>
> static struct i2c_driver inv_mpu_driver = {
> @@ -262,7 +261,7 @@ static struct i2c_driver inv_mpu_driver = {
> .id_table = inv_mpu_id,
> .driver = {
> .of_match_table = inv_of_match,
> - .acpi_match_table = ACPI_PTR(inv_acpi_match),
> + .acpi_match_table = inv_acpi_match,
> .name = "inv-mpu6050-i2c",
> .pm = &inv_mpu_pmops,
> },
> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c
> index 6800356b25fb..44b4f74b9256 100644
> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c
> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c
> @@ -2,8 +2,8 @@
> /*
> * Copyright (C) 2015 Intel Corporation Inc.
> */
> +#include <linux/mod_devicetable.h>
> #include <linux/module.h>
> -#include <linux/acpi.h>
> #include <linux/of.h>
> #include <linux/property.h>
> #include <linux/spi/spi.h>
> @@ -148,7 +148,7 @@ static struct spi_driver inv_mpu_driver = {
> .id_table = inv_mpu_id,
> .driver = {
> .of_match_table = inv_of_match,
> - .acpi_match_table = ACPI_PTR(inv_acpi_match),
> + .acpi_match_table = inv_acpi_match,
> .name = "inv-mpu6000-spi",
> .pm = &inv_mpu_pmops,
> },
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1 1/3] iio: imu: inv_mpu6050: Drop wrong use of ACPI_PTR()
2022-02-05 16:45 ` [PATCH v1 1/3] iio: imu: inv_mpu6050: Drop wrong use of ACPI_PTR() Jonathan Cameron
@ 2022-02-05 18:45 ` Andy Shevchenko
2022-02-06 15:28 ` Jonathan Cameron
0 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2022-02-05 18:45 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, linux-kernel, Lars-Peter Clausen
On Sat, Feb 05, 2022 at 04:45:35PM +0000, Jonathan Cameron wrote:
> On Thu, 3 Feb 2022 17:59:18 +0200
> Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
>
> > ACPI_PTR() is more harmful than helpful. For example, in this case
> > if CONFIG_ACPI=n, the ID table left unused which is not what we want.
> >
> > Instead of adding ifdeffery or attribute here and there, drop ACPI_PTR().
> >
> > Fixes: 3b3870646642 ("iio: imu: inv_mpu6050: Mark acpi match table as maybe unused")
> > Fixes: fd64df16f40e ("iio: imu: inv_mpu6050: Add SPI support for MPU6000")
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>
> Hi Andy,
>
> Whilst I fully support tidying this up, what is 'fixing' as such?
> Will get rid of an unused warning for the spi case but that sort
> of things doesn't always get fixes tags.
True, however I can find a handful examples when this kind of patches were backported.
> They tend to result
> in backports and I wouldn't think it was worth backporting this
> unless I'm missing something...
It's not critical, so can you drop the tags when applying, if you think that's
okay?
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1 1/3] iio: imu: inv_mpu6050: Drop wrong use of ACPI_PTR()
2022-02-05 18:45 ` Andy Shevchenko
@ 2022-02-06 15:28 ` Jonathan Cameron
0 siblings, 0 replies; 6+ messages in thread
From: Jonathan Cameron @ 2022-02-06 15:28 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: linux-iio, linux-kernel, Lars-Peter Clausen
On Sat, 5 Feb 2022 20:45:01 +0200
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
> On Sat, Feb 05, 2022 at 04:45:35PM +0000, Jonathan Cameron wrote:
> > On Thu, 3 Feb 2022 17:59:18 +0200
> > Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
> >
> > > ACPI_PTR() is more harmful than helpful. For example, in this case
> > > if CONFIG_ACPI=n, the ID table left unused which is not what we want.
> > >
> > > Instead of adding ifdeffery or attribute here and there, drop ACPI_PTR().
> > >
> > > Fixes: 3b3870646642 ("iio: imu: inv_mpu6050: Mark acpi match table as maybe unused")
> > > Fixes: fd64df16f40e ("iio: imu: inv_mpu6050: Add SPI support for MPU6000")
> > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> >
> > Hi Andy,
> >
> > Whilst I fully support tidying this up, what is 'fixing' as such?
> > Will get rid of an unused warning for the spi case but that sort
> > of things doesn't always get fixes tags.
>
> True, however I can find a handful examples when this kind of patches were backported.
>
> > They tend to result
> > in backports and I wouldn't think it was worth backporting this
> > unless I'm missing something...
>
> It's not critical, so can you drop the tags when applying, if you think that's
> okay?
>
Sure. I've dropped the Fixes tags and applied the series.
Thanks,
Jonathan
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-02-06 15:22 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-03 15:59 [PATCH v1 1/3] iio: imu: inv_mpu6050: Drop wrong use of ACPI_PTR() Andy Shevchenko
2022-02-03 15:59 ` [PATCH v1 2/3] iio: imu: inv_mpu6050: Check ACPI companion directly Andy Shevchenko
2022-02-03 15:59 ` [PATCH v1 3/3] iio: imu: inv_mpu6050: Make use of device properties Andy Shevchenko
2022-02-05 16:45 ` [PATCH v1 1/3] iio: imu: inv_mpu6050: Drop wrong use of ACPI_PTR() Jonathan Cameron
2022-02-05 18:45 ` Andy Shevchenko
2022-02-06 15:28 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox