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

Commit 05e2d827 authored by Mattia Dongili's avatar Mattia Dongili Committed by Len Brown
Browse files

sony_acpi: Allow easier debugging for the unknown SNC methods.



Allow the existence of a setter method without a getter and viceversa,
additionaly set /proc file permissions reflecting it.
Fix also the error exit path.

Signed-off-by: default avatarMattia Dongili <malattia@linux.it>
Signed-off-by: default avatarLen Brown <len.brown@intel.com>
parent c561162f
Loading
Loading
Loading
Loading
+21 −9
Original line number Original line Diff line number Diff line
@@ -296,6 +296,7 @@ static int sony_acpi_add(struct acpi_device *device)
	acpi_status status;
	acpi_status status;
	int result;
	int result;
	acpi_handle handle;
	acpi_handle handle;
	mode_t proc_file_mode;
	struct sony_acpi_value *item;
	struct sony_acpi_value *item;


	sony_acpi_acpi_device = device;
	sony_acpi_acpi_device = device;
@@ -334,20 +335,31 @@ static int sony_acpi_add(struct acpi_device *device)
	}
	}


	for (item = sony_acpi_values; item->name; ++item) {
	for (item = sony_acpi_values; item->name; ++item) {
		proc_file_mode = 0;

		if (!debug && item->debug)
		if (!debug && item->debug)
			continue;
			continue;


		if (item->acpiget &&
		if (item->acpiget &&
		    ACPI_FAILURE(acpi_get_handle(sony_acpi_handle,
		    ACPI_SUCCESS(acpi_get_handle(sony_acpi_handle,
		    		 item->acpiget, &handle)))
		    		 item->acpiget, &handle)))
		    	continue;
			proc_file_mode = S_IRUSR;
		else
			printk(LOG_PFX "unable to get ACPI handle for %s (get)\n",
					item->name);


		if (item->acpiset &&
		if (item->acpiset &&
		    ACPI_FAILURE(acpi_get_handle(sony_acpi_handle,
		    ACPI_SUCCESS(acpi_get_handle(sony_acpi_handle,
		    		 item->acpiset, &handle)))
		    		 item->acpiset, &handle)))
			proc_file_mode |= S_IWUSR;
		else
			printk(LOG_PFX "unable to get ACPI handle for %s (set)\n",
					item->name);

		if (proc_file_mode == 0)
			continue;
			continue;


		item->proc = create_proc_entry(item->name, 0666,
		item->proc = create_proc_entry(item->name, proc_file_mode,
					       acpi_device_dir(device));
					       acpi_device_dir(device));
		if (!item->proc) {
		if (!item->proc) {
			printk(LOG_PFX "unable to create proc entry\n");
			printk(LOG_PFX "unable to create proc entry\n");
@@ -366,15 +378,15 @@ static int sony_acpi_add(struct acpi_device *device)
	return 0;
	return 0;


outproc:
outproc:
	for (item = sony_acpi_values; item->name; ++item)
		if (item->proc)
			remove_proc_entry(item->name, acpi_device_dir(device));
outnotify:
	status = acpi_remove_notify_handler(sony_acpi_handle,
	status = acpi_remove_notify_handler(sony_acpi_handle,
					    ACPI_DEVICE_NOTIFY,
					    ACPI_DEVICE_NOTIFY,
					    sony_acpi_notify);
					    sony_acpi_notify);
	if (ACPI_FAILURE(status))
	if (ACPI_FAILURE(status))
		printk(LOG_PFX "unable to remove notify handler\n");
		printk(LOG_PFX "unable to remove notify handler\n");
outnotify:
	for (item = sony_acpi_values; item->name; ++item)
		if (item->proc)
			remove_proc_entry(item->name, acpi_device_dir(device));
outwalk:
outwalk:
	return result;
	return result;
}
}