Skip to content

Commit 3978959

Browse files
andy-shevij-intel
authored andcommitted
platform/x86: xo15-ebook: Replace open coded acpi_match_acpi_device()
Replace open coded acpi_match_acpi_device() in ebook_switch_add(). Note, while it is a bit longer it is more robust in case more IDs will be added. Reviewed-by: Hans de Goede <[email protected]> Signed-off-by: Andy Shevchenko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Ilpo Järvinen <[email protected]> Signed-off-by: Ilpo Järvinen <[email protected]>
1 parent 48173b0 commit 3978959

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

drivers/platform/x86/xo15-ebook.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ static SIMPLE_DEV_PM_OPS(ebook_switch_pm, NULL, ebook_switch_resume);
8181

8282
static int ebook_switch_add(struct acpi_device *device)
8383
{
84+
const struct acpi_device_id *id;
8485
struct ebook_switch *button;
8586
struct input_dev *input;
86-
const char *hid = acpi_device_hid(device);
8787
char *name, *class;
8888
int error;
8989

@@ -102,16 +102,17 @@ static int ebook_switch_add(struct acpi_device *device)
102102
name = acpi_device_name(device);
103103
class = acpi_device_class(device);
104104

105-
if (strcmp(hid, XO15_EBOOK_HID)) {
106-
pr_err("Unsupported hid [%s]\n", hid);
105+
id = acpi_match_acpi_device(ebook_device_ids, device);
106+
if (!id) {
107+
dev_err(&device->dev, "Unsupported hid\n");
107108
error = -ENODEV;
108109
goto err_free_input;
109110
}
110111

111112
strcpy(name, XO15_EBOOK_DEVICE_NAME);
112113
sprintf(class, "%s/%s", XO15_EBOOK_CLASS, XO15_EBOOK_SUBCLASS);
113114

114-
snprintf(button->phys, sizeof(button->phys), "%s/button/input0", hid);
115+
snprintf(button->phys, sizeof(button->phys), "%s/button/input0", id->id);
115116

116117
input->name = name;
117118
input->phys = button->phys;

0 commit comments

Comments
 (0)