rtc: rv3029: remove open coded regmap_update_bits
rv3029_update_bits open codes regmap_update_bits and forgets to properly lock the register range while doing so. Use regmap_update_bits instead. Link: https://lore.kernel.org/r/20191214221022.622482-4-alexandre.belloni@bootlin.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
This commit is contained in:
parent
c509e4344b
commit
609e97fe31
@ -137,23 +137,6 @@ static int rv3029_write_regs(struct device *dev, u8 reg, u8 const buf[],
|
|||||||
return regmap_bulk_write(rv3029->regmap, reg, buf, len);
|
return regmap_bulk_write(rv3029->regmap, reg, buf, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int rv3029_update_bits(struct device *dev, u8 reg, u8 mask, u8 set)
|
|
||||||
{
|
|
||||||
u8 buf;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
ret = rv3029_read_regs(dev, reg, &buf, 1);
|
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
buf &= ~mask;
|
|
||||||
buf |= set & mask;
|
|
||||||
ret = rv3029_write_regs(dev, reg, &buf, 1);
|
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int rv3029_get_sr(struct device *dev, u8 *buf)
|
static int rv3029_get_sr(struct device *dev, u8 *buf)
|
||||||
{
|
{
|
||||||
int ret = rv3029_read_regs(dev, RV3029_STATUS, buf, 1);
|
int ret = rv3029_read_regs(dev, RV3029_STATUS, buf, 1);
|
||||||
@ -200,14 +183,17 @@ static int rv3029_eeprom_busywait(struct device *dev)
|
|||||||
|
|
||||||
static int rv3029_eeprom_exit(struct device *dev)
|
static int rv3029_eeprom_exit(struct device *dev)
|
||||||
{
|
{
|
||||||
|
struct rv3029_data *rv3029 = dev_get_drvdata(dev);
|
||||||
|
|
||||||
/* Re-enable eeprom refresh */
|
/* Re-enable eeprom refresh */
|
||||||
return rv3029_update_bits(dev, RV3029_ONOFF_CTRL,
|
return regmap_update_bits(rv3029->regmap, RV3029_ONOFF_CTRL,
|
||||||
RV3029_ONOFF_CTRL_EERE,
|
RV3029_ONOFF_CTRL_EERE,
|
||||||
RV3029_ONOFF_CTRL_EERE);
|
RV3029_ONOFF_CTRL_EERE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int rv3029_eeprom_enter(struct device *dev)
|
static int rv3029_eeprom_enter(struct device *dev)
|
||||||
{
|
{
|
||||||
|
struct rv3029_data *rv3029 = dev_get_drvdata(dev);
|
||||||
int ret;
|
int ret;
|
||||||
u8 sr;
|
u8 sr;
|
||||||
|
|
||||||
@ -236,8 +222,8 @@ static int rv3029_eeprom_enter(struct device *dev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Disable eeprom refresh. */
|
/* Disable eeprom refresh. */
|
||||||
ret = rv3029_update_bits(dev, RV3029_ONOFF_CTRL, RV3029_ONOFF_CTRL_EERE,
|
ret = regmap_update_bits(rv3029->regmap, RV3029_ONOFF_CTRL,
|
||||||
0);
|
RV3029_ONOFF_CTRL_EERE, 0);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user