History log of /linux-master/drivers/power/supply/olpc_battery.c
Revision Date Author Comments
# a441f3b9 05-Dec-2022 ye xingchen <ye.xingchen@zte.com.cn>

power: supply: use sysfs_emit() instead of sprintf() for sysfs show()

As documented in Documentation/filesystems/sysfs.rst the sysfs show()
function should use sysfs_emit() or sysfs_emit_at() to format the
userspace return value. This replaces all sysfs related instances of
sprintf() with sysfs_emit() in the power-supply subsystem.

Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
[Drop sysfs_emit changes done for code not related to sysfs show
and reword commit message]
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>


# c9d84681 21-Jun-2022 Liang He <windhl@126.com>

power: supply: olpc_battery: Hold the reference returned by of_find_compatible_node

In olpc_battery_probe(), we should hold the reference returned by
of_find_compatible_node() and use it to call of_node_put() for
refcount balance.

Signed-off-by: Liang He <windhl@126.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>


# 29e9eff4 21-Dec-2019 Lubomir Rintel <lkundrak@v3.sk>

power: supply: olpc_battery: fix the power supply name

The framework is unhappy about them, because it uses the names in sysfs
attributes:

power_supply olpc-ac: hwmon: 'olpc-ac' is not a valid name attribute, please fix
power_supply olpc-battery: hwmon: 'olpc-battery' is not a valid name attribute, please fix

See also commit 648cd48c9e56 ("hwmon: Do not accept invalid name
attributes") and commit 74d3b6419772 ("hwmon: Relax name attribute
validation for new APIs").

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>


# d2912cb1 04-Jun-2019 Thomas Gleixner <tglx@linutronix.de>

treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500

Based on 2 normalized pattern(s):

this program is free software you can redistribute it and or modify
it under the terms of the gnu general public license version 2 as
published by the free software foundation

this program is free software you can redistribute it and or modify
it under the terms of the gnu general public license version 2 as
published by the free software foundation #

extracted by the scancode license scanner the SPDX license identifier

GPL-2.0-only

has been chosen to replace the boilerplate/reference in 4122 file(s).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Enrico Weigelt <info@metux.net>
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Allison Randal <allison@lohutok.net>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190604081206.933168790@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# ec9964b4 13-May-2019 Lubomir Rintel <lkundrak@v3.sk>

Platform: OLPC: Move EC-specific functionality out from x86

Move the olpc-ec driver away from the X86 OLPC platform so that it could be
used by the ARM based laptops too. Notably, the driver for the OLPC battery,
which is also used on the ARM models, builds on this driver's interface.

It is actually plaform independent: the OLPC EC commands with their argument
and responses are mostly the same despite the delivery mechanism is
different.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


# baf5964e 11-May-2019 Lubomir Rintel <lkundrak@v3.sk>

power: supply: olpc_battery: force the le/be casts

The endianness of data returned from the EC depends on the particular EC
version determined at run time. Cast from little/big endian explicitey
in the routine that flips endianness to the native one to make sparse
happy.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Reported-by: kbuild test robot <lkp@intel.com>
Fixes: 76311b9a3295 ("power: supply: olpc_battery: Add OLPC XO 1.75 support")
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>


# 31e22087 18-Apr-2019 Lubomir Rintel <lkundrak@v3.sk>

power: supply: olpc_battery: Have the framework register sysfs files for us

The power framework gained ability to register groups of sysfs
attributes in commit cef8fe6a382c ("power: supply: core: add support for
custom sysfs attributes").

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Suggested-by: Sebastian Reichel <sre@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>


# 76311b9a 18-Apr-2019 Lubomir Rintel <lkundrak@v3.sk>

power: supply: olpc_battery: Add OLPC XO 1.75 support

The battery and the protocol are essentially the same as OLPC XO 1.5,
but the responses from the EC are LSB first.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>


# 8ecefda2 18-Apr-2019 Lubomir Rintel <lkundrak@v3.sk>

power: supply: olpc_battery: Avoid using platform_info

This wouldn't work on the DT-based ARM platform. Let's read the EC version
directly from the EC driver instead.

This removes x86 specific bits that would prevent this driver from being
used with the EC of ARM-based OLPC XO 1.75.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>


# b0280d05 18-Apr-2019 Lubomir Rintel <lkundrak@v3.sk>

power: supply: olpc_battery: Use devm_power_supply_register()

This simplifies the error handling.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>


# 33554d81 18-Apr-2019 Lubomir Rintel <lkundrak@v3.sk>

power: supply: olpc_battery: Move priv data to a struct

The global variables for private data are not too nice. I'd like some
more, and that would clutter the global name space even further.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>


# f7a228ea 18-Apr-2019 Lubomir Rintel <lkundrak@v3.sk>

power: supply: olpc_battery: Use DT to get battery version

Avoid using the x86 OLPC platform specific call to get the board
version. That wouldn't work on FDT-based ARM MMP2 platform.

Add the XO 1.5 compatible string too. This is actually not completely
necessary as the battery nodes on XO 1.5 claim to be compatible with
"olpc,xo1-battery", but there are, in fact, differencies.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>


# ed54ffbe 16-Nov-2018 Lubomir Rintel <lkundrak@v3.sk>

power: supply: olpc_battery: correct the temperature units

According to [1] and [2], the temperature values are in tenths of degree
Celsius. Exposing the Celsius value makes the battery appear on fire:

$ upower -i /org/freedesktop/UPower/devices/battery_olpc_battery
...
temperature: 236.9 degrees C

Tested on OLPC XO-1 and OLPC XO-1.75 laptops.

[1] include/linux/power_supply.h
[2] Documentation/power/power_supply_class.txt

Fixes: fb972873a767 ("[BATTERY] One Laptop Per Child power/battery driver")
Cc: stable@vger.kernel.org
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>


# ac316725 19-Jun-2018 Randy Dunlap <rdunlap@infradead.org>

headers: separate linux/mod_devicetable.h from linux/platform_device.h

At over 4000 #includes, <linux/platform_device.h> is the 9th most
#included header file in the Linux kernel. It does not need
<linux/mod_devicetable.h>, so drop that header and explicitly add
<linux/mod_devicetable.h> to source files that need it.

4146 #include <linux/platform_device.h>

After this patch, there are 225 files that use <linux/mod_devicetable.h>,
for a reduction of around 3900 times that <linux/mod_devicetable.h>
does not have to be read & parsed.

225 #include <linux/mod_devicetable.h>

This patch was build-tested on 20 different arch-es.

It also makes these drivers SubmitChecklist#1 compliant.

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Reported-by: kbuild test robot <lkp@intel.com> # drivers/media/platform/vimc/
Reported-by: kbuild test robot <lkp@intel.com> # drivers/pinctrl/pinctrl-u300.c
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# c023b906 21-Aug-2017 Bhumika Goyal <bhumirks@gmail.com>

power: supply: make device_attribute const

Make these const as they are only passed as an argument to the
function device_create_file and device_remove_file and the corresponding
arguments are of type const.
Done using Coccinelle.

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>


# 16ac345b 02-Aug-2017 Bhumika Goyal <bhumirks@gmail.com>

power: supply: add const to bin_attribute structures

Add const to bin_attribute structures as they are only passed to the
functions sysfs_{remove/create}_bin_file or
device_{remove/create}_bin_file. The corresponding parameters
passed are of type const, so declare the structures to be const.

Done using Coccinelle:

@m disable optional_qualifier@
identifier s;
position p;
@@
static struct bin_attribute s@p={...};

@okay1@
position p;
identifier m.s;
@@
(
sysfs_create_bin_file(...,&s@p,...)
|
sysfs_remove_bin_file(...,&s@p,...)
)

@bad@
position p!={m.p,okay1.p};
identifier m.s;
@@
s@p

@change depends on !bad disable optional_qualifier@
identifier m.s;
@@
static
+const
struct bin_attribute s={...};

Same script was modified for device_{create/remove}_bin_file functions.

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>


# 8c0984e5 17-Jun-2016 Sebastian Reichel <sre@kernel.org>

power: move power supply drivers to power/supply

This moves all power supply drivers from drivers/power/
to drivers/power/supply/. The intention is a cleaner
source tree, since drivers/power/ also contains frameworks
unrelated to power supply, like adaptive voltage scaling.

Signed-off-by: Sebastian Reichel <sre@kernel.org>