diff mbox

[v2] sony-laptop: add new thermal control handle

Message ID 20160623204322.Horde.KP6NgW-vjq4KeyukqDxSgtN@horde.stefanseidel.info (mailing list archive)
State Changes Requested, archived
Headers show

Commit Message

Stefan Seidel June 23, 2016, 6:43 p.m. UTC
Hi,

sorry about the wrong first patch, I had missed an unwanted hunk.

On at least the SVD11 there is an additional thermal control setting that
is found at a different handle address but otherwise behaves the same as
the other one.

Signed-off-by: Stefan Seidel <lkml@stefanseidel.info>
---
  drivers/platform/x86/sony-laptop.c | 26 ++++++++++++++++++--------
  1 file changed, 18 insertions(+), 8 deletions(-)

  static int sony_nc_lid_resume_setup(struct platform_device *pd,
@@ -1363,7 +1364,8 @@ static void sony_nc_function_setup(struct  
acpi_device *device,
  						result);
  			break;
  		case 0x0122:
-			result = sony_nc_thermal_setup(pf_device);
+		case 0x015F:
+			result = sony_nc_thermal_setup(pf_device, handle);
  			if (result)
  				pr_err("couldn't set up thermal profile function (%d)\n",
  						result);
@@ -1476,6 +1478,7 @@ static void sony_nc_function_cleanup(struct  
platform_device *pd)
  			sony_nc_lid_resume_cleanup(pd);
  			break;
  		case 0x0122:
+		case 0x015F:
  			sony_nc_thermal_cleanup(pd);
  			break;
  		case 0x0128:
@@ -1547,6 +1550,7 @@ static void sony_nc_function_resume(void)
  			sony_call_snc_handle(handle, 0x100, &result);
  			break;
  		case 0x0122:
+		case 0x015F:
  			sony_nc_thermal_resume();
  			break;
  		case 0x0124:
@@ -2150,14 +2154,16 @@ struct snc_thermal_ctrl {
  	unsigned int profiles;
  	struct device_attribute mode_attr;
  	struct device_attribute profiles_attr;
+	unsigned int handle;
  };
  static struct snc_thermal_ctrl *th_handle;

-#define THM_PROFILE_MAX 3
+#define THM_PROFILE_MAX 4
  static const char * const snc_thermal_profiles[] = {
  	"balanced",
  	"silent",
-	"performance"
+	"performance",
+	"cooling"
  };

  static int sony_nc_thermal_mode_set(unsigned short mode)
@@ -2173,7 +2179,8 @@ static int sony_nc_thermal_mode_set(unsigned short mode)
  	if ((mode && !(th_handle->profiles & mode)) || mode >= THM_PROFILE_MAX)
  		return -EINVAL;

-	if (sony_call_snc_handle(0x0122, mode << 0x10 | 0x0200, &result))
+	if (sony_call_snc_handle(th_handle->handle, mode << 0x10 | 0x0200,
+				 &result))
  		return -EIO;

  	th_handle->mode = mode;
@@ -2185,7 +2192,7 @@ static int sony_nc_thermal_mode_get(void)
  {
  	unsigned int result;

-	if (sony_call_snc_handle(0x0122, 0x0100, &result))
+	if (sony_call_snc_handle(th_handle->handle, 0x0100, &result))
  		return -EIO;

  	return result & 0xff;
@@ -2245,14 +2252,17 @@ static ssize_t  
sony_nc_thermal_mode_show(struct device *dev,
  	return count;
  }

-static int sony_nc_thermal_setup(struct platform_device *pd)
+static int sony_nc_thermal_setup(struct platform_device *pd,
+				 unsigned int handle)
  {
  	int ret = 0;
  	th_handle = kzalloc(sizeof(struct snc_thermal_ctrl), GFP_KERNEL);
  	if (!th_handle)
  		return -ENOMEM;

-	ret = sony_call_snc_handle(0x0122, 0x0000, &th_handle->profiles);
+	th_handle->handle = handle;
+
+	ret = sony_call_snc_handle(handle, 0x0000, &th_handle->profiles);
  	if (ret) {
  		pr_warn("couldn't to read the thermal profiles\n");
  		goto outkzalloc;

Comments

Mattia Dongili June 28, 2016, 5:15 a.m. UTC | #1
On Thu, Jun 23, 2016 at 08:43:22PM +0200, Stefan Seidel wrote:
> Hi,
> 
> sorry about the wrong first patch, I had missed an unwanted hunk.
> 
> On at least the SVD11 there is an additional thermal control setting that
> is found at a different handle address but otherwise behaves the same as
> the other one.

Hi Stefan,

this patch looks ok.
I'm tempted to say that the "cooling" option should be limited to models
that support it, though IIRC (and the comment seems to confirm), it's
already the case that not all models support the current 3 options.

I cannot test this code myself not having a Duo.
For reference, could you send me (even privately) the DSDT from your Duo
model?

Thanks.

Reviewed-by: Mattia Dongili <malattia@linux.it>

> Signed-off-by: Stefan Seidel <lkml@stefanseidel.info>
> ---
>  drivers/platform/x86/sony-laptop.c | 26 ++++++++++++++++++--------
>  1 file changed, 18 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/platform/x86/sony-laptop.c
> b/drivers/platform/x86/sony-laptop.c
> index 1dba359..6c9deb3 100644
> --- a/drivers/platform/x86/sony-laptop.c
> +++ b/drivers/platform/x86/sony-laptop.c
> @@ -148,7 +148,8 @@ static int sony_nc_battery_care_setup(struct
> platform_device *pd,
>  		unsigned int handle);
>  static void sony_nc_battery_care_cleanup(struct platform_device *pd);
> 
> -static int sony_nc_thermal_setup(struct platform_device *pd);
> +static int sony_nc_thermal_setup(struct platform_device *pd,
> +				  unsigned int handle);
>  static void sony_nc_thermal_cleanup(struct platform_device *pd);
> 
>  static int sony_nc_lid_resume_setup(struct platform_device *pd,
> @@ -1363,7 +1364,8 @@ static void sony_nc_function_setup(struct acpi_device
> *device,
>  						result);
>  			break;
>  		case 0x0122:
> -			result = sony_nc_thermal_setup(pf_device);
> +		case 0x015F:
> +			result = sony_nc_thermal_setup(pf_device, handle);
>  			if (result)
>  				pr_err("couldn't set up thermal profile function (%d)\n",
>  						result);
> @@ -1476,6 +1478,7 @@ static void sony_nc_function_cleanup(struct
> platform_device *pd)
>  			sony_nc_lid_resume_cleanup(pd);
>  			break;
>  		case 0x0122:
> +		case 0x015F:
>  			sony_nc_thermal_cleanup(pd);
>  			break;
>  		case 0x0128:
> @@ -1547,6 +1550,7 @@ static void sony_nc_function_resume(void)
>  			sony_call_snc_handle(handle, 0x100, &result);
>  			break;
>  		case 0x0122:
> +		case 0x015F:
>  			sony_nc_thermal_resume();
>  			break;
>  		case 0x0124:
> @@ -2150,14 +2154,16 @@ struct snc_thermal_ctrl {
>  	unsigned int profiles;
>  	struct device_attribute mode_attr;
>  	struct device_attribute profiles_attr;
> +	unsigned int handle;
>  };
>  static struct snc_thermal_ctrl *th_handle;
> 
> -#define THM_PROFILE_MAX 3
> +#define THM_PROFILE_MAX 4
>  static const char * const snc_thermal_profiles[] = {
>  	"balanced",
>  	"silent",
> -	"performance"
> +	"performance",
> +	"cooling"
>  };
> 
>  static int sony_nc_thermal_mode_set(unsigned short mode)
> @@ -2173,7 +2179,8 @@ static int sony_nc_thermal_mode_set(unsigned short mode)
>  	if ((mode && !(th_handle->profiles & mode)) || mode >= THM_PROFILE_MAX)
>  		return -EINVAL;
> 
> -	if (sony_call_snc_handle(0x0122, mode << 0x10 | 0x0200, &result))
> +	if (sony_call_snc_handle(th_handle->handle, mode << 0x10 | 0x0200,
> +				 &result))
>  		return -EIO;
> 
>  	th_handle->mode = mode;
> @@ -2185,7 +2192,7 @@ static int sony_nc_thermal_mode_get(void)
>  {
>  	unsigned int result;
> 
> -	if (sony_call_snc_handle(0x0122, 0x0100, &result))
> +	if (sony_call_snc_handle(th_handle->handle, 0x0100, &result))
>  		return -EIO;
> 
>  	return result & 0xff;
> @@ -2245,14 +2252,17 @@ static ssize_t sony_nc_thermal_mode_show(struct
> device *dev,
>  	return count;
>  }
> 
> -static int sony_nc_thermal_setup(struct platform_device *pd)
> +static int sony_nc_thermal_setup(struct platform_device *pd,
> +				 unsigned int handle)
>  {
>  	int ret = 0;
>  	th_handle = kzalloc(sizeof(struct snc_thermal_ctrl), GFP_KERNEL);
>  	if (!th_handle)
>  		return -ENOMEM;
> 
> -	ret = sony_call_snc_handle(0x0122, 0x0000, &th_handle->profiles);
> +	th_handle->handle = handle;
> +
> +	ret = sony_call_snc_handle(handle, 0x0000, &th_handle->profiles);
>  	if (ret) {
>  		pr_warn("couldn't to read the thermal profiles\n");
>  		goto outkzalloc;
> -- 
> 2.8.3
> 
>
Darren Hart July 1, 2016, 7:30 p.m. UTC | #2
On Thu, Jun 23, 2016 at 08:43:22PM +0200, Stefan Seidel wrote:
> Hi,
> 
> sorry about the wrong first patch, I had missed an unwanted hunk.
> 

Hi Stefan, please provide commentary like the above in a cover letter (PATCH
0/N), so the patch itself can be applied directly.

> On at least the SVD11 there is an additional thermal control setting that
> is found at a different handle address but otherwise behaves the same as
> the other one.
> 
> Signed-off-by: Stefan Seidel <lkml@stefanseidel.info>


Please include all maintainers and lists reported by get_maintainers.pl on Cc.

The patch comes in corrupted and does not apply. It appears to be line wrapped.
checkpatch --fix-inplace was unable to correct it. Please check your mail client
settings, send the patch to yourself and verify you can apply it, then resend.

> ---
>  drivers/platform/x86/sony-laptop.c | 26 ++++++++++++++++++--------
>  1 file changed, 18 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/platform/x86/sony-laptop.c
> b/drivers/platform/x86/sony-laptop.c
> index 1dba359..6c9deb3 100644
> --- a/drivers/platform/x86/sony-laptop.c
> +++ b/drivers/platform/x86/sony-laptop.c
> @@ -148,7 +148,8 @@ static int sony_nc_battery_care_setup(struct
> platform_device *pd,
>  		unsigned int handle);
>  static void sony_nc_battery_care_cleanup(struct platform_device *pd);
> 
> -static int sony_nc_thermal_setup(struct platform_device *pd);
> +static int sony_nc_thermal_setup(struct platform_device *pd,
> +				  unsigned int handle);
>  static void sony_nc_thermal_cleanup(struct platform_device *pd);
> 
>  static int sony_nc_lid_resume_setup(struct platform_device *pd,
> @@ -1363,7 +1364,8 @@ static void sony_nc_function_setup(struct acpi_device
> *device,
>  						result);
>  			break;
>  		case 0x0122:
> -			result = sony_nc_thermal_setup(pf_device);
> +		case 0x015F:
> +			result = sony_nc_thermal_setup(pf_device, handle);
>  			if (result)
>  				pr_err("couldn't set up thermal profile function (%d)\n",
>  						result);
> @@ -1476,6 +1478,7 @@ static void sony_nc_function_cleanup(struct
> platform_device *pd)
>  			sony_nc_lid_resume_cleanup(pd);
>  			break;
>  		case 0x0122:
> +		case 0x015F:
>  			sony_nc_thermal_cleanup(pd);
>  			break;
>  		case 0x0128:
> @@ -1547,6 +1550,7 @@ static void sony_nc_function_resume(void)
>  			sony_call_snc_handle(handle, 0x100, &result);
>  			break;
>  		case 0x0122:
> +		case 0x015F:
>  			sony_nc_thermal_resume();
>  			break;
>  		case 0x0124:
> @@ -2150,14 +2154,16 @@ struct snc_thermal_ctrl {
>  	unsigned int profiles;
>  	struct device_attribute mode_attr;
>  	struct device_attribute profiles_attr;
> +	unsigned int handle;
>  };
>  static struct snc_thermal_ctrl *th_handle;
> 
> -#define THM_PROFILE_MAX 3
> +#define THM_PROFILE_MAX 4

You mention the new control behaves the same, but here you are adding a profile,
and blow you add "cooling"... this seems like an additional change which needs
to be documented in the commit message at the very least.

>  static const char * const snc_thermal_profiles[] = {
>  	"balanced",
>  	"silent",
> -	"performance"
> +	"performance",
> +	"cooling"
>  };
> 
>  static int sony_nc_thermal_mode_set(unsigned short mode)
> @@ -2173,7 +2179,8 @@ static int sony_nc_thermal_mode_set(unsigned short mode)
>  	if ((mode && !(th_handle->profiles & mode)) || mode >= THM_PROFILE_MAX)
>  		return -EINVAL;
> 
> -	if (sony_call_snc_handle(0x0122, mode << 0x10 | 0x0200, &result))
> +	if (sony_call_snc_handle(th_handle->handle, mode << 0x10 | 0x0200,
> +				 &result))
>  		return -EIO;
> 
>  	th_handle->mode = mode;
> @@ -2185,7 +2192,7 @@ static int sony_nc_thermal_mode_get(void)
>  {
>  	unsigned int result;
> 
> -	if (sony_call_snc_handle(0x0122, 0x0100, &result))
> +	if (sony_call_snc_handle(th_handle->handle, 0x0100, &result))
>  		return -EIO;
> 
>  	return result & 0xff;
> @@ -2245,14 +2252,17 @@ static ssize_t sony_nc_thermal_mode_show(struct
> device *dev,
>  	return count;
>  }
> 
> -static int sony_nc_thermal_setup(struct platform_device *pd)
> +static int sony_nc_thermal_setup(struct platform_device *pd,
> +				 unsigned int handle)
>  {
>  	int ret = 0;
>  	th_handle = kzalloc(sizeof(struct snc_thermal_ctrl), GFP_KERNEL);
>  	if (!th_handle)
>  		return -ENOMEM;
> 
> -	ret = sony_call_snc_handle(0x0122, 0x0000, &th_handle->profiles);
> +	th_handle->handle = handle;
> +
> +	ret = sony_call_snc_handle(handle, 0x0000, &th_handle->profiles);
>  	if (ret) {
>  		pr_warn("couldn't to read the thermal profiles\n");
>  		goto outkzalloc;
> -- 
> 2.8.3
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe platform-driver-x86" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
diff mbox

Patch

diff --git a/drivers/platform/x86/sony-laptop.c  
b/drivers/platform/x86/sony-laptop.c
index 1dba359..6c9deb3 100644
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -148,7 +148,8 @@  static int sony_nc_battery_care_setup(struct  
platform_device *pd,
  		unsigned int handle);
  static void sony_nc_battery_care_cleanup(struct platform_device *pd);

-static int sony_nc_thermal_setup(struct platform_device *pd);
+static int sony_nc_thermal_setup(struct platform_device *pd,
+				  unsigned int handle);
  static void sony_nc_thermal_cleanup(struct platform_device *pd);