mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2025-01-20 23:51:45 +07:00
rtc: ds1343: use regmap_update_bits for glitch filter
Use regmap_update_bits to update DS1343_CONTROL_REG in a race free manner when setting the glitch filter. Link: https://lore.kernel.org/r/20191019204941.6203-5-alexandre.belloni@bootlin.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
This commit is contained in:
parent
580daaf43a
commit
ac08888b25
@ -108,20 +108,18 @@ static ssize_t ds1343_store_glitchfilter(struct device *dev,
|
|||||||
const char *buf, size_t count)
|
const char *buf, size_t count)
|
||||||
{
|
{
|
||||||
struct ds1343_priv *priv = dev_get_drvdata(dev->parent);
|
struct ds1343_priv *priv = dev_get_drvdata(dev->parent);
|
||||||
int data;
|
int data = 0;
|
||||||
|
int res;
|
||||||
regmap_read(priv->map, DS1343_CONTROL_REG, &data);
|
|
||||||
|
|
||||||
if (strncmp(buf, "enabled", 7) == 0)
|
if (strncmp(buf, "enabled", 7) == 0)
|
||||||
data |= DS1343_EGFIL;
|
data = DS1343_EGFIL;
|
||||||
|
else if (strncmp(buf, "disabled", 8))
|
||||||
else if (strncmp(buf, "disabled", 8) == 0)
|
|
||||||
data &= ~(DS1343_EGFIL);
|
|
||||||
|
|
||||||
else
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
regmap_write(priv->map, DS1343_CONTROL_REG, data);
|
res = regmap_update_bits(priv->map, DS1343_CONTROL_REG,
|
||||||
|
DS1343_EGFIL, data);
|
||||||
|
if (res)
|
||||||
|
return res;
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user