2023-06-09 15:53:49

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v2 3/3] ata: ahci_platform: Make code agnostic to OF/ACPI

With the help of a new device_is_compatible() make
the driver code agnostic to the OF/ACPI. This makes
it neater. As a side effect the header inclusions is
corrected (seems mod_devicetable.h was implicitly
included).

Signed-off-by: Andy Shevchenko <[email protected]>
---
drivers/ata/ahci_platform.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/ata/ahci_platform.c b/drivers/ata/ahci_platform.c
index ab30c7138d73..81fc63f6b008 100644
--- a/drivers/ata/ahci_platform.c
+++ b/drivers/ata/ahci_platform.c
@@ -9,14 +9,14 @@
*/

#include <linux/kernel.h>
+#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/pm.h>
#include <linux/device.h>
-#include <linux/of_device.h>
#include <linux/platform_device.h>
+#include <linux/property.h>
#include <linux/libata.h>
#include <linux/ahci_platform.h>
-#include <linux/acpi.h>
#include <linux/pci_ids.h>
#include "ahci.h"

@@ -56,10 +56,10 @@ static int ahci_probe(struct platform_device *pdev)
if (rc)
return rc;

- if (of_device_is_compatible(dev->of_node, "hisilicon,hisi-ahci"))
+ if (device_is_compatible(dev, "hisilicon,hisi-ahci"))
hpriv->flags |= AHCI_HFLAG_NO_FBS | AHCI_HFLAG_NO_NCQ;

- port = acpi_device_get_match_data(dev);
+ port = device_get_match_data(dev);
if (!port)
port = &ahci_port_info;

--
2.40.0.1.gaa8946217a0b



2023-06-12 08:42:52

by Sakari Ailus

[permalink] [raw]
Subject: Re: [PATCH v2 3/3] ata: ahci_platform: Make code agnostic to OF/ACPI

Hi Andy,

On Fri, Jun 09, 2023 at 06:49:00PM +0300, Andy Shevchenko wrote:
> With the help of a new device_is_compatible() make
> the driver code agnostic to the OF/ACPI. This makes
> it neater. As a side effect the header inclusions is
> corrected (seems mod_devicetable.h was implicitly
> included).

You're wrapping the lines well before 75. Why?

>
> Signed-off-by: Andy Shevchenko <[email protected]>

Reviewed-by: Sakari Ailus <[email protected]>

--
Sakari Ailus

2023-06-12 09:28:13

by Sakari Ailus

[permalink] [raw]
Subject: Re: [PATCH v2 3/3] ata: ahci_platform: Make code agnostic to OF/ACPI

Hi Andy,

On Fri, Jun 09, 2023 at 06:49:00PM +0300, Andy Shevchenko wrote:
> With the help of a new device_is_compatible() make
> the driver code agnostic to the OF/ACPI. This makes
> it neater. As a side effect the header inclusions is
> corrected (seems mod_devicetable.h was implicitly
> included).
>
> Signed-off-by: Andy Shevchenko <[email protected]>
> ---
> drivers/ata/ahci_platform.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/ata/ahci_platform.c b/drivers/ata/ahci_platform.c
> index ab30c7138d73..81fc63f6b008 100644
> --- a/drivers/ata/ahci_platform.c
> +++ b/drivers/ata/ahci_platform.c
> @@ -9,14 +9,14 @@
> */
>
> #include <linux/kernel.h>
> +#include <linux/mod_devicetable.h>
> #include <linux/module.h>
> #include <linux/pm.h>
> #include <linux/device.h>
> -#include <linux/of_device.h>
> #include <linux/platform_device.h>
> +#include <linux/property.h>
> #include <linux/libata.h>
> #include <linux/ahci_platform.h>
> -#include <linux/acpi.h>
> #include <linux/pci_ids.h>
> #include "ahci.h"
>
> @@ -56,10 +56,10 @@ static int ahci_probe(struct platform_device *pdev)
> if (rc)
> return rc;
>
> - if (of_device_is_compatible(dev->of_node, "hisilicon,hisi-ahci"))
> + if (device_is_compatible(dev, "hisilicon,hisi-ahci"))
> hpriv->flags |= AHCI_HFLAG_NO_FBS | AHCI_HFLAG_NO_NCQ;
>
> - port = acpi_device_get_match_data(dev);
> + port = device_get_match_data(dev);

There are just a handful of users for acpi_device_get_match_data() in the
tree. The code could be moved to acpi_fwnode_device_get_match_data() after
coverting these. May be out of scope of this set though.

> if (!port)
> port = &ahci_port_info;
>

--
Kind regards,

Sakari Ailus

2023-06-12 15:36:11

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH v2 3/3] ata: ahci_platform: Make code agnostic to OF/ACPI

On Mon, Jun 12, 2023 at 09:06:52AM +0000, Sakari Ailus wrote:
> On Fri, Jun 09, 2023 at 06:49:00PM +0300, Andy Shevchenko wrote:

...

> > - if (of_device_is_compatible(dev->of_node, "hisilicon,hisi-ahci"))
> > + if (device_is_compatible(dev, "hisilicon,hisi-ahci"))
> > hpriv->flags |= AHCI_HFLAG_NO_FBS | AHCI_HFLAG_NO_NCQ;
> >
> > - port = acpi_device_get_match_data(dev);
> > + port = device_get_match_data(dev);
>
> There are just a handful of users for acpi_device_get_match_data() in the
> tree. The code could be moved to acpi_fwnode_device_get_match_data() after
> coverting these. May be out of scope of this set though.

Why do we need that one if we can use device_get_match_data() directly?
It will be also flexible in case one of OF code will need something like
this (custom info structure for the respective compatible string).
That said, I don't think we need to change to acpi_*() whatever.

--
With Best Regards,
Andy Shevchenko



2023-06-12 15:45:38

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH v2 3/3] ata: ahci_platform: Make code agnostic to OF/ACPI

On Mon, Jun 12, 2023 at 08:02:44AM +0000, Sakari Ailus wrote:
> On Fri, Jun 09, 2023 at 06:49:00PM +0300, Andy Shevchenko wrote:
> > With the help of a new device_is_compatible() make
> > the driver code agnostic to the OF/ACPI. This makes
> > it neater. As a side effect the header inclusions is
> > corrected (seems mod_devicetable.h was implicitly
> > included).
>
> You're wrapping the lines well before 75. Why?

Didn't pay attention to that much. Is it a problem? Should I send a new
version because of that?

> > Signed-off-by: Andy Shevchenko <[email protected]>
>
> Reviewed-by: Sakari Ailus <[email protected]>

Thank you!

--
With Best Regards,
Andy Shevchenko



2023-06-13 09:42:35

by Sakari Ailus

[permalink] [raw]
Subject: Re: [PATCH v2 3/3] ata: ahci_platform: Make code agnostic to OF/ACPI

Hi Andy,

On Mon, Jun 12, 2023 at 06:19:22PM +0300, Andy Shevchenko wrote:
> On Mon, Jun 12, 2023 at 09:06:52AM +0000, Sakari Ailus wrote:
> > On Fri, Jun 09, 2023 at 06:49:00PM +0300, Andy Shevchenko wrote:
>
> ...
>
> > > - if (of_device_is_compatible(dev->of_node, "hisilicon,hisi-ahci"))
> > > + if (device_is_compatible(dev, "hisilicon,hisi-ahci"))
> > > hpriv->flags |= AHCI_HFLAG_NO_FBS | AHCI_HFLAG_NO_NCQ;
> > >
> > > - port = acpi_device_get_match_data(dev);
> > > + port = device_get_match_data(dev);
> >
> > There are just a handful of users for acpi_device_get_match_data() in the
> > tree. The code could be moved to acpi_fwnode_device_get_match_data() after
> > coverting these. May be out of scope of this set though.
>
> Why do we need that one if we can use device_get_match_data() directly?

That was what I wanted to point your attention to. ;-)

> It will be also flexible in case one of OF code will need something like
> this (custom info structure for the respective compatible string).
> That said, I don't think we need to change to acpi_*() whatever.

I agree.

--
Kind regards,

Sakari Ailus

2023-06-13 09:58:34

by Serge Semin

[permalink] [raw]
Subject: Re: [PATCH v2 3/3] ata: ahci_platform: Make code agnostic to OF/ACPI

On Fri, Jun 09, 2023 at 06:49:00PM +0300, Andy Shevchenko wrote:
> With the help of a new device_is_compatible() make
> the driver code agnostic to the OF/ACPI. This makes
> it neater. As a side effect the header inclusions is
> corrected (seems mod_devicetable.h was implicitly
> included).

I don't think the driver will get to be fully agnostic after this
patch because for instance the ahci_platform_get_resources() method
directly uses the OF-available functions, walks over the OF subnodes,
touches the OF-properties, etc. So AFAICS in order to be fully OF/ACPI
agnostic the entire libahci_platform.o driver needs to be converted
too, but it's not trivial at all.

Anyway as a start this patch looks good.
Reviewed-by: Serge Semin <[email protected]>

-Serge(y)

>
> Signed-off-by: Andy Shevchenko <[email protected]>
> ---
> drivers/ata/ahci_platform.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/ata/ahci_platform.c b/drivers/ata/ahci_platform.c
> index ab30c7138d73..81fc63f6b008 100644
> --- a/drivers/ata/ahci_platform.c
> +++ b/drivers/ata/ahci_platform.c
> @@ -9,14 +9,14 @@
> */
>
> #include <linux/kernel.h>
> +#include <linux/mod_devicetable.h>
> #include <linux/module.h>
> #include <linux/pm.h>
> #include <linux/device.h>
> -#include <linux/of_device.h>
> #include <linux/platform_device.h>
> +#include <linux/property.h>
> #include <linux/libata.h>
> #include <linux/ahci_platform.h>
> -#include <linux/acpi.h>
> #include <linux/pci_ids.h>
> #include "ahci.h"
>
> @@ -56,10 +56,10 @@ static int ahci_probe(struct platform_device *pdev)
> if (rc)
> return rc;
>
> - if (of_device_is_compatible(dev->of_node, "hisilicon,hisi-ahci"))
> + if (device_is_compatible(dev, "hisilicon,hisi-ahci"))
> hpriv->flags |= AHCI_HFLAG_NO_FBS | AHCI_HFLAG_NO_NCQ;
>
> - port = acpi_device_get_match_data(dev);
> + port = device_get_match_data(dev);
> if (!port)
> port = &ahci_port_info;
>
> --
> 2.40.0.1.gaa8946217a0b
>
>


2023-06-13 10:02:17

by Sakari Ailus

[permalink] [raw]
Subject: Re: [PATCH v2 3/3] ata: ahci_platform: Make code agnostic to OF/ACPI

On Mon, Jun 12, 2023 at 06:20:17PM +0300, Andy Shevchenko wrote:
> On Mon, Jun 12, 2023 at 08:02:44AM +0000, Sakari Ailus wrote:
> > On Fri, Jun 09, 2023 at 06:49:00PM +0300, Andy Shevchenko wrote:
> > > With the help of a new device_is_compatible() make
> > > the driver code agnostic to the OF/ACPI. This makes
> > > it neater. As a side effect the header inclusions is
> > > corrected (seems mod_devicetable.h was implicitly
> > > included).
> >
> > You're wrapping the lines well before 75. Why?
>
> Didn't pay attention to that much. Is it a problem? Should I send a new
> version because of that?

I guess not. But it's a good practice to wrap at 75 instead.

--
Sakari Ailus