aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform/x86/sony-laptop.c
diff options
context:
space:
mode:
authorMattia Dongili <malattia@linux.it>2011-04-05 10:38:35 -0400
committerMatthew Garrett <mjg@redhat.com>2011-04-12 11:27:42 -0400
commit855b8bc9953fdf40095fdec9d91d49736ca7b17c (patch)
treeb36486f2ead7363495a55a48cc34242b0369f24b /drivers/platform/x86/sony-laptop.c
parent8713b04ab8da256493410bd4f25170d2e0836534 (diff)
sony-laptop: only show the handles sysfs file in debug mode
It makes no sense to expose this type of information to userspace unless the driver was explicitly loaded with the debug option. Signed-off-by: Mattia Dongili <malattia@linux.it> Signed-off-by: Matthew Garrett <mjg@redhat.com>
Diffstat (limited to 'drivers/platform/x86/sony-laptop.c')
-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 }