Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

authored by

Kevin P. Fleming and committed by
Alexandre Belloni
6e429f6b ac363ace

+11 -6
+11 -6
drivers/rtc/rtc-abx80x.c
··· 555 555 .ioctl = abx80x_ioctl, 556 556 }; 557 557 558 - static int abx80x_dt_trickle_cfg(struct device_node *np) 558 + static int abx80x_dt_trickle_cfg(struct i2c_client *client) 559 559 { 560 + struct device_node *np = client->dev.of_node; 560 561 const char *diode; 561 562 int trickle_cfg = 0; 562 563 int i, ret; ··· 567 566 if (ret) 568 567 return ret; 569 568 570 - if (!strcmp(diode, "standard")) 569 + if (!strcmp(diode, "standard")) { 571 570 trickle_cfg |= ABX8XX_TRICKLE_STANDARD_DIODE; 572 - else if (!strcmp(diode, "schottky")) 571 + } else if (!strcmp(diode, "schottky")) { 573 572 trickle_cfg |= ABX8XX_TRICKLE_SCHOTTKY_DIODE; 574 - else 573 + } else { 574 + dev_dbg(&client->dev, "Invalid tc-diode value: %s\n", diode); 575 575 return -EINVAL; 576 + } 576 577 577 578 ret = of_property_read_u32(np, "abracon,tc-resistor", &tmp); 578 579 if (ret) ··· 584 581 if (trickle_resistors[i] == tmp) 585 582 break; 586 583 587 - if (i == sizeof(trickle_resistors)) 584 + if (i == sizeof(trickle_resistors)) { 585 + dev_dbg(&client->dev, "Invalid tc-resistor value: %u\n", tmp); 588 586 return -EINVAL; 587 + } 589 588 590 589 return (trickle_cfg | i); 591 590 } ··· 799 794 } 800 795 801 796 if (np && abx80x_caps[part].has_tc) 802 - trickle_cfg = abx80x_dt_trickle_cfg(np); 797 + trickle_cfg = abx80x_dt_trickle_cfg(client); 803 798 804 799 if (trickle_cfg > 0) { 805 800 dev_info(&client->dev, "Enabling trickle charger: %02x\n",