Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 855b8bc9 authored by Mattia Dongili's avatar Mattia Dongili Committed by Matthew Garrett
Browse files

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: default avatarMattia Dongili <malattia@linux.it>
Signed-off-by: default avatarMatthew Garrett <mjg@redhat.com>
parent 8713b04a
Loading
Loading
Loading
Loading
+14 −11
Original line number Original line Diff line number Diff line
@@ -771,11 +771,6 @@ static int sony_nc_handles_setup(struct platform_device *pd)
	if (!handles)
	if (!handles)
		return -ENOMEM;
		return -ENOMEM;


	sysfs_attr_init(&handles->devattr.attr);
	handles->devattr.attr.name = "handles";
	handles->devattr.attr.mode = S_IRUGO;
	handles->devattr.show = sony_nc_handles_show;

	for (i = 0; i < ARRAY_SIZE(handles->cap); i++) {
	for (i = 0; i < ARRAY_SIZE(handles->cap); i++) {
		if (!acpi_callsetfunc(sony_nc_acpi_handle,
		if (!acpi_callsetfunc(sony_nc_acpi_handle,
					"SN00", i + 0x20, &result)) {
					"SN00", i + 0x20, &result)) {
@@ -785,12 +780,19 @@ static int sony_nc_handles_setup(struct platform_device *pd)
		}
		}
	}
	}


	if (debug) {
		sysfs_attr_init(&handles->devattr.attr);
		handles->devattr.attr.name = "handles";
		handles->devattr.attr.mode = S_IRUGO;
		handles->devattr.show = sony_nc_handles_show;

		/* allow reading capabilities via sysfs */
		/* allow reading capabilities via sysfs */
		if (device_create_file(&pd->dev, &handles->devattr)) {
		if (device_create_file(&pd->dev, &handles->devattr)) {
			kfree(handles);
			kfree(handles);
			handles = NULL;
			handles = NULL;
			return -1;
			return -1;
		}
		}
	}


	return 0;
	return 0;
}
}
@@ -798,6 +800,7 @@ static int sony_nc_handles_setup(struct platform_device *pd)
static int sony_nc_handles_cleanup(struct platform_device *pd)
static int sony_nc_handles_cleanup(struct platform_device *pd)
{
{
	if (handles) {
	if (handles) {
		if (debug)
			device_remove_file(&pd->dev, &handles->devattr);
			device_remove_file(&pd->dev, &handles->devattr);
		kfree(handles);
		kfree(handles);
		handles = NULL;
		handles = NULL;