LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [RFT, PATCH v1 1/1] platform/x86: dell-smo8800: Convert to be a platform driver
@ 2021-08-03 19:40 Andy Shevchenko
2021-08-04 20:00 ` Pali Rohár
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Andy Shevchenko @ 2021-08-03 19:40 UTC (permalink / raw)
To: Hans de Goede, Mario Limonciello, Andy Shevchenko,
platform-driver-x86, linux-kernel
Cc: Mark Gross, Pali Rohár
ACPI core in conjunction with platform driver core provides
an infrastructure to enumerate ACPI devices. Use it in order
to remove a lot of boilerplate code.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/platform/x86/dell/Kconfig | 2 +-
drivers/platform/x86/dell/dell-smo8800.c | 74 ++++++------------------
2 files changed, 20 insertions(+), 56 deletions(-)
diff --git a/drivers/platform/x86/dell/Kconfig b/drivers/platform/x86/dell/Kconfig
index 9e7314d90bea..821aba31821c 100644
--- a/drivers/platform/x86/dell/Kconfig
+++ b/drivers/platform/x86/dell/Kconfig
@@ -140,7 +140,7 @@ config DELL_SMBIOS_SMM
config DELL_SMO8800
tristate "Dell Latitude freefall driver (ACPI SMO88XX)"
default m
- depends on ACPI
+ depends on ACPI || COMPILE_TEST
help
Say Y here if you want to support SMO88XX freefall devices
on Dell Latitude laptops.
diff --git a/drivers/platform/x86/dell/dell-smo8800.c b/drivers/platform/x86/dell/dell-smo8800.c
index 5d9304a7de1b..3385e852104c 100644
--- a/drivers/platform/x86/dell/dell-smo8800.c
+++ b/drivers/platform/x86/dell/dell-smo8800.c
@@ -10,13 +10,14 @@
#define DRIVER_NAME "smo8800"
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/acpi.h>
+#include <linux/fs.h>
#include <linux/interrupt.h>
+#include <linux/kernel.h>
#include <linux/miscdevice.h>
+#include <linux/mod_devicetable.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
#include <linux/uaccess.h>
-#include <linux/fs.h>
struct smo8800_device {
u32 irq; /* acpi device irq */
@@ -44,37 +45,6 @@ static irqreturn_t smo8800_interrupt_thread(int irq, void *data)
return IRQ_HANDLED;
}
-static acpi_status smo8800_get_resource(struct acpi_resource *resource,
- void *context)
-{
- struct acpi_resource_extended_irq *irq;
-
- if (resource->type != ACPI_RESOURCE_TYPE_EXTENDED_IRQ)
- return AE_OK;
-
- irq = &resource->data.extended_irq;
- if (!irq || !irq->interrupt_count)
- return AE_OK;
-
- *((u32 *)context) = irq->interrupts[0];
- return AE_CTRL_TERMINATE;
-}
-
-static u32 smo8800_get_irq(struct acpi_device *device)
-{
- u32 irq = 0;
- acpi_status status;
-
- status = acpi_walk_resources(device->handle, METHOD_NAME__CRS,
- smo8800_get_resource, &irq);
- if (ACPI_FAILURE(status)) {
- dev_err(&device->dev, "acpi_walk_resources failed\n");
- return 0;
- }
-
- return irq;
-}
-
static ssize_t smo8800_misc_read(struct file *file, char __user *buf,
size_t count, loff_t *pos)
{
@@ -136,7 +106,7 @@ static const struct file_operations smo8800_misc_fops = {
.release = smo8800_misc_release,
};
-static int smo8800_add(struct acpi_device *device)
+static int smo8800_probe(struct platform_device *device)
{
int err;
struct smo8800_device *smo8800;
@@ -160,14 +130,12 @@ static int smo8800_add(struct acpi_device *device)
return err;
}
- device->driver_data = smo8800;
+ platform_set_drvdata(device, smo8800);
- smo8800->irq = smo8800_get_irq(device);
- if (!smo8800->irq) {
- dev_err(&device->dev, "failed to obtain IRQ\n");
- err = -EINVAL;
+ err = platform_get_irq(device, 0);
+ if (err < 0)
goto error;
- }
+ smo8800->irq = err;
err = request_threaded_irq(smo8800->irq, smo8800_interrupt_quick,
smo8800_interrupt_thread,
@@ -189,9 +157,9 @@ static int smo8800_add(struct acpi_device *device)
return err;
}
-static int smo8800_remove(struct acpi_device *device)
+static int smo8800_remove(struct platform_device *device)
{
- struct smo8800_device *smo8800 = device->driver_data;
+ struct smo8800_device *smo8800 = platform_get_drvdata(device);
free_irq(smo8800->irq, smo8800);
misc_deregister(&smo8800->miscdev);
@@ -211,21 +179,17 @@ static const struct acpi_device_id smo8800_ids[] = {
{ "SMO8831", 0 },
{ "", 0 },
};
-
MODULE_DEVICE_TABLE(acpi, smo8800_ids);
-static struct acpi_driver smo8800_driver = {
- .name = DRIVER_NAME,
- .class = "Latitude",
- .ids = smo8800_ids,
- .ops = {
- .add = smo8800_add,
- .remove = smo8800_remove,
+static struct platform_driver smo8800_driver = {
+ .probe = smo8800_probe,
+ .remove = smo8800_remove,
+ .driver = {
+ .name = DRIVER_NAME,
+ .acpi_match_table = smo8800_ids,
},
- .owner = THIS_MODULE,
};
-
-module_acpi_driver(smo8800_driver);
+module_platform_driver(smo8800_driver);
MODULE_DESCRIPTION("Dell Latitude freefall driver (ACPI SMO88XX)");
MODULE_LICENSE("GPL");
--
2.30.2
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RFT, PATCH v1 1/1] platform/x86: dell-smo8800: Convert to be a platform driver
2021-08-03 19:40 [RFT, PATCH v1 1/1] platform/x86: dell-smo8800: Convert to be a platform driver Andy Shevchenko
@ 2021-08-04 20:00 ` Pali Rohár
[not found] ` <CAHp75Vc1r+9N6_BiJzO3JYppgaokKiQwk4sLrp72kPEDgYEweg@mail.gmail.com>
2021-08-05 19:22 ` Pali Rohár
2021-08-06 13:46 ` Hans de Goede
2 siblings, 1 reply; 7+ messages in thread
From: Pali Rohár @ 2021-08-04 20:00 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Hans de Goede, Mario Limonciello, platform-driver-x86,
linux-kernel, Mark Gross
On Tuesday 03 August 2021 22:40:39 Andy Shevchenko wrote:
> ACPI core in conjunction with platform driver core provides
> an infrastructure to enumerate ACPI devices. Use it in order
> to remove a lot of boilerplate code.
Are there any other dependences for this patch? And in which kernel
version is (or will be) introduced this ACPI infrastructure?
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> drivers/platform/x86/dell/Kconfig | 2 +-
> drivers/platform/x86/dell/dell-smo8800.c | 74 ++++++------------------
> 2 files changed, 20 insertions(+), 56 deletions(-)
>
> diff --git a/drivers/platform/x86/dell/Kconfig b/drivers/platform/x86/dell/Kconfig
> index 9e7314d90bea..821aba31821c 100644
> --- a/drivers/platform/x86/dell/Kconfig
> +++ b/drivers/platform/x86/dell/Kconfig
> @@ -140,7 +140,7 @@ config DELL_SMBIOS_SMM
> config DELL_SMO8800
> tristate "Dell Latitude freefall driver (ACPI SMO88XX)"
> default m
> - depends on ACPI
> + depends on ACPI || COMPILE_TEST
> help
> Say Y here if you want to support SMO88XX freefall devices
> on Dell Latitude laptops.
> diff --git a/drivers/platform/x86/dell/dell-smo8800.c b/drivers/platform/x86/dell/dell-smo8800.c
> index 5d9304a7de1b..3385e852104c 100644
> --- a/drivers/platform/x86/dell/dell-smo8800.c
> +++ b/drivers/platform/x86/dell/dell-smo8800.c
> @@ -10,13 +10,14 @@
>
> #define DRIVER_NAME "smo8800"
>
> -#include <linux/kernel.h>
> -#include <linux/module.h>
> -#include <linux/acpi.h>
> +#include <linux/fs.h>
> #include <linux/interrupt.h>
> +#include <linux/kernel.h>
> #include <linux/miscdevice.h>
> +#include <linux/mod_devicetable.h>
> +#include <linux/module.h>
> +#include <linux/platform_device.h>
> #include <linux/uaccess.h>
> -#include <linux/fs.h>
>
> struct smo8800_device {
> u32 irq; /* acpi device irq */
> @@ -44,37 +45,6 @@ static irqreturn_t smo8800_interrupt_thread(int irq, void *data)
> return IRQ_HANDLED;
> }
>
> -static acpi_status smo8800_get_resource(struct acpi_resource *resource,
> - void *context)
> -{
> - struct acpi_resource_extended_irq *irq;
> -
> - if (resource->type != ACPI_RESOURCE_TYPE_EXTENDED_IRQ)
> - return AE_OK;
> -
> - irq = &resource->data.extended_irq;
> - if (!irq || !irq->interrupt_count)
> - return AE_OK;
> -
> - *((u32 *)context) = irq->interrupts[0];
> - return AE_CTRL_TERMINATE;
> -}
> -
> -static u32 smo8800_get_irq(struct acpi_device *device)
> -{
> - u32 irq = 0;
> - acpi_status status;
> -
> - status = acpi_walk_resources(device->handle, METHOD_NAME__CRS,
> - smo8800_get_resource, &irq);
> - if (ACPI_FAILURE(status)) {
> - dev_err(&device->dev, "acpi_walk_resources failed\n");
> - return 0;
> - }
> -
> - return irq;
> -}
> -
> static ssize_t smo8800_misc_read(struct file *file, char __user *buf,
> size_t count, loff_t *pos)
> {
> @@ -136,7 +106,7 @@ static const struct file_operations smo8800_misc_fops = {
> .release = smo8800_misc_release,
> };
>
> -static int smo8800_add(struct acpi_device *device)
> +static int smo8800_probe(struct platform_device *device)
> {
> int err;
> struct smo8800_device *smo8800;
> @@ -160,14 +130,12 @@ static int smo8800_add(struct acpi_device *device)
> return err;
> }
>
> - device->driver_data = smo8800;
> + platform_set_drvdata(device, smo8800);
>
> - smo8800->irq = smo8800_get_irq(device);
> - if (!smo8800->irq) {
> - dev_err(&device->dev, "failed to obtain IRQ\n");
> - err = -EINVAL;
> + err = platform_get_irq(device, 0);
> + if (err < 0)
> goto error;
> - }
> + smo8800->irq = err;
>
> err = request_threaded_irq(smo8800->irq, smo8800_interrupt_quick,
> smo8800_interrupt_thread,
> @@ -189,9 +157,9 @@ static int smo8800_add(struct acpi_device *device)
> return err;
> }
>
> -static int smo8800_remove(struct acpi_device *device)
> +static int smo8800_remove(struct platform_device *device)
> {
> - struct smo8800_device *smo8800 = device->driver_data;
> + struct smo8800_device *smo8800 = platform_get_drvdata(device);
>
> free_irq(smo8800->irq, smo8800);
> misc_deregister(&smo8800->miscdev);
> @@ -211,21 +179,17 @@ static const struct acpi_device_id smo8800_ids[] = {
> { "SMO8831", 0 },
> { "", 0 },
> };
> -
> MODULE_DEVICE_TABLE(acpi, smo8800_ids);
>
> -static struct acpi_driver smo8800_driver = {
> - .name = DRIVER_NAME,
> - .class = "Latitude",
> - .ids = smo8800_ids,
> - .ops = {
> - .add = smo8800_add,
> - .remove = smo8800_remove,
> +static struct platform_driver smo8800_driver = {
> + .probe = smo8800_probe,
> + .remove = smo8800_remove,
> + .driver = {
> + .name = DRIVER_NAME,
> + .acpi_match_table = smo8800_ids,
> },
> - .owner = THIS_MODULE,
> };
> -
> -module_acpi_driver(smo8800_driver);
> +module_platform_driver(smo8800_driver);
>
> MODULE_DESCRIPTION("Dell Latitude freefall driver (ACPI SMO88XX)");
> MODULE_LICENSE("GPL");
> --
> 2.30.2
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RFT, PATCH v1 1/1] platform/x86: dell-smo8800: Convert to be a platform driver
[not found] ` <CAHp75Vc1r+9N6_BiJzO3JYppgaokKiQwk4sLrp72kPEDgYEweg@mail.gmail.com>
@ 2021-08-05 8:11 ` Pali Rohár
2021-08-05 8:29 ` Andy Shevchenko
0 siblings, 1 reply; 7+ messages in thread
From: Pali Rohár @ 2021-08-05 8:11 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Andy Shevchenko, Hans de Goede, Mario Limonciello,
platform-driver-x86, linux-kernel, Mark Gross
On Thursday 05 August 2021 10:20:40 Andy Shevchenko wrote:
> On Wednesday, August 4, 2021, Pali Rohár <pali@kernel.org> wrote:
>
> > On Tuesday 03 August 2021 22:40:39 Andy Shevchenko wrote:
> > > ACPI core in conjunction with platform driver core provides
> > > an infrastructure to enumerate ACPI devices. Use it in order
> > > to remove a lot of boilerplate code.
> >
> > Are there any other dependences for this patch?
>
>
> >
> Assuming that you are asking because something is not working, what are the
> symptoms?
>
Because I thought that it is something new, but I have not found
anything special about it in last kernel versions...
> > And in which kernel
> > version is (or will be) introduced this ACPI infrastructure?
>
>
> I don’t remember, I think it is in v3 era or even v2.6.x.
... and this answers why.
I will try to find some time to test this change on a real hw.
>
>
> >
> > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > > ---
> > > drivers/platform/x86/dell/Kconfig | 2 +-
> > > drivers/platform/x86/dell/dell-smo8800.c | 74 ++++++------------------
> > > 2 files changed, 20 insertions(+), 56 deletions(-)
> > >
> > > diff --git a/drivers/platform/x86/dell/Kconfig
> > b/drivers/platform/x86/dell/Kconfig
> > > index 9e7314d90bea..821aba31821c 100644
> > > --- a/drivers/platform/x86/dell/Kconfig
> > > +++ b/drivers/platform/x86/dell/Kconfig
> > > @@ -140,7 +140,7 @@ config DELL_SMBIOS_SMM
> > > config DELL_SMO8800
> > > tristate "Dell Latitude freefall driver (ACPI SMO88XX)"
> > > default m
> > > - depends on ACPI
> > > + depends on ACPI || COMPILE_TEST
> > > help
> > > Say Y here if you want to support SMO88XX freefall devices
> > > on Dell Latitude laptops.
> > > diff --git a/drivers/platform/x86/dell/dell-smo8800.c
> > b/drivers/platform/x86/dell/dell-smo8800.c
> > > index 5d9304a7de1b..3385e852104c 100644
> > > --- a/drivers/platform/x86/dell/dell-smo8800.c
> > > +++ b/drivers/platform/x86/dell/dell-smo8800.c
> > > @@ -10,13 +10,14 @@
> > >
> > > #define DRIVER_NAME "smo8800"
> > >
> > > -#include <linux/kernel.h>
> > > -#include <linux/module.h>
> > > -#include <linux/acpi.h>
> > > +#include <linux/fs.h>
> > > #include <linux/interrupt.h>
> > > +#include <linux/kernel.h>
> > > #include <linux/miscdevice.h>
> > > +#include <linux/mod_devicetable.h>
> > > +#include <linux/module.h>
> > > +#include <linux/platform_device.h>
> > > #include <linux/uaccess.h>
> > > -#include <linux/fs.h>
> > >
> > > struct smo8800_device {
> > > u32 irq; /* acpi device irq */
> > > @@ -44,37 +45,6 @@ static irqreturn_t smo8800_interrupt_thread(int irq,
> > void *data)
> > > return IRQ_HANDLED;
> > > }
> > >
> > > -static acpi_status smo8800_get_resource(struct acpi_resource *resource,
> > > - void *context)
> > > -{
> > > - struct acpi_resource_extended_irq *irq;
> > > -
> > > - if (resource->type != ACPI_RESOURCE_TYPE_EXTENDED_IRQ)
> > > - return AE_OK;
> > > -
> > > - irq = &resource->data.extended_irq;
> > > - if (!irq || !irq->interrupt_count)
> > > - return AE_OK;
> > > -
> > > - *((u32 *)context) = irq->interrupts[0];
> > > - return AE_CTRL_TERMINATE;
> > > -}
> > > -
> > > -static u32 smo8800_get_irq(struct acpi_device *device)
> > > -{
> > > - u32 irq = 0;
> > > - acpi_status status;
> > > -
> > > - status = acpi_walk_resources(device->handle, METHOD_NAME__CRS,
> > > - smo8800_get_resource, &irq);
> > > - if (ACPI_FAILURE(status)) {
> > > - dev_err(&device->dev, "acpi_walk_resources failed\n");
> > > - return 0;
> > > - }
> > > -
> > > - return irq;
> > > -}
> > > -
> > > static ssize_t smo8800_misc_read(struct file *file, char __user *buf,
> > > size_t count, loff_t *pos)
> > > {
> > > @@ -136,7 +106,7 @@ static const struct file_operations
> > smo8800_misc_fops = {
> > > .release = smo8800_misc_release,
> > > };
> > >
> > > -static int smo8800_add(struct acpi_device *device)
> > > +static int smo8800_probe(struct platform_device *device)
> > > {
> > > int err;
> > > struct smo8800_device *smo8800;
> > > @@ -160,14 +130,12 @@ static int smo8800_add(struct acpi_device *device)
> > > return err;
> > > }
> > >
> > > - device->driver_data = smo8800;
> > > + platform_set_drvdata(device, smo8800);
> > >
> > > - smo8800->irq = smo8800_get_irq(device);
> > > - if (!smo8800->irq) {
> > > - dev_err(&device->dev, "failed to obtain IRQ\n");
> > > - err = -EINVAL;
> > > + err = platform_get_irq(device, 0);
> > > + if (err < 0)
> > > goto error;
> > > - }
> > > + smo8800->irq = err;
> > >
> > > err = request_threaded_irq(smo8800->irq, smo8800_interrupt_quick,
> > > smo8800_interrupt_thread,
> > > @@ -189,9 +157,9 @@ static int smo8800_add(struct acpi_device *device)
> > > return err;
> > > }
> > >
> > > -static int smo8800_remove(struct acpi_device *device)
> > > +static int smo8800_remove(struct platform_device *device)
> > > {
> > > - struct smo8800_device *smo8800 = device->driver_data;
> > > + struct smo8800_device *smo8800 = platform_get_drvdata(device);
> > >
> > > free_irq(smo8800->irq, smo8800);
> > > misc_deregister(&smo8800->miscdev);
> > > @@ -211,21 +179,17 @@ static const struct acpi_device_id smo8800_ids[] =
> > {
> > > { "SMO8831", 0 },
> > > { "", 0 },
> > > };
> > > -
> > > MODULE_DEVICE_TABLE(acpi, smo8800_ids);
> > >
> > > -static struct acpi_driver smo8800_driver = {
> > > - .name = DRIVER_NAME,
> > > - .class = "Latitude",
> > > - .ids = smo8800_ids,
> > > - .ops = {
> > > - .add = smo8800_add,
> > > - .remove = smo8800_remove,
> > > +static struct platform_driver smo8800_driver = {
> > > + .probe = smo8800_probe,
> > > + .remove = smo8800_remove,
> > > + .driver = {
> > > + .name = DRIVER_NAME,
> > > + .acpi_match_table = smo8800_ids,
> > > },
> > > - .owner = THIS_MODULE,
> > > };
> > > -
> > > -module_acpi_driver(smo8800_driver);
> > > +module_platform_driver(smo8800_driver);
> > >
> > > MODULE_DESCRIPTION("Dell Latitude freefall driver (ACPI SMO88XX)");
> > > MODULE_LICENSE("GPL");
> > > --
> > > 2.30.2
> > >
> >
>
>
> --
> With Best Regards,
> Andy Shevchenko
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RFT, PATCH v1 1/1] platform/x86: dell-smo8800: Convert to be a platform driver
2021-08-05 8:11 ` Pali Rohár
@ 2021-08-05 8:29 ` Andy Shevchenko
0 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2021-08-05 8:29 UTC (permalink / raw)
To: Pali Rohár
Cc: Andy Shevchenko, Hans de Goede, Mario Limonciello,
platform-driver-x86, linux-kernel, Mark Gross
On Thu, Aug 5, 2021 at 11:11 AM Pali Rohár <pali@kernel.org> wrote:
> On Thursday 05 August 2021 10:20:40 Andy Shevchenko wrote:
> > On Wednesday, August 4, 2021, Pali Rohár <pali@kernel.org> wrote:
> > > On Tuesday 03 August 2021 22:40:39 Andy Shevchenko wrote:
...
> > > And in which kernel
> > > version is (or will be) introduced this ACPI infrastructure?
> >
> >
> > I don’t remember, I think it is in v3 era or even v2.6.x.
>
> ... and this answers why.
Since you have asked, it's v3.8-rc1 with the commit
91e568780588 ("ACPI: Add support for platform bus type")
> I will try to find some time to test this change on a real hw.
Thanks in advance!
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RFT, PATCH v1 1/1] platform/x86: dell-smo8800: Convert to be a platform driver
2021-08-03 19:40 [RFT, PATCH v1 1/1] platform/x86: dell-smo8800: Convert to be a platform driver Andy Shevchenko
2021-08-04 20:00 ` Pali Rohár
@ 2021-08-05 19:22 ` Pali Rohár
2021-08-06 9:04 ` Andy Shevchenko
2021-08-06 13:46 ` Hans de Goede
2 siblings, 1 reply; 7+ messages in thread
From: Pali Rohár @ 2021-08-05 19:22 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Hans de Goede, platform-driver-x86, linux-kernel, Mark Gross
On Tuesday 03 August 2021 22:40:39 Andy Shevchenko wrote:
> ACPI core in conjunction with platform driver core provides
> an infrastructure to enumerate ACPI devices. Use it in order
> to remove a lot of boilerplate code.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested on Dell Latitude E6440. After applying this patch /dev/freefall
device is created and can be opened (for waiting for disk fall). Also
interrupt is registered in /proc/interrupts file:
23: 0 0 0 0 IR-IO-APIC 23-edge smo8800
But I have not done real hard disk fall on this machine :-) so I guess
it would work as before applying this patch.
Reviewed-by: Pali Rohár <pali@kernel.org>
Tested-by: Pali Rohár <pali@kernel.org>
> ---
> drivers/platform/x86/dell/Kconfig | 2 +-
> drivers/platform/x86/dell/dell-smo8800.c | 74 ++++++------------------
> 2 files changed, 20 insertions(+), 56 deletions(-)
>
> diff --git a/drivers/platform/x86/dell/Kconfig b/drivers/platform/x86/dell/Kconfig
> index 9e7314d90bea..821aba31821c 100644
> --- a/drivers/platform/x86/dell/Kconfig
> +++ b/drivers/platform/x86/dell/Kconfig
> @@ -140,7 +140,7 @@ config DELL_SMBIOS_SMM
> config DELL_SMO8800
> tristate "Dell Latitude freefall driver (ACPI SMO88XX)"
> default m
> - depends on ACPI
> + depends on ACPI || COMPILE_TEST
> help
> Say Y here if you want to support SMO88XX freefall devices
> on Dell Latitude laptops.
> diff --git a/drivers/platform/x86/dell/dell-smo8800.c b/drivers/platform/x86/dell/dell-smo8800.c
> index 5d9304a7de1b..3385e852104c 100644
> --- a/drivers/platform/x86/dell/dell-smo8800.c
> +++ b/drivers/platform/x86/dell/dell-smo8800.c
> @@ -10,13 +10,14 @@
>
> #define DRIVER_NAME "smo8800"
>
> -#include <linux/kernel.h>
> -#include <linux/module.h>
> -#include <linux/acpi.h>
> +#include <linux/fs.h>
> #include <linux/interrupt.h>
> +#include <linux/kernel.h>
> #include <linux/miscdevice.h>
> +#include <linux/mod_devicetable.h>
> +#include <linux/module.h>
> +#include <linux/platform_device.h>
> #include <linux/uaccess.h>
> -#include <linux/fs.h>
>
> struct smo8800_device {
> u32 irq; /* acpi device irq */
> @@ -44,37 +45,6 @@ static irqreturn_t smo8800_interrupt_thread(int irq, void *data)
> return IRQ_HANDLED;
> }
>
> -static acpi_status smo8800_get_resource(struct acpi_resource *resource,
> - void *context)
> -{
> - struct acpi_resource_extended_irq *irq;
> -
> - if (resource->type != ACPI_RESOURCE_TYPE_EXTENDED_IRQ)
> - return AE_OK;
> -
> - irq = &resource->data.extended_irq;
> - if (!irq || !irq->interrupt_count)
> - return AE_OK;
> -
> - *((u32 *)context) = irq->interrupts[0];
> - return AE_CTRL_TERMINATE;
> -}
> -
> -static u32 smo8800_get_irq(struct acpi_device *device)
> -{
> - u32 irq = 0;
> - acpi_status status;
> -
> - status = acpi_walk_resources(device->handle, METHOD_NAME__CRS,
> - smo8800_get_resource, &irq);
> - if (ACPI_FAILURE(status)) {
> - dev_err(&device->dev, "acpi_walk_resources failed\n");
> - return 0;
> - }
> -
> - return irq;
> -}
> -
> static ssize_t smo8800_misc_read(struct file *file, char __user *buf,
> size_t count, loff_t *pos)
> {
> @@ -136,7 +106,7 @@ static const struct file_operations smo8800_misc_fops = {
> .release = smo8800_misc_release,
> };
>
> -static int smo8800_add(struct acpi_device *device)
> +static int smo8800_probe(struct platform_device *device)
> {
> int err;
> struct smo8800_device *smo8800;
> @@ -160,14 +130,12 @@ static int smo8800_add(struct acpi_device *device)
> return err;
> }
>
> - device->driver_data = smo8800;
> + platform_set_drvdata(device, smo8800);
>
> - smo8800->irq = smo8800_get_irq(device);
> - if (!smo8800->irq) {
> - dev_err(&device->dev, "failed to obtain IRQ\n");
> - err = -EINVAL;
> + err = platform_get_irq(device, 0);
> + if (err < 0)
> goto error;
> - }
> + smo8800->irq = err;
>
> err = request_threaded_irq(smo8800->irq, smo8800_interrupt_quick,
> smo8800_interrupt_thread,
> @@ -189,9 +157,9 @@ static int smo8800_add(struct acpi_device *device)
> return err;
> }
>
> -static int smo8800_remove(struct acpi_device *device)
> +static int smo8800_remove(struct platform_device *device)
> {
> - struct smo8800_device *smo8800 = device->driver_data;
> + struct smo8800_device *smo8800 = platform_get_drvdata(device);
>
> free_irq(smo8800->irq, smo8800);
> misc_deregister(&smo8800->miscdev);
> @@ -211,21 +179,17 @@ static const struct acpi_device_id smo8800_ids[] = {
> { "SMO8831", 0 },
> { "", 0 },
> };
> -
> MODULE_DEVICE_TABLE(acpi, smo8800_ids);
>
> -static struct acpi_driver smo8800_driver = {
> - .name = DRIVER_NAME,
> - .class = "Latitude",
> - .ids = smo8800_ids,
> - .ops = {
> - .add = smo8800_add,
> - .remove = smo8800_remove,
> +static struct platform_driver smo8800_driver = {
> + .probe = smo8800_probe,
> + .remove = smo8800_remove,
> + .driver = {
> + .name = DRIVER_NAME,
> + .acpi_match_table = smo8800_ids,
> },
> - .owner = THIS_MODULE,
> };
> -
> -module_acpi_driver(smo8800_driver);
> +module_platform_driver(smo8800_driver);
>
> MODULE_DESCRIPTION("Dell Latitude freefall driver (ACPI SMO88XX)");
> MODULE_LICENSE("GPL");
> --
> 2.30.2
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RFT, PATCH v1 1/1] platform/x86: dell-smo8800: Convert to be a platform driver
2021-08-05 19:22 ` Pali Rohár
@ 2021-08-06 9:04 ` Andy Shevchenko
0 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2021-08-06 9:04 UTC (permalink / raw)
To: Pali Rohár
Cc: Hans de Goede, platform-driver-x86, linux-kernel, Mark Gross
On Thu, Aug 05, 2021 at 09:22:21PM +0200, Pali Rohár wrote:
> On Tuesday 03 August 2021 22:40:39 Andy Shevchenko wrote:
> > ACPI core in conjunction with platform driver core provides
> > an infrastructure to enumerate ACPI devices. Use it in order
> > to remove a lot of boilerplate code.
> >
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>
> Tested on Dell Latitude E6440. After applying this patch /dev/freefall
> device is created and can be opened (for waiting for disk fall). Also
> interrupt is registered in /proc/interrupts file:
>
> 23: 0 0 0 0 IR-IO-APIC 23-edge smo8800
>
> But I have not done real hard disk fall on this machine :-) so I guess
> it would work as before applying this patch.
At least the change doesn't touch any functional parts except device driver
enumeration.
> Reviewed-by: Pali Rohár <pali@kernel.org>
> Tested-by: Pali Rohár <pali@kernel.org>
Thank you!
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RFT, PATCH v1 1/1] platform/x86: dell-smo8800: Convert to be a platform driver
2021-08-03 19:40 [RFT, PATCH v1 1/1] platform/x86: dell-smo8800: Convert to be a platform driver Andy Shevchenko
2021-08-04 20:00 ` Pali Rohár
2021-08-05 19:22 ` Pali Rohár
@ 2021-08-06 13:46 ` Hans de Goede
2 siblings, 0 replies; 7+ messages in thread
From: Hans de Goede @ 2021-08-06 13:46 UTC (permalink / raw)
To: Andy Shevchenko, Mario Limonciello, platform-driver-x86, linux-kernel
Cc: Mark Gross, Pali Rohár
Hi,
On 8/3/21 9:40 PM, Andy Shevchenko wrote:
> ACPI core in conjunction with platform driver core provides
> an infrastructure to enumerate ACPI devices. Use it in order
> to remove a lot of boilerplate code.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Thank you for your patch, I've applied this patch to my review-hans
branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans
Note it will show up in my review-hans branch once I've pushed my
local branch there, which might take a while.
Once I've run some tests on this branch the patches there will be
added to the platform-drivers-x86/for-next branch and eventually
will be included in the pdx86 pull-request to Linus for the next
merge-window.
Regards,
Hans
> ---
> drivers/platform/x86/dell/Kconfig | 2 +-
> drivers/platform/x86/dell/dell-smo8800.c | 74 ++++++------------------
> 2 files changed, 20 insertions(+), 56 deletions(-)
>
> diff --git a/drivers/platform/x86/dell/Kconfig b/drivers/platform/x86/dell/Kconfig
> index 9e7314d90bea..821aba31821c 100644
> --- a/drivers/platform/x86/dell/Kconfig
> +++ b/drivers/platform/x86/dell/Kconfig
> @@ -140,7 +140,7 @@ config DELL_SMBIOS_SMM
> config DELL_SMO8800
> tristate "Dell Latitude freefall driver (ACPI SMO88XX)"
> default m
> - depends on ACPI
> + depends on ACPI || COMPILE_TEST
> help
> Say Y here if you want to support SMO88XX freefall devices
> on Dell Latitude laptops.
> diff --git a/drivers/platform/x86/dell/dell-smo8800.c b/drivers/platform/x86/dell/dell-smo8800.c
> index 5d9304a7de1b..3385e852104c 100644
> --- a/drivers/platform/x86/dell/dell-smo8800.c
> +++ b/drivers/platform/x86/dell/dell-smo8800.c
> @@ -10,13 +10,14 @@
>
> #define DRIVER_NAME "smo8800"
>
> -#include <linux/kernel.h>
> -#include <linux/module.h>
> -#include <linux/acpi.h>
> +#include <linux/fs.h>
> #include <linux/interrupt.h>
> +#include <linux/kernel.h>
> #include <linux/miscdevice.h>
> +#include <linux/mod_devicetable.h>
> +#include <linux/module.h>
> +#include <linux/platform_device.h>
> #include <linux/uaccess.h>
> -#include <linux/fs.h>
>
> struct smo8800_device {
> u32 irq; /* acpi device irq */
> @@ -44,37 +45,6 @@ static irqreturn_t smo8800_interrupt_thread(int irq, void *data)
> return IRQ_HANDLED;
> }
>
> -static acpi_status smo8800_get_resource(struct acpi_resource *resource,
> - void *context)
> -{
> - struct acpi_resource_extended_irq *irq;
> -
> - if (resource->type != ACPI_RESOURCE_TYPE_EXTENDED_IRQ)
> - return AE_OK;
> -
> - irq = &resource->data.extended_irq;
> - if (!irq || !irq->interrupt_count)
> - return AE_OK;
> -
> - *((u32 *)context) = irq->interrupts[0];
> - return AE_CTRL_TERMINATE;
> -}
> -
> -static u32 smo8800_get_irq(struct acpi_device *device)
> -{
> - u32 irq = 0;
> - acpi_status status;
> -
> - status = acpi_walk_resources(device->handle, METHOD_NAME__CRS,
> - smo8800_get_resource, &irq);
> - if (ACPI_FAILURE(status)) {
> - dev_err(&device->dev, "acpi_walk_resources failed\n");
> - return 0;
> - }
> -
> - return irq;
> -}
> -
> static ssize_t smo8800_misc_read(struct file *file, char __user *buf,
> size_t count, loff_t *pos)
> {
> @@ -136,7 +106,7 @@ static const struct file_operations smo8800_misc_fops = {
> .release = smo8800_misc_release,
> };
>
> -static int smo8800_add(struct acpi_device *device)
> +static int smo8800_probe(struct platform_device *device)
> {
> int err;
> struct smo8800_device *smo8800;
> @@ -160,14 +130,12 @@ static int smo8800_add(struct acpi_device *device)
> return err;
> }
>
> - device->driver_data = smo8800;
> + platform_set_drvdata(device, smo8800);
>
> - smo8800->irq = smo8800_get_irq(device);
> - if (!smo8800->irq) {
> - dev_err(&device->dev, "failed to obtain IRQ\n");
> - err = -EINVAL;
> + err = platform_get_irq(device, 0);
> + if (err < 0)
> goto error;
> - }
> + smo8800->irq = err;
>
> err = request_threaded_irq(smo8800->irq, smo8800_interrupt_quick,
> smo8800_interrupt_thread,
> @@ -189,9 +157,9 @@ static int smo8800_add(struct acpi_device *device)
> return err;
> }
>
> -static int smo8800_remove(struct acpi_device *device)
> +static int smo8800_remove(struct platform_device *device)
> {
> - struct smo8800_device *smo8800 = device->driver_data;
> + struct smo8800_device *smo8800 = platform_get_drvdata(device);
>
> free_irq(smo8800->irq, smo8800);
> misc_deregister(&smo8800->miscdev);
> @@ -211,21 +179,17 @@ static const struct acpi_device_id smo8800_ids[] = {
> { "SMO8831", 0 },
> { "", 0 },
> };
> -
> MODULE_DEVICE_TABLE(acpi, smo8800_ids);
>
> -static struct acpi_driver smo8800_driver = {
> - .name = DRIVER_NAME,
> - .class = "Latitude",
> - .ids = smo8800_ids,
> - .ops = {
> - .add = smo8800_add,
> - .remove = smo8800_remove,
> +static struct platform_driver smo8800_driver = {
> + .probe = smo8800_probe,
> + .remove = smo8800_remove,
> + .driver = {
> + .name = DRIVER_NAME,
> + .acpi_match_table = smo8800_ids,
> },
> - .owner = THIS_MODULE,
> };
> -
> -module_acpi_driver(smo8800_driver);
> +module_platform_driver(smo8800_driver);
>
> MODULE_DESCRIPTION("Dell Latitude freefall driver (ACPI SMO88XX)");
> MODULE_LICENSE("GPL");
>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-08-06 13:46 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-03 19:40 [RFT, PATCH v1 1/1] platform/x86: dell-smo8800: Convert to be a platform driver Andy Shevchenko
2021-08-04 20:00 ` Pali Rohár
[not found] ` <CAHp75Vc1r+9N6_BiJzO3JYppgaokKiQwk4sLrp72kPEDgYEweg@mail.gmail.com>
2021-08-05 8:11 ` Pali Rohár
2021-08-05 8:29 ` Andy Shevchenko
2021-08-05 19:22 ` Pali Rohár
2021-08-06 9:04 ` Andy Shevchenko
2021-08-06 13:46 ` Hans de Goede
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).