linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gpio Add my driver new id
@ 2021-12-03  9:26 Richard Hsu
  2021-12-03 10:15 ` Bartosz Golaszewski
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Hsu @ 2021-12-03  9:26 UTC (permalink / raw)
  To: linus.walleij, brgl, Richard_Hsu
  Cc: linux-gpio, linux-kernel, Yd_Tseng, Cindy1_Hsu, Andrew_Su

 drivers/gpio/gpio-amdpt.c | 12 ++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/gpio-amdpt.c b/drivers/gpio/gpio-amdpt.c
index bbf53e289141..4d01d4341a67 100644
--- a/drivers/gpio/gpio-amdpt.c
+++ b/drivers/gpio/gpio-amdpt.c
@@ -14,6 +14,7 @@
 #include <linux/platform_device.h>

 #define PT_TOTAL_GPIO 8
+#define PT_TOTAL_GPIO_EX 24

 /* PCI-E MMIO register offsets */
 #define PT_DIRECTION_REG   0x00
@@ -72,10 +73,12 @@ static void pt_gpio_free(struct gpio_chip *gc, unsigned offset)
 static int pt_gpio_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
+	struct acpi_device *acpi_dev;
+	acpi_handle handle = ACPI_HANDLE(dev);
 	struct pt_gpio_chip *pt_gpio;
 	int ret = 0;

-	if (!ACPI_COMPANION(dev)) {
+	if (acpi_bus_get_device(handle, &acpi_dev)) {
 		dev_err(dev, "PT GPIO device node not found\n");
 		return -ENODEV;
 	}
@@ -100,10 +103,14 @@ static int pt_gpio_probe(struct platform_device *pdev)
 		return ret;
 	}

+	if (!strncmp(acpi_dev_name(acpi_dev), "AMDIF031", 8))
+		pt_gpio->gc.ngpio = PT_TOTAL_GPIO_EX;
+	else
+		pt_gpio->gc.ngpio = PT_TOTAL_GPIO;
+
 	pt_gpio->gc.owner            = THIS_MODULE;
 	pt_gpio->gc.request          = pt_gpio_request;
 	pt_gpio->gc.free             = pt_gpio_free;
-	pt_gpio->gc.ngpio            = PT_TOTAL_GPIO;
 #if defined(CONFIG_OF_GPIO)
 	pt_gpio->gc.of_node          = dev->of_node;
 #endif
@@ -135,6 +142,7 @@ static int pt_gpio_remove(struct platform_device *pdev)
 static const struct acpi_device_id pt_gpio_acpi_match[] = {
 	{ "AMDF030", 0 },
 	{ "AMDIF030", 0 },
+	{ "AMDIF031", 0 },
 	{ },
 };
 MODULE_DEVICE_TABLE(acpi, pt_gpio_acpi_match);
--
2.30.2


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

* Re: [PATCH] gpio Add my driver new id
  2021-12-03  9:26 [PATCH] gpio Add my driver new id Richard Hsu
@ 2021-12-03 10:15 ` Bartosz Golaszewski
  2021-12-03 21:21   ` Andy Shevchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Bartosz Golaszewski @ 2021-12-03 10:15 UTC (permalink / raw)
  To: Richard Hsu
  Cc: Linus Walleij, Richard_Hsu, open list:GPIO SUBSYSTEM,
	Linux Kernel Mailing List, Yd_Tseng, Cindy1_Hsu, Andrew_Su,
	Andy Shevchenko

On Fri, Dec 3, 2021 at 10:26 AM Richard Hsu <saraon640529@gmail.com> wrote:
>
>  drivers/gpio/gpio-amdpt.c | 12 ++++++++++--
>  1 files changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpio/gpio-amdpt.c b/drivers/gpio/gpio-amdpt.c
> index bbf53e289141..4d01d4341a67 100644
> --- a/drivers/gpio/gpio-amdpt.c
> +++ b/drivers/gpio/gpio-amdpt.c
> @@ -14,6 +14,7 @@
>  #include <linux/platform_device.h>
>
>  #define PT_TOTAL_GPIO 8
> +#define PT_TOTAL_GPIO_EX 24
>
>  /* PCI-E MMIO register offsets */
>  #define PT_DIRECTION_REG   0x00
> @@ -72,10 +73,12 @@ static void pt_gpio_free(struct gpio_chip *gc, unsigned offset)
>  static int pt_gpio_probe(struct platform_device *pdev)
>  {
>         struct device *dev = &pdev->dev;
> +       struct acpi_device *acpi_dev;
> +       acpi_handle handle = ACPI_HANDLE(dev);
>         struct pt_gpio_chip *pt_gpio;
>         int ret = 0;
>
> -       if (!ACPI_COMPANION(dev)) {
> +       if (acpi_bus_get_device(handle, &acpi_dev)) {
>                 dev_err(dev, "PT GPIO device node not found\n");
>                 return -ENODEV;
>         }
> @@ -100,10 +103,14 @@ static int pt_gpio_probe(struct platform_device *pdev)
>                 return ret;
>         }
>
> +       if (!strncmp(acpi_dev_name(acpi_dev), "AMDIF031", 8))
> +               pt_gpio->gc.ngpio = PT_TOTAL_GPIO_EX;
> +       else
> +               pt_gpio->gc.ngpio = PT_TOTAL_GPIO;
> +
>         pt_gpio->gc.owner            = THIS_MODULE;
>         pt_gpio->gc.request          = pt_gpio_request;
>         pt_gpio->gc.free             = pt_gpio_free;
> -       pt_gpio->gc.ngpio            = PT_TOTAL_GPIO;
>  #if defined(CONFIG_OF_GPIO)
>         pt_gpio->gc.of_node          = dev->of_node;
>  #endif
> @@ -135,6 +142,7 @@ static int pt_gpio_remove(struct platform_device *pdev)
>  static const struct acpi_device_id pt_gpio_acpi_match[] = {
>         { "AMDF030", 0 },
>         { "AMDIF030", 0 },
> +       { "AMDIF031", 0 },
>         { },
>  };
>  MODULE_DEVICE_TABLE(acpi, pt_gpio_acpi_match);
> --
> 2.30.2
>

Hi Richard,

Please Cc Andy next time on any GPIO stuff related to ACPI. I'll let
him comment on the code. Your commit message must be more descriptive
- the title should say "gpio: <driver name>: <do this and that>".
Please also add a commit message explaining what the code does in
detail.

Bart

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

* Re: [PATCH] gpio Add my driver new id
  2021-12-03 10:15 ` Bartosz Golaszewski
@ 2021-12-03 21:21   ` Andy Shevchenko
  2021-12-06  6:49     ` Richard Hsu(許育彰)
  0 siblings, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2021-12-03 21:21 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Richard Hsu, Linus Walleij, Richard_Hsu,
	open list:GPIO SUBSYSTEM, Linux Kernel Mailing List, Yd_Tseng,
	Cindy1_Hsu, Andrew_Su

On Fri, Dec 03, 2021 at 11:15:46AM +0100, Bartosz Golaszewski wrote:
> On Fri, Dec 3, 2021 at 10:26 AM Richard Hsu <saraon640529@gmail.com> wrote:

Thanks, Bart, for pointing out to this.

> >  #define PT_TOTAL_GPIO 8
> > +#define PT_TOTAL_GPIO_EX 24

...

> > +       struct acpi_device *acpi_dev;
> > +       acpi_handle handle = ACPI_HANDLE(dev);

> > -       if (!ACPI_COMPANION(dev)) {
> > +       if (acpi_bus_get_device(handle, &acpi_dev)) {

What you are doing here is open coding the ACPI_COMPANION().
But see below.

...

> > +       if (!strncmp(acpi_dev_name(acpi_dev), "AMDIF031", 8))
> > +               pt_gpio->gc.ngpio = PT_TOTAL_GPIO_EX;
> > +       else
> > +               pt_gpio->gc.ngpio = PT_TOTAL_GPIO;

Instead of doing this...

> >  static const struct acpi_device_id pt_gpio_acpi_match[] = {
> >         { "AMDF030", 0 },
> >         { "AMDIF030", 0 },
> > +       { "AMDIF031", 0 },

Just use .driver_data here and if needed in the other ID tables and then simply
retrieve it (w/o any conditions) in the code above:

	pt_gpio->gc.ngpio = (uintptr_t)device_get_match_data(dev);

> >         { },
> >  };

> Please Cc Andy next time on any GPIO stuff related to ACPI. I'll let
> him comment on the code. Your commit message must be more descriptive
> - the title should say "gpio: <driver name>: <do this and that>".
> Please also add a commit message explaining what the code does in
> detail.

-- 
With Best Regards,
Andy Shevchenko



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

* RE: [PATCH] gpio Add my driver new id
  2021-12-03 21:21   ` Andy Shevchenko
@ 2021-12-06  6:49     ` Richard Hsu(許育彰)
  0 siblings, 0 replies; 4+ messages in thread
From: Richard Hsu(許育彰) @ 2021-12-06  6:49 UTC (permalink / raw)
  To: Andy Shevchenko, Bartosz Golaszewski,
	Richard Hsu(許育彰)
  Cc: Richard Hsu, Linus Walleij, open list:GPIO SUBSYSTEM,
	Linux Kernel Mailing List, Yd Tseng(曾裕達),
	Cindy1 Hsu(許凱茵),
	Andrew Su(蘇俊源)

Hi Andy & Bartosz!
    Sorry for the late reply. New acpi device AMDIF031 have 24 gpio pins and older AMDF030/AMDIF030 have 8 gpio pins, 
I use acpi_bus_get_device() that check acpi device and gain acpi_dev info to replace the original. Then we check and compare device name from acpi_dev_name(acpi_dev).
If AMDIF031(pt_gpio->gc.ngpio = 24) or AMDF030/AMDIF030 (pt_gpio->gc.ngpio = 8).

I will try to use .driver_data, and add commit messages on title and code that explain what the code does in detail later

Thanks
     Richard
   
     > >  #define PT_TOTAL_GPIO 8
> > +#define PT_TOTAL_GPIO_EX 24

...

> > +       struct acpi_device *acpi_dev;
> > +       acpi_handle handle = ACPI_HANDLE(dev);

> > -       if (!ACPI_COMPANION(dev)) {
> > +       if (acpi_bus_get_device(handle, &acpi_dev)) {

What you are doing here is open coding the ACPI_COMPANION().
But see below.
...

> > +       if (!strncmp(acpi_dev_name(acpi_dev), "AMDIF031", 8))
> > +               pt_gpio->gc.ngpio = PT_TOTAL_GPIO_EX;
> > +       else
> > +               pt_gpio->gc.ngpio = PT_TOTAL_GPIO;

Instead of doing this...


> >  static const struct acpi_device_id pt_gpio_acpi_match[] = {
> >         { "AMDF030", 0 },
> >         { "AMDIF030", 0 },
> > +       { "AMDIF031", 0 },


-----Original Message-----
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com> 
Sent: Saturday, December 4, 2021 5:21 AM
To: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: Richard Hsu <saraon640529@gmail.com>; Linus Walleij <linus.walleij@linaro.org>; Richard Hsu(許育彰) <Richard_Hsu@asmedia.com.tw>; open list:GPIO SUBSYSTEM <linux-gpio@vger.kernel.org>; Linux Kernel Mailing List <linux-kernel@vger.kernel.org>; Yd Tseng(曾裕達) <Yd_Tseng@asmedia.com.tw>; Cindy1 Hsu(許凱茵) <Cindy1_Hsu@asmedia.com.tw>; Andrew Su(蘇俊源) <Andrew_Su@asmedia.com.tw>
Subject: Re: [PATCH] gpio Add my driver new id

On Fri, Dec 03, 2021 at 11:15:46AM +0100, Bartosz Golaszewski wrote:
> On Fri, Dec 3, 2021 at 10:26 AM Richard Hsu <saraon640529@gmail.com> wrote:

Thanks, Bart, for pointing out to this.

> >  #define PT_TOTAL_GPIO 8
> > +#define PT_TOTAL_GPIO_EX 24

...

> > +       struct acpi_device *acpi_dev;
> > +       acpi_handle handle = ACPI_HANDLE(dev);

> > -       if (!ACPI_COMPANION(dev)) {
> > +       if (acpi_bus_get_device(handle, &acpi_dev)) {

What you are doing here is open coding the ACPI_COMPANION().
But see below.

...

> > +       if (!strncmp(acpi_dev_name(acpi_dev), "AMDIF031", 8))
> > +               pt_gpio->gc.ngpio = PT_TOTAL_GPIO_EX;
> > +       else
> > +               pt_gpio->gc.ngpio = PT_TOTAL_GPIO;

Instead of doing this...

> >  static const struct acpi_device_id pt_gpio_acpi_match[] = {
> >         { "AMDF030", 0 },
> >         { "AMDIF030", 0 },
> > +       { "AMDIF031", 0 },

Just use .driver_data here and if needed in the other ID tables and then simply retrieve it (w/o any conditions) in the code above:

	pt_gpio->gc.ngpio = (uintptr_t)device_get_match_data(dev);

> >         { },
> >  };

> Please Cc Andy next time on any GPIO stuff related to ACPI. I'll let 
> him comment on the code. Your commit message must be more descriptive
> - the title should say "gpio: <driver name>: <do this and that>".
> Please also add a commit message explaining what the code does in 
> detail.

--
With Best Regards,
Andy Shevchenko


<p></p>

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

end of thread, other threads:[~2021-12-06  6:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-03  9:26 [PATCH] gpio Add my driver new id Richard Hsu
2021-12-03 10:15 ` Bartosz Golaszewski
2021-12-03 21:21   ` Andy Shevchenko
2021-12-06  6:49     ` Richard Hsu(許育彰)

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).