summaryrefslogtreecommitdiffstats
path: root/drivers/power/power_supply_sysfs.c
Commit message (Collapse)AuthorAgeFilesLines
* power: move power supply drivers to power/supplySebastian Reichel2016-08-111-337/+0
| | | | | | | | | 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>
* power_supply: fix return value of get_propertyRhyland Klein2016-07-011-1/+1
| | | | | | | | | | | | | | | power_supply_get_property() should ideally return -EAGAIN if it is called while the power_supply is being registered. There was no way previously to determine if use_cnt == 0 meant that the power_supply wasn't fully registered yet, or if it had already been unregistered. Add a new boolean to the power_supply struct to simply show if registration is completed. Lastly, modify the check in power_supply_show_property() to also ignore -EAGAIN when so it doesn't complain about not returning the property. Signed-off-by: Rhyland Klein <rklein@nvidia.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
* power_supply: Add types for USB Type C and PD chargersBenson Leung2016-02-151-1/+2
| | | | | | | | | | | | | | | | | | | This adds power supply types for USB chargers defined in the USB Type-C Specification 1.1 and in the USB Power Delivery Specification Revision 2.0 V1.1. The following are added : POWER_SUPPLY_TYPE_USB_TYPE_C, /* Type C Port */ POWER_SUPPLY_TYPE_USB_PD, /* Power Delivery Port */ POWER_SUPPLY_TYPE_USB_PD_DRP, /* PD Dual Role Port */ Signed-off-by: Benson Leung <bleung@chromium.org> [tomeu: remove the mention to Type C from the comments] Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com> Reviewed-by: Alec Berg <alecaberg@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Todd Broch <tbroch@chromium.org> Signed-off-by: Sebastian Reichel <sre@kernel.org>
* power_supply: sysfs: Bring back write to writeable propertiesKrzysztof Kozlowski2015-06-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The fix for NULL pointer exception related to calling uevent for not finished probe caused to set all writeable properties as non-writeable. This was caused by checking if property is writeable before the initial increase of power supply usage counter and in the same time using wrapper over property_is_writeable(). The wrapper returns ENODEV if the usage counter is still 0. The call trace looked like: device probe: power_supply_register() use_cnt = 0; device_add() create sysfs entries power_supply_attr_is_visible() power_supply_property_is_writeable() if (use_cnt == 0) return -ENODEV; use_cnt++; Replace the usage of wrapper with direct call to property_is_writeable() from driver. This should be safe call during device probe because implementations of this callback just return 0/1 for different properties and they do not access any of the driver's internal data. Fixes: 8e59c7f23410 ("power_supply: Fix NULL pointer dereference during bq27x00_battery probe") Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
* power_supply: Use wrappers to avoid races when registering power supplyKrzysztof Kozlowski2015-05-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Use wrappers over get_property() and set_property() internally in power supply and for sysfs interface. The wrappers provide safe access if power supply is not yet registered or t is being destroyed. In case of syfs the theoretical race could happen between ending of driver's probe and parallel sysfs access: some_driver_probe() userspace ==================================== =========================== drv->psy = power_supply_register() device_add() sysfs entries are created atomic_inc(&psy->use_cnt); store on sysfs attributes drv->set_property() dereference of drv->psy drv->psy = returned psy; For leds the race could happen between power supply being destroyed and ongoing power_supply_changed_work(). Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
* power_supply: Change ownership from driver to coreKrzysztof Kozlowski2015-03-131-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Change the ownership of power_supply structure from each driver implementing the class to the power supply core. The patch changes power_supply_register() function thus all drivers implementing power supply class are adjusted. Each driver provides the implementation of power supply. However it should not be the owner of power supply class instance because it is exposed by core to other subsystems with power_supply_get_by_name(). These other subsystems have no knowledge when the driver will unregister the power supply. This leads to several issues when driver is unbound - mostly because user of power supply accesses freed memory. Instead let the core own the instance of struct 'power_supply'. Other users of this power supply will still access valid memory because it will be freed when device reference count reaches 0. Currently this means "it will leak" but power_supply_put() call in next patches will solve it. This solves invalid memory references in following race condition scenario: Thread 1: charger manager Thread 2: power supply driver, used by charger manager THREAD 1 (charger manager) THREAD 2 (power supply driver) ========================== ============================== psy = power_supply_get_by_name() Driver unbind, .remove power_supply_unregister() Device fully removed psy->get_property() The 'get_property' call is executed in invalid context because the driver was unbound and struct 'power_supply' memory was freed. This could be observed easily with charger manager driver (here compiled with max17040 fuel gauge): $ cat /sys/devices/virtual/power_supply/cm-battery/capacity & $ echo "1-0036" > /sys/bus/i2c/drivers/max17040/unbind [ 55.725123] Unable to handle kernel NULL pointer dereference at virtual address 00000000 [ 55.732584] pgd = d98d4000 [ 55.734060] [00000000] *pgd=5afa2831, *pte=00000000, *ppte=00000000 [ 55.740318] Internal error: Oops: 80000007 [#1] PREEMPT SMP ARM [ 55.746210] Modules linked in: [ 55.749259] CPU: 1 PID: 2936 Comm: cat Tainted: G W 3.19.0-rc1-next-20141226-00048-gf79f475f3c44-dirty #1496 [ 55.760190] Hardware name: SAMSUNG EXYNOS (Flattened Device Tree) [ 55.766270] task: d9b76f00 ti: daf54000 task.ti: daf54000 [ 55.771647] PC is at 0x0 [ 55.774182] LR is at charger_get_property+0x2f4/0x36c [ 55.779201] pc : [<00000000>] lr : [<c034b0b4>] psr: 60000013 [ 55.779201] sp : daf55e90 ip : 00000003 fp : 00000000 [ 55.790657] r10: 00000000 r9 : c06e2878 r8 : d9b26c68 [ 55.795865] r7 : dad81610 r6 : daec7410 r5 : daf55ebc r4 : 00000000 [ 55.802367] r3 : 00000000 r2 : daf55ebc r1 : 0000002a r0 : d9b26c68 [ 55.808879] Flags: nZCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user [ 55.815994] Control: 10c5387d Table: 598d406a DAC: 00000015 [ 55.821723] Process cat (pid: 2936, stack limit = 0xdaf54210) [ 55.827451] Stack: (0xdaf55e90 to 0xdaf56000) [ 55.831795] 5e80: 60000013 c01459c4 0000002a c06f8ef8 [ 55.839956] 5ea0: db651000 c06f8ef8 daebac00 c04cb668 daebac08 c0346864 00000000 c01459c4 [ 55.848115] 5ec0: d99eaa80 c06f8ef8 00000fff 00001000 db651000 c027f25c c027f240 d99eaa80 [ 55.856274] 5ee0: d9a06c00 c0146218 daf55f18 00001000 d99eaa80 db4c18c0 00000001 00000001 [ 55.864468] 5f00: daf55f80 c0144c78 c0144c54 c0107f90 00015000 d99eaab0 00000000 00000000 [ 55.872603] 5f20: 000051c7 00000000 db4c18c0 c04a9370 00015000 00001000 daf55f80 00001000 [ 55.880763] 5f40: daf54000 00015000 00000000 c00e53dc db4c18c0 c00e548c 0000000d 00008124 [ 55.888937] 5f60: 00000001 00000000 00000000 db4c18c0 db4c18c0 00001000 00015000 c00e5550 [ 55.897099] 5f80: 00000000 00000000 00001000 00001000 00015000 00000003 00000003 c000f364 [ 55.905239] 5fa0: 00000000 c000f1a0 00001000 00015000 00000003 00015000 00001000 0001333c [ 55.913399] 5fc0: 00001000 00015000 00000003 00000003 00000002 00000000 00000000 00000000 [ 55.921560] 5fe0: 7fffe000 be999850 0000a225 b6f3c19c 60000010 00000003 00000000 00000000 [ 55.929744] [<c034b0b4>] (charger_get_property) from [<c0346864>] (power_supply_show_property+0x48/0x20c) [ 55.939286] [<c0346864>] (power_supply_show_property) from [<c027f25c>] (dev_attr_show+0x1c/0x48) [ 55.948130] [<c027f25c>] (dev_attr_show) from [<c0146218>] (sysfs_kf_seq_show+0x84/0x104) [ 55.956298] [<c0146218>] (sysfs_kf_seq_show) from [<c0144c78>] (kernfs_seq_show+0x24/0x28) [ 55.964536] [<c0144c78>] (kernfs_seq_show) from [<c0107f90>] (seq_read+0x1b0/0x484) [ 55.972172] [<c0107f90>] (seq_read) from [<c00e53dc>] (__vfs_read+0x18/0x4c) [ 55.979188] [<c00e53dc>] (__vfs_read) from [<c00e548c>] (vfs_read+0x7c/0x100) [ 55.986304] [<c00e548c>] (vfs_read) from [<c00e5550>] (SyS_read+0x40/0x8c) [ 55.993164] [<c00e5550>] (SyS_read) from [<c000f1a0>] (ret_fast_syscall+0x0/0x48) [ 56.000626] Code: bad PC value [ 56.011652] ---[ end trace 7b64343fbdae8ef1 ]--- Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Reviewed-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> [for the nvec part] Reviewed-by: Marc Dietrich <marvin24@gmx.de> [for compal-laptop.c] Acked-by: Darren Hart <dvhart@linux.intel.com> [for the mfd part] Acked-by: Lee Jones <lee.jones@linaro.org> [for the hid part] Acked-by: Jiri Kosina <jkosina@suse.cz> [for the acpi part] Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
* power_supply: sysfs: Use power_supply_*() API for accessing function attrsKrzysztof Kozlowski2015-03-131-3/+3
| | | | | | | | | | | | | | | | Replace direct calls to power supply function attributes with wrappers. Wrappers provide safe access in case of unregistering the power supply (e.g. by removing the driver). Replace: - get_property -> power_supply_get_property - set_property -> power_supply_set_property - property_is_writeable -> power_supply_property_is_writeable Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Acked-by: Jonghwa Lee <jonghwa3.lee@samsung.com> Acked-by: Pavel Machek <pavel@ucw.cz> Reviewed-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Reviewed-by: Sebastian Reichel <sre@kernel.org> Signed-off-by: Sebastian Reichel <sre@kernel.org>
* power-supply: Check for failures only when we can failViresh Kumar2014-09-161-10/+11
| | | | | | | | | In power_supply_show_property() routine, we call ->get_property() conditionally and should check for failure in that case only. There is no point comparing 'ret' for errors when 'ret' is surely zero. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Sebastian Reichel <sre@kernel.org>
* power_supply: Add boot and calibration attributesRamakrishna Pallala2014-09-061-0/+3
| | | | | | | | | | | | | | | | Usually PMIC's come with coulomb counting mechanism which can be used to implement a Fuel Gauginig solution in Software itself. One of key input to these SW Fuel Gauge solutioons is the boot up parameters like boot voltage and boot current. This patch adds the VOLTAGE_BOOT and CURRENT_BOOT power supply attributes to report bootup voltage and current. This patch also adds CALIBRATE power supply attribute which useful is for calibrating the battery/coulomb counter. Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
* power_supply: Add inlmt,iterm, min/max temp propsJenny TC2014-07-181-0/+4
| | | | | | | | | | | | | | | | | | Add new power supply properties for input current, charge termination current, min and max temperature POWER_SUPPLY_PROP_TEMP_MIN - minimum operatable temperature POWER_SUPPLY_PROP_TEMP_MAX - maximum operatable temperature POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT - input current limit programmed by charger. Indicates the input current for a charging source. POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT - Charge termination current used to detect the end of charge condition Signed-off-by: Jenny TC <jenny.tc@intel.com> Acked-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Sebastian Reichel <sre@kernel.org>
* power_supply: Replace strict_strtol() with kstrtol()Jingoo Han2013-08-091-1/+1
| | | | | | | | The usage of strict_strtol() is not preferred, because strict_strtol() is obsolete. Thus, kstrtol() should be used. Signed-off-by: Jingoo Han <jg1.han@samsung.com> Signed-off-by: Anton Vorontsov <anton@enomsg.org>
* power_supply: Add watchdog and safety timer expiries under PROP_HEALTH_*Ramakrishna Pallala2013-01-051-1/+2
| | | | | | | | | | | | | | | | As most of the charger chips come with two kinds of safety features related to timing: 1. Watchdog Timer (interms of seconds/mins) 2. Safety Timer (interms of hours) This patch adds these to fault causes in POWER_SUPPLY_PROP_HEALTH_* enums so that whenever there is either watchdog timeout or safety timer timeout driver could notify the user space accurately about the fault and will also be helpful for debug. Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com> Signed-off-by: Anton Vorontsov <anton@enomsg.org>
* power_supply: Add support for CHARGE_CONTROL_* attributesRamakrishna Pallala2012-11-171-0/+2
| | | | | | | | | | | Add support for power supply attributes CHARGE_CONTROL_LIMIT and CHARGE_CONTROL_LIMIT_MAX. These new attributes will enable the user space to implement custom charging algorithms based on platform state. Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com> Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
* power_supply: Add new power supply properties CHARGE_CURRENT/VOLTAGE_MAXRamakrishna Pallala2012-08-221-0/+2
| | | | | | | | | | | | | | | | | There are different types of chargers avalibale like AC, Solar, USB, etc.. Even in USB we have different types SDP/DCP/CDP/ACA and all these chargers have different o/p ratings. For example SDP supports only 500mA of charge current whereas AC charger can support upto 8A or more. Similarly batteries also come with charge current and voltage ratings and these ratings vary depending on its capacity and the technology used. This patch adds two new power supply properties CONSTANT_CHARGE_CURRENT_MAX and CONSTANT_CHARGE_CURRENT_MAX. Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com> Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
* power_supply: Add new power supply AUTHENTIC propertyRamakrishna Pallala2012-08-221-0/+1
| | | | | | | | | | | It is possible that users can use non-standard chargers or use invalid batteries especially with mobile devices. This patch adds a new power supply property called 'AUTHENTIC' to indicate this to the user(user space). Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com> Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
* power_supply: Add min/max alert properties for CAPACITY, TEMP, TEMP_AMBIENTRamakrishna Pallala2012-07-131-0/+6
| | | | | | | | | | | | | | | | | | | | | | | Minimum and maximum alerts on power supply properties will help or allow the user space to "proactively" create policies like connect/disconnect charger or stop/start the user apps based on capacity or temperature parameters. These parameters can be used to avoid unnecessary polling from user space and even from kernel space if the underlying HW can support INT triggers (ex: max17042/47). This patch adds the following power supply alert type properties: CAPACITY_ALERT_MIN CAPACITY_ALERT_MAX TEMP_ALERT_MIN TEMP_ALERT_MAX TEMP_AMBIENT_ALERT_MIN TEMP_AMBIENT_ALERT_MAX Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com> Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
* power_supply: Add constant charge_current and charge_voltage propertiesRamakrishna Pallala2012-06-191-0/+2
| | | | | | | | | | | | | | | | | | Constant Charge Current(CC) is charging parameter which limit the maximum current which can be pumped into the battery during charge cycle. Constant Charge Voltage(CV) is also charging parameter which limit the maximum voltage that battery can reach during charge cycle. It is very common practice that at low or high temperatures we do not charge the batteries upto it's fullest charge voltage to avoid battery and user safety issues. These sysfs properties will be useful for debug and to implement certain user space policies like "Charging limited due to OverTemp". Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com> Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
* power_supply: Add voltage_ocv property and use it for max17042 driverRamakrishna Pallala2012-05-041-0/+1
| | | | | | | | | | | | | This adds a new sysfs file called 'voltage_ocv' which gives the Open Circuit Voltage of the battery. This property can be used for platform shutdown policies and can be useful for initial capacity estimations. Note: This patch is generated against linux-next branch. Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com> Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
* device.h: cleanup users outside of linux/include (C files)Paul Gortmaker2012-03-111-0/+1
| | | | | | | | | | | | | | For files that are actively using linux/device.h, make sure that they call it out. This will allow us to clean up some of the implicit uses of linux/device.h within include/* without introducing build regressions. Yes, this was created by "cheating" -- i.e. the headers were cleaned up, and then the fallout was found and fixed, and then the two commits were reordered. This ensures we don't introduce build regressions into the git history. Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
* Merge git://git.infradead.org/battery-2.6Linus Torvalds2012-01-111-3/+9
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * git://git.infradead.org/battery-2.6: (68 commits) power_supply: Mark da9052 driver as broken power_supply: Drop usage of nowarn variant of sysfs_create_link() s3c_adc_battery: Average over more than one adc sample power_supply: Add DA9052 battery driver isp1704_charger: Fix missing check jz4740-battery: Fix signedness bug power_supply: Assume mains power by default sbs-battery: Fix devicetree match table ARM: rx51: Add bq27200 i2c board info sbs-battery: Change power supply name devicetree-bindings: Propagate bq20z75->sbs rename to dt bindings devicetree-bindings: Add vendor entry for Smart Battery Systems sbs-battery: Rename internals to new name bq20z75: Rename to sbs-battery wm97xx_battery: Use DEFINE_MUTEX() for work_lock max8997_charger: Remove duplicate module.h lp8727_charger: Some minor fixes for the header lp8727_charger: Add header file power_supply: Convert drivers/power/* to use module_platform_driver() power_supply: Add "unknown" in power supply type ...
| * Merge branch 'power-supply-scope' of ↵Anton Vorontsov2012-01-041-0/+7
| |\ | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/jeremy/xen
| | * power_supply: add SCOPE attribute to power suppliesJeremy Fitzhardinge2011-12-091-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds a "scope" attribute to a power_supply, which indicates how much of the system it powers. It appears in sysfs as "scope" or in the uevent file as POWER_SUPPLY_SCOPE=. There are presently three possible values: Unknown - unknown power topology System - the power supply powers the whole system Device - it powers a specific device, or tree of devices A power supply which doesn't have a "scope" attribute should be assumed to have "System" scope. In general, usermode should assume that loss of all System-scoped power supplies will power off the whole system, but any single one is sufficient to power the system. Signed-off-by: Jeremy Fitzhardinge <jeremy@goop.org> Cc: Richard Hughes <richard@hughsie.com>
| * | power_supply: Add "unknown" in power supply typeKim, Milo2012-01-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | For the default value of power supply type, "unknown" is added. With default prop value, supply type property can be displayed as default - "Unknown". Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com> Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
| * | power_supply: Fix sysfs format warningRandy Dunlap2011-08-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Fix format warning: drivers/power/power_supply_sysfs.c:82: warning: format '%d' expects type 'int', but argument 4 has type 'ssize_t' Signed-off-by: Randy Dunlap <rdunlap@xenotime.net> Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
| * | wm831x_power: Only register WM831x battery charger if enabledMark Brown2011-08-191-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Don't tell the system about the battery charger if it's not enabled, we can reasonably assume that if the charger is not enabled then no battery will ever be connected so reporting state is at best going to waste time and at worst going to cause confusing information in the UI. For simplicity and robustness we continue to register and handle interrupts from the charger. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
* | | switch ->is_visible() to returning umode_tAl Viro2012-01-031-2/+2
| |/ |/| | | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* | drivers: power_supply_sysfs.c needs stat.hPaul Gortmaker2011-10-311-0/+1
|/ | | | | | | | | | | | | | | | | It was actually getting this before by a tangled mess of implict includes that is going to be cleaned up. Fix it now, so we don't get this after the cleanup. power_supply_sysfs.c: In function ‘power_supply_attr_is_visible’: power_supply_sysfs.c:184: error: ‘S_IRUSR’ undeclared (first use in this function) power_supply_sysfs.c:184: error: (Each undeclared identifier is reported only once power_supply_sysfs.c:184: error: for each function it appears in.) power_supply_sysfs.c:184: error: ‘S_IRGRP’ undeclared (first use in this function) power_supply_sysfs.c:184: error: ‘S_IROTH’ undeclared (first use in this function) power_supply_sysfs.c:196: error: ‘S_IWUSR’ undeclared (first use in this function) make[3]: *** [drivers/power/power_supply_sysfs.o] Error 1 Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
* power_supply: Ignore -ENODATA errors when generating ueventsLars-Peter Clausen2011-02-221-1/+1
| | | | | | | | | | | | | | | Sometimes a driver can not report a meaningful value for a certain property and returns -ENODATA. Currently when generating a uevent and a property return -ENODATA it is treated as an error an no uevent is generated at all. This is not an desirable behavior. This patch adds a special case for -ENODATA and ignores properties which return this error code when generating the uevent. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Tested-by: Grazvydas Ignotas <notasas@gmail.com>
* power_supply: Introduce maximum current propertyHeikki Krogerus2010-10-061-0/+1
| | | | | | | USB only gives the maximum current allowed to draw. Signed-off-by: Heikki Krogerus <ext-heikki.krogerus@nokia.com> Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
* power_supply: Add types for USB chargersHeikki Krogerus2010-10-061-1/+2
| | | | | | | | This adds power supply types for USB chargers defined in Battery Charging Specification 1.1. Signed-off-by: Heikki Krogerus <ext-heikki.krogerus@nokia.com> Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
* power_supply: Fix regression for 'type' propertyDaniel Mack2010-05-251-2/+4
| | | | | | | | | | | | | | | Commit 5f487cd34f4337f9bc27ca19da72a39d1b0a0ab4 (power_supply: Use attribute groups) causes a regression the power supply core does not export the 'type' attribute anymore. POWER_SUPPLY_PROP_TYPE is handled by the power supply core without the low-level driver, so power_supply_attr_is_visible() must always return the entry as readable. Reported-by: Rafael J. Wysocki <rjw@sisk.pl> Signed-off-by: Daniel Mack <daniel@caiaq.de> Tested-by: Rafael J. Wysocki <rjw@sisk.pl> Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
* power_supply: Add support for writeable propertiesDaniel Mack2010-05-191-3/+35
| | | | | | | | | | | | | | | | | | | | | | | | | This patch adds support for writeable power supply properties and exposes them as writeable to sysfs. A power supply implementation must implement two new function calls in order to use that feature: int set_property(struct power_supply *psy, enum power_supply_property psp, const union power_supply_propval *val); int property_is_writeable(struct power_supply *psy, enum power_supply_property psp); Signed-off-by: Daniel Mack <daniel@caiaq.de> Cc: David Woodhouse <dwmw2@infradead.org> Cc: Alexey Starikovskiy <astarikovskiy@suse.de> Cc: Len Brown <len.brown@intel.com> Cc: Mark Brown <broonie@opensource.wolfsonmicro.com> Cc: Matt Reimer <mreimer@vpop.net> Cc: Evgeniy Polyakov <zbr@ioremap.net> Cc: Tejun Heo <tj@kernel.org> Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
* power_supply: Use attribute groupsAnton Vorontsov2010-05-191-77/+38
| | | | | | | | | | | | | | This fixes a race between power supply device and initial attributes creation, plus makes it possible to implement writable properties. [Daniel Mack - removed superflous return statement and dropped .mode attribute from POWER_SUPPLY_ATTR] Suggested-by: Greg KH <gregkh@suse.de> Suggested-by: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com> Tested-by: Daniel Mack <daniel@caiaq.de>
* include cleanup: Update gfp.h and slab.h includes to prepare for breaking ↵Tejun Heo2010-03-301-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | implicit slab.h inclusion from percpu.h percpu.h is included by sched.h and module.h and thus ends up being included when building most .c files. percpu.h includes slab.h which in turn includes gfp.h making everything defined by the two files universally available and complicating inclusion dependencies. percpu.h -> slab.h dependency is about to be removed. Prepare for this change by updating users of gfp and slab facilities include those headers directly instead of assuming availability. As this conversion needs to touch large number of source files, the following script is used as the basis of conversion. http://userweb.kernel.org/~tj/misc/slabh-sweep.py The script does the followings. * Scan files for gfp and slab usages and update includes such that only the necessary includes are there. ie. if only gfp is used, gfp.h, if slab is used, slab.h. * When the script inserts a new include, it looks at the include blocks and try to put the new include such that its order conforms to its surrounding. It's put in the include block which contains core kernel includes, in the same order that the rest are ordered - alphabetical, Christmas tree, rev-Xmas-tree or at the end if there doesn't seem to be any matching order. * If the script can't find a place to put a new include (mostly because the file doesn't have fitting include block), it prints out an error message indicating which .h file needs to be added to the file. The conversion was done in the following steps. 1. The initial automatic conversion of all .c files updated slightly over 4000 files, deleting around 700 includes and adding ~480 gfp.h and ~3000 slab.h inclusions. The script emitted errors for ~400 files. 2. Each error was manually checked. Some didn't need the inclusion, some needed manual addition while adding it to implementation .h or embedding .c file was more appropriate for others. This step added inclusions to around 150 files. 3. The script was run again and the output was compared to the edits from #2 to make sure no file was left behind. 4. Several build tests were done and a couple of problems were fixed. e.g. lib/decompress_*.c used malloc/free() wrappers around slab APIs requiring slab.h to be added manually. 5. The script was run on all .h files but without automatically editing them as sprinkling gfp.h and slab.h inclusions around .h files could easily lead to inclusion dependency hell. Most gfp.h inclusion directives were ignored as stuff from gfp.h was usually wildly available and often used in preprocessor macros. Each slab.h inclusion directive was examined and added manually as necessary. 6. percpu.h was updated not to include slab.h. 7. Build test were done on the following configurations and failures were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my distributed build env didn't work with gcov compiles) and a few more options had to be turned off depending on archs to make things build (like ipr on powerpc/64 which failed due to missing writeq). * x86 and x86_64 UP and SMP allmodconfig and a custom test config. * powerpc and powerpc64 SMP allmodconfig * sparc and sparc64 SMP allmodconfig * ia64 SMP allmodconfig * s390 SMP allmodconfig * alpha SMP allmodconfig * um on x86_64 SMP allmodconfig 8. percpu.h modifications were reverted so that it could be applied as a separate patch and serve as bisection point. Given the fact that I had only a couple of failures from tests on step 6, I'm fairly confident about the coverage of this conversion patch. If there is a breakage, it's likely to be something in one of the arch headers which should be easily discoverable easily on most builds of the specific arch. Signed-off-by: Tejun Heo <tj@kernel.org> Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
* POWER: Add support for cycle_countAlexey Starikovskiy2010-01-151-0/+1
| | | | | Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de> Signed-off-by: Len Brown <len.brown@intel.com>
* power_supply_sysfs: Handle -ENODATA in a special wayAnton Vorontsov2009-12-031-1/+4
| | | | | | | | | | | There are cases when some device can not report any meaningful value, e.g. TWL4030 charger can report voltage only when charging is active. In these cases drivers will return -ENODATA, and we shouldn't flood kernel log with error messages. Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
* power_supply: Add a charge_type property, and use it for olpc driverAndres Salomon2009-07-021-0/+6
| | | | | | | | | | | | | This adds a new sysfs file called 'charge_type' which displays the type of charging (unknown, n/a, trickle charge, or fast charging). This allows things like battery diagnostics to determine what the battery/EC is doing without resorting to changing the 'status' sysfs output. Signed-off-by: Andres Salomon <dilinger@collabora.co.uk> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
* Revert "power: remove POWER_SUPPLY_PROP_CAPACITY_LEVEL"Andres Salomon2009-07-011-0/+6
| | | | | | | | | | | | | | | This reverts commit 8efe444038a205e79b38b7ad03878824901849a8 and 4cbc76eadf56399cd11fb736b33c53aec9caab8c. Richard@laptop.org was apparently using CAPACITY_LEVEL for debugging battery/EC problems, and was upset that it was removed. This readds it. Conflicts: Documentation/power_supply_class.txt Signed-off-by: Andres Salomon <dilinger@collabora.co.uk> Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
* ACPI: battery: add power_{now,avg} properties to power_classAlexey Starikovskiy2009-03-271-0/+2
| | | | | | | | | | ACPI has smart batteries, which work in units of energy and measure rate of (dis)charge as power, thus it is not appropriate to export it as a current_now. Current_now will still be exported to allow for userland applications to match. Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de> Signed-off-by: Len Brown <len.brown@intel.com>
* power_supply: Add cold to the POWER_SUPPLY_HEALTH report valuesMark Brown2009-01-041-1/+1
| | | | | | | | | Some systems are able to report problems with batteries being under temperature. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Acked-by: Anton Vorontsov <cbouatmailru@gmail.com> Signed-off-by: Samuel Ortiz <sameo@openedhand.com>
* x86: sysfs: kill owner field from attributeParag Warudkar2008-10-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Tejun's commit 7b595756ec1f49e0049a9e01a1298d53a7faaa15 made sysfs attribute->owner unnecessary. But the field was left in the structure to ease the merge. It's been over a year since that change and it is now time to start killing attribute->owner along with its users - one arch at a time! This patch is attempt #1 to get rid of attribute->owner only for CONFIG_X86_64 or CONFIG_X86_32 . We will deal with other arches later on as and when possible - avr32 will be the next since that is something I can test. Compile (make allyesconfig / make allmodconfig / custom config) and boot tested. akpm: the idea is that we put the declaration of sttribute.owner inside `#ifndef CONFIG_X86'. But that proved to be too ambitious for now because new usages kept on turning up in subsystem trees. [akpm: remove the ifdef for now] Signed-off-by: Parag Warudkar <parag.lkml@gmail.com> Cc: Greg KH <greg@kroah.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Tejun Heo <htejun@gmail.com> Cc: Len Brown <lenb@kernel.org> Cc: Jens Axboe <jens.axboe@oracle.com> Cc: Jean Delvare <khali@linux-fr.org> Cc: Roland Dreier <rolandd@cisco.com> Cc: David Brownell <david-b@pacbell.net> Cc: Alessandro Zummo <a.zummo@towertech.it> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
* Merge branch 'master' of /home/cbou/linux-2.6Anton Vorontsov2008-07-301-1/+1
|\ | | | | | | | | | | | | Conflicts: drivers/power/Kconfig drivers/power/Makefile
| * power_supply: Fix race in power_supply_ueventDmitry Baryshkov2008-06-101-1/+1
| | | | | | | | | | | | | | | | | | | | Commit 54d29ad33e3483bcc7ca433a21cf294854e5154a (Power Supply: fix race in device_create) introduced a race in power_supply_uevent. Previously it checked that power_supply is available by checking for dev->driver_data. But now dev->driver_data is set before power_supply->dev is initialised. Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com> Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
* | power_supply: add CHARGE_COUNTER property and olpc_battery support for itAndres Salomon2008-05-131-0/+1
|/ | | | | | | | | | | | | This adds PROP_CHARGE_COUNTER to the power supply class (documenting it as well). The OLPC battery driver uses this for spitting out its ACR values (in uAh). We have some rounding errors (the data sheet claims 416.7, the math actually works out to 416.666667, so we're forced to choose between overflows or precision loss. I chose precision loss, and stuck w/ data sheet values), but I don't think anyone will care that much. Signed-off-by: Andres Salomon <dilinger@debian.org> Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
* Merge branch 'release' of ↵Linus Torvalds2008-02-071-0/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6 * 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6: (112 commits) ACPI: fix build warning Revert "cpuidle: build fix for non-x86" ACPI: update intrd DSDT override console messages ACPI: update DSDT override documentation ACPI: Add "acpi_no_initrd_override" kernel parameter ACPI: its a directory not a folder.... ACPI: misc cleanups ACPI: add missing prink prefix strings ACPI: cleanup acpi.h ACPICA: fix CONFIG_ACPI_DEBUG_FUNC_TRACE build ACPI: video: Ignore ACPI video devices that aren't present in hardware ACPI: video: reset brightness on resume ACPI: video: call ACPI notifier chain for ACPI video notifications ACPI: create notifier chain to get hotkey events to graphics driver ACPI: video: delete unused display switch on hotkey event code ACPI: video: create "brightness_switch_enabled" modparam cpuidle: Add a poll_idle method ACPI: cpuidle: Support C1 idle time accounting ACPI: enable MWAIT for C1 idle ACPI: idle: Fix acpi_safe_halt usages and interrupt enabling/disabling ...
| * ACPI: battery: add sysfs serial numbermaximilian attems2008-02-051-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | egrep serial /proc/acpi/battery/BAT0/info serial number: 32090 serial number can tell you from the imminent danger of beeing set on fire. Signed-off-by: maximilian attems <max@stro.at> Acked-by: Alexey Starikovskiy <astarikovskiy@suse.de> Signed-off-by: Len Brown <len.brown@intel.com>
* | power_supply: remove capacity_level from list of sysfs attributesThadeu Lima de Souza Cascardo2008-02-071-1/+0
|/ | | | | | | | | | | | | | | | | | | | | | This commit: commit 8efe444038a205e79b38b7ad03878824901849a8 Author: Andres Salomon <dilinger@queued.net> Date: Wed Dec 12 14:12:56 2007 -0500 power: remove POWER_SUPPLY_PROP_CAPACITY_LEVEL Removed CAPACITY_LEVEL from every other code, leaving the array with sysfs attributes with one more entry than the number of enums in power_supply.h. This leads to some attributes containing the value of the attribute right after it. For example, temp_ambient would have the value of time_to_empty_now. In my case, I had time_to_full_avg have the value which should be in model_name, when the former was usually empty. Cc: Andres Salomon <dilinger@debian.org> Cc: David Woodhouse <dwmw2@infradead.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
* power_supply: add few more values and propsDmitry Baryshkov2008-02-021-1/+4
| | | | | | | | Add LiMn (one of the most common for small non-rechargable batteries) battery technology and voltage_min/_max properties support. Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com> Signed-off-by: Anton Vorontsov <cbou@mail.ru>
* power: fix incorrect unregistration in power_supply_create_attrs error pathAndres Salomon2008-02-021-4/+2
| | | | | | | | | | | | | In power_supply_create_attrs(), we create static attributes as referenced by power_supply_static_attrs[i]. After that, if we fail, we unregister via power_supply_static_attrs[psy->properties[i]]. This is incorrect, as psy->properties has absolutely no bearing on static attribs. This patch fixes it to unregister the correct attrib. Another line which was unnecessarily line wrapped is also unwrapped. Signed-off-by: Andres Salomon <dilinger@debian.org> Signed-off-by: David Woodhouse <dwmw2@infradead.org>
* power: remove POWER_SUPPLY_PROP_CAPACITY_LEVELAndres Salomon2008-02-021-6/+0
| | | | | | | | | | | | | | | | | | | | | | | The CAPACITY_LEVEL stuff defines various levels of charge; however, what is the difference between them? What differentiates between HIGH and NORMAL, LOW and CRITICAL, etc? As it appears that these are fairly arbitrary, we end up making such policy decisions in the kernel (or in hardware). This is the sort of decision that should be made in userspace, not in the kernel. If the hardware does not support _CAPACITY and it cannot be easily calculated, then perhaps the driver should register a custom CAPACITY_LEVEL attribute; however, userspace should not become accustomed to looking for such a thing, and we should certainly not encourage drivers to provide CAPACITY_LEVEL stubs. The following removes support for POWER_SUPPLY_PROP_CAPACITY_LEVEL. The OLPC battery driver is the only driver making use of this, so it's removed from there as well. Signed-off-by: Andres Salomon <dilinger@debian.org> Signed-off-by: David Woodhouse <dwmw2@infradead.org>
OpenPOWER on IntegriCloud