aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/intel_menlow.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/misc/intel_menlow.c')
-rw-r--r--drivers/misc/intel_menlow.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/drivers/misc/intel_menlow.c b/drivers/misc/intel_menlow.c
index e00a2756e97e..27b7662955bb 100644
--- a/drivers/misc/intel_menlow.c
+++ b/drivers/misc/intel_menlow.c
@@ -52,6 +52,11 @@ MODULE_LICENSE("GPL");
52#define MEMORY_ARG_CUR_BANDWIDTH 1 52#define MEMORY_ARG_CUR_BANDWIDTH 1
53#define MEMORY_ARG_MAX_BANDWIDTH 0 53#define MEMORY_ARG_MAX_BANDWIDTH 0
54 54
55/*
56 * GTHS returning 'n' would mean that [0,n-1] states are supported
57 * In that case max_cstate would be n-1
58 * GTHS returning '0' would mean that no bandwidth control states are supported
59 */
55static int memory_get_int_max_bandwidth(struct thermal_cooling_device *cdev, 60static int memory_get_int_max_bandwidth(struct thermal_cooling_device *cdev,
56 unsigned long *max_state) 61 unsigned long *max_state)
57{ 62{
@@ -71,6 +76,9 @@ static int memory_get_int_max_bandwidth(struct thermal_cooling_device *cdev,
71 if (ACPI_FAILURE(status)) 76 if (ACPI_FAILURE(status))
72 return -EFAULT; 77 return -EFAULT;
73 78
79 if (!value)
80 return -EINVAL;
81
74 *max_state = value - 1; 82 *max_state = value - 1;
75 return 0; 83 return 0;
76} 84}
@@ -121,7 +129,7 @@ static int memory_set_cur_bandwidth(struct thermal_cooling_device *cdev,
121 if (memory_get_int_max_bandwidth(cdev, &max_state)) 129 if (memory_get_int_max_bandwidth(cdev, &max_state))
122 return -EFAULT; 130 return -EFAULT;
123 131
124 if (max_state < 0 || state > max_state) 132 if (state > max_state)
125 return -EINVAL; 133 return -EINVAL;
126 134
127 arg_list.count = 1; 135 arg_list.count = 1;