aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorChris Kimber <chris.kimber@stericsson.com>2011-06-08 15:49:59 +0100
committersaid m bagheri <ebgheri@steludxu2848.(none)>2011-06-29 10:30:25 +0200
commit99c358c786fa20842853d89ecedbb0d4c909a973 (patch)
treef51e50c0c7dab081f816bec10d1d02f923375022 /drivers
parentb4377a9f2901505582a97aeea3993199e0a507c8 (diff)
hwmon: ab8500: Automatically monitor sensors when an alarm is set
When setting a min/max/max_hyst alarm value for a sensor, it is no longer neccessary to manually kick of a monitoring job. ST-Ericsson Linux next: - ST-Ericsson ID: - ST-Ericsson FOSS-OUT ID: Trivial Change-Id: I24f8f81481f3ff96b54c197ffcbe60f2e50a0d7c Signed-off-by: Chris Kimber <chris.kimber@stericsson.com> Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/24714 Reviewed-by: QATEST Reviewed-by: Martin PERSSON <martin.persson@stericsson.com> Reviewed-by: Linus WALLEIJ <linus.walleij@stericsson.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/hwmon/ab8500.c46
1 files changed, 31 insertions, 15 deletions
diff --git a/drivers/hwmon/ab8500.c b/drivers/hwmon/ab8500.c
index c8c05c6fa15..1cfab4948e4 100644
--- a/drivers/hwmon/ab8500.c
+++ b/drivers/hwmon/ab8500.c
@@ -46,6 +46,7 @@
* frame, this driver will. Time unit is ms.
*/
#define DEFAULT_POWER_OFF_DELAY 10000
+#define DEFAULT_MONITOR_DELAY 1000
#define NUM_SENSORS 5
@@ -91,13 +92,17 @@ static bool find_active_thresholds(struct ab8500_temp *data)
dev_dbg(&data->pdev->dev, "No active thresholds,"
"cancel deferred job (if it exists)"
"and reset temp monitor delay\n");
- mutex_lock(&data->lock);
- data->gpadc_monitor_delay = 0;
cancel_delayed_work_sync(&data->work);
- mutex_unlock(&data->lock);
return false;
}
+
+static inline void schedule_monitor(struct ab8500_temp *data) {
+ unsigned long delay_in_jiffies;
+ delay_in_jiffies = msecs_to_jiffies(data->gpadc_monitor_delay);
+ schedule_delayed_work(&data->work, delay_in_jiffies);
+}
+
static void thermal_power_off(struct work_struct *work)
{
struct ab8500_temp *data = container_of(work, struct ab8500_temp,
@@ -226,22 +231,21 @@ static ssize_t set_temp_monitor_delay(struct device *dev,
const char *buf, size_t count)
{
int res;
- unsigned long delay_in_jiffies, delay_in_s;
+ unsigned long delay_in_s;
struct ab8500_temp *data = dev_get_drvdata(dev);
- if (!find_active_thresholds(data)) {
- dev_dbg(dev, "No thresholds to monitor, disregarding delay\n");
- return count;
- }
res = strict_strtoul(buf, 10, &delay_in_s);
if (res < 0)
return res;
mutex_lock(&data->lock);
data->gpadc_monitor_delay = delay_in_s * 1000;
+
+ if (find_active_thresholds(data)) {
+ schedule_monitor(data);
+ }
+
mutex_unlock(&data->lock);
- delay_in_jiffies = msecs_to_jiffies(data->gpadc_monitor_delay);
- schedule_delayed_work(&data->work, delay_in_jiffies);
return count;
}
@@ -251,7 +255,7 @@ static ssize_t set_temp_power_off_delay(struct device *dev,
const char *buf, size_t count)
{
int res;
- unsigned long delay_in_jiffies, delay_in_s;
+ unsigned long delay_in_s;
struct ab8500_temp *data = dev_get_drvdata(dev);
res = strict_strtoul(buf, 10, &delay_in_s);
@@ -261,7 +265,6 @@ static ssize_t set_temp_power_off_delay(struct device *dev,
mutex_lock(&data->lock);
data->power_off_delay = delay_in_s * 1000;
mutex_unlock(&data->lock);
- delay_in_jiffies = msecs_to_jiffies(data->power_off_delay);
return count;
}
@@ -366,9 +369,13 @@ static ssize_t set_min(struct device *dev, struct device_attribute *devattr,
data->min_alarm[attr->index - 1] = 0;
data->min[attr->index - 1] = val;
- mutex_unlock(&data->lock);
+
if (val == 0)
(void) find_active_thresholds(data);
+ else
+ schedule_monitor(data);
+
+ mutex_unlock(&data->lock);
return count;
}
@@ -392,9 +399,13 @@ static ssize_t set_max(struct device *dev, struct device_attribute *devattr,
data->max_alarm[attr->index - 1] = 0;
data->max[attr->index - 1] = val;
- mutex_unlock(&data->lock);
+
if (val == 0)
(void) find_active_thresholds(data);
+ else
+ schedule_monitor(data);
+
+ mutex_unlock(&data->lock);
return count;
}
@@ -419,9 +430,13 @@ static ssize_t set_max_hyst(struct device *dev,
data->max_hyst_alarm[attr->index - 1] = 0;
data->max_hyst[attr->index - 1] = val;
- mutex_unlock(&data->lock);
+
if (val == 0)
(void) find_active_thresholds(data);
+ else
+ schedule_monitor(data);
+
+ mutex_unlock(&data->lock);
return count;
}
@@ -668,6 +683,7 @@ static int __devinit ab8500_temp_probe(struct platform_device *pdev)
mutex_init(&data->lock);
data->pdev = pdev;
data->power_off_delay = DEFAULT_POWER_OFF_DELAY;
+ data->gpadc_monitor_delay = DEFAULT_MONITOR_DELAY;
platform_set_drvdata(pdev, data);