platform-driver-x86.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kai-Heng Feng <kai.heng.feng@canonical.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	platform-driver-x86@vger.kernel.org,
	Eric Piel <eric.piel@tremplin-utc.net>,
	Arnd Bergmann <arnd@arndb.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Hans de Goede <hdegoede@redhat.com>,
	Mark Gross <mgross@linux.intel.com>
Subject: Re: [PATCH v2 2/2] platform/x86: hp_accel: Convert to be a platform driver
Date: Wed, 25 Aug 2021 18:41:19 +0800	[thread overview]
Message-ID: <CAAd53p6pQcura_tejtW7osiHfSnn6pCcxfm1e13==qmQA8C1bw@mail.gmail.com> (raw)
In-Reply-To: <20210823093222.19544-3-andriy.shevchenko@linux.intel.com>

On Mon, Aug 23, 2021 at 5:32 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> 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>

The lis3lv02d still works with this patch.

Tested-by: Kai-Heng Feng <kai.heng.feng@canonical.com>

> ---
>  drivers/platform/x86/hp_accel.c | 64 ++++++++-------------------------
>  1 file changed, 14 insertions(+), 50 deletions(-)
>
> diff --git a/drivers/platform/x86/hp_accel.c b/drivers/platform/x86/hp_accel.c
> index 54a4addc7903..cc53f725c041 100644
> --- a/drivers/platform/x86/hp_accel.c
> +++ b/drivers/platform/x86/hp_accel.c
> @@ -28,9 +28,6 @@
>  #include <linux/serio.h>
>  #include "../../misc/lis3lv02d/lis3lv02d.h"
>
> -#define DRIVER_NAME     "hp_accel"
> -#define ACPI_MDPS_CLASS "accelerometer"
> -
>  /* Delayed LEDs infrastructure ------------------------------------ */
>
>  /* Special LED class that can defer work */
> @@ -269,30 +266,6 @@ static struct delayed_led_classdev hpled_led = {
>         .set_brightness = hpled_set,
>  };
>
> -static acpi_status
> -lis3lv02d_get_resource(struct acpi_resource *resource, void *context)
> -{
> -       if (resource->type == ACPI_RESOURCE_TYPE_EXTENDED_IRQ) {
> -               struct acpi_resource_extended_irq *irq;
> -               u32 *device_irq = context;
> -
> -               irq = &resource->data.extended_irq;
> -               *device_irq = irq->interrupts[0];
> -       }
> -
> -       return AE_OK;
> -}
> -
> -static void lis3lv02d_enum_resources(struct acpi_device *device)
> -{
> -       acpi_status status;
> -
> -       status = acpi_walk_resources(device->handle, METHOD_NAME__CRS,
> -                                       lis3lv02d_get_resource, &lis3_dev.irq);
> -       if (ACPI_FAILURE(status))
> -               printk(KERN_DEBUG DRIVER_NAME ": Error getting resources\n");
> -}
> -
>  static bool hp_accel_i8042_filter(unsigned char data, unsigned char str,
>                                   struct serio *port)
>  {
> @@ -322,23 +295,19 @@ static bool hp_accel_i8042_filter(unsigned char data, unsigned char str,
>         return false;
>  }
>
> -static int lis3lv02d_add(struct acpi_device *device)
> +static int lis3lv02d_probe(struct platform_device *device)
>  {
>         int ret;
>
> -       if (!device)
> -               return -EINVAL;
> -
> -       lis3_dev.bus_priv = device;
> +       lis3_dev.bus_priv = ACPI_COMPANION(&device->dev);
>         lis3_dev.init = lis3lv02d_acpi_init;
>         lis3_dev.read = lis3lv02d_acpi_read;
>         lis3_dev.write = lis3lv02d_acpi_write;
> -       strcpy(acpi_device_name(device), DRIVER_NAME);
> -       strcpy(acpi_device_class(device), ACPI_MDPS_CLASS);
> -       device->driver_data = &lis3_dev;
>
>         /* obtain IRQ number of our device from ACPI */
> -       lis3lv02d_enum_resources(device);
> +       ret = platform_get_irq_optional(device, 0);
> +       if (ret > 0)
> +               lis3_dev.irq = ret;
>
>         /* If possible use a "standard" axes order */
>         if (lis3_dev.ac.x && lis3_dev.ac.y && lis3_dev.ac.z) {
> @@ -371,11 +340,8 @@ static int lis3lv02d_add(struct acpi_device *device)
>         return ret;
>  }
>
> -static int lis3lv02d_remove(struct acpi_device *device)
> +static int lis3lv02d_remove(struct platform_device *device)
>  {
> -       if (!device)
> -               return -EINVAL;
> -
>         i8042_remove_filter(hp_accel_i8042_filter);
>         lis3lv02d_joystick_disable(&lis3_dev);
>         lis3lv02d_poweroff(&lis3_dev);
> @@ -386,7 +352,6 @@ static int lis3lv02d_remove(struct acpi_device *device)
>         return lis3lv02d_remove_fs(&lis3_dev);
>  }
>
> -
>  #ifdef CONFIG_PM_SLEEP
>  static int lis3lv02d_suspend(struct device *dev)
>  {
> @@ -422,17 +387,16 @@ static const struct dev_pm_ops hp_accel_pm = {
>  #endif
>
>  /* For the HP MDPS aka 3D Driveguard */
> -static struct acpi_driver lis3lv02d_driver = {
> -       .name  = DRIVER_NAME,
> -       .class = ACPI_MDPS_CLASS,
> -       .ids   = lis3lv02d_device_ids,
> -       .ops = {
> -               .add     = lis3lv02d_add,
> -               .remove  = lis3lv02d_remove,
> +static struct platform_driver lis3lv02d_driver = {
> +       .probe  = lis3lv02d_probe,
> +       .remove = lis3lv02d_remove,
> +       .driver = {
> +               .name   = "hp_accel",
> +               .pm     = HP_ACCEL_PM,
> +               .acpi_match_table = lis3lv02d_device_ids,
>         },
> -       .drv.pm = HP_ACCEL_PM,
>  };
> -module_acpi_driver(lis3lv02d_driver);
> +module_platform_driver(lis3lv02d_driver);
>
>  MODULE_DESCRIPTION("Glue between LIS3LV02Dx and HP ACPI BIOS and support for disk protection LED.");
>  MODULE_AUTHOR("Yan Burman, Eric Piel, Pavel Machek");
> --
> 2.32.0
>

  reply	other threads:[~2021-08-25 10:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-23  9:32 [RFT, PATCH v2 0/2] platform/x86: hp_accel: Clean up and convert Andy Shevchenko
2021-08-23  9:32 ` [PATCH v2 1/2] platform/x86: hp_accel: Remove _INI method call Andy Shevchenko
2021-08-25 10:40   ` Kai-Heng Feng
2021-08-23  9:32 ` [PATCH v2 2/2] platform/x86: hp_accel: Convert to be a platform driver Andy Shevchenko
2021-08-25 10:41   ` Kai-Heng Feng [this message]
2021-08-25 11:11     ` Andy Shevchenko
2021-08-26 13:13 ` [RFT, PATCH v2 0/2] platform/x86: hp_accel: Clean up and convert Hans de Goede

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAAd53p6pQcura_tejtW7osiHfSnn6pCcxfm1e13==qmQA8C1bw@mail.gmail.com' \
    --to=kai.heng.feng@canonical.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=arnd@arndb.de \
    --cc=eric.piel@tremplin-utc.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=hdegoede@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgross@linux.intel.com \
    --cc=platform-driver-x86@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).