提交 bf04a772 编写于 作者: B Bjorn Helgaas 提交者: Len Brown

ACPI: button: cache hid/name/class pointers

This patch adds temporaries to cache the acpi_device_hid(),
acpi_device_name(), and acpi_device_class() pointers so we
don't have to clutter the code with so many uses of those
interfaces.
Signed-off-by: NBjorn Helgaas <bjorn.helgaas@hp.com>
Signed-off-by: NLen Brown <len.brown@intel.com>
上级 1bce8113
...@@ -300,6 +300,7 @@ static int acpi_button_add(struct acpi_device *device) ...@@ -300,6 +300,7 @@ static int acpi_button_add(struct acpi_device *device)
{ {
struct acpi_button *button; struct acpi_button *button;
struct input_dev *input; struct input_dev *input;
char *hid, *name, *class;
int error; int error;
button = kzalloc(sizeof(struct acpi_button), GFP_KERNEL); button = kzalloc(sizeof(struct acpi_button), GFP_KERNEL);
...@@ -315,40 +316,41 @@ static int acpi_button_add(struct acpi_device *device) ...@@ -315,40 +316,41 @@ static int acpi_button_add(struct acpi_device *device)
goto err_free_button; goto err_free_button;
} }
hid = acpi_device_hid(device);
name = acpi_device_name(device);
class = acpi_device_class(device);
/* /*
* Determine the button type (via hid), as fixed-feature buttons * Determine the button type (via hid), as fixed-feature buttons
* need to be handled a bit differently than generic-space. * need to be handled a bit differently than generic-space.
*/ */
if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_POWER)) { if (!strcmp(hid, ACPI_BUTTON_HID_POWER)) {
button->type = ACPI_BUTTON_TYPE_POWER; button->type = ACPI_BUTTON_TYPE_POWER;
strcpy(acpi_device_name(device), ACPI_BUTTON_DEVICE_NAME_POWER); strcpy(name, ACPI_BUTTON_DEVICE_NAME_POWER);
sprintf(acpi_device_class(device), "%s/%s", sprintf(class, "%s/%s",
ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_POWER); ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_POWER);
} else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_POWERF)) { } else if (!strcmp(hid, ACPI_BUTTON_HID_POWERF)) {
button->type = ACPI_BUTTON_TYPE_POWERF; button->type = ACPI_BUTTON_TYPE_POWERF;
strcpy(acpi_device_name(device), strcpy(name, ACPI_BUTTON_DEVICE_NAME_POWERF);
ACPI_BUTTON_DEVICE_NAME_POWERF); sprintf(class, "%s/%s",
sprintf(acpi_device_class(device), "%s/%s",
ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_POWER); ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_POWER);
} else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_SLEEP)) { } else if (!strcmp(hid, ACPI_BUTTON_HID_SLEEP)) {
button->type = ACPI_BUTTON_TYPE_SLEEP; button->type = ACPI_BUTTON_TYPE_SLEEP;
strcpy(acpi_device_name(device), ACPI_BUTTON_DEVICE_NAME_SLEEP); strcpy(name, ACPI_BUTTON_DEVICE_NAME_SLEEP);
sprintf(acpi_device_class(device), "%s/%s", sprintf(class, "%s/%s",
ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_SLEEP); ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_SLEEP);
} else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_SLEEPF)) { } else if (!strcmp(hid, ACPI_BUTTON_HID_SLEEPF)) {
button->type = ACPI_BUTTON_TYPE_SLEEPF; button->type = ACPI_BUTTON_TYPE_SLEEPF;
strcpy(acpi_device_name(device), strcpy(name, ACPI_BUTTON_DEVICE_NAME_SLEEPF);
ACPI_BUTTON_DEVICE_NAME_SLEEPF); sprintf(class, "%s/%s",
sprintf(acpi_device_class(device), "%s/%s",
ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_SLEEP); ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_SLEEP);
} else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_LID)) { } else if (!strcmp(hid, ACPI_BUTTON_HID_LID)) {
button->type = ACPI_BUTTON_TYPE_LID; button->type = ACPI_BUTTON_TYPE_LID;
strcpy(acpi_device_name(device), ACPI_BUTTON_DEVICE_NAME_LID); strcpy(name, ACPI_BUTTON_DEVICE_NAME_LID);
sprintf(acpi_device_class(device), "%s/%s", sprintf(class, "%s/%s",
ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_LID); ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_LID);
} else { } else {
printk(KERN_ERR PREFIX "Unsupported hid [%s]\n", printk(KERN_ERR PREFIX "Unsupported hid [%s]\n", hid);
acpi_device_hid(device));
error = -ENODEV; error = -ENODEV;
goto err_free_input; goto err_free_input;
} }
...@@ -357,10 +359,9 @@ static int acpi_button_add(struct acpi_device *device) ...@@ -357,10 +359,9 @@ static int acpi_button_add(struct acpi_device *device)
if (error) if (error)
goto err_free_input; goto err_free_input;
snprintf(button->phys, sizeof(button->phys), snprintf(button->phys, sizeof(button->phys), "%s/button/input0", hid);
"%s/button/input0", acpi_device_hid(device));
input->name = acpi_device_name(device); input->name = name;
input->phys = button->phys; input->phys = button->phys;
input->id.bustype = BUS_HOST; input->id.bustype = BUS_HOST;
input->id.product = button->type; input->id.product = button->type;
...@@ -401,8 +402,7 @@ static int acpi_button_add(struct acpi_device *device) ...@@ -401,8 +402,7 @@ static int acpi_button_add(struct acpi_device *device)
device->wakeup.state.enabled = 1; device->wakeup.state.enabled = 1;
} }
printk(KERN_INFO PREFIX "%s [%s]\n", printk(KERN_INFO PREFIX "%s [%s]\n", name, acpi_device_bid(device));
acpi_device_name(device), acpi_device_bid(device));
return 0; return 0;
err_remove_fs: err_remove_fs:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册