X86 platform drivers
 help / color / mirror / Atom feed
* [PATCH] Keyboard backlight control for some Vaio Fit models
@ 2015-12-15  5:12 Mattia Dongili
  2015-12-15 18:01 ` Darren Hart
  0 siblings, 1 reply; 3+ messages in thread
From: Mattia Dongili @ 2015-12-15  5:12 UTC (permalink / raw)
  To: Darren Hart; +Cc: platform-driver-x86, Mattia Dongili, Dominik Matta

SVF1521P6EW, SVF1521DCXW, SVF13N1L2ES and likely most SVF*.
do not expose separate timeout controls in auto mode.

Signed-off-by: Dominik Matta <dominik@matta.sk>
Signed-off-by: Mattia Dongili <malattia@linux.it>
---
 drivers/platform/x86/sony-laptop.c | 65 ++++++++++++++++++++++++++------------
 1 file changed, 45 insertions(+), 20 deletions(-)

diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
index f73c295..e9caa34 100644
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -1393,6 +1393,7 @@ static void sony_nc_function_setup(struct acpi_device *device,
 		case 0x0143:
 		case 0x014b:
 		case 0x014c:
+		case 0x0153:
 		case 0x0163:
 			result = sony_nc_kbd_backlight_setup(pf_device, handle);
 			if (result)
@@ -1490,6 +1491,7 @@ static void sony_nc_function_cleanup(struct platform_device *pd)
 		case 0x0143:
 		case 0x014b:
 		case 0x014c:
+		case 0x0153:
 		case 0x0163:
 			sony_nc_kbd_backlight_cleanup(pd, handle);
 			break;
@@ -1773,6 +1775,7 @@ struct kbd_backlight {
 	unsigned int base;
 	unsigned int mode;
 	unsigned int timeout;
+	unsigned int has_timeout;
 	struct device_attribute mode_attr;
 	struct device_attribute timeout_attr;
 };
@@ -1877,6 +1880,8 @@ static int sony_nc_kbd_backlight_setup(struct platform_device *pd,
 		unsigned int handle)
 {
 	int result;
+	int probe_base = 0;
+	int ctl_base = 0;
 	int ret = 0;
 
 	if (kbdbl_ctl) {
@@ -1885,11 +1890,25 @@ static int sony_nc_kbd_backlight_setup(struct platform_device *pd,
 		return -EBUSY;
 	}
 
-	/* verify the kbd backlight presence, these handles are not used for
-	 * keyboard backlight only
+	/* verify the kbd backlight presence, some of these handles are not used
+	 * for keyboard backlight only
 	 */
-	ret = sony_call_snc_handle(handle, handle == 0x0137 ? 0x0B00 : 0x0100,
-			&result);
+	switch (handle) {
+	case 0x0153:
+		probe_base = 0x0;
+		ctl_base = 0x0;
+		break;
+	case 0x0137:
+		probe_base = 0x0B00;
+		ctl_base = 0x0C00;
+		break;
+	default:
+		probe_base = 0x0100;
+		ctl_base = 0x4000;
+		break;
+	}
+
+	ret = sony_call_snc_handle(handle, probe_base, &result);
 	if (ret)
 		return ret;
 
@@ -1906,10 +1925,9 @@ static int sony_nc_kbd_backlight_setup(struct platform_device *pd,
 	kbdbl_ctl->mode = kbd_backlight;
 	kbdbl_ctl->timeout = kbd_backlight_timeout;
 	kbdbl_ctl->handle = handle;
-	if (handle == 0x0137)
-		kbdbl_ctl->base = 0x0C00;
-	else
-		kbdbl_ctl->base = 0x4000;
+	kbdbl_ctl->base = ctl_base;
+	/* Some models do not allow timeout control */
+	kbdbl_ctl->has_timeout = handle != 0x0153;
 
 	sysfs_attr_init(&kbdbl_ctl->mode_attr.attr);
 	kbdbl_ctl->mode_attr.attr.name = "kbd_backlight";
@@ -1917,22 +1935,28 @@ static int sony_nc_kbd_backlight_setup(struct platform_device *pd,
 	kbdbl_ctl->mode_attr.show = sony_nc_kbd_backlight_mode_show;
 	kbdbl_ctl->mode_attr.store = sony_nc_kbd_backlight_mode_store;
 
-	sysfs_attr_init(&kbdbl_ctl->timeout_attr.attr);
-	kbdbl_ctl->timeout_attr.attr.name = "kbd_backlight_timeout";
-	kbdbl_ctl->timeout_attr.attr.mode = S_IRUGO | S_IWUSR;
-	kbdbl_ctl->timeout_attr.show = sony_nc_kbd_backlight_timeout_show;
-	kbdbl_ctl->timeout_attr.store = sony_nc_kbd_backlight_timeout_store;
-
 	ret = device_create_file(&pd->dev, &kbdbl_ctl->mode_attr);
 	if (ret)
 		goto outkzalloc;
 
-	ret = device_create_file(&pd->dev, &kbdbl_ctl->timeout_attr);
-	if (ret)
-		goto outmode;
-
 	__sony_nc_kbd_backlight_mode_set(kbdbl_ctl->mode);
-	__sony_nc_kbd_backlight_timeout_set(kbdbl_ctl->timeout);
+
+	if (kbdbl_ctl->has_timeout) {
+		sysfs_attr_init(&kbdbl_ctl->timeout_attr.attr);
+		kbdbl_ctl->timeout_attr.attr.name = "kbd_backlight_timeout";
+		kbdbl_ctl->timeout_attr.attr.mode = S_IRUGO | S_IWUSR;
+		kbdbl_ctl->timeout_attr.show =
+			sony_nc_kbd_backlight_timeout_show;
+		kbdbl_ctl->timeout_attr.store =
+			sony_nc_kbd_backlight_timeout_store;
+
+		ret = device_create_file(&pd->dev, &kbdbl_ctl->timeout_attr);
+		if (ret)
+			goto outmode;
+
+		__sony_nc_kbd_backlight_timeout_set(kbdbl_ctl->timeout);
+	}
+
 
 	return 0;
 
@@ -1949,7 +1973,8 @@ static void sony_nc_kbd_backlight_cleanup(struct platform_device *pd,
 {
 	if (kbdbl_ctl && handle == kbdbl_ctl->handle) {
 		device_remove_file(&pd->dev, &kbdbl_ctl->mode_attr);
-		device_remove_file(&pd->dev, &kbdbl_ctl->timeout_attr);
+		if (kbdbl_ctl->has_timeout)
+			device_remove_file(&pd->dev, &kbdbl_ctl->timeout_attr);
 		kfree(kbdbl_ctl);
 		kbdbl_ctl = NULL;
 	}
-- 
2.6.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Keyboard backlight control for some Vaio Fit models
  2015-12-15  5:12 [PATCH] Keyboard backlight control for some Vaio Fit models Mattia Dongili
@ 2015-12-15 18:01 ` Darren Hart
  2015-12-16 15:04   ` Mattia Dongili
  0 siblings, 1 reply; 3+ messages in thread
From: Darren Hart @ 2015-12-15 18:01 UTC (permalink / raw)
  To: Mattia Dongili; +Cc: platform-driver-x86, Dominik Matta

On Mon, Dec 14, 2015 at 09:12:32PM -0800, Mattia Dongili wrote:
> SVF1521P6EW, SVF1521DCXW, SVF13N1L2ES and likely most SVF*.
> do not expose separate timeout controls in auto mode.
> 
> Signed-off-by: Dominik Matta <dominik@matta.sk>
> Signed-off-by: Mattia Dongili <malattia@linux.it>
> ---
>  drivers/platform/x86/sony-laptop.c | 65 ++++++++++++++++++++++++++------------
>  1 file changed, 45 insertions(+), 20 deletions(-)
> 

Thanks Mattia,

The changes look fine.

At some point we should address some of the style inconsistencies with this
driver, but to nitpic on them for this patch wouldn't be productive. I've merged
this patch - please consider the following for future work with the goal toward
making the kernel code as consistent as possible to aid in legibility and
maintainability.

> @@ -1877,6 +1880,8 @@ static int sony_nc_kbd_backlight_setup(struct platform_device *pd,
>  		unsigned int handle)
>  {
>  	int result;
> +	int probe_base = 0;
> +	int ctl_base = 0;
>  	int ret = 0;

This isn't in CodingStyle, but is enforced by several maintainers and something
I'm trying to standardize on within platform/drivers/x86.

Please declare variables in decreasing line length in the absence of
dependencies. Also called "Reverse Christmas Tree Order".

So the above would become:

int probe_base = 0;
int ctl_base = 0;
int ret = 0;
int result;

Some maintainers prefer merging like types, especially with similar purpose. I'm
ambivalent on this.

>  
>  	if (kbdbl_ctl) {
> @@ -1885,11 +1890,25 @@ static int sony_nc_kbd_backlight_setup(struct platform_device *pd,
>  		return -EBUSY;
>  	}
>  
> -	/* verify the kbd backlight presence, these handles are not used for
> -	 * keyboard backlight only
> +	/* verify the kbd backlight presence, some of these handles are not used
> +	 * for keyboard backlight only
>  	 */

Comment blocks should start with a blank line:

/*
 * This is the first line.
 * This is the second.
 */

And should use standard sentence capitalization.

Thanks,

-- 
Darren Hart
Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Keyboard backlight control for some Vaio Fit models
  2015-12-15 18:01 ` Darren Hart
@ 2015-12-16 15:04   ` Mattia Dongili
  0 siblings, 0 replies; 3+ messages in thread
From: Mattia Dongili @ 2015-12-16 15:04 UTC (permalink / raw)
  To: Darren Hart; +Cc: platform-driver-x86, Dominik Matta

On Tue, Dec 15, 2015 at 10:01:28AM -0800, Darren Hart wrote:
> On Mon, Dec 14, 2015 at 09:12:32PM -0800, Mattia Dongili wrote:
> > SVF1521P6EW, SVF1521DCXW, SVF13N1L2ES and likely most SVF*.
> > do not expose separate timeout controls in auto mode.
> > 
> > Signed-off-by: Dominik Matta <dominik@matta.sk>
> > Signed-off-by: Mattia Dongili <malattia@linux.it>
> > ---
> >  drivers/platform/x86/sony-laptop.c | 65 ++++++++++++++++++++++++++------------
> >  1 file changed, 45 insertions(+), 20 deletions(-)
> > 
> 
> Thanks Mattia,
> 
> The changes look fine.
> 
> At some point we should address some of the style inconsistencies with this
> driver, but to nitpic on them for this patch wouldn't be productive. I've merged
> this patch - please consider the following for future work with the goal toward
> making the kernel code as consistent as possible to aid in legibility and
> maintainability.

Thanks Darren.

This driver needs many things, but yes, I'll keep in mind
these other guidelines for any future change.

Best,
-- 
mattia
:wq!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-12-16 15:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-15  5:12 [PATCH] Keyboard backlight control for some Vaio Fit models Mattia Dongili
2015-12-15 18:01 ` Darren Hart
2015-12-16 15:04   ` Mattia Dongili

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox