aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/power (follow)
AgeCommit message (Collapse)AuthorFilesLines
2018-06-12treewide: devm_kzalloc() -> devm_kcalloc()Kees Cook2-14/+19
The devm_kzalloc() function has a 2-factor argument form, devm_kcalloc(). This patch replaces cases of: devm_kzalloc(handle, a * b, gfp) with: devm_kcalloc(handle, a * b, gfp) as well as handling cases of: devm_kzalloc(handle, a * b * c, gfp) with: devm_kzalloc(handle, array3_size(a, b, c), gfp) as it's slightly less ugly than: devm_kcalloc(handle, array_size(a, b), c, gfp) This does, however, attempt to ignore constant size factors like: devm_kzalloc(handle, 4 * 1024, gfp) though any constants defined via macros get caught up in the conversion. Any factors with a sizeof() of "unsigned char", "char", and "u8" were dropped, since they're redundant. Some manual whitespace fixes were needed in this patch, as Coccinelle really liked to write "=devm_kcalloc..." instead of "= devm_kcalloc...". The Coccinelle script used for this was: // Fix redundant parens around sizeof(). @@ expression HANDLE; type TYPE; expression THING, E; @@ ( devm_kzalloc(HANDLE, - (sizeof(TYPE)) * E + sizeof(TYPE) * E , ...) | devm_kzalloc(HANDLE, - (sizeof(THING)) * E + sizeof(THING) * E , ...) ) // Drop single-byte sizes and redundant parens. @@ expression HANDLE; expression COUNT; typedef u8; typedef __u8; @@ ( devm_kzalloc(HANDLE, - sizeof(u8) * (COUNT) + COUNT , ...) | devm_kzalloc(HANDLE, - sizeof(__u8) * (COUNT) + COUNT , ...) | devm_kzalloc(HANDLE, - sizeof(char) * (COUNT) + COUNT , ...) | devm_kzalloc(HANDLE, - sizeof(unsigned char) * (COUNT) + COUNT , ...) | devm_kzalloc(HANDLE, - sizeof(u8) * COUNT + COUNT , ...) | devm_kzalloc(HANDLE, - sizeof(__u8) * COUNT + COUNT , ...) | devm_kzalloc(HANDLE, - sizeof(char) * COUNT + COUNT , ...) | devm_kzalloc(HANDLE, - sizeof(unsigned char) * COUNT + COUNT , ...) ) // 2-factor product with sizeof(type/expression) and identifier or constant. @@ expression HANDLE; type TYPE; expression THING; identifier COUNT_ID; constant COUNT_CONST; @@ ( - devm_kzalloc + devm_kcalloc (HANDLE, - sizeof(TYPE) * (COUNT_ID) + COUNT_ID, sizeof(TYPE) , ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - sizeof(TYPE) * COUNT_ID + COUNT_ID, sizeof(TYPE) , ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - sizeof(TYPE) * (COUNT_CONST) + COUNT_CONST, sizeof(TYPE) , ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - sizeof(TYPE) * COUNT_CONST + COUNT_CONST, sizeof(TYPE) , ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - sizeof(THING) * (COUNT_ID) + COUNT_ID, sizeof(THING) , ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - sizeof(THING) * COUNT_ID + COUNT_ID, sizeof(THING) , ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - sizeof(THING) * (COUNT_CONST) + COUNT_CONST, sizeof(THING) , ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - sizeof(THING) * COUNT_CONST + COUNT_CONST, sizeof(THING) , ...) ) // 2-factor product, only identifiers. @@ expression HANDLE; identifier SIZE, COUNT; @@ - devm_kzalloc + devm_kcalloc (HANDLE, - SIZE * COUNT + COUNT, SIZE , ...) // 3-factor product with 1 sizeof(type) or sizeof(expression), with // redundant parens removed. @@ expression HANDLE; expression THING; identifier STRIDE, COUNT; type TYPE; @@ ( devm_kzalloc(HANDLE, - sizeof(TYPE) * (COUNT) * (STRIDE) + array3_size(COUNT, STRIDE, sizeof(TYPE)) , ...) | devm_kzalloc(HANDLE, - sizeof(TYPE) * (COUNT) * STRIDE + array3_size(COUNT, STRIDE, sizeof(TYPE)) , ...) | devm_kzalloc(HANDLE, - sizeof(TYPE) * COUNT * (STRIDE) + array3_size(COUNT, STRIDE, sizeof(TYPE)) , ...) | devm_kzalloc(HANDLE, - sizeof(TYPE) * COUNT * STRIDE + array3_size(COUNT, STRIDE, sizeof(TYPE)) , ...) | devm_kzalloc(HANDLE, - sizeof(THING) * (COUNT) * (STRIDE) + array3_size(COUNT, STRIDE, sizeof(THING)) , ...) | devm_kzalloc(HANDLE, - sizeof(THING) * (COUNT) * STRIDE + array3_size(COUNT, STRIDE, sizeof(THING)) , ...) | devm_kzalloc(HANDLE, - sizeof(THING) * COUNT * (STRIDE) + array3_size(COUNT, STRIDE, sizeof(THING)) , ...) | devm_kzalloc(HANDLE, - sizeof(THING) * COUNT * STRIDE + array3_size(COUNT, STRIDE, sizeof(THING)) , ...) ) // 3-factor product with 2 sizeof(variable), with redundant parens removed. @@ expression HANDLE; expression THING1, THING2; identifier COUNT; type TYPE1, TYPE2; @@ ( devm_kzalloc(HANDLE, - sizeof(TYPE1) * sizeof(TYPE2) * COUNT + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2)) , ...) | devm_kzalloc(HANDLE, - sizeof(TYPE1) * sizeof(THING2) * (COUNT) + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2)) , ...) | devm_kzalloc(HANDLE, - sizeof(THING1) * sizeof(THING2) * COUNT + array3_size(COUNT, sizeof(THING1), sizeof(THING2)) , ...) | devm_kzalloc(HANDLE, - sizeof(THING1) * sizeof(THING2) * (COUNT) + array3_size(COUNT, sizeof(THING1), sizeof(THING2)) , ...) | devm_kzalloc(HANDLE, - sizeof(TYPE1) * sizeof(THING2) * COUNT + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2)) , ...) | devm_kzalloc(HANDLE, - sizeof(TYPE1) * sizeof(THING2) * (COUNT) + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2)) , ...) ) // 3-factor product, only identifiers, with redundant parens removed. @@ expression HANDLE; identifier STRIDE, SIZE, COUNT; @@ ( devm_kzalloc(HANDLE, - (COUNT) * STRIDE * SIZE + array3_size(COUNT, STRIDE, SIZE) , ...) | devm_kzalloc(HANDLE, - COUNT * (STRIDE) * SIZE + array3_size(COUNT, STRIDE, SIZE) , ...) | devm_kzalloc(HANDLE, - COUNT * STRIDE * (SIZE) + array3_size(COUNT, STRIDE, SIZE) , ...) | devm_kzalloc(HANDLE, - (COUNT) * (STRIDE) * SIZE + array3_size(COUNT, STRIDE, SIZE) , ...) | devm_kzalloc(HANDLE, - COUNT * (STRIDE) * (SIZE) + array3_size(COUNT, STRIDE, SIZE) , ...) | devm_kzalloc(HANDLE, - (COUNT) * STRIDE * (SIZE) + array3_size(COUNT, STRIDE, SIZE) , ...) | devm_kzalloc(HANDLE, - (COUNT) * (STRIDE) * (SIZE) + array3_size(COUNT, STRIDE, SIZE) , ...) | devm_kzalloc(HANDLE, - COUNT * STRIDE * SIZE + array3_size(COUNT, STRIDE, SIZE) , ...) ) // Any remaining multi-factor products, first at least 3-factor products, // when they're not all constants... @@ expression HANDLE; expression E1, E2, E3; constant C1, C2, C3; @@ ( devm_kzalloc(HANDLE, C1 * C2 * C3, ...) | devm_kzalloc(HANDLE, - (E1) * E2 * E3 + array3_size(E1, E2, E3) , ...) | devm_kzalloc(HANDLE, - (E1) * (E2) * E3 + array3_size(E1, E2, E3) , ...) | devm_kzalloc(HANDLE, - (E1) * (E2) * (E3) + array3_size(E1, E2, E3) , ...) | devm_kzalloc(HANDLE, - E1 * E2 * E3 + array3_size(E1, E2, E3) , ...) ) // And then all remaining 2 factors products when they're not all constants, // keeping sizeof() as the second factor argument. @@ expression HANDLE; expression THING, E1, E2; type TYPE; constant C1, C2, C3; @@ ( devm_kzalloc(HANDLE, sizeof(THING) * C2, ...) | devm_kzalloc(HANDLE, sizeof(TYPE) * C2, ...) | devm_kzalloc(HANDLE, C1 * C2 * C3, ...) | devm_kzalloc(HANDLE, C1 * C2, ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - sizeof(TYPE) * (E2) + E2, sizeof(TYPE) , ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - sizeof(TYPE) * E2 + E2, sizeof(TYPE) , ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - sizeof(THING) * (E2) + E2, sizeof(THING) , ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - sizeof(THING) * E2 + E2, sizeof(THING) , ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - (E1) * E2 + E1, E2 , ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - (E1) * (E2) + E1, E2 , ...) | - devm_kzalloc + devm_kcalloc (HANDLE, - E1 * E2 + E1, E2 , ...) ) Signed-off-by: Kees Cook <keescook@chromium.org>
2018-06-12treewide: kzalloc() -> kcalloc()Kees Cook2-2/+2
The kzalloc() function has a 2-factor argument form, kcalloc(). This patch replaces cases of: kzalloc(a * b, gfp) with: kcalloc(a * b, gfp) as well as handling cases of: kzalloc(a * b * c, gfp) with: kzalloc(array3_size(a, b, c), gfp) as it's slightly less ugly than: kzalloc_array(array_size(a, b), c, gfp) This does, however, attempt to ignore constant size factors like: kzalloc(4 * 1024, gfp) though any constants defined via macros get caught up in the conversion. Any factors with a sizeof() of "unsigned char", "char", and "u8" were dropped, since they're redundant. The Coccinelle script used for this was: // Fix redundant parens around sizeof(). @@ type TYPE; expression THING, E; @@ ( kzalloc( - (sizeof(TYPE)) * E + sizeof(TYPE) * E , ...) | kzalloc( - (sizeof(THING)) * E + sizeof(THING) * E , ...) ) // Drop single-byte sizes and redundant parens. @@ expression COUNT; typedef u8; typedef __u8; @@ ( kzalloc( - sizeof(u8) * (COUNT) + COUNT , ...) | kzalloc( - sizeof(__u8) * (COUNT) + COUNT , ...) | kzalloc( - sizeof(char) * (COUNT) + COUNT , ...) | kzalloc( - sizeof(unsigned char) * (COUNT) + COUNT , ...) | kzalloc( - sizeof(u8) * COUNT + COUNT , ...) | kzalloc( - sizeof(__u8) * COUNT + COUNT , ...) | kzalloc( - sizeof(char) * COUNT + COUNT , ...) | kzalloc( - sizeof(unsigned char) * COUNT + COUNT , ...) ) // 2-factor product with sizeof(type/expression) and identifier or constant. @@ type TYPE; expression THING; identifier COUNT_ID; constant COUNT_CONST; @@ ( - kzalloc + kcalloc ( - sizeof(TYPE) * (COUNT_ID) + COUNT_ID, sizeof(TYPE) , ...) | - kzalloc + kcalloc ( - sizeof(TYPE) * COUNT_ID + COUNT_ID, sizeof(TYPE) , ...) | - kzalloc + kcalloc ( - sizeof(TYPE) * (COUNT_CONST) + COUNT_CONST, sizeof(TYPE) , ...) | - kzalloc + kcalloc ( - sizeof(TYPE) * COUNT_CONST + COUNT_CONST, sizeof(TYPE) , ...) | - kzalloc + kcalloc ( - sizeof(THING) * (COUNT_ID) + COUNT_ID, sizeof(THING) , ...) | - kzalloc + kcalloc ( - sizeof(THING) * COUNT_ID + COUNT_ID, sizeof(THING) , ...) | - kzalloc + kcalloc ( - sizeof(THING) * (COUNT_CONST) + COUNT_CONST, sizeof(THING) , ...) | - kzalloc + kcalloc ( - sizeof(THING) * COUNT_CONST + COUNT_CONST, sizeof(THING) , ...) ) // 2-factor product, only identifiers. @@ identifier SIZE, COUNT; @@ - kzalloc + kcalloc ( - SIZE * COUNT + COUNT, SIZE , ...) // 3-factor product with 1 sizeof(type) or sizeof(expression), with // redundant parens removed. @@ expression THING; identifier STRIDE, COUNT; type TYPE; @@ ( kzalloc( - sizeof(TYPE) * (COUNT) * (STRIDE) + array3_size(COUNT, STRIDE, sizeof(TYPE)) , ...) | kzalloc( - sizeof(TYPE) * (COUNT) * STRIDE + array3_size(COUNT, STRIDE, sizeof(TYPE)) , ...) | kzalloc( - sizeof(TYPE) * COUNT * (STRIDE) + array3_size(COUNT, STRIDE, sizeof(TYPE)) , ...) | kzalloc( - sizeof(TYPE) * COUNT * STRIDE + array3_size(COUNT, STRIDE, sizeof(TYPE)) , ...) | kzalloc( - sizeof(THING) * (COUNT) * (STRIDE) + array3_size(COUNT, STRIDE, sizeof(THING)) , ...) | kzalloc( - sizeof(THING) * (COUNT) * STRIDE + array3_size(COUNT, STRIDE, sizeof(THING)) , ...) | kzalloc( - sizeof(THING) * COUNT * (STRIDE) + array3_size(COUNT, STRIDE, sizeof(THING)) , ...) | kzalloc( - sizeof(THING) * COUNT * STRIDE + array3_size(COUNT, STRIDE, sizeof(THING)) , ...) ) // 3-factor product with 2 sizeof(variable), with redundant parens removed. @@ expression THING1, THING2; identifier COUNT; type TYPE1, TYPE2; @@ ( kzalloc( - sizeof(TYPE1) * sizeof(TYPE2) * COUNT + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2)) , ...) | kzalloc( - sizeof(TYPE1) * sizeof(THING2) * (COUNT) + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2)) , ...) | kzalloc( - sizeof(THING1) * sizeof(THING2) * COUNT + array3_size(COUNT, sizeof(THING1), sizeof(THING2)) , ...) | kzalloc( - sizeof(THING1) * sizeof(THING2) * (COUNT) + array3_size(COUNT, sizeof(THING1), sizeof(THING2)) , ...) | kzalloc( - sizeof(TYPE1) * sizeof(THING2) * COUNT + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2)) , ...) | kzalloc( - sizeof(TYPE1) * sizeof(THING2) * (COUNT) + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2)) , ...) ) // 3-factor product, only identifiers, with redundant parens removed. @@ identifier STRIDE, SIZE, COUNT; @@ ( kzalloc( - (COUNT) * STRIDE * SIZE + array3_size(COUNT, STRIDE, SIZE) , ...) | kzalloc( - COUNT * (STRIDE) * SIZE + array3_size(COUNT, STRIDE, SIZE) , ...) | kzalloc( - COUNT * STRIDE * (SIZE) + array3_size(COUNT, STRIDE, SIZE) , ...) | kzalloc( - (COUNT) * (STRIDE) * SIZE + array3_size(COUNT, STRIDE, SIZE) , ...) | kzalloc( - COUNT * (STRIDE) * (SIZE) + array3_size(COUNT, STRIDE, SIZE) , ...) | kzalloc( - (COUNT) * STRIDE * (SIZE) + array3_size(COUNT, STRIDE, SIZE) , ...) | kzalloc( - (COUNT) * (STRIDE) * (SIZE) + array3_size(COUNT, STRIDE, SIZE) , ...) | kzalloc( - COUNT * STRIDE * SIZE + array3_size(COUNT, STRIDE, SIZE) , ...) ) // Any remaining multi-factor products, first at least 3-factor products, // when they're not all constants... @@ expression E1, E2, E3; constant C1, C2, C3; @@ ( kzalloc(C1 * C2 * C3, ...) | kzalloc( - (E1) * E2 * E3 + array3_size(E1, E2, E3) , ...) | kzalloc( - (E1) * (E2) * E3 + array3_size(E1, E2, E3) , ...) | kzalloc( - (E1) * (E2) * (E3) + array3_size(E1, E2, E3) , ...) | kzalloc( - E1 * E2 * E3 + array3_size(E1, E2, E3) , ...) ) // And then all remaining 2 factors products when they're not all constants, // keeping sizeof() as the second factor argument. @@ expression THING, E1, E2; type TYPE; constant C1, C2, C3; @@ ( kzalloc(sizeof(THING) * C2, ...) | kzalloc(sizeof(TYPE) * C2, ...) | kzalloc(C1 * C2 * C3, ...) | kzalloc(C1 * C2, ...) | - kzalloc + kcalloc ( - sizeof(TYPE) * (E2) + E2, sizeof(TYPE) , ...) | - kzalloc + kcalloc ( - sizeof(TYPE) * E2 + E2, sizeof(TYPE) , ...) | - kzalloc + kcalloc ( - sizeof(THING) * (E2) + E2, sizeof(THING) , ...) | - kzalloc + kcalloc ( - sizeof(THING) * E2 + E2, sizeof(THING) , ...) | - kzalloc + kcalloc ( - (E1) * E2 + E1, E2 , ...) | - kzalloc + kcalloc ( - (E1) * (E2) + E1, E2 , ...) | - kzalloc + kcalloc ( - E1 * E2 + E1, E2 , ...) ) Signed-off-by: Kees Cook <keescook@chromium.org>
2018-06-09Merge tag 'for-v4.18' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supplyLinus Torvalds14-398/+137
Pull power supply and reset updates from Sebastian Reichel: - bq27xxx: Add BQ27426 support - ab8500: Drop AB8540/9540 support - Introduced new usb_type property - Properly document the power-supply ABI - misc. cleanups and fixes * tag 'for-v4.18' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply: MAINTAINERS: add entry for LEGO MINDSTORMS EV3 power: supply: ab8500_charger: fix spelling mistake: "faile" -> "failed" power: supply: axp288_fuel_gauge: Remove polling from the driver power: supply: axp288_fuelguage: Do not bind when the fg function is not used power: supply: axp288_charger: Do not bind when the charge function is not used power: supply: axp288_charger: Support 3500 and 4000 mA input current limit power: supply: s3c-adc-battery: fix driver data initialization power: supply: charger-manager: Verify polling interval only when polling requested power: supply: sysfs: Use enum to specify property power: supply: ab8500: Drop AB8540/9540 support power: supply: ab8500_fg: fix spelling mistake: "Disharge" -> "Discharge" power: supply: simplify getting .drvdata power: supply: bq27xxx: Add support for BQ27426 gpio-poweroff: Use gpiod_set_value_cansleep
2018-06-05Merge tag 'usb-4.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usbLinus Torvalds2-2/+58
Pull USB and PHY updates from Greg KH: "Here is the big USB pull request for 4.18-rc1. Lots of stuff here, the highlights are: - phy driver updates and new additions - usual set of xhci driver updates - normal set of musb updates - gadget driver updates and new controllers - typec work, it's getting closer to getting fully out of the staging portion of the tree. - lots of minor cleanups and bugfixes. All of these have been in linux-next for a while with no reported issues" * tag 'usb-4.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (263 commits) Revert "xhci: Reset Renesas uPD72020x USB controller for 32-bit DMA issue" xhci: Add quirk to zero 64bit registers on Renesas PCIe controllers xhci: Allow more than 32 quirks usb: xhci: force all memory allocations to node selftests: add test for USB over IP driver USB: typec: fsusb302: no need to check return value of debugfs_create_dir() USB: gadget: udc: s3c2410_udc: no need to check return value of debugfs_create functions USB: gadget: udc: renesas_usb3: no need to check return value of debugfs_create functions USB: gadget: udc: pxa27x_udc: no need to check return value of debugfs_create functions USB: gadget: udc: gr_udc: no need to check return value of debugfs_create functions USB: gadget: udc: bcm63xx_udc: no need to check return value of debugfs_create functions USB: udc: atmel_usba_udc: no need to check return value of debugfs_create functions USB: dwc3: no need to check return value of debugfs_create functions USB: dwc2: no need to check return value of debugfs_create functions USB: core: no need to check return value of debugfs_create functions USB: chipidea: no need to check return value of debugfs_create functions USB: ehci-hcd: no need to check return value of debugfs_create functions USB: fhci-hcd: no need to check return value of debugfs_create functions USB: fotg210-hcd: no need to check return value of debugfs_create functions USB: imx21-hcd: no need to check return value of debugfs_create functions ...
2018-05-24power: supply: Add fwnode pointer to power_supply_config structAdam Thomson1-1/+3
To allow users of the power supply framework to be hw description agnostic, this commit adds the ability to pass a fwnode pointer, via the power_supply_config structure, to the initialisation code of the core, instead of explicitly specifying of_ndoe. If that fwnode pointer is provided then it will automatically resolve down to of_node on platforms which support it, otherwise it will be NULL. In the future, when ACPI support is added, this can be modified to accommodate ACPI without the need to change calling code which already provides the fwnode handle in this manner. Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com> Suggested-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-17PM / AVS: rockchip-io: add io selectors and supplies for PX30David Wu1-0/+68
This adds the necessary data for handling io voltage domains on PX30. As interesting tidbit, the PX30 contains two separate iodomain areas. One in the regular General Register Files (GRF) and one in PMUGRF in the pmu power domain. Signed-off-by: David Wu <david.wu@rock-chips.com> Reviewed-by: Heiko Stuebner <heiko@sntech.de> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2018-05-01power: supply: ab8500_charger: fix spelling mistake: "faile" -> "failed"Colin Ian King1-1/+1
trivial fix to spelling mistake in dev_error message. Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-04-26Merge tag 'tags/tcpm-pps-4.18' into psy-nextSebastian Reichel2-1/+56
Tag/Merge point for adding typeC power supply support This is a signed tag/merge point to handle the cross-tree merge of the USB and power supply subsystems for the patch series: Subject: [PATCH v8 0/6] typec: tcpm: Add sink side support for PPS It is based on the usb.git tree, in the usb-next branch, for merging in 4.18-rc1. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-04-26power: supply: axp288_fuel_gauge: Remove polling from the driverHans de Goede1-16/+0
Userspace class/power_supply consumers such as upower, already know some supplies need to be polled to get up2date info. Doing this in the kernel and then waking up userspace just causes unnecessary wakeups and i2c transfers. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-04-26power: supply: axp288_fuelguage: Do not bind when the fg function is not usedHans de Goede1-0/+11
Some devices with an AXP288 PMIC do not have a battery at all, or use external charger and fuelgauge ICs instead of the AXP288 builtin functionality. On such devices we should not bind to the fuelgauge function to avoid exporting a non working power_supply class device. This also avoids the following errors repeating over and over again in dmesg: axp288_fuel_gauge axp288_fuel_gauge: capacity measurement not valid axp288_fuel_gauge axp288_fuel_gauge: Error 0xe2 contents not valid power_supply axp288_fuel_gauge: driver failed to report 'charge_now' property: -6 Cc: Carlo Caione <carlo@endlessm.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-04-26power: supply: axp288_charger: Do not bind when the charge function is not usedHans de Goede1-0/+12
Some devices with an AXP288 PMIC do not have a battery at all, or use external charger and fuelgauge ICs instead of the AXP288 builtin functionality. On such devices we should not bind to the charge function to avoid exporting a non working power_supply class device. Cc: Carlo Caione <carlo@endlessm.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-04-26power: supply: axp288_charger: Support 3500 and 4000 mA input current limitHans de Goede1-3/+11
The AXP288 supports an input-current-limit of up to 4000 mA, this commit adds support for the 3500 and 4000 mA settings which were missing until now. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-04-26power: supply: s3c-adc-battery: fix driver data initializationSergiy Kibrik1-3/+5
For power_supply_get_drvdata() routine to work correctly the driver data has to be provided when registering power supply, otherwise driver gives up immediately with these errors: power_supply main-battery: no battery infos ?! power_supply main-battery: driver failed to report `status' property: -22 Signed-off-by: Sergiy Kibrik <sakib@darkstar.site> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-04-26power: supply: charger-manager: Verify polling interval only when polling requestedLadislav Michl1-2/+3
Driver bails out with -EINVAL when no polling specififaion is requested. Fix that by verifing polling interval only if polling_mode is different from CM_POLL_DISABLE. Signed-off-by: Ladislav Michl <ladis@linux-mips.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-04-25power: supply: sysfs: Use enum to specify propertyLadislav Michl1-33/+44
Power supply property is in fact enum, so reflect it in code. Also use switch statement in show property function as is done for storing property. Signed-off-by: Ladislav Michl <ladis@linux-mips.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-04-25power: supply: ab8500: Drop AB8540/9540 supportLinus Walleij5-331/+30
The AB8540 was an evolved version of the AB8500, but it was never mass produced or put into products, only reference designs exist. The upstream support was never completed and it is unlikely that this will happen so drop the support for now to simplify maintenance of the AB8500. Cc: Loic Pallardy <loic.pallardy@st.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Acked-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-04-25power: supply: ab8500_fg: fix spelling mistake: "Disharge" -> "Discharge"Colin Ian King1-1/+1
Trivial fix to spelling mistake in dev_dbg message text Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-04-25power: supply: simplify getting .drvdataWolfram Sang1-2/+1
We should get drvdata from struct device directly. Going via platform_device is an unneeded step back and forth. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-04-25power: supply: bq27xxx: Add support for BQ27426Andrew F. Davis2-0/+11
This device is software similar to the BQ27426 except it has different data memory offsets. Add support here. Signed-off-by: Andrew F. Davis <afd@ti.com> Acked-by: Pali Rohár <pali.rohar@gmail.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-04-25gpio-poweroff: Use gpiod_set_value_cansleepMike Looijmans1-2/+2
The power-off call is done in a context that must be able to sleep, so use gpiod_set_value_cansleep instead of the atomic gpiod_set_value call. This fixes a kernel warning at shutdown when the gpio is controlled through an IO expander for example. Signed-off-by: Mike Looijmans <mike.looijmans@topic.nl> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-04-25power: supply: Add 'usb_type' property and supporting codeAdam Thomson2-1/+52
This commit adds the 'usb_type' property to represent USB supplies which can report a number of different types based on a connection event. Examples of this already exist in drivers whereby the existing 'type' property is updated, based on an event, to represent what was connected (e.g. USB, USB_DCP, USB_ACA, ...). Current implementations however don't show all supported connectable types, so this knowledge has to be exlicitly known for each driver that supports this. The 'usb_type' property is intended to fill this void and show users all possible USB types supported by a driver. The property, when read, shows all available types for the driver, and the one currently chosen is highlighted/bracketed. It is expected that the 'type' property would then just show the top-level type 'USB', and this would be static. Currently the 'usb_type' enum contains all of the USB variant types that exist for the 'type' enum at this time, and in addition has SDP and PPS types. The mirroring is intentional so as to not impact existing usage of the 'type' property. Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-04-25power: supply: Add error checking of psy desc during registrationAdam Thomson1-0/+3
Currently there's no error checking of this parameter in the registration function and it's blindly added to psy class and subsequently used as is. For example if this is NULL the call to psy_register_thermal() will try to dereference the pointer thus causing a kernel dump. This commit updates the registration code to add some basic checks on the desc pointer validity, name, and presence of properties. Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-04-05Merge tag 'armsoc-soc' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-socLinus Torvalds1-7/+34
Pull ARM SoC platform updates from Arnd Bergmann: "This release brings up a new platform based on the old ARM9 core: the Nuvoton NPCM is used as a baseboard management controller, competing with the better known ASpeed AST2xx series. Another important change is the addition of ARMv7-A based chips in mach-stm32. The older parts in this platform are ARMv7-M based microcontrollers, now they are expanding to general-purpose workloads. The other changes are the usual defconfig updates to enable additional drivers, lesser bugfixes. The largest updates as often are the ongoing OMAP cleanups, but we also have a number of changes for the older PXA and davinci platforms this time. For the Renesas shmobile/r-car platform, some new infrastructure is needed to make the watchdog work correctly. Supporting Multiprocessing on Allwinner A80 required a significant amount of new code, but is not doing anything unexpected" * tag 'armsoc-soc' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc: (179 commits) arm: npcm: modify configuration for the NPCM7xx BMC. MAINTAINERS: update entry for ARM/berlin ARM: omap2: fix am43xx build without L2X0 ARM: davinci: da8xx: simplify CFGCHIP regmap_config ARM: davinci: da8xx: fix oops in USB PHY driver due to stack allocated platform_data ARM: multi_v7_defconfig: add NXP FlexCAN IP support ARM: multi_v7_defconfig: enable thermal driver for i.MX devices ARM: multi_v7_defconfig: add RN5T618 PMIC family support ARM: multi_v7_defconfig: add NXP graphics drivers ARM: multi_v7_defconfig: add GPMI NAND controller support ARM: multi_v7_defconfig: add OCOTP driver for NXP SoCs ARM: multi_v7_defconfig: configure I2C driver built-in arm64: defconfig: add CONFIG_UNIPHIER_THERMAL and CONFIG_SNI_AVE ARM: imx: fix imx6sll-only build ARM: imx: select ARM_CPU_SUSPEND for CPU_IDLE as well ARM: mxs_defconfig: Re-sync defconfig ARM: imx_v4_v5_defconfig: Use the generic fsl-asoc-card driver ARM: imx_v4_v5_defconfig: Re-sync defconfig arm64: defconfig: enable stmmac ethernet to defconfig ARM: EXYNOS: Simplify code in coupled CPU idle hot path ...
2018-04-03Merge tag 'for-v4.17' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supplyLinus Torvalds16-197/+478
Pull power supply and reset updates from Sebastian Reichel: - Microsemi Ocelot reset support - Spreadtrum SC27xx reset support - generic gpio charger: lot's of cleanups - axp20x fuel gauge: add AXP813 support - misc fixes, including one devicetree change for the Nokia N900, that has been Acked-by Tony Lindgren * tag 'for-v4.17' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply: (27 commits) power: reset: at91-reset: Switch from the pr_*() to the dev_*() logging functions power: reset: at91-poweroff: Remove redundant dev_err call in at91_poweroff_probe() power: reset: at91-poweroff: Switch from the pr_*() to the dev_*() logging functions power: reset: make function sc27xx_poweroff_shutdown static power: supply: da9150-fg: remove VLA usage ARM: dts: omap3-n900: Add link between battery and charger power: supply: bq2415x: add DT referencing support power: supply: bq27xxx: support missing supplier device max17042: propagate of_node to power supply device power: supply: axp288_fuel_gauge: Fix full status reporting power: supply: axp288_fuel_gauge: Do not register FG on ECS EF20EA power: reset: gpio-poweroff: Support for timeout from device property dt-bindings: power: reset: gpio-poweroff: Add 'timeout-ms' property power: reset: Add Spreadtrum SC27xx PMIC power off support power: supply: axp20x_battery: add support for AXP813 dt-bindings: power: supply: axp20x: add AXP813 battery DT binding power: supply: axp20x_battery: use data struct for variant specific code power: supply: gpio-charger: Remove pdata from gpio_charger power: supply: gpio-charger: Use GPIOF_ACTIVE_LOW for legacy setup power: supply: gpio-charger: Remove redundant dev_err call in probe function ...
2018-03-19power: reset: at91-reset: Switch from the pr_*() to the dev_*() logging functionsLadislav Michl1-2/+2
Use dev_info() instead of pr_info(). Signed-off-by: Ladislav Michl <ladis@linux-mips.org> Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-03-19power: reset: at91-poweroff: Remove redundant dev_err call in at91_poweroff_probe()Ladislav Michl1-3/+1
There is an error message within devm_ioremap_resource already, so remove the dev_err call to avoid redundancy. Signed-off-by: Ladislav Michl <ladis@linux-mips.org> Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-03-19power: reset: at91-poweroff: Switch from the pr_*() to the dev_*() logging functionsLadislav Michl1-4/+6
Use dev_info() instead of pr_info(). Signed-off-by: Ladislav Michl <ladis@linux-mips.org> Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-03-13power: reset: make function sc27xx_poweroff_shutdown staticColin Ian King1-1/+1
The function sc27xx_poweroff_shutdown is local to the source and does not need to be in global scope, so make it static. Cleans up sparse warning: drivers/power/reset/sc27xx-poweroff.c:28:6: warning: symbol 'sc27xx_poweroff_shutdown' was not declared. Should it be static? Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-03-12Merge branch 'fixes' into for-nextSebastian Reichel4-18/+23
Merge for-stable fixes branch into for-next development branch. Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-03-12power: supply: da9150-fg: remove VLA usageGustavo A. R. Silva1-2/+2
In preparation to enabling -Wvla, remove VLA usage and replace it with fixed-length arrays. DA9150_QIF_LONG_SIZE (4 bytes) is the biggest size of an attribute which can be accessed [1]. Fixed as part of the directive to remove all VLAs from the kernel: https://lkml.org/lkml/2018/3/7/621 [1] https://marc.info/?l=kernel-hardening&m=152059600524753&w=2 Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com> Acked-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-03-12power: supply: bq2415x: add DT referencing supportSebastian Reichel1-1/+4
Add support for using bq2415x together with power_supply_am_i_supplied(). Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-03-12power: supply: bq27xxx: support missing supplier deviceSebastian Reichel1-1/+1
power_supply_am_i_supplied() can return negative error codes. In this case we should assume, that no charger is connected and the battery should be marked as DISCHARGING instead of NOT_CHARGING. Reported-by: Merlijn Wajer <merlijn@wizzup.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-03-12max17042: propagate of_node to power supply devicePierre Bourdon1-0/+1
max17042_get_status uses the core power_supply_am_i_supplied. That function relies on DT properties to figure out the power supply topology, and will error out without DT. Fixes max17042 battery status being reported as "unknown". Signed-off-by: Pierre Bourdon <delroth@google.com> Signed-off-by: Andre Heider <a.heider@gmail.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-03-09power: supply: axp288_fuel_gauge: Fix full status reportingHans de Goede1-12/+35
Commit 2b5a4b4bf222 ("power: supply: axp288_fuel_gauge: Rework get_status()"), switched from 0A current detection to using the capacity register for full detection. It turns out this fixes full reporting on some devices which keep trickle charging long after the capacity register reach 100%, but breaks it on some other devices where the charger stops charging before the capacity register reaches 100%. This commit fixes this by also checking for 0A current when the reported capacity is above 90%. Fixes: 2b5a4b4bf222 ("psy: axp288_fuel_gauge: Rework get_status()") Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-03-09power: supply: axp288_fuel_gauge: Do not register FG on ECS EF20EACarlo Caione1-0/+6
The ECS EF20EA laptop ships an AXP288 but it is actually using a different, separate FG chip for AC and battery monitoring. On this laptop we need to keep using the regular ACPI driver and disable the AXP288 FG to avoid reporting two batteries to userspace. Signed-off-by: Carlo Caione <carlo@endlessm.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-03-09power: reset: gpio-poweroff: Support for timeout from device propertyMoritz Fischer1-2/+6
Add support for reading a timeout value from device property. Fall back to previous default of 3s if nothing is specified. Signed-off-by: Moritz Fischer <mdf@kernel.org> Signed-off-by: Sebastian Reichel <sre@kernel.org>
2018-03-09power: reset: Add Spreadtrum SC27xx PMIC power off supportBaolin Wang3-0/+76
On Spreadtrum platform, we need power off system through external SC27xx series PMICs including the SC2720, SC2721, SC2723, SC2730 and SC2731 chips. Thus this patch adds SC27xx series PMICs power-off support. Signed-off-by: Baolin Wang <baolin.wang@linaro.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-03-09power: supply: axp20x_battery: add support for AXP813Quentin Schulz1-0/+42
The X-Powers AXP813 PMIC has got some slight differences from AXP20X/AXP22X PMICs: - the maximum voltage supplied by the PMIC is 4.35 instead of 4.36/4.24 for AXP20X/AXP22X, - the constant charge current formula is different, It also has a bit to tell whether the battery percentage returned by the PMIC is valid. Signed-off-by: Quentin Schulz <quentin.schulz@bootlin.com> Reviewed-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-03-09power: supply: axp20x_battery: use data struct for variant specific codeQuentin Schulz1-35/+67
We used to use IDs to select a function or a feature depending on the variant. It's easier to maintain the code by adding data structure storing the few differences between variants so that we don't add a pile of if conditions. Let's use this data structure and update the code to use it. Signed-off-by: Quentin Schulz <quentin.schulz@bootlin.com> Reviewed-by: Chen-Yu Tsai <wens@csie.org> [updated POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN write property to use the introduced set_max_voltage() callback] Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-03-09power: supply: gpio-charger: Remove pdata from gpio_chargerLadislav Michl1-54/+41
Platform data are now used only during probe time, so remove them from gpio_charger structure and consolidate probing function accordingly. Signed-off-by: Ladislav Michl <ladis@linux-mips.org> [Replace of_property_read_string with dev_property_read_string] Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-03-09power: supply: gpio-charger: Use GPIOF_ACTIVE_LOW for legacy setupLadislav Michl1-9/+8
Setting GPIOF_ACTIVE_LOW flag based on platform data gpio_active_low makes return value of gpiod_get_value_cansleep directly usable. Signed-off-by: Ladislav Michl <ladis@linux-mips.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-03-09power: supply: gpio-charger: Remove redundant dev_err call in probe functionLadislav Michl1-3/+1
There is an error message within devm_kzalloc already. Signed-off-by: Ladislav Michl <ladis@linux-mips.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-02-28PM / AVS: SmartReflex: Prepare to use device tree based probingTony Lindgren1-7/+34
We are currently probing smartreflex with omap_device while we are already probing smartreflex related interconnect target module with ti-sysc driver and dts data. Before we can flip things on for ti-sysc, we need to prepare the smartreflex driver a bit: 1. The smartreflex clock is really for the whole interconnect target module. So it may be configured at the parent device level with ti-sysc 2. With ti-sysc, we have the child device manage interconnect target module directly if pm_runtime_irq_safe() is set and there is only one child. In that case nobody else is going to call pm_runtime_get and put, so we need to add these calls to idle smartreflex properly after probe if not fully configured 3. With ti-sysc, the parent driver may rebind. So we want to use platform_driver_register() and don't want probe to be __init Note that this patch depends on the related changes to ti-sysc driver and omap_device probing to prevent both ti-sysc and omap_device to try to probe smartreflex. Cc: linux-pm@vger.kernel.org Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Acked-by: Kevin Hilman <khilman@baylibre.com> Signed-off-by: Tony Lindgren <tony@atomide.com>
2018-02-22power: gemini-poweroff: Avoid spurious poweroffLinus Walleij1-13/+17
On the D-Link DIR-685 we get spurious poweroff from infrared. Since that block (CIR) doesn't even have a driver this can be safely ignored, we can revisit this code once we have a device supporting CIR. On the D-Link DNS-313 we get spurious poweroff from the power button. This appears to be an initialization issue: we need to enable the block (start the state machine) before we clear any dangling IRQ. This patch fixes both issues. Fixes: f7a388d6cd1c ("power: reset: Add a driver for the Gemini poweroff") Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-02-22power: supply: ltc2941-battery-gauge: Fix temperature unitsLadislav Michl1-4/+4
Temperature is measured in tenths of degree Celsius. Fixes: 085bc24d1553 ("Add LTC2941/LTC2943 Battery Gauge Driver") Signed-off-by: Ladislav Michl <ladis@linux-mips.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-02-21power: add to_power_supply macro to the APIOgnjen Galic3-11/+1
This patch adds the to_power_supply macro to upcast a device to a power_supply struct. This is needed because the same piece of code using container_of is used in various other places, so we abstract away such low-level operations via a macro. Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Ognjen Galic <smclt30p@gmail.com> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2018-02-13power: supply: gpio-charger: use helper variable to access device infoLadislav Michl1-22/+20
Using explicit struct device variable makes code a bit more readable. Signed-off-by: Ladislav Michl <ladis@linux-mips.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-02-13power: supply: gpio-charger: Drop driver remove functionLadislav Michl1-36/+7
Simplify error unwinding using devm_* allocators. This also makes driver remove function empty, so remove it. Signed-off-by: Ladislav Michl <ladis@linux-mips.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-02-12power: supply: ltc2941-battery-gauge: Add charge empty and full propertiesLadislav Michl1-9/+50
Add properties for charge empty and charge full thresholds. Signed-off-by: Ladislav Michl <ladis@linux-mips.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-02-12power: reset: Add a driver for the Microsemi Ocelot resetAlexandre Belloni3-0/+96
The Microsemi Ocelot SoC has a register allowing to reset the MIPS core. Unfortunately, the syscon-reboot driver can't be used directly (but almost) as the reset control may be disabled using another register. Cc: linux-pm@vger.kernel.org Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>