rtc: abx80x: Provide debug feedback for invalid dt properties

When the user provides an invalid value for tc-diode or
tc-resistor generate a debug message instead of silently
ignoring it.

Signed-off-by: Kevin P. Fleming <kevin+linux@km6g.us>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20200530122956.360689-1-kevin+linux@km6g.us
This commit is contained in:
Kevin P. Fleming
2020-05-30 08:29:56 -04:00
committed by Alexandre Belloni
parent ac363ace16
commit 6e429f6b8c

View File

@@ -555,8 +555,9 @@ static const struct rtc_class_ops abx80x_rtc_ops = {
.ioctl = abx80x_ioctl, .ioctl = abx80x_ioctl,
}; };
static int abx80x_dt_trickle_cfg(struct device_node *np) static int abx80x_dt_trickle_cfg(struct i2c_client *client)
{ {
struct device_node *np = client->dev.of_node;
const char *diode; const char *diode;
int trickle_cfg = 0; int trickle_cfg = 0;
int i, ret; int i, ret;
@@ -566,12 +567,14 @@ static int abx80x_dt_trickle_cfg(struct device_node *np)
if (ret) if (ret)
return ret; return ret;
if (!strcmp(diode, "standard")) if (!strcmp(diode, "standard")) {
trickle_cfg |= ABX8XX_TRICKLE_STANDARD_DIODE; trickle_cfg |= ABX8XX_TRICKLE_STANDARD_DIODE;
else if (!strcmp(diode, "schottky")) } else if (!strcmp(diode, "schottky")) {
trickle_cfg |= ABX8XX_TRICKLE_SCHOTTKY_DIODE; trickle_cfg |= ABX8XX_TRICKLE_SCHOTTKY_DIODE;
else } else {
dev_dbg(&client->dev, "Invalid tc-diode value: %s\n", diode);
return -EINVAL; return -EINVAL;
}
ret = of_property_read_u32(np, "abracon,tc-resistor", &tmp); ret = of_property_read_u32(np, "abracon,tc-resistor", &tmp);
if (ret) if (ret)
@@ -581,8 +584,10 @@ static int abx80x_dt_trickle_cfg(struct device_node *np)
if (trickle_resistors[i] == tmp) if (trickle_resistors[i] == tmp)
break; break;
if (i == sizeof(trickle_resistors)) if (i == sizeof(trickle_resistors)) {
dev_dbg(&client->dev, "Invalid tc-resistor value: %u\n", tmp);
return -EINVAL; return -EINVAL;
}
return (trickle_cfg | i); return (trickle_cfg | i);
} }
@@ -794,7 +799,7 @@ static int abx80x_probe(struct i2c_client *client,
} }
if (np && abx80x_caps[part].has_tc) if (np && abx80x_caps[part].has_tc)
trickle_cfg = abx80x_dt_trickle_cfg(np); trickle_cfg = abx80x_dt_trickle_cfg(client);
if (trickle_cfg > 0) { if (trickle_cfg > 0) {
dev_info(&client->dev, "Enabling trickle charger: %02x\n", dev_info(&client->dev, "Enabling trickle charger: %02x\n",