power: supply: bd71828: sysfs for auto input current limitation
Subsystems (2)
Andreas Kemnade
maintainerPATCH 1/1 power: supply: bd71828: sysfs for auto input current limitation
Add the possibility to disable the auto adjustment for input current limitation via sysfs because it gives strange results under certain circumstances e.g. when powering the device with solar panels resulting in no input power usage at all.
--- .../ABI/testing/sysfs-class-power-bd71828 | 12 ++++ drivers/power/supply/bd71828-power.c | 69 ++++++++++++++++++- 2 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 Documentation/ABI/testing/sysfs-class-power-bd71828
Documentation/ABI/testing/sysfs-class-power-bd71828 new file +12 -0
@@ -0,0 +1,12 @@ +What: /sys/class/power_supply/bd71828_ac/auto_dcin_limit +Description: + Enable/Disable automatic management of input current limit + (ILIM_DCIN_EN bit). + + Possible values are: + + ============ =========================================== + 1 automatic adjustment of input current limit + 0 no adjustment of input current limit. This + helps for more unusual power sources like + solar modules.
drivers/power/supply/bd71828-power.c +68 -1
90 lines not on this page · raw message
Signature · 1 line
2.47.3
Thanks Andreas!
Quoted 6 lines · Andreas Kemnade
Add the possibility to disable the auto adjustment for input current limitation via sysfs because it gives strange results under certain circumstances e.g. when powering the device with solar panels resulting in no input power usage at all.
Signed-off-by Andreas Kemnade <[email protected]>
Quoted 5 lines
--- .../ABI/testing/sysfs-class-power-bd71828 | 12 ++++ drivers/power/supply/bd71828-power.c | 69 ++++++++++++++++++- 2 files changed, 80 insertions(+), 1 deletion(-)create mode 100644
Documentation/ABI/testing/sysfs-class-power-bd71828
// snip
Quoted 5 lines
drivers/power/supply/bd71828-power.c +5
-0+static ssize_t auto_dcin_limit_store (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t len) +{ +struct bd71828_power *pwr =dev_get_drvdata (dev->parent);
drivers/power/supply/bd71828-power.c static int bd7182x_get_rsens(struct bd71828_power *pwr) · line 1133
Quoted 10 lines
drivers/power/supply/bd71828-power.c +10
-0+int ret; +bool v; + + ret =kstrtobool (buf, &v); +if (ret <0 ) +return ret; + + ret =regmap_update_bits (pwr->regmap,BD71828_REG_DCIN_SET , +BD71828_MASK_ILIM_DCIN_EN , + v ?BD71828_MASK_ILIM_DCIN_EN :0 );
'nit'. I am not a big fan of the ternary. I would consider using an if-else or the regmap_assign_bits(). Not worth re-spinning though.
drivers/power/supply/bd71828-power.c static int bd7182x_get_rsens(struct bd71828_power *pwr) · line 1155
Quoted 9 lines
drivers/power/supply/bd71828-power.c +9
-0+static bool bd71828_ac_sysfs_group_visible (struct kobject *kobj) +{ +struct device *dev =kobj_to_dev (kobj); +struct bd71828_power *pwr =dev_get_drvdata (dev->parent); + +return !!pwr->regs->dcin_set; +} + +DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE (bd71828_ac_sysfs);
Ah. I didn't know DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE() existed. Thanks for teaching me a thing again :)
Yours,
-- Matti
Signature · 5 lines
Matti Vaittinen Linux kernel developer at ROHM Semiconductors Oulu Finland ~~ When things go utterly wrong vim users can always type :help! ~~
Sebastian Reichel
AppliedQuoted 6 lines · Andreas Kemnade
Add the possibility to disable the auto adjustment for input current limitation via sysfs because it gives strange results under certain circumstances e.g. when powering the device with solar panels resulting in no input power usage at all.
Applied, thanks!
[1/1] power: supply: bd71828: sysfs for auto input current limitation
commit: e92786dd86a24bf02ab4503856799192b7f073c7
Best regards,
Signature · 1 line
Sebastian Reichel <[email protected]>