Message ID | 20231006153152.3502912-1-andriy.shevchenko@linux.intel.com (mailing list archive) |
---|---|
State | Superseded, archived |
Headers | show |
Series | [v2,1/1] platform/x86: xo15-ebook: Replace open coded acpi_match_device() | expand |
Hi, On 10/6/23 17:31, Andy Shevchenko wrote: > Replace open coded acpi_match_device() in ebook_switch_add(). > > Note, while it is a bit longer it is more robust in case > more IDs will be added. > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Thanks, patch looks good to me: Reviewed-by: Hans de Goede <hdegoede@redhat.com> Regards, Hans p.s. This driver too really should be converted to not be an acpi_driver instead it should bind to the instantiated platform_device for the adev, but that would require someone with actual hw access to test the conversion ... > --- > v2: fixed compilation error > drivers/platform/x86/xo15-ebook.c | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) > > diff --git a/drivers/platform/x86/xo15-ebook.c b/drivers/platform/x86/xo15-ebook.c > index 391f7ea4431e..2ae8a58adcd0 100644 > --- a/drivers/platform/x86/xo15-ebook.c > +++ b/drivers/platform/x86/xo15-ebook.c > @@ -81,9 +81,9 @@ static SIMPLE_DEV_PM_OPS(ebook_switch_pm, NULL, ebook_switch_resume); > > static int ebook_switch_add(struct acpi_device *device) > { > + const struct acpi_device_id *id; > struct ebook_switch *button; > struct input_dev *input; > - const char *hid = acpi_device_hid(device); > char *name, *class; > int error; > > @@ -102,8 +102,9 @@ static int ebook_switch_add(struct acpi_device *device) > name = acpi_device_name(device); > class = acpi_device_class(device); > > - if (strcmp(hid, XO15_EBOOK_HID)) { > - pr_err("Unsupported hid [%s]\n", hid); > + id = acpi_match_device(ebook_device_ids, device); > + if (!id) { > + dev_err(&device->dev, "Unsupported hid\n"); > error = -ENODEV; > goto err_free_input; > } > @@ -111,7 +112,7 @@ static int ebook_switch_add(struct acpi_device *device) > strcpy(name, XO15_EBOOK_DEVICE_NAME); > sprintf(class, "%s/%s", XO15_EBOOK_CLASS, XO15_EBOOK_SUBCLASS); > > - snprintf(button->phys, sizeof(button->phys), "%s/button/input0", hid); > + snprintf(button->phys, sizeof(button->phys), "%s/button/input0", id->id); > > input->name = name; > input->phys = button->phys;
Hi Andy, kernel test robot noticed the following build errors: [auto build test ERROR on linus/master] [also build test ERROR on v6.6-rc4 next-20231006] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/platform-x86-xo15-ebook-Replace-open-coded-acpi_match_device/20231006-233327 base: linus/master patch link: https://lore.kernel.org/r/20231006153152.3502912-1-andriy.shevchenko%40linux.intel.com patch subject: [PATCH v2 1/1] platform/x86: xo15-ebook: Replace open coded acpi_match_device() config: i386-buildonly-randconfig-003-20231007 (https://download.01.org/0day-ci/archive/20231007/202310070210.fA8JzLkG-lkp@intel.com/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231007/202310070210.fA8JzLkG-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202310070210.fA8JzLkG-lkp@intel.com/ All errors (new ones prefixed by >>): drivers/platform/x86/xo15-ebook.c: In function 'ebook_switch_add': >> drivers/platform/x86/xo15-ebook.c:105:50: error: passing argument 2 of 'acpi_match_device' from incompatible pointer type [-Werror=incompatible-pointer-types] 105 | id = acpi_match_device(ebook_device_ids, device); | ^~~~~~ | | | struct acpi_device * In file included from drivers/platform/x86/xo15-ebook.c:17: include/linux/acpi.h:712:69: note: expected 'const struct device *' but argument is of type 'struct acpi_device *' 712 | const struct device *dev); | ~~~~~~~~~~~~~~~~~~~~~^~~ cc1: some warnings being treated as errors vim +/acpi_match_device +105 drivers/platform/x86/xo15-ebook.c 81 82 static int ebook_switch_add(struct acpi_device *device) 83 { 84 const struct acpi_device_id *id; 85 struct ebook_switch *button; 86 struct input_dev *input; 87 char *name, *class; 88 int error; 89 90 button = kzalloc(sizeof(struct ebook_switch), GFP_KERNEL); 91 if (!button) 92 return -ENOMEM; 93 94 device->driver_data = button; 95 96 button->input = input = input_allocate_device(); 97 if (!input) { 98 error = -ENOMEM; 99 goto err_free_button; 100 } 101 102 name = acpi_device_name(device); 103 class = acpi_device_class(device); 104 > 105 id = acpi_match_device(ebook_device_ids, device); 106 if (!id) { 107 dev_err(&device->dev, "Unsupported hid\n"); 108 error = -ENODEV; 109 goto err_free_input; 110 } 111 112 strcpy(name, XO15_EBOOK_DEVICE_NAME); 113 sprintf(class, "%s/%s", XO15_EBOOK_CLASS, XO15_EBOOK_SUBCLASS); 114 115 snprintf(button->phys, sizeof(button->phys), "%s/button/input0", id->id); 116 117 input->name = name; 118 input->phys = button->phys; 119 input->id.bustype = BUS_HOST; 120 input->dev.parent = &device->dev; 121 122 input->evbit[0] = BIT_MASK(EV_SW); 123 set_bit(SW_TABLET_MODE, input->swbit); 124 125 error = input_register_device(input); 126 if (error) 127 goto err_free_input; 128 129 ebook_send_state(device); 130 131 if (device->wakeup.flags.valid) { 132 /* Button's GPE is run-wake GPE */ 133 acpi_enable_gpe(device->wakeup.gpe_device, 134 device->wakeup.gpe_number); 135 device_set_wakeup_enable(&device->dev, true); 136 } 137 138 return 0; 139 140 err_free_input: 141 input_free_device(input); 142 err_free_button: 143 kfree(button); 144 return error; 145 } 146
On Fri, Oct 06, 2023 at 05:34:19PM +0200, Hans de Goede wrote: > On 10/6/23 17:31, Andy Shevchenko wrote: ... ` > Thanks, patch looks good to me: > Reviewed-by: Hans de Goede <hdegoede@redhat.com> Same issue as with other patch... ... > > + id = acpi_match_device(ebook_device_ids, device); Should be acpi_match_acpi_device(). > > + if (!id) { > > + dev_err(&device->dev, "Unsupported hid\n"); > > error = -ENODEV; > > goto err_free_input; > > }
diff --git a/drivers/platform/x86/xo15-ebook.c b/drivers/platform/x86/xo15-ebook.c index 391f7ea4431e..2ae8a58adcd0 100644 --- a/drivers/platform/x86/xo15-ebook.c +++ b/drivers/platform/x86/xo15-ebook.c @@ -81,9 +81,9 @@ static SIMPLE_DEV_PM_OPS(ebook_switch_pm, NULL, ebook_switch_resume); static int ebook_switch_add(struct acpi_device *device) { + const struct acpi_device_id *id; struct ebook_switch *button; struct input_dev *input; - const char *hid = acpi_device_hid(device); char *name, *class; int error; @@ -102,8 +102,9 @@ static int ebook_switch_add(struct acpi_device *device) name = acpi_device_name(device); class = acpi_device_class(device); - if (strcmp(hid, XO15_EBOOK_HID)) { - pr_err("Unsupported hid [%s]\n", hid); + id = acpi_match_device(ebook_device_ids, device); + if (!id) { + dev_err(&device->dev, "Unsupported hid\n"); error = -ENODEV; goto err_free_input; } @@ -111,7 +112,7 @@ static int ebook_switch_add(struct acpi_device *device) strcpy(name, XO15_EBOOK_DEVICE_NAME); sprintf(class, "%s/%s", XO15_EBOOK_CLASS, XO15_EBOOK_SUBCLASS); - snprintf(button->phys, sizeof(button->phys), "%s/button/input0", hid); + snprintf(button->phys, sizeof(button->phys), "%s/button/input0", id->id); input->name = name; input->phys = button->phys;
Replace open coded acpi_match_device() in ebook_switch_add(). Note, while it is a bit longer it is more robust in case more IDs will be added. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> --- v2: fixed compilation error drivers/platform/x86/xo15-ebook.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)