Skip to content

Commit

Permalink
rtc: ds1343: check regmap_read return value
Browse files Browse the repository at this point in the history
Check whether regmap_read fails before continuing in the sysfs .show
callbacks.

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Alexandre Belloni <[email protected]>
  • Loading branch information
alexandrebelloni committed Oct 19, 2019
1 parent ac08888 commit ce0fd9d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions drivers/rtc/rtc-ds1343.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,11 @@ static ssize_t ds1343_show_glitchfilter(struct device *dev,
{
struct ds1343_priv *priv = dev_get_drvdata(dev->parent);
int glitch_filt_status, data;
int res;

regmap_read(priv->map, DS1343_CONTROL_REG, &data);
res = regmap_read(priv->map, DS1343_CONTROL_REG, &data);
if (res)
return res;

glitch_filt_status = !!(data & DS1343_EGFIL);

Expand Down Expand Up @@ -147,10 +150,12 @@ static ssize_t ds1343_show_tricklecharger(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct ds1343_priv *priv = dev_get_drvdata(dev->parent);
int data;
int res, data;
char *diodes = "disabled", *resistors = " ";

regmap_read(priv->map, DS1343_TRICKLE_REG, &data);
res = regmap_read(priv->map, DS1343_TRICKLE_REG, &data);
if (res)
return res;

if ((data & 0xf0) == DS1343_TRICKLE_MAGIC) {
switch (data & 0x0c) {
Expand Down

0 comments on commit ce0fd9d

Please sign in to comment.