aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform
diff options
context:
space:
mode:
authorZhang Rui <rui.zhang@intel.com>2013-09-02 20:32:05 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-09-23 19:37:55 -0400
commit8a8bce1dc50c9beab55fc697230f910a9142fc3d (patch)
tree4317fc07065ea6939a877f2aa20132d9881929fd /drivers/platform
parent70122e3d3108d89d7d2dc0d8a11e7163a84d9d40 (diff)
sony-laptop: convert acpi_get_handle() to acpi_has_method()
acpi_has_method() is a new ACPI API introduced to check the existence of an ACPI control method. It can be used to replace acpi_get_handle() in the case that 1. the calling function doesn't need the ACPI handle of the control method. and 2. the calling function doesn't care the reason why the method is unavailable. Convert acpi_get_handle() to acpi_has_method() in drivers/platform/x86/sony-laptop.c in this patch. Signed-off-by: Zhang Rui <rui.zhang@intel.com> CC: Matthew Garrett <matthew.garrett@nebula.com> CC: Mattia Dongili <malattia@linux.it> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/platform')
-rw-r--r--drivers/platform/x86/sony-laptop.c28
1 files changed, 9 insertions, 19 deletions
diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
index d3fd52036fd6..3b32852d6d2d 100644
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -1509,7 +1509,6 @@ static void sony_nc_function_resume(void)
1509static int sony_nc_resume(struct device *dev) 1509static int sony_nc_resume(struct device *dev)
1510{ 1510{
1511 struct sony_nc_value *item; 1511 struct sony_nc_value *item;
1512 acpi_handle handle;
1513 1512
1514 for (item = sony_nc_values; item->name; item++) { 1513 for (item = sony_nc_values; item->name; item++) {
1515 int ret; 1514 int ret;
@@ -1524,15 +1523,13 @@ static int sony_nc_resume(struct device *dev)
1524 } 1523 }
1525 } 1524 }
1526 1525
1527 if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle, "ECON", 1526 if (acpi_has_method(sony_nc_acpi_handle, "ECON")) {
1528 &handle))) {
1529 int arg = 1; 1527 int arg = 1;
1530 if (sony_nc_int_call(sony_nc_acpi_handle, "ECON", &arg, NULL)) 1528 if (sony_nc_int_call(sony_nc_acpi_handle, "ECON", &arg, NULL))
1531 dprintk("ECON Method failed\n"); 1529 dprintk("ECON Method failed\n");
1532 } 1530 }
1533 1531
1534 if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle, "SN00", 1532 if (acpi_has_method(sony_nc_acpi_handle, "SN00"))
1535 &handle)))
1536 sony_nc_function_resume(); 1533 sony_nc_function_resume();
1537 1534
1538 return 0; 1535 return 0;
@@ -2690,7 +2687,6 @@ static void sony_nc_backlight_ng_read_limits(int handle,
2690 2687
2691static void sony_nc_backlight_setup(void) 2688static void sony_nc_backlight_setup(void)
2692{ 2689{
2693 acpi_handle unused;
2694 int max_brightness = 0; 2690 int max_brightness = 0;
2695 const struct backlight_ops *ops = NULL; 2691 const struct backlight_ops *ops = NULL;
2696 struct backlight_properties props; 2692 struct backlight_properties props;
@@ -2725,8 +2721,7 @@ static void sony_nc_backlight_setup(void)
2725 sony_nc_backlight_ng_read_limits(0x14c, &sony_bl_props); 2721 sony_nc_backlight_ng_read_limits(0x14c, &sony_bl_props);
2726 max_brightness = sony_bl_props.maxlvl - sony_bl_props.offset; 2722 max_brightness = sony_bl_props.maxlvl - sony_bl_props.offset;
2727 2723
2728 } else if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle, "GBRT", 2724 } else if (acpi_has_method(sony_nc_acpi_handle, "GBRT")) {
2729 &unused))) {
2730 ops = &sony_backlight_ops; 2725 ops = &sony_backlight_ops;
2731 max_brightness = SONY_MAX_BRIGHTNESS - 1; 2726 max_brightness = SONY_MAX_BRIGHTNESS - 1;
2732 2727
@@ -2758,7 +2753,6 @@ static int sony_nc_add(struct acpi_device *device)
2758{ 2753{
2759 acpi_status status; 2754 acpi_status status;
2760 int result = 0; 2755 int result = 0;
2761 acpi_handle handle;
2762 struct sony_nc_value *item; 2756 struct sony_nc_value *item;
2763 2757
2764 pr_info("%s v%s\n", SONY_NC_DRIVER_NAME, SONY_LAPTOP_DRIVER_VERSION); 2758 pr_info("%s v%s\n", SONY_NC_DRIVER_NAME, SONY_LAPTOP_DRIVER_VERSION);
@@ -2798,15 +2792,13 @@ static int sony_nc_add(struct acpi_device *device)
2798 goto outplatform; 2792 goto outplatform;
2799 } 2793 }
2800 2794
2801 if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle, "ECON", 2795 if (acpi_has_method(sony_nc_acpi_handle, "ECON")) {
2802 &handle))) {
2803 int arg = 1; 2796 int arg = 1;
2804 if (sony_nc_int_call(sony_nc_acpi_handle, "ECON", &arg, NULL)) 2797 if (sony_nc_int_call(sony_nc_acpi_handle, "ECON", &arg, NULL))
2805 dprintk("ECON Method failed\n"); 2798 dprintk("ECON Method failed\n");
2806 } 2799 }
2807 2800
2808 if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle, "SN00", 2801 if (acpi_has_method(sony_nc_acpi_handle, "SN00")) {
2809 &handle))) {
2810 dprintk("Doing SNC setup\n"); 2802 dprintk("Doing SNC setup\n");
2811 /* retrieve the available handles */ 2803 /* retrieve the available handles */
2812 result = sony_nc_handles_setup(sony_pf_device); 2804 result = sony_nc_handles_setup(sony_pf_device);
@@ -2829,9 +2821,8 @@ static int sony_nc_add(struct acpi_device *device)
2829 2821
2830 /* find the available acpiget as described in the DSDT */ 2822 /* find the available acpiget as described in the DSDT */
2831 for (; item->acpiget && *item->acpiget; ++item->acpiget) { 2823 for (; item->acpiget && *item->acpiget; ++item->acpiget) {
2832 if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle, 2824 if (acpi_has_method(sony_nc_acpi_handle,
2833 *item->acpiget, 2825 *item->acpiget)) {
2834 &handle))) {
2835 dprintk("Found %s getter: %s\n", 2826 dprintk("Found %s getter: %s\n",
2836 item->name, *item->acpiget); 2827 item->name, *item->acpiget);
2837 item->devattr.attr.mode |= S_IRUGO; 2828 item->devattr.attr.mode |= S_IRUGO;
@@ -2841,9 +2832,8 @@ static int sony_nc_add(struct acpi_device *device)
2841 2832
2842 /* find the available acpiset as described in the DSDT */ 2833 /* find the available acpiset as described in the DSDT */
2843 for (; item->acpiset && *item->acpiset; ++item->acpiset) { 2834 for (; item->acpiset && *item->acpiset; ++item->acpiset) {
2844 if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle, 2835 if (acpi_has_method(sony_nc_acpi_handle,
2845 *item->acpiset, 2836 *item->acpiset)) {
2846 &handle))) {
2847 dprintk("Found %s setter: %s\n", 2837 dprintk("Found %s setter: %s\n",
2848 item->name, *item->acpiset); 2838 item->name, *item->acpiset);
2849 item->devattr.attr.mode |= S_IWUSR; 2839 item->devattr.attr.mode |= S_IWUSR;