diff --git a/drivers/platform/chrome/chromeos_tbmc.c b/drivers/platform/chrome/chromeos_tbmc.c index 9c988e697d09..5133806b2d95 100644 --- a/drivers/platform/chrome/chromeos_tbmc.c +++ b/drivers/platform/chrome/chromeos_tbmc.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #define DRV_NAME "chromeos_tbmc" @@ -40,22 +41,20 @@ static int chromeos_tbmc_query_switch(struct acpi_device *adev, static __maybe_unused int chromeos_tbmc_resume(struct device *dev) { - struct acpi_device *adev = to_acpi_device(dev); - - return chromeos_tbmc_query_switch(adev, adev->driver_data); + return chromeos_tbmc_query_switch(ACPI_COMPANION(dev), dev_get_drvdata(dev)); } static void chromeos_tbmc_notify(acpi_handle handle, u32 event, void *data) { - struct acpi_device *adev = data; + struct device *dev = data; - acpi_pm_wakeup_event(&adev->dev); + acpi_pm_wakeup_event(dev); switch (event) { case 0x80: - chromeos_tbmc_query_switch(adev, adev->driver_data); + chromeos_tbmc_query_switch(ACPI_COMPANION(dev), dev_get_drvdata(dev)); break; default: - dev_err(&adev->dev, "Unexpected event: 0x%08X\n", event); + dev_err(dev, "Unexpected event: 0x%08X\n", event); } } @@ -66,10 +65,11 @@ static int chromeos_tbmc_open(struct input_dev *idev) return chromeos_tbmc_query_switch(adev, idev); } -static int chromeos_tbmc_add(struct acpi_device *adev) +static int chromeos_tbmc_probe(struct platform_device *pdev) { struct input_dev *idev; - struct device *dev = &adev->dev; + struct device *dev = &pdev->dev; + struct acpi_device *adev = ACPI_COMPANION(dev); int ret; idev = devm_input_allocate_device(dev); @@ -85,7 +85,7 @@ static int chromeos_tbmc_add(struct acpi_device *adev) idev->open = chromeos_tbmc_open; input_set_drvdata(idev, adev); - adev->driver_data = idev; + platform_set_drvdata(pdev, idev); input_set_capability(idev, EV_SW, SW_TABLET_MODE); ret = input_register_device(idev); @@ -96,7 +96,7 @@ static int chromeos_tbmc_add(struct acpi_device *adev) device_init_wakeup(dev, true); ret = acpi_dev_install_notify_handler(adev, ACPI_DEVICE_NOTIFY, - chromeos_tbmc_notify, adev); + chromeos_tbmc_notify, dev); if (ret) { dev_err(dev, "cannot install ACPI notify handler\n"); device_init_wakeup(dev, false); @@ -106,11 +106,11 @@ static int chromeos_tbmc_add(struct acpi_device *adev) return 0; } -static void chromeos_tbmc_remove(struct acpi_device *adev) +static void chromeos_tbmc_remove(struct platform_device *pdev) { - acpi_dev_remove_notify_handler(adev, ACPI_DEVICE_NOTIFY, - chromeos_tbmc_notify); - device_init_wakeup(&adev->dev, false); + acpi_dev_remove_notify_handler(ACPI_COMPANION(&pdev->dev), + ACPI_DEVICE_NOTIFY, chromeos_tbmc_notify); + device_init_wakeup(&pdev->dev, false); } static const struct acpi_device_id chromeos_tbmc_acpi_device_ids[] = { @@ -122,18 +122,17 @@ MODULE_DEVICE_TABLE(acpi, chromeos_tbmc_acpi_device_ids); static SIMPLE_DEV_PM_OPS(chromeos_tbmc_pm_ops, NULL, chromeos_tbmc_resume); -static struct acpi_driver chromeos_tbmc_driver = { - .name = DRV_NAME, - .class = DRV_NAME, - .ids = chromeos_tbmc_acpi_device_ids, - .ops = { - .add = chromeos_tbmc_add, - .remove = chromeos_tbmc_remove, +static struct platform_driver chromeos_tbmc_driver = { + .probe = chromeos_tbmc_probe, + .remove = chromeos_tbmc_remove, + .driver = { + .name = DRV_NAME, + .acpi_match_table = chromeos_tbmc_acpi_device_ids, + .pm = &chromeos_tbmc_pm_ops, }, - .drv.pm = &chromeos_tbmc_pm_ops, }; -module_acpi_driver(chromeos_tbmc_driver); +module_platform_driver(chromeos_tbmc_driver); MODULE_LICENSE("GPL v2"); MODULE_DESCRIPTION("ChromeOS ACPI tablet switch driver");