aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/platform/x86/sony-laptop.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
index 33c3b8c066ee..33d9555470c3 100644
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -771,11 +771,6 @@ static int sony_nc_handles_setup(struct platform_device *pd)
771 if (!handles) 771 if (!handles)
772 return -ENOMEM; 772 return -ENOMEM;
773 773
774 sysfs_attr_init(&handles->devattr.attr);
775 handles->devattr.attr.name = "handles";
776 handles->devattr.attr.mode = S_IRUGO;
777 handles->devattr.show = sony_nc_handles_show;
778
779 for (i = 0; i < ARRAY_SIZE(handles->cap); i++) { 774 for (i = 0; i < ARRAY_SIZE(handles->cap); i++) {
780 if (!acpi_callsetfunc(sony_nc_acpi_handle, 775 if (!acpi_callsetfunc(sony_nc_acpi_handle,
781 "SN00", i + 0x20, &result)) { 776 "SN00", i + 0x20, &result)) {
@@ -785,11 +780,18 @@ static int sony_nc_handles_setup(struct platform_device *pd)
785 } 780 }
786 } 781 }
787 782
788 /* allow reading capabilities via sysfs */ 783 if (debug) {
789 if (device_create_file(&pd->dev, &handles->devattr)) { 784 sysfs_attr_init(&handles->devattr.attr);
790 kfree(handles); 785 handles->devattr.attr.name = "handles";
791 handles = NULL; 786 handles->devattr.attr.mode = S_IRUGO;
792 return -1; 787 handles->devattr.show = sony_nc_handles_show;
788
789 /* allow reading capabilities via sysfs */
790 if (device_create_file(&pd->dev, &handles->devattr)) {
791 kfree(handles);
792 handles = NULL;
793 return -1;
794 }
793 } 795 }
794 796
795 return 0; 797 return 0;
@@ -798,7 +800,8 @@ static int sony_nc_handles_setup(struct platform_device *pd)
798static int sony_nc_handles_cleanup(struct platform_device *pd) 800static int sony_nc_handles_cleanup(struct platform_device *pd)
799{ 801{
800 if (handles) { 802 if (handles) {
801 device_remove_file(&pd->dev, &handles->devattr); 803 if (debug)
804 device_remove_file(&pd->dev, &handles->devattr);
802 kfree(handles); 805 kfree(handles);
803 handles = NULL; 806 handles = NULL;
804 } 807 }