#include <linux/init.h>
#include <linux/module.h>
#include <linux/slab.h>
-#include <linux/mutex.h>
#include <linux/regmap.h>
#include <linux/util_macros.h>
/* Client data (each client gets its own) */
struct lm95234_data {
struct regmap *regmap;
- struct mutex update_lock;
enum chips type;
};
u32 tcrit;
int ret;
- mutex_lock(&data->update_lock);
-
ret = regmap_read(data->regmap, LM95234_REG_TCRIT1(0), &tcrit);
if (ret)
- goto unlock;
+ return ret;
val = DIV_ROUND_CLOSEST(clamp_val(val, -255000, 255000), 1000);
val = clamp_val((int)tcrit - val, 0, 31);
- ret = regmap_write(data->regmap, LM95234_REG_TCRIT_HYST, val);
-unlock:
- mutex_unlock(&data->update_lock);
- return ret;
+ return regmap_write(data->regmap, LM95234_REG_TCRIT_HYST, val);
}
static int lm95234_crit_reg(int channel)
return PTR_ERR(regmap);
data->regmap = regmap;
- mutex_init(&data->update_lock);
/* Initialize the LM95234 chip */
err = lm95234_init_client(dev, regmap);