Commit Graph

1107 Commits

Author SHA1 Message Date
Linus Torvalds 36a1624d88 power supply and reset changes for the v4.2 series
* New charger drivers: BQ24257, BQ25890, AXP288, RT9455
  * MAX17042 battery: add health & temperature support
  * BQ2415x charger: add ACPI support
  * misc. fixes and cleanups
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABCgAGBQJViI++AAoJENju1/PIO/qasPYP/0YMZdNNEUA/z1Uv8litaGbe
 gCzLRKuevt/996eVQcGJwsla/7AZwNgpUJya28mpiRqp+RbsTB4bkiGCkD2aO2Jw
 p34h9tIugU5H8+iL1+vl/ztpjwwm/bxEQHNpHK/YwqQLP7QazI6/yyRAUzYu0bGk
 RUndaStY/UZ/9KtSfGYF54kpxCXVQS0aHPMXXKQREr3Hg/VMlBoKQeAvJ7jTTjST
 7s9ZncO70jeY1NrSSdRY+anbuUNYqt0ndbaHhlpayGxnWL+PGdd2mNKq/ycGmBld
 8PwnDs+6fLv24PGYnkwbTryCbdvU9ZYUuNVb4XNTY+8x8CSPNuM8yYhqkmmq1dfI
 zXy1U9TCkLtKSk+7rxKWZc0WuWn2D9UJvr1zAoK9TMafdLi3YIMbm1TemKpLX/HJ
 chORnioPNgBiLmSzJ+nizWfWU5BQ5MhJamzhER0dRG9u8/2YJzCyNfd2miGrvAdL
 LecLcWopEDa+cAg5HM3usKcv0GsBJIes/jmtSMv2URWk8FHcXsDMsnl+D/77/LmV
 PM+HNJ/cNi7WGMgMO6lb1gULaRdAb6tZS865p2Abx5NkNjjRQw9A8EIwP30SPWh7
 aPhU6jxDdmhpez4nJeyHdjcQqnlE+Cxz9vwj8IMgneTjSl4guUY1HcgmAHJtrKGC
 WNB/r32UzJ5AZ0VxBB15
 =192M
 -----END PGP SIGNATURE-----

Merge tag 'for-4.2' of git://git.infradead.org/battery-2.6

Pull power supply and reset updates from Sebastian Reichel:

 - new charger drivers: BQ24257, BQ25890, AXP288, RT9455

 - MAX17042 battery: add health & temperature support

 - BQ2415x charger: add ACPI support

 - misc fixes and cleanups

* tag 'for-4.2' of git://git.infradead.org/battery-2.6: (32 commits)
  power_supply: Correct kerneldoc copy paste errors
  wm831x_power: Fix off-by-one at free_irq()
  power_supply: rt9455_charger: Fix error reported by static analysis tool
  power_supply: bq24257: use flags argument of devm_gpiod_get
  power_supply: bq25890: use flags argument of devm_gpiod_get
  sbs-battery: add option to always register battery
  power: Add devm_power_supply_get_by_phandle() helper function
  power_supply: max17042: Add OF support for setting thresholds
  power_supply: sysfs: Bring back write to writeable properties
  power_supply: rt9455_charger: Check if CONFIG_USB_PHY is enabled
  power: reset: gpio-restart: increase priority slightly
  power_supply: bq25890: make chip_id int
  power_supply: Add support for Richtek RT9455 battery charger
  Documentation: devicetree: Add Richtek RT9455 bindings
  of: Add vendor prefix for Richtek Technology Corporation
  power_supply: 88pm860x_charger: Do not call free_irq() twice
  power: bq24190_charger: Change first_time flag reset condition
  power: axp288_charger: axp288 charger driver
  power: max17042_battery: add HEALTH and TEMP_* properties support
  power_supply: Add support for TI BQ25890 charger chip
  ...
2015-06-23 16:10:27 -07:00
Bjorn Andersson 43df61051a power_supply: Correct kerneldoc copy paste errors
Signed-off-by: Bjorn Andersson <bjorn.andersson@sonymobile.com>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-06-19 14:21:01 +02:00
Takeshi Yoshimura 85a5965e1d wm831x_power: Fix off-by-one at free_irq()
An error handling in wm831x_power_probe() mistakenly frees a failed-to-
request irq as well as other irqs. I added missing decrement of the loop
counter.

Signed-off-by: Takeshi Yoshimura <yos@sslab.ics.keio.ac.jp>
Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-06-15 12:30:32 +02:00
Anda-Maria Nicolae 3d7f1800af power_supply: rt9455_charger: Fix error reported by static analysis tool
The result of container_of macro cannot be NULL, so there is no need to
check whether info is NULL.

Signed-off-by: Anda-Maria Nicolae <anda-maria.nicolae@intel.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-06-13 04:06:44 +02:00
Uwe Kleine-König e31cd7824d power_supply: bq24257: use flags argument of devm_gpiod_get
Since 39b2bbe3d7 (gpio: add flags argument to gpiod_get*() functions)
which appeared in v3.17-rc1, the gpiod_get* functions take an additional
parameter that allows to specify direction and initial value for output.

Simplify driver accordingly. Furthermore this is one caller less that
stops us making the flags argument to gpiod_get*() mandatory.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-06-13 04:06:38 +02:00
Uwe Kleine-König 0007fa362a power_supply: bq25890: use flags argument of devm_gpiod_get
Since 39b2bbe3d7 (gpio: add flags argument to gpiod_get*() functions)
which appeared in v3.17-rc1, the gpiod_get* functions take an additional
parameter that allows to specify direction and initial value for output.

Simplify driver accordingly. Furthermore this is one caller less that
stops us making the flags argument to gpiod_get*() mandatory.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-06-13 04:06:33 +02:00
Frans Klaver f4ed950a63 sbs-battery: add option to always register battery
Commit a22b41a31e ("sbs-battery: Probe should try talking to the
device") introduced a step in probing the SBS battery, that tries to
talk to the device before actually registering it, saying:

    this driver doesn't actually try talking to the device at probe
    time, so if it's incorrectly configured in the device tree or
    platform data (or if the battery has been removed from the system),
    then probe will succeed and every access will sit there and time
    out. The end result is a possibly laggy system that thinks it has a
    battery but can never read status, which isn't very useful.

Which is of course reasonable. However, it is also very well possible
for a device to boot up on wall-power and be connected to a battery
later on. This is a scenario that the driver supported before said patch
was applied, and even easily achieved by booting up with the battery
attached and removing it later on. sbs-battery's 'present' sysfs file
can be used to determine if the device is available or not.

So with automated device detection lacking for now, in some cases it is
possible that one wants to register a battery, even if none are attached
at the moment. To facilitate this, add a module parameter that can be
used to configure forced loading module loading time. If set, the battery
will always be registered without checking the sanity of the connection.

Signed-off-by: Frans Klaver <frans.klaver@xsens.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-06-10 16:18:46 +02:00
Hans de Goede fe27e1dfe9 power: Add devm_power_supply_get_by_phandle() helper function
This commit adds a resource-managed version of the
power_supply_get_by_phandle() function.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-06-10 16:15:54 +02:00
Krzysztof Kozlowski a6e6b63ee2 power_supply: max17042: Add OF support for setting thresholds
The commit edd4ab0559 ("power: max17042_battery: add HEALTH and TEMP_*
properties support") added support for setting voltage and temperature
thresholds with platform data. For DeviceTree default of 0 was always
used.

This caused reporting battery health always as over voltage or
over heated.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Fixes: edd4ab0559 ("power: max17042_battery: add HEALTH and TEMP_* properties support")
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-06-10 16:14:03 +02:00
Krzysztof Kozlowski 5c6e3a97e9 power_supply: sysfs: Bring back write to writeable properties
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: 8e59c7f234 ("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>
2015-06-10 16:10:59 +02:00
Anda-Maria Nicolae fb323eccbc power_supply: rt9455_charger: Check if CONFIG_USB_PHY is enabled
If CONFIG_USB_PHY is not enabled, struct notifier_block is not defined and
compilation fails. Therefore, the functions that process USB event
notifications are defined only if CONFIG_USB_PHY is enabled.
There is no need to define these functions if CONFIG_USB_PHY is not
enabled, since no USB notifications are received in this case.
Also, since rt9455_set_boost_voltage_before_boost_mode() function is
called only if USB_EVENT_ID notification is received, this function should
also be defined only if CONFIG_USB_PHY is enabled.

Signed-off-by: Anda-Maria Nicolae <anda-maria.nicolae@intel.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-06-03 13:23:55 +02:00
Heiko Stübner bcd56fe1aa power: reset: gpio-restart: increase priority slightly
gpio-restart uses a priority of 128 and currently most soc-level restart
mechanisms use the same - with some exceptions even using 192.
But while the soc-level restarts are provided by the soc itself,
gpio-restarts will most of the time be board-specfic and be used
when some special board condition makes the soc-level restart
only a second choice.

The problem at hand manifested itself on the rk3288-veyron devices.
While the soc-level restart can sucessfully restart all other rockchip
boards I have, the veyron devices use an external restart mechanism that
seems to not only reset the soc but also some external needed components.

With both restart handlers having priority 128 in my tests the soc-specific
variant took precedent in all cases. While it could restart the soc
sucessfully in all cases, firmware then got an issue when talking to an
external component, resulting in the device being put into recovery mode.

So, give the board-specific restart handler a slight push and move it
to priority 129 to make it more important than the generic soc-specific
restart-handler.

Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-06-02 20:59:03 +02:00
Laurentiu Palcu 23fa43a28d power_supply: bq25890: make chip_id int
Smatch static checker correctly detected an impossible condition because
chip_id was declared as u8, instead of int:

drivers/power/bq25890_charger.c:843 bq25890_probe()
warn: impossible condition '(bq->chip_id < 0) => (0-255 < 0)'

Also, while at it, fix the return value too.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-06-02 20:58:19 +02:00
Anda-Maria Nicolae e86d69dd78 power_supply: Add support for Richtek RT9455 battery charger
Based on the datasheet found here:
http://www.richtek.com/download_ds.jsp?p=RT9455

Signed-off-by: Anda-Maria Nicolae <anda-maria.nicolae@intel.com>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski.k@gmail.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-05-30 03:34:55 +02:00
Takeshi Yoshimura a1cab5bb87 power_supply: 88pm860x_charger: Do not call free_irq() twice
My static checker detected double free_irq() in pm860x_charger_remove().
Unloading this module always causes a warning. This patch removes the
first redundant free_irq() call.

Signed-off-by: Takeshi Yoshimura <yos@sslab.ics.keio.ac.jp>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-05-29 16:06:10 +02:00
Thomas Elste cd054ee165 power: bq24190_charger: Change first_time flag reset condition
The initial register reset of BQ24190 generates a charger status change
whose propagation via power_supply_changed is prevented using a flag.
This flag gets never reset so all following events are ignored as well
leading for example to userspace not detecting charger connects/disconnects.

Therefor change the reset condition of first_time flag, so only the
propagation of the first charger status change is prevented.

Signed-off-by: Thomas Elste <thomas.elste@imms.de>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-05-29 04:26:50 +02:00
Ramakrishna Pallala 843735b788 power: axp288_charger: axp288 charger driver
This patch adds new power supply charger driver support
for X-Power AXP288 PMIC integrated charger.

This driver interfaces with the axp20x mfd driver as a cell
and listens to extcon cable events for setting up charging.

Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-05-24 10:32:24 +02:00
Ramakrishna Pallala edd4ab0559 power: max17042_battery: add HEALTH and TEMP_* properties support
This patch adds the support for following battery properties
to max17042 fuel gauge driver.

POWER_SUPPLY_PROP_TEMP_ALERT_MIN
POWER_SUPPLY_PROP_TEMP_ALERT_MAX
POWER_SUPPLY_PROP_TEMP_MIN
POWER_SUPPLY_PROP_TEMP_MAX
POWER_SUPPLY_PROP_HEALTH

Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski.k@gmail.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-05-23 22:43:28 +02:00
Laurentiu Palcu 4aeae9cb0d power_supply: Add support for TI BQ25890 charger chip
More details about the chip can be found here:
http://www.ti.com/product/bq25890

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@intel.com>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-05-23 21:31:26 +02:00
Krzysztof Kozlowski 4970d839aa power_supply: charger-manager: Add parent for power supply
The 'parent' argument passed to power_supply_register() is now used to
postpone callbacks to the driver until the driver's probe end.

Pass current device from charger-manager to utilize that. This will move
created power supply from virtual to platform devices.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-05-23 20:06:19 +02:00
Krzysztof Kozlowski a9f6a19b57 power_supply: Use wrappers to avoid races when registering power supply
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>
2015-05-23 20:06:19 +02:00
Uwe Kleine-König 9f6cd98fc3 power: reset: ltc2952: use _optional variant of devm_gpiod_get
devm_gpiod_get_optional returns NULL if devm_gpiod_get would return an
ENOENT error pointer.

There is no semantic change intended.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-05-23 20:03:42 +02:00
Uwe Kleine-König a34c0a8bf8 power: reset: gpio-poweroff: let devm_gpiod_get set direction of gpio
Since 39b2bbe3d7 (gpio: add flags argument to gpiod_get*() functions)
which appeared in v3.17-rc1, the gpiod_get* functions take an additional
parameter that allows to specify direction and initial value for output.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-05-23 20:03:30 +02:00
Anda-Maria Nicolae b01e7c3b80 power_supply: bq2415x_charger: Add ACPI support
Replace of_property_read_u32() with device_property_read_u32(), which is a
wrapper over ACPI and device tree enumeration methods.
When ACPI enumeration is used, automode is not supported. Therefore,
bq2415x_charger does not update its input current automatically, depending
on the USB port type that is connected to. Input current may be updated via
sysfs.

Signed-off-by: Anda-Maria Nicolae <anda-maria.nicolae@intel.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-05-23 20:03:00 +02:00
Anda-Maria Nicolae f6d8b7744f power_supply: bq2415x_charger: Fix coding style issues
This patch fixes the following issues reported by checkpatch.pl:
- use -EINVAL instead of -ENOSYS, to fix warning message:
  "ENOSYS means 'invalid syscall nr' and nothing else"
- remove unnecessary log message
- split lines whose length is greater than 80 characters
- if an arm statement uses braces, add braces to the other arms of the
  respective statement, too
- match alignment with open parenthesis

Signed-off-by: Anda-Maria Nicolae <anda-maria.nicolae@intel.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-05-23 20:02:59 +02:00
Krzysztof Kozlowski 3236672092 power: at91-reset: Constify platform_device_id
The platform_device_id is not modified by the driver and core uses it as
const.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski.k@gmail.com>
Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-05-23 19:44:23 +02:00
Krzysztof Kozlowski f1f27a4acf power: axp288_fuel_gauge: Constify platform_device_id
The platform_device_id is not modified by the driver and core uses it as
const.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski.k@gmail.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-05-23 19:44:14 +02:00
Laurentiu Palcu 2219a93596 power_supply: Add TI BQ24257 charger driver
Based on the datasheet found here:
http://www.ti.com/lit/ds/symlink/bq24257.pdf

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@intel.com>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski.k@gmail.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-05-23 18:54:34 +02:00
Krzysztof Kozlowski 7f1a57fdd6 power_supply: Fix possible NULL pointer dereference on early uevent
Don't call the power_supply_changed() from power_supply_register() when
parent is still probing because it may lead to accessing parent too
early.

In bq27x00_battery this caused NULL pointer exception because uevent of
power_supply_changed called back the the get_property() method provided
by the driver. The get_property() method accessed pointer which should
be returned by power_supply_register().

Starting from bq27x00_battery_probe():
  di->bat = power_supply_register()
    power_supply_changed()
      kobject_uevent()
        power_supply_uevent()
          power_supply_show_property()
            power_supply_get_property()
              bq27x00_battery_get_property()
                dereference of di->bat which is NULL here

The dereference of di->bat (value returned by power_supply_register())
is the currently visible problem. However calling back the methods
provided by driver before ending the probe may lead to accessing other
driver-related data which is not yet initialized.

The call to power_supply_changed() is postponed till probing ends -
mutex of parent device is released.

Reported-by: H. Nikolaus Schaller <hns@goldelico.com>
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Fixes: 297d716f62 ("power_supply: Change ownership from driver to core")
Tested-By: Dr. H. Nikolaus Schaller <hns@goldelico.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-05-21 15:41:09 +02:00
Krzysztof Kozlowski 8e59c7f234 power_supply: Fix NULL pointer dereference during bq27x00_battery probe
Power supply is often registered during probe of a driver. The
power_supply_register() returns pointer to newly allocated structure as
return value. However before returning the power_supply_register()
calls back the get_property() method provided by the driver through
uevent.

In that time the driver probe is still in progress and driver did not
assigned pointer to power supply to its local variables. This leads to
NULL pointer dereference from get_property() function.
Starting from bq27x00_battery_probe():
  di->bat = power_supply_register()
    device_add()
      kobject_uevent()
        power_supply_uevent()
          power_supply_show_property()
            power_supply_get_property()
              bq27x00_battery_get_property()
                dereference of (di->bat) which is NULL here

The first uevent of power supply (the one coming from device creation)
should not call back to the driver. To prevent that from happening,
increment the atomic use counter at the end of power_supply_register().
This means that power_supply_get_property() will return -ENODEV.

IMPORTANT:
The patch has impact on this first uevent sent from power supply because
it will not contain properties from power supply.

The uevent with properties will be sent later after indicating that
power supply has changed. This also has a race now, but will be fixed in
other patches.

Reported-by: H. Nikolaus Schaller <hns@goldelico.com>
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Fixes: 297d716f62 ("power_supply: Change ownership from driver to core")
Tested-By: Dr. H. Nikolaus Schaller <hns@goldelico.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-05-21 15:40:54 +02:00
Thomas Gleixner c3b5d3cea5 Merge branch 'linus' into timers/core
Make sure the upstream fixes are applied before adding further
modifications.
2015-05-19 16:12:32 +02:00
Marek Belisko 8ebb7e9c1a power: bq27x00_battery: Add missing MODULE_ALIAS
Without MODULE_ALIAS bq27x00_battery module won't get loaded automatically.

Signed-off-by: Marek Belisko <marek@goldelico.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-05-01 23:01:48 +02:00
Florian Fainelli 0a73125d30 power: reset: Add MFD_SYSCON depends for brcmstb
The Broadcom STB reboot driver depends on MFD_SYSCON, it uses
syscon_regmap_lookup_by_phandle() which will not lookup syscon phandles
if MFD_SYSCON is disabled, and instead will return -ENOSYS since it is
turned into an inline stub.

Fixes: 030494e750 ("power: reset: Add reboot driver for brcmstb")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-05-01 22:48:28 +02:00
Thomas Gleixner d8818257d3 power: reset: ltc2952: Remove bogus hrtimer_start() return value checks
The return value of hrtimer_start() tells whether the timer was
inactive or active already when hrtimer_start() was called.

The code emits a bogus warning if the timer was active already
claiming that the timer could not be started.

Remove it.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Sebastian Reichel <sre@kernel.org>
Cc: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Frans Klaver <frans.klaver@xsens.com>
Cc: "René Moll" <linux@r-moll.nl>
Cc: Wolfram Sang <wsa@the-dreams.de>
Cc: linux-pm@vger.kernel.org
Acked-by: Frans Klaver <frans.klaver@xsens.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-04-30 17:47:17 +02:00
Dmitry Eremin-Solenikov ce992369cf power_supply: fix oops in collie_battery driver
Fix an oops happening due to typo in 297d716f62
[power_supply: Change ownership from driver to core].

Unable to handle kernel NULL pointer dereference at virtual address 00000050
pgd = c0004000
[00000050] *pgd=00000000
Internal error: Oops: 17 [#1] ARM
Modules linked in:
CPU: 0 PID: 1 Comm: swapper Not tainted 4.1.0-rc1+ #35
Hardware name: Sharp-Collie
task: c381a720 ti: c381e000 task.ti: c381e000
PC is at collie_bat_get_property+0x10/0x258
LR is at collie_bat_get_property+0x10/0x258
pc : [<c0235d28>]    lr : [<c0235d28>]    psr: 20000013
sp : c381fd60  ip : 00000001  fp : 00000000
r10: c37b84c0  r9 : c068c9b8  r8 : c37b84a0
r7 : c37b84c0  r6 : c381fd84  r5 : 00000000  r4 : 00000000
r3 : c0369380  r2 : c381fd84  r1 : 00000000  r0 : 00000000
Flags: nzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment kernel
Control: 0000717f  Table: c3784000  DAC: 00000017
Process swapper (pid: 1, stack limit = 0xc381e190)
Stack: (0xc381fd60 to 0xc3820000)
fd60: c0369380 00000000 c37c0000 c068c9b8 c37b84c0 c0234380 00000000 c0234bc0
fd80: c042fcec c37b84a0 c0357c64 00000000 c37b84c0 c37c0000 c37b84a0 c0234e98
fda0: c37be020 00000000 ff0a0004 c37b84c8 c37be020 c37b84c0 c042fcec c383dbc0
fdc0: c0364060 00000000 00000000 c01be6a8 00000000 c015b220 c37b84c8 c381fdf0
fde0: c37b84c8 c37b84c8 c37b84c8 c37be020 c041e278 c015b478 c04a45b4 c0045290
fe00: c381a720 c0345d50 00000001 c37bf020 c0e511d8 c00453c0 c0688058 c37b84c8
fe20: 00000000 c37b84c0 c37780c0 c0e511d8 c38e2f60 c0e52d24 c04a45b4 c01be134
fe40: c37b8550 c37b8550 00000000 c0347a8c c37b84a0 00000000 c37b84c0 c0369380
fe60: c37780c0 00000001 00000061 c02347a0 00000001 c0e52e6c c068d144 c37b77a0
fe80: 00000000 c068d164 00000000 c0235b3c 00000000 c067fbb4 00000000 c068d1e4
fea0: 00000000 00000000 00000000 00000000 00000000 00000000 c37b77a0 c068d144
fec0: c3778020 c06953c0 c049de68 c01d5f54 c0688800 c3778020 c068d144 c0688700
fee0: c06953c0 c01d6000 c0675b80 c0675b80 c37b77a0 c0009624 c381a720 c000d8dc
ff00: 00000001 c381ff54 c048a500 c00453c0 c00095a0 20000153 ffffffff c000d8dc
ff20: c049cbd0 00000001 c04aa064 00000007 c04a9fb0 00000006 c06953c0 c06953c0
ff40: c048a590 c04a45c0 c04a9ffc 00000006 c06953c0 c06953c0 c048a590 c04a45c0
ff60: 00000061 c048adf8 00000006 00000006 c048a590 c0036450 00000001 00000000
ff80: c00363ec 00000000 c033ee7c 00000000 00000000 00000000 00000000 00000000
ffa0: 00000000 c033ee84 00000000 c000a3c8 00000000 00000000 00000000 00000000
ffc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
ffe0: 00000000 00000000 00000000 00000000 00000013 00000000 00000000 00000000
[<c0235d28>] (collie_bat_get_property) from [<c0234380>] (power_supply_get_property+0x1c/0x28)
[<c0234380>] (power_supply_get_property) from [<c0234bc0>] (power_supply_show_property+0x50/0x1dc)
[<c0234bc0>] (power_supply_show_property) from [<c0234e98>] (power_supply_uevent+0x9c/0x1cc)
[<c0234e98>] (power_supply_uevent) from [<c01be6a8>] (dev_uevent+0xb4/0x1d0)
[<c01be6a8>] (dev_uevent) from [<c015b478>] (kobject_uevent_env+0x1cc/0x4f8)
[<c015b478>] (kobject_uevent_env) from [<c01be134>] (device_add+0x374/0x524)
[<c01be134>] (device_add) from [<c02347a0>] (__power_supply_register+0x120/0x180)
[<c02347a0>] (__power_supply_register) from [<c0235b3c>] (collie_bat_probe+0xe8/0x1b4)
[<c0235b3c>] (collie_bat_probe) from [<c01d5f54>] (ucb1x00_add_dev+0x30/0x88)
[<c01d5f54>] (ucb1x00_add_dev) from [<c01d6000>] (ucb1x00_register_driver+0x54/0x78)
[<c01d6000>] (ucb1x00_register_driver) from [<c0009624>] (do_one_initcall+0x84/0x1f4)
[<c0009624>] (do_one_initcall) from [<c048adf8>] (kernel_init_freeable+0xf8/0x1b4)
[<c048adf8>] (kernel_init_freeable) from [<c033ee84>] (kernel_init+0x8/0xec)
[<c033ee84>] (kernel_init) from [<c000a3c8>] (ret_from_fork+0x14/0x2c)
Code: e92d40f8 e1a05001 e1a06002 ebfff9bc (e5903050)
---[ end trace 447ee06b251d66b2 ]---

Fixes: 297d716f62 ("power_supply: Change ownership from driver to core")
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-04-30 17:39:40 +02:00
Wei Yongjun 932df43005 power/reset: at91: fix return value check in at91_reset_platform_probe()
In case of error, the function devm_ioremap() returns NULL
not ERR_PTR(). The IS_ERR() test in the return value check
should be replaced with NULL test.

Fixes: ecfe64d8c5 ("power: reset: Add AT91 reset driver")
Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-04-30 17:33:52 +02:00
Ramakrishna Pallala 409e718e09 axp288_fuel_gauge: Add original author details
Add the original author details of the axp288_fuel_gauge driver.

Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
Acked-by: Todd Brandt <todd.e.brandt@linux.intel.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-04-30 17:19:55 +02:00
Thomas Gleixner 4101ecc23d power: reset: ltc2952: Remove bogus hrtimer_start() return value checks
The return value of hrtimer_start() tells whether the timer was
inactive or active already when hrtimer_start() was called.

The code emits a bogus warning if the timer was active already
claiming that the timer could not be started.

Remove it along with the bogus comment in the else path.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Frans Klaver <frans.klaver@xsens.com>
Cc: Sebastian Reichel <sre@kernel.org>
Cc: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Wolfram Sang <wsa@the-dreams.de>
Cc: linux-pm@vger.kernel.org
2015-04-23 14:38:01 +02:00
Marek Belisko 5939d9dfe4 power: twl4030_madc_battery: Add missing MODULE_ALIAS
Without MODULE_ALIAS twl4030_madc_battery won't get loaded automatically.

Signed-off-by: Marek Belisko <marek@goldelico.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-04-06 19:39:57 +02:00
Marek Belisko 7e5e43893d power: twl4030-madc-battery: Convert to iio consumer.
Because of added iio error handling private data allocation was converted
to managed to simplify code.

Signed-off-by: Marek Belisko <marek@goldelico.com>
Reviewed-By: Sebastian Reichel <sre@debian.org>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-04-06 19:18:43 +02:00
Moritz Fischer 8a577608ba power: reset: Add generic SYSCON register mapped poweroff.
Add a generic SYSCON register mapped poweroff mechanism.

Signed-off-by: Moritz Fischer <moritz.fischer@ettus.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-04-06 18:49:48 +02:00
Beomho Seo bbaeeaaf31 power: max17042_battery: add missed blank
This patch add missed blank line after decalations.

Signed-off-by: Beomho Seo <beomho.seo@samsung.com>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-04-06 17:46:46 +02:00
Beomho Seo 709c2c70c8 power: max17042_battery: Use reg type instead of chip type
Currently, max17042 battery driver choose register map by MAX17042_DevName
register. But it is return IC specific firmware version. So other maxim chip
hard to use this drvier. This patch choose chip type from driver_data.

Signed-off-by: Beomho Seo <beomho.seo@samsung.com>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-04-06 17:46:27 +02:00
Ben Dooks 7be5ac2c32 power/reset: at91: big endian fixes for atsama5d3x
Fix the passing of big endian data to routines that will be writing
it to the bus in the wrong order.

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-03-26 15:21:00 +01:00
Krzysztof Kozlowski ecf896b97d power_supply: charger-manager: Fix dereferencing of ERR_PTR
If power_supply_register() fails do not dereference returned ERR_PTR.
The pointer was dereferenced to print name of battery which registration
failed. Instead use the name from the power supply description passed to
the power_supply_register() function.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-03-24 13:40:14 +01:00
Fabian Frederick 8fb0885504 power: constify of_device_id array
of_device_id is always used as const.
(See driver.of_match_table and open firmware functions)

Signed-off-by: Fabian Frederick <fabf@skynet.be>

[for vexpress]
Acked-by: Sudeep Holla <sudeep.holla@arm.com>

Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-03-20 13:23:06 +01:00
Richard Weinberger 039ab50bda power/reset/rmobile-reset.c: Fix !HAS_IOMEM build
Fixes:
drivers/power/reset/rmobile-reset.c: In function ‘rmobile_reset_probe’:
drivers/power/reset/rmobile-reset.c:61:2: error: implicit declaration of function ‘iounmap’ [-Werror=implicit-function-declaration]
  iounmap(sysc_base2);

Signed-off-by: Richard Weinberger <richard@nod.at>
Acked-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-03-20 13:06:01 +01:00
Krzysztof Kozlowski c94a3d4032 power_supply: 88pm860x_charger: Fix possible NULL pointer dereference and use of initialized variable
Do not put reference to power supply in early exit paths of
pm860x_done_handler() because:
1. it is not yet initialized,
2. it is NULL.

This fixes possible NULL pointer dereference and following build
warning:
drivers/power/88pm860x_charger.c: In function ‘pm860x_done_handler’:
drivers/power/88pm860x_charger.c:516:18: warning: ‘psy’ may be used uninitialized in this function [-Wmaybe-uninitialized]

Additionally this puts the power supply reference before unlocking
mutex. This actually is not needed (there is no race here) but has
logical sense and makes the exit paths cleaner.

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-03-20 12:46:04 +01:00
Krzysztof Kozlowski 1a8dbe6f92 power_supply: bq2415x_charger: Decrement the power supply's device reference counter
Use power_supply_put() to decrement the power supply's device reference
counter (increased by power_supply_get_by_name() or
power_supply_get_by_phandle()).

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@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>
2015-03-13 23:15:54 +01:00
Krzysztof Kozlowski 52016ac072 power_supply: 88pm860x_charger: Decrement the power supply's device reference counter
Use power_supply_put() to decrement the power supply's device reference
counter.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@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>
2015-03-13 23:15:54 +01:00