[PATCH RESEND] media: atomisp: do not select COMMON_CLK to fix builds
From: Krzysztof Kozlowski COMMON_CLK is a user-selectable option with its own dependencies. The most important dependency is !HAVE_LEGACY_CLK. User-selectable drivers should not select COMMON_CLK because they will create a dependency cycle and build failures. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Stephen Boyd --- drivers/staging/media/atomisp/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/media/atomisp/Kconfig b/drivers/staging/media/atomisp/Kconfig index 37577bb72998..742edb261d85 100644 --- a/drivers/staging/media/atomisp/Kconfig +++ b/drivers/staging/media/atomisp/Kconfig @@ -2,9 +2,9 @@ menuconfig INTEL_ATOMISP bool "Enable support to Intel Atom ISP camera drivers" depends on X86 && EFI && PCI && ACPI + depends on COMMON_CLK select IOSF_MBI select MEDIA_CONTROLLER - select COMMON_CLK help Enable support for the Intel ISP2 camera interfaces and MIPI sensor drivers. -- 2.25.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 0/3] clk/sunxi/media: Fix builds with COMMON_CLK and HAVE_LEGACY_CLK
Hi, Multiple configurations create unbuildable config by selecting COMMON_CLK and HAVE_LEGACY_CLK. The first simply should not be selected. The patches 2/3 and 3/3 address this specific problem. I performed few compile tests and I am still building other configurations, therefore they were marked as RFC. Best regards, Krzysztof Krzysztof Kozlowski (3): clk: fix redefinition of clk_prepare on MIPS with HAVE_LEGACY_CLK ARM: sunxi: do not select COMMON_CLK to fix builds media: atomisp: do not select COMMON_CLK to fix builds arch/arm/mach-sunxi/Kconfig | 1 + drivers/clk/clk.c | 4 drivers/staging/media/atomisp/Kconfig | 2 +- sound/soc/sunxi/Kconfig | 2 +- 4 files changed, 7 insertions(+), 2 deletions(-) -- 2.25.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 1/3] clk: fix redefinition of clk_prepare on MIPS with HAVE_LEGACY_CLK
COMMON_CLK even though is a user-selectable symbol, is still selected by multiple other config options. COMMON_CLK should not be used when legacy clocks are provided by architecture, so it correctly depends on !HAVE_LEGACY_CLK. However it is possible to create a config which selects both COMMON_CLK (by SND_SUN8I_CODEC) and HAVE_LEGACY_CLK (by SOC_RT305X) which leads to compile errors (MIPS architecture): drivers/clk/clk.c:855:6: error: redefinition of ‘clk_unprepare’ In file included from drivers/clk/clk.c:9: include/linux/clk.h:263:20: note: previous definition of ‘clk_unprepare’ was here The definitions clk_bulk_prepare() (and unprepare) already have proper surrounding #ifdef so add them also for clk_prepare()/clk_unprepare(). Signed-off-by: Krzysztof Kozlowski --- drivers/clk/clk.c | 4 1 file changed, 4 insertions(+) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index f83dac54ed85..f4f68c7c2fb5 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -841,6 +841,7 @@ static void clk_core_unprepare_lock(struct clk_core *core) clk_prepare_unlock(); } +#ifdef CONFIG_HAVE_CLK_PREPARE /** * clk_unprepare - undo preparation of a clock source * @clk: the clk being unprepared @@ -860,6 +861,7 @@ void clk_unprepare(struct clk *clk) clk_core_unprepare_lock(clk->core); } EXPORT_SYMBOL_GPL(clk_unprepare); +#endif static int clk_core_prepare(struct clk_core *core) { @@ -921,6 +923,7 @@ static int clk_core_prepare_lock(struct clk_core *core) return ret; } +#ifdef CONFIG_HAVE_CLK_PREPARE /** * clk_prepare - prepare a clock source * @clk: the clk being prepared @@ -941,6 +944,7 @@ int clk_prepare(struct clk *clk) return clk_core_prepare_lock(clk->core); } EXPORT_SYMBOL_GPL(clk_prepare); +#endif /* CONFIG_HAVE_CLK_PREPARE */ static void clk_core_disable(struct clk_core *core) { -- 2.25.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[RFC 2/3] ARM: sunxi: do not select COMMON_CLK to fix builds
COMMON_CLK is a user-selectable option with its own dependencies. The most important dependency is !HAVE_LEGACY_CLK. User-selectable drivers should not select COMMON_CLK because they will create a dependency cycle and build failures. For example on MIPS a configuration with COMMON_CLK (selected by SND_SUN8I_CODEC) and HAVE_LEGACY_CLK (selected by SOC_RT305X) is possible: WARNING: unmet direct dependencies detected for COMMON_CLK Depends on [n]: !HAVE_LEGACY_CLK [=y] Selected by [y]: - SND_SUN8I_CODEC [=y] && SOUND [=y] && !UML && SND [=y] && SND_SOC [=y] && (ARCH_SUNXI || COMPILE_TEST [=y]) && OF [=y] && (MACH_SUN8I || ARM64 && ARCH_SUNXI || COMPILE_TEST [=y]) /usr/bin/mips-linux-gnu-ld: drivers/clk/clk.o: in function `clk_set_rate': (.text+0xaeb4): multiple definition of `clk_set_rate'; arch/mips/ralink/clk.o:(.text+0x88): first defined here Signed-off-by: Krzysztof Kozlowski --- arch/arm/mach-sunxi/Kconfig | 1 + sound/soc/sunxi/Kconfig | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig index eeadb1a4dcfe..4d9f9b6d329d 100644 --- a/arch/arm/mach-sunxi/Kconfig +++ b/arch/arm/mach-sunxi/Kconfig @@ -4,6 +4,7 @@ menuconfig ARCH_SUNXI depends on ARCH_MULTI_V5 || ARCH_MULTI_V7 select ARCH_HAS_RESET_CONTROLLER select CLKSRC_MMIO + select COMMON_CLK select GENERIC_IRQ_CHIP select GPIOLIB select PINCTRL diff --git a/sound/soc/sunxi/Kconfig b/sound/soc/sunxi/Kconfig index 69b9d8515335..ddcaaa98d3cb 100644 --- a/sound/soc/sunxi/Kconfig +++ b/sound/soc/sunxi/Kconfig @@ -14,7 +14,7 @@ config SND_SUN8I_CODEC tristate "Allwinner SUN8I audio codec" depends on OF depends on MACH_SUN8I || (ARM64 && ARCH_SUNXI) || COMPILE_TEST - select COMMON_CLK + depends on COMMON_CLK select REGMAP_MMIO help This option enables the digital part of the internal audio codec for -- 2.25.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[RFC 3/3] media: atomisp: do not select COMMON_CLK to fix builds
COMMON_CLK is a user-selectable option with its own dependencies. The most important dependency is !HAVE_LEGACY_CLK. User-selectable drivers should not select COMMON_CLK because they will create a dependency cycle and build failures. Signed-off-by: Krzysztof Kozlowski --- drivers/staging/media/atomisp/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/media/atomisp/Kconfig b/drivers/staging/media/atomisp/Kconfig index 37577bb72998..742edb261d85 100644 --- a/drivers/staging/media/atomisp/Kconfig +++ b/drivers/staging/media/atomisp/Kconfig @@ -2,9 +2,9 @@ menuconfig INTEL_ATOMISP bool "Enable support to Intel Atom ISP camera drivers" depends on X86 && EFI && PCI && ACPI + depends on COMMON_CLK select IOSF_MBI select MEDIA_CONTROLLER - select COMMON_CLK help Enable support for the Intel ISP2 camera interfaces and MIPI sensor drivers. -- 2.25.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [RFC 2/3] ARM: sunxi: do not select COMMON_CLK to fix builds
On Mon, Nov 16, 2020 at 10:36:12PM -0600, Samuel Holland wrote: > On 11/15/20 11:09 AM, Krzysztof Kozlowski wrote: > > COMMON_CLK is a user-selectable option with its own dependencies. The > > most important dependency is !HAVE_LEGACY_CLK. User-selectable drivers > > should not select COMMON_CLK because they will create a dependency cycle > > and build failures. For example on MIPS a configuration with COMMON_CLK > > (selected by SND_SUN8I_CODEC) and HAVE_LEGACY_CLK (selected by > > SOC_RT305X) is possible: > > Ah, that makes sense. > > > > > WARNING: unmet direct dependencies detected for COMMON_CLK > > Depends on [n]: !HAVE_LEGACY_CLK [=y] > > Selected by [y]: > > - SND_SUN8I_CODEC [=y] && SOUND [=y] && !UML && SND [=y] && SND_SOC > > [=y] && > > (ARCH_SUNXI || COMPILE_TEST [=y]) && OF [=y] && (MACH_SUN8I || ARM64 > > && ARCH_SUNXI || COMPILE_TEST [=y]) > > > > /usr/bin/mips-linux-gnu-ld: drivers/clk/clk.o: in function > > `clk_set_rate': > > (.text+0xaeb4): multiple definition of `clk_set_rate'; > > arch/mips/ralink/clk.o:(.text+0x88): first defined here > > > > Signed-off-by: Krzysztof Kozlowski > > --- > > arch/arm/mach-sunxi/Kconfig | 1 + > > sound/soc/sunxi/Kconfig | 2 +- > > 2 files changed, 2 insertions(+), 1 deletion(-) > > > > diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig > > index eeadb1a4dcfe..4d9f9b6d329d 100644 > > --- a/arch/arm/mach-sunxi/Kconfig > > +++ b/arch/arm/mach-sunxi/Kconfig > > @@ -4,6 +4,7 @@ menuconfig ARCH_SUNXI > > depends on ARCH_MULTI_V5 || ARCH_MULTI_V7 > > select ARCH_HAS_RESET_CONTROLLER > > select CLKSRC_MMIO > > + select COMMON_CLK > > This is not necessary, since ARCH_SUNXI depends (through ARCH_MULTI_V{5,7}) on > ARCH_MULTIPLATFORM, which selects COMMON_CLK already. Thanks. I'll send a v2 with changes and your review. Best regards, Krzysztof ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 1/3] clk: fix redefinition of clk_prepare on MIPS with HAVE_LEGACY_CLK
On Tue, Nov 17, 2020 at 11:41:57PM -0800, Stephen Boyd wrote: > Quoting Krzysztof Kozlowski (2020-11-15 09:09:48) > > COMMON_CLK even though is a user-selectable symbol, is still selected by > > multiple other config options. COMMON_CLK should not be used when > > legacy clocks are provided by architecture, so it correctly depends on > > !HAVE_LEGACY_CLK. > > > > However it is possible to create a config which selects both COMMON_CLK > > (by SND_SUN8I_CODEC) and HAVE_LEGACY_CLK (by SOC_RT305X) which leads to > > Why is SND_SUN8I_CODEC selecting COMMON_CLK? Or really, why is > SOC_RT305X selecting HAVE_LEGACY_CLK? The SND_SUN8I_CODEC I fixed in following patch (I sent separately v2 of it). The SOC_RT305X select HAVE_LEGACY_CLK? because it is an old, Ralink platform, not converted to Common clock frm. Few clock operations are defined in: arch/mips/ralink/clk.c Best regards, Krzysztof ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 1/3] clk: fix redefinition of clk_prepare on MIPS with HAVE_LEGACY_CLK
On Tue, Nov 24, 2020 at 04:11:31PM -0800, Stephen Boyd wrote: > Quoting Krzysztof Kozlowski (2020-11-17 23:48:12) > > On Tue, Nov 17, 2020 at 11:41:57PM -0800, Stephen Boyd wrote: > > > Quoting Krzysztof Kozlowski (2020-11-15 09:09:48) > > > > COMMON_CLK even though is a user-selectable symbol, is still selected by > > > > multiple other config options. COMMON_CLK should not be used when > > > > legacy clocks are provided by architecture, so it correctly depends on > > > > !HAVE_LEGACY_CLK. > > > > > > > > However it is possible to create a config which selects both COMMON_CLK > > > > (by SND_SUN8I_CODEC) and HAVE_LEGACY_CLK (by SOC_RT305X) which leads to > > > > > > Why is SND_SUN8I_CODEC selecting COMMON_CLK? Or really, why is > > > SOC_RT305X selecting HAVE_LEGACY_CLK? > > > > The SND_SUN8I_CODEC I fixed in following patch (I sent separately v2 of > > it). > > > > The SOC_RT305X select HAVE_LEGACY_CLK? because it is an old, Ralink > > platform, not converted to Common clock frm. Few clock operations are > > defined in: arch/mips/ralink/clk.c > > > > Ok so this patch isn't necessary then? For this particular build failure - it is not necessary anymore. However there might more of such errors - just not discovered yet. Also, the clock bulk API has such ifdefs so it kind of symmetrical and consistent approach. > It seems OK to select > HAVE_LEGACY_CLK but not to select COMMON_CLK unless it's architecture > code that can't be enabled when the other architecture code is selecting > HAVE_LEGACY_CLK. Best regards, Krzysztof ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v2 07/48] dt-bindings: arm: tegra: Add binding for core power domain
On Thu, Dec 17, 2020 at 09:05:57PM +0300, Dmitry Osipenko wrote: > All NVIDIA Tegra SoCs have a core power domain where majority of hardware > blocks reside. Add binding for the core power domain. > > Signed-off-by: Dmitry Osipenko > --- > .../arm/tegra/nvidia,tegra20-core-domain.yaml | 48 +++ > 1 file changed, 48 insertions(+) > create mode 100644 > Documentation/devicetree/bindings/arm/tegra/nvidia,tegra20-core-domain.yaml > > diff --git > a/Documentation/devicetree/bindings/arm/tegra/nvidia,tegra20-core-domain.yaml > b/Documentation/devicetree/bindings/arm/tegra/nvidia,tegra20-core-domain.yaml > new file mode 100644 > index ..f3d8fd2d8371 > --- /dev/null > +++ > b/Documentation/devicetree/bindings/arm/tegra/nvidia,tegra20-core-domain.yaml > @@ -0,0 +1,48 @@ > +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause > +%YAML 1.2 > +--- > +$id: http://devicetree.org/schemas/arm/tegra/nvidia,tegra20-core-domain.yaml# > +$schema: http://devicetree.org/meta-schemas/core.yaml# > + > +title: NVIDIA Tegra Core Power Domain > + > +maintainers: > + - Dmitry Osipenko > + - Jon Hunter > + - Thierry Reding > + > +properties: > + compatible: > +enum: > + - nvidia,tegra20-core-domain > + - nvidia,tegra30-core-domain The file should be in bindings/power. Include also the power-domain.yaml schema. > + > + operating-points-v2: > +description: > + Should contain level, voltages and opp-supported-hw property. > + The supported-hw is a bitfield indicating SoC speedo or process > + ID mask. > + > + "#power-domain-cells": > +const: 0 > + > + power-supply: > +description: > + Phandle to voltage regulator connected to the SoC Core power rail. > + > +required: > + - compatible > + - operating-points-v2 > + - "#power-domain-cells" > + - power-supply > + > +additionalProperties: false > + > +examples: > + - | > +core-domain { power-domain (to follow schema and devicetree spec) Best regards, Krzysztof > +compatible = "nvidia,tegra20-core-domain"; > +operating-points-v2 = <&opp_table>; > +power-supply = <®ulator>; > +#power-domain-cells = <0>; > +}; > -- > 2.29.2 > ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v2 41/48] memory: tegra20-emc: Use devm_tegra_core_dev_init_opp_table()
On Thu, Dec 17, 2020 at 09:06:31PM +0300, Dmitry Osipenko wrote: > Use common devm_tegra_core_dev_init_opp_table() helper for the OPP table > initialization. > > Signed-off-by: Dmitry Osipenko > --- > drivers/memory/tegra/tegra20-emc.c | 57 +++--- > 1 file changed, 4 insertions(+), 53 deletions(-) If there was no more Tegra MC work planned, this could easily go via Tegra SoC tree. However I expect still work of your interconnect patches, so maybe it's better to stick these in same tree. In such case I would need a stable tag with the devm_tegra_core_dev_init_opp_table() helper for memory controller tree. Best regards, Krzysztof ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v2 00/48] Introduce core voltage scaling for NVIDIA Tegra20/30 SoCs
On Thu, Dec 17, 2020 at 09:05:50PM +0300, Dmitry Osipenko wrote: > Introduce core voltage scaling for NVIDIA Tegra20/30 SoCs, which reduces > power consumption and heating of the Tegra chips. Tegra SoC has multiple > hardware units which belong to a core power domain of the SoC and share > the core voltage. The voltage must be selected in accordance to a minimum > requirement of every core hardware unit. > > The minimum core voltage requirement depends on: > > 1. Clock enable state of a hardware unit. > 2. Clock frequency. > 3. Unit's internal idling/active state. > > This series is tested on Acer A500 (T20), AC100 (T20), Nexus 7 (T30), > Ouya (T30), TK1 (T124) and some others. I also added voltage scaling to > the Ventana (T20) and Cardhu (T30) boards which are tested by NVIDIA's CI > farm. Tegra30 is now couple degrees cooler on Nexus 7 and stays cool on > Ouya (instead of becoming burning hot) while system is idling. It should > be possible to improve this further by implementing a more advanced power > management features for the kernel drivers. > > The DVFS support is opt-in for all boards, meaning that older DTBs will > continue to work like they did it before this series. It should be possible > to easily add the core voltage scaling support for Tegra114+ SoCs based on > this grounding work later on, if anyone will want to implement it. The same comment as for your interconnect work: for sets touching multiple systems please mention the dependencies between patches in the cover letter. Not as a reply to such remark like I make here, but as a separate entry in the cover letter. Best regards, Krzysztof ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH trivial 3/3] treewide: arch: Fix Kconfig indentation
Adjust indentation from spaces to tab (+optional two spaces) as in coding style with command like: $ sed -e 's/^/\t/' -i */Kconfig Signed-off-by: Krzysztof Kozlowski --- arch/Kconfig | 4 ++-- arch/alpha/Kconfig | 2 +- arch/arm/Kconfig.debug | 4 ++-- arch/arm/mach-ep93xx/Kconfig | 8 arch/arm/mach-hisi/Kconfig | 2 +- arch/arm/mach-ixp4xx/Kconfig | 16 arch/arm/mach-mmp/Kconfig | 2 +- arch/arm/mach-omap1/Kconfig| 14 +++--- arch/arm/mach-prima2/Kconfig | 6 +++--- arch/arm/mach-s3c24xx/Kconfig | 4 ++-- arch/arm/mach-s3c64xx/Kconfig | 6 +++--- arch/arm/plat-samsung/Kconfig | 2 +- arch/arm64/Kconfig | 6 +++--- arch/arm64/Kconfig.debug | 2 +- arch/h8300/Kconfig | 4 ++-- arch/h8300/Kconfig.cpu | 4 ++-- arch/m68k/Kconfig.bus | 2 +- arch/m68k/Kconfig.debug| 16 arch/m68k/Kconfig.machine | 8 arch/nds32/Kconfig.cpu | 18 +- arch/openrisc/Kconfig | 26 +- arch/powerpc/Kconfig.debug | 18 +- arch/powerpc/platforms/Kconfig.cputype | 2 +- arch/riscv/Kconfig.socs| 2 +- arch/sh/boards/Kconfig | 2 +- arch/sh/mm/Kconfig | 2 +- arch/um/Kconfig| 2 +- arch/x86/Kconfig | 18 +- 28 files changed, 101 insertions(+), 101 deletions(-) diff --git a/arch/Kconfig b/arch/Kconfig index 5f8a5d84dbbe..8d4f77bbed29 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -76,7 +76,7 @@ config JUMP_LABEL depends on HAVE_ARCH_JUMP_LABEL depends on CC_HAS_ASM_GOTO help - This option enables a transparent branch optimization that +This option enables a transparent branch optimization that makes certain almost-always-true or almost-always-false branch conditions even cheaper to execute within the kernel. @@ -84,7 +84,7 @@ config JUMP_LABEL scheduler functionality, networking code and KVM have such branches and include support for this optimization technique. - If it is detected that the compiler has support for "asm goto", +If it is detected that the compiler has support for "asm goto", the kernel will compile such branches with just a nop instruction. When the condition flag is toggled to true, the nop will be converted to a jump instruction to execute the diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig index ef179033a7c2..30a6291355cb 100644 --- a/arch/alpha/Kconfig +++ b/arch/alpha/Kconfig @@ -545,7 +545,7 @@ config NR_CPUS default "4" if !ALPHA_GENERIC && !ALPHA_MARVEL help MARVEL support can handle a maximum of 32 CPUs, all the others - with working support have a maximum of 4 CPUs. + with working support have a maximum of 4 CPUs. config ARCH_DISCONTIGMEM_ENABLE bool "Discontiguous Memory Support" diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug index 8bcbd0cd739b..0e5d52fbddbd 100644 --- a/arch/arm/Kconfig.debug +++ b/arch/arm/Kconfig.debug @@ -274,7 +274,7 @@ choice select DEBUG_UART_8250 help Say Y here if you want the debug print routines to direct - their output to the CNS3xxx UART0. + their output to the CNS3xxx UART0. config DEBUG_DAVINCI_DA8XX_UART1 bool "Kernel low-level debugging on DaVinci DA8XX using UART1" @@ -828,7 +828,7 @@ choice select DEBUG_UART_8250 help Say Y here if you want kernel low-level debugging support - on Rockchip RV1108 based platforms. + on Rockchip RV1108 based platforms. config DEBUG_RV1108_UART1 bool "Kernel low-level debugging messages via Rockchip RV1108 UART1" diff --git a/arch/arm/mach-ep93xx/Kconfig b/arch/arm/mach-ep93xx/Kconfig index f2db5fd38145..bf81dfab7f1b 100644 --- a/arch/arm/mach-ep93xx/Kconfig +++ b/arch/arm/mach-ep93xx/Kconfig @@ -126,10 +126,10 @@ config MACH_MICRO9S Contec Micro9-Slim board. config MACH_SIM_ONE -bool "Support Simplemachines Sim.One board" -help - Say 'Y' here if you want your kernel to support the - Simplemachines Sim.One board. + bool "Support Simplemachines Sim.One board" + help + Say 'Y' here if you want your kernel to support the + Simplemachines Sim.One board. config MACH_SNAPPER_CL1
[PATCH trivial 1/3] treewide: drivers: Fix Kconfig indentation
Adjust indentation from spaces to tab (+optional two spaces) as in coding style with command like: $ sed -e 's/^/\t/' -i */Kconfig Signed-off-by: Krzysztof Kozlowski --- drivers/acpi/Kconfig | 8 +- drivers/ata/Kconfig | 12 +-- drivers/auxdisplay/Kconfig| 14 +-- drivers/base/firmware_loader/Kconfig | 2 +- drivers/block/Kconfig | 28 +++--- drivers/block/mtip32xx/Kconfig| 2 +- drivers/char/Kconfig | 6 +- drivers/char/agp/Kconfig | 2 +- drivers/char/hw_random/Kconfig| 10 +- drivers/char/ipmi/Kconfig | 20 ++-- drivers/clk/Kconfig | 2 +- drivers/clk/mediatek/Kconfig | 10 +- drivers/clk/versatile/Kconfig | 2 +- drivers/clocksource/Kconfig | 20 ++-- drivers/cpufreq/Kconfig.x86 | 6 +- drivers/cpuidle/Kconfig | 8 +- drivers/cpuidle/Kconfig.arm | 16 ++-- drivers/crypto/Kconfig| 4 +- drivers/crypto/caam/Kconfig | 14 +-- drivers/crypto/chelsio/Kconfig| 30 +++--- drivers/crypto/stm32/Kconfig | 6 +- drivers/crypto/ux500/Kconfig | 16 ++-- drivers/devfreq/Kconfig | 6 +- drivers/dma/Kconfig | 46 - drivers/edac/Kconfig | 2 +- drivers/firmware/Kconfig | 4 +- drivers/firmware/efi/Kconfig | 2 +- drivers/hid/Kconfig | 2 +- drivers/hwmon/Kconfig | 14 +-- drivers/i2c/busses/Kconfig| 16 ++-- drivers/i2c/muxes/Kconfig | 18 ++-- drivers/iio/gyro/Kconfig | 8 +- drivers/infiniband/hw/bnxt_re/Kconfig | 12 +-- drivers/input/keyboard/Kconfig| 8 +- drivers/input/mouse/Kconfig | 6 +- drivers/input/tablet/Kconfig | 20 ++-- drivers/input/touchscreen/Kconfig | 2 +- drivers/iommu/Kconfig | 2 +- drivers/irqchip/Kconfig | 10 +- drivers/isdn/hardware/mISDN/Kconfig | 2 +- drivers/macintosh/Kconfig | 6 +- drivers/md/Kconfig| 54 +-- drivers/media/Kconfig | 6 +- drivers/media/radio/si470x/Kconfig| 4 +- drivers/memstick/core/Kconfig | 18 ++-- drivers/memstick/host/Kconfig | 4 +- drivers/misc/Kconfig | 16 ++-- drivers/mtd/nand/onenand/Kconfig | 12 +-- drivers/nfc/nfcmrvl/Kconfig | 2 +- drivers/pci/Kconfig | 24 ++--- drivers/pci/controller/dwc/Kconfig| 6 +- drivers/pci/hotplug/Kconfig | 2 +- drivers/perf/Kconfig | 14 +-- drivers/phy/hisilicon/Kconfig | 6 +- drivers/pinctrl/Kconfig | 18 ++-- drivers/pinctrl/freescale/Kconfig | 12 +-- drivers/pinctrl/qcom/Kconfig | 34 +++ drivers/platform/chrome/Kconfig | 6 +- drivers/platform/mellanox/Kconfig | 4 +- drivers/platform/x86/Kconfig | 48 +- drivers/power/avs/Kconfig | 12 +-- drivers/power/supply/Kconfig | 30 +++--- drivers/regulator/Kconfig | 8 +- drivers/rpmsg/Kconfig | 2 +- drivers/rtc/Kconfig | 6 +- drivers/scsi/Kconfig | 22 ++--- drivers/scsi/aic7xxx/Kconfig.aic7xxx | 14 +-- drivers/scsi/pcmcia/Kconfig | 2 +- drivers/scsi/qedf/Kconfig | 4 +- drivers/scsi/smartpqi/Kconfig | 8 +- drivers/soc/fsl/Kconfig | 8 +- drivers/soc/qcom/Kconfig | 22 ++--- drivers/soc/rockchip/Kconfig | 18 ++-- drivers/spi/Kconfig | 18 ++-- drivers/staging/fbtft/Kconfig | 12 +-- drivers/staging/fwserial/Kconfig | 6 +- drivers/staging/most/Kconfig | 8 +- drivers/staging/nvec/Kconfig | 10 +- drivers/staging/pi433/Kconfig | 24 ++--- drivers/staging/uwb/Kconfig | 42 .../vc04_services/bcm2835-audio/Kconfig | 12 +-- drivers/staging/wusbcore/Kconfig | 2 +- drivers/tty/Kconfig | 26 ++--- drivers/tty/hvc/Kconfig | 4 +- drivers/tty/serial/8250/Kconfig | 2 +- drivers/tty/seri
[PATCH trivial 2/3] treewide: Fix Kconfig indentation
Adjust indentation from spaces to tab (+optional two spaces) as in coding style with command like: $ sed -e 's/^/\t/' -i */Kconfig Signed-off-by: Krzysztof Kozlowski --- certs/Kconfig | 14 ++--- init/Kconfig | 28 +- kernel/trace/Kconfig | 8 lib/Kconfig| 2 +- lib/Kconfig.debug | 36 +- lib/Kconfig.kgdb | 8 mm/Kconfig | 28 +- samples/Kconfig| 2 +- security/apparmor/Kconfig | 2 +- security/integrity/Kconfig | 24 +++ security/integrity/ima/Kconfig | 12 ++-- security/safesetid/Kconfig | 24 +++ 12 files changed, 94 insertions(+), 94 deletions(-) diff --git a/certs/Kconfig b/certs/Kconfig index c94e93d8bccf..0358c66d3d7c 100644 --- a/certs/Kconfig +++ b/certs/Kconfig @@ -6,14 +6,14 @@ config MODULE_SIG_KEY default "certs/signing_key.pem" depends on MODULE_SIG help - Provide the file name of a private key/certificate in PEM format, - or a PKCS#11 URI according to RFC7512. The file should contain, or - the URI should identify, both the certificate and its corresponding - private key. +Provide the file name of a private key/certificate in PEM format, +or a PKCS#11 URI according to RFC7512. The file should contain, or +the URI should identify, both the certificate and its corresponding +private key. - If this option is unchanged from its default "certs/signing_key.pem", - then the kernel will automatically generate the private key and - certificate as described in Documentation/admin-guide/module-signing.rst +If this option is unchanged from its default "certs/signing_key.pem", +then the kernel will automatically generate the private key and +certificate as described in Documentation/admin-guide/module-signing.rst config SYSTEM_TRUSTED_KEYRING bool "Provide system-wide ring of trusted keys" diff --git a/init/Kconfig b/init/Kconfig index 6d4db887f696..f59c854839d2 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -169,10 +169,10 @@ config BUILD_SALT string "Build ID Salt" default "" help - The build ID is used to link binaries and their debug info. Setting - this option will use the value in the calculation of the build id. - This is mostly useful for distributions which want to ensure the - build is unique between builds. It's safe to leave the default. + The build ID is used to link binaries and their debug info. Setting + this option will use the value in the calculation of the build id. + This is mostly useful for distributions which want to ensure the + build is unique between builds. It's safe to leave the default. config HAVE_KERNEL_GZIP bool @@ -1327,9 +1327,9 @@ menuconfig EXPERT select DEBUG_KERNEL help This option allows certain base kernel options and settings - to be disabled or tweaked. This is for specialized - environments which can tolerate a "non-standard" kernel. - Only use this if you really know what you are doing. + to be disabled or tweaked. This is for specialized + environments which can tolerate a "non-standard" kernel. + Only use this if you really know what you are doing. config UID16 bool "Enable 16-bit UID system calls" if EXPERT @@ -1439,11 +1439,11 @@ config BUG bool "BUG() support" if EXPERT default y help - Disabling this option eliminates support for BUG and WARN, reducing - the size of your kernel image and potentially quietly ignoring - numerous fatal conditions. You should only consider disabling this - option for embedded systems with no facilities for reporting errors. - Just say Y. + Disabling this option eliminates support for BUG and WARN, reducing + the size of your kernel image and potentially quietly ignoring + numerous fatal conditions. You should only consider disabling this + option for embedded systems with no facilities for reporting errors. + Just say Y. config ELF_CORE depends on COREDUMP @@ -1459,8 +1459,8 @@ config PCSPKR_PLATFORM select I8253_LOCK default y help - This option allows to disable the internal PC-Speaker - support, saving some memory. + This option allows to disable the internal PC-Speaker + support, saving some memory. config BASE_FULL default y diff --git a/kernel/trace/Kconfig b/kernel/tr
[RESEND TRIVIAL 3/3] treewide: arch: Fix Kconfig indentation
Adjust indentation from spaces to tab (+optional two spaces) as in coding style with command like: $ sed -e 's/^/\t/' -i */Kconfig Signed-off-by: Krzysztof Kozlowski --- arch/Kconfig | 4 ++-- arch/alpha/Kconfig | 2 +- arch/arm/Kconfig.debug | 4 ++-- arch/arm/mach-ep93xx/Kconfig | 8 arch/arm/mach-hisi/Kconfig | 2 +- arch/arm/mach-ixp4xx/Kconfig | 16 arch/arm/mach-mmp/Kconfig | 2 +- arch/arm/mach-omap1/Kconfig| 14 +++--- arch/arm/mach-prima2/Kconfig | 6 +++--- arch/arm/mach-s3c24xx/Kconfig | 4 ++-- arch/arm/mach-s3c64xx/Kconfig | 6 +++--- arch/arm/plat-samsung/Kconfig | 2 +- arch/arm64/Kconfig | 6 +++--- arch/arm64/Kconfig.debug | 2 +- arch/h8300/Kconfig | 4 ++-- arch/h8300/Kconfig.cpu | 4 ++-- arch/m68k/Kconfig.bus | 2 +- arch/m68k/Kconfig.debug| 16 arch/m68k/Kconfig.machine | 8 arch/nds32/Kconfig.cpu | 18 +- arch/openrisc/Kconfig | 26 +- arch/powerpc/Kconfig.debug | 18 +- arch/powerpc/platforms/Kconfig.cputype | 2 +- arch/riscv/Kconfig.socs| 2 +- arch/sh/boards/Kconfig | 2 +- arch/sh/mm/Kconfig | 2 +- arch/um/Kconfig| 2 +- arch/x86/Kconfig | 18 +- 28 files changed, 101 insertions(+), 101 deletions(-) diff --git a/arch/Kconfig b/arch/Kconfig index 5f8a5d84dbbe..8d4f77bbed29 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -76,7 +76,7 @@ config JUMP_LABEL depends on HAVE_ARCH_JUMP_LABEL depends on CC_HAS_ASM_GOTO help - This option enables a transparent branch optimization that +This option enables a transparent branch optimization that makes certain almost-always-true or almost-always-false branch conditions even cheaper to execute within the kernel. @@ -84,7 +84,7 @@ config JUMP_LABEL scheduler functionality, networking code and KVM have such branches and include support for this optimization technique. - If it is detected that the compiler has support for "asm goto", +If it is detected that the compiler has support for "asm goto", the kernel will compile such branches with just a nop instruction. When the condition flag is toggled to true, the nop will be converted to a jump instruction to execute the diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig index ef179033a7c2..30a6291355cb 100644 --- a/arch/alpha/Kconfig +++ b/arch/alpha/Kconfig @@ -545,7 +545,7 @@ config NR_CPUS default "4" if !ALPHA_GENERIC && !ALPHA_MARVEL help MARVEL support can handle a maximum of 32 CPUs, all the others - with working support have a maximum of 4 CPUs. + with working support have a maximum of 4 CPUs. config ARCH_DISCONTIGMEM_ENABLE bool "Discontiguous Memory Support" diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug index 8bcbd0cd739b..0e5d52fbddbd 100644 --- a/arch/arm/Kconfig.debug +++ b/arch/arm/Kconfig.debug @@ -274,7 +274,7 @@ choice select DEBUG_UART_8250 help Say Y here if you want the debug print routines to direct - their output to the CNS3xxx UART0. + their output to the CNS3xxx UART0. config DEBUG_DAVINCI_DA8XX_UART1 bool "Kernel low-level debugging on DaVinci DA8XX using UART1" @@ -828,7 +828,7 @@ choice select DEBUG_UART_8250 help Say Y here if you want kernel low-level debugging support - on Rockchip RV1108 based platforms. + on Rockchip RV1108 based platforms. config DEBUG_RV1108_UART1 bool "Kernel low-level debugging messages via Rockchip RV1108 UART1" diff --git a/arch/arm/mach-ep93xx/Kconfig b/arch/arm/mach-ep93xx/Kconfig index f2db5fd38145..bf81dfab7f1b 100644 --- a/arch/arm/mach-ep93xx/Kconfig +++ b/arch/arm/mach-ep93xx/Kconfig @@ -126,10 +126,10 @@ config MACH_MICRO9S Contec Micro9-Slim board. config MACH_SIM_ONE -bool "Support Simplemachines Sim.One board" -help - Say 'Y' here if you want your kernel to support the - Simplemachines Sim.One board. + bool "Support Simplemachines Sim.One board" + help + Say 'Y' here if you want your kernel to support the + Simplemachines Sim.One board. config MACH_SNAPPER_CL1
[RESEND TRIVIAL 1/3] treewide: drivers: Fix Kconfig indentation
Adjust indentation from spaces to tab (+optional two spaces) as in coding style with command like: $ sed -e 's/^/\t/' -i */Kconfig Signed-off-by: Krzysztof Kozlowski --- drivers/acpi/Kconfig | 8 +- drivers/ata/Kconfig | 12 +-- drivers/auxdisplay/Kconfig| 14 +-- drivers/base/firmware_loader/Kconfig | 2 +- drivers/block/Kconfig | 28 +++--- drivers/block/mtip32xx/Kconfig| 2 +- drivers/char/Kconfig | 6 +- drivers/char/agp/Kconfig | 2 +- drivers/char/hw_random/Kconfig| 10 +- drivers/char/ipmi/Kconfig | 20 ++-- drivers/clk/Kconfig | 2 +- drivers/clk/mediatek/Kconfig | 10 +- drivers/clk/versatile/Kconfig | 2 +- drivers/clocksource/Kconfig | 20 ++-- drivers/cpufreq/Kconfig.x86 | 6 +- drivers/cpuidle/Kconfig | 8 +- drivers/cpuidle/Kconfig.arm | 16 ++-- drivers/crypto/Kconfig| 4 +- drivers/crypto/caam/Kconfig | 14 +-- drivers/crypto/chelsio/Kconfig| 30 +++--- drivers/crypto/stm32/Kconfig | 6 +- drivers/crypto/ux500/Kconfig | 16 ++-- drivers/devfreq/Kconfig | 6 +- drivers/dma/Kconfig | 46 - drivers/edac/Kconfig | 2 +- drivers/firmware/Kconfig | 4 +- drivers/firmware/efi/Kconfig | 2 +- drivers/hid/Kconfig | 2 +- drivers/hwmon/Kconfig | 14 +-- drivers/i2c/busses/Kconfig| 16 ++-- drivers/i2c/muxes/Kconfig | 18 ++-- drivers/iio/gyro/Kconfig | 8 +- drivers/infiniband/hw/bnxt_re/Kconfig | 12 +-- drivers/input/keyboard/Kconfig| 8 +- drivers/input/mouse/Kconfig | 6 +- drivers/input/tablet/Kconfig | 20 ++-- drivers/input/touchscreen/Kconfig | 2 +- drivers/iommu/Kconfig | 2 +- drivers/irqchip/Kconfig | 10 +- drivers/isdn/hardware/mISDN/Kconfig | 2 +- drivers/macintosh/Kconfig | 6 +- drivers/md/Kconfig| 54 +-- drivers/media/Kconfig | 6 +- drivers/media/radio/si470x/Kconfig| 4 +- drivers/memstick/core/Kconfig | 18 ++-- drivers/memstick/host/Kconfig | 4 +- drivers/misc/Kconfig | 16 ++-- drivers/mtd/nand/onenand/Kconfig | 12 +-- drivers/nfc/nfcmrvl/Kconfig | 2 +- drivers/pci/Kconfig | 24 ++--- drivers/pci/controller/dwc/Kconfig| 6 +- drivers/pci/hotplug/Kconfig | 2 +- drivers/perf/Kconfig | 14 +-- drivers/phy/hisilicon/Kconfig | 6 +- drivers/pinctrl/Kconfig | 18 ++-- drivers/pinctrl/freescale/Kconfig | 12 +-- drivers/pinctrl/qcom/Kconfig | 34 +++ drivers/platform/chrome/Kconfig | 6 +- drivers/platform/mellanox/Kconfig | 4 +- drivers/platform/x86/Kconfig | 48 +- drivers/power/avs/Kconfig | 12 +-- drivers/power/supply/Kconfig | 30 +++--- drivers/regulator/Kconfig | 8 +- drivers/rpmsg/Kconfig | 2 +- drivers/rtc/Kconfig | 6 +- drivers/scsi/Kconfig | 22 ++--- drivers/scsi/aic7xxx/Kconfig.aic7xxx | 14 +-- drivers/scsi/pcmcia/Kconfig | 2 +- drivers/scsi/qedf/Kconfig | 4 +- drivers/scsi/smartpqi/Kconfig | 8 +- drivers/soc/fsl/Kconfig | 8 +- drivers/soc/qcom/Kconfig | 22 ++--- drivers/soc/rockchip/Kconfig | 18 ++-- drivers/spi/Kconfig | 18 ++-- drivers/staging/fbtft/Kconfig | 12 +-- drivers/staging/fwserial/Kconfig | 6 +- drivers/staging/most/Kconfig | 8 +- drivers/staging/nvec/Kconfig | 10 +- drivers/staging/pi433/Kconfig | 24 ++--- drivers/staging/uwb/Kconfig | 42 .../vc04_services/bcm2835-audio/Kconfig | 12 +-- drivers/staging/wusbcore/Kconfig | 2 +- drivers/tty/Kconfig | 26 ++--- drivers/tty/hvc/Kconfig | 4 +- drivers/tty/serial/8250/Kconfig | 2 +- drivers/tty/seri
[RESEND TRIVIAL 2/3] treewide: Fix Kconfig indentation
Adjust indentation from spaces to tab (+optional two spaces) as in coding style with command like: $ sed -e 's/^/\t/' -i */Kconfig Signed-off-by: Krzysztof Kozlowski --- certs/Kconfig | 14 ++--- init/Kconfig | 28 +- kernel/trace/Kconfig | 8 lib/Kconfig| 2 +- lib/Kconfig.debug | 36 +- lib/Kconfig.kgdb | 8 mm/Kconfig | 28 +- samples/Kconfig| 2 +- security/apparmor/Kconfig | 2 +- security/integrity/Kconfig | 24 +++ security/integrity/ima/Kconfig | 12 ++-- security/safesetid/Kconfig | 24 +++ 12 files changed, 94 insertions(+), 94 deletions(-) diff --git a/certs/Kconfig b/certs/Kconfig index c94e93d8bccf..0358c66d3d7c 100644 --- a/certs/Kconfig +++ b/certs/Kconfig @@ -6,14 +6,14 @@ config MODULE_SIG_KEY default "certs/signing_key.pem" depends on MODULE_SIG help - Provide the file name of a private key/certificate in PEM format, - or a PKCS#11 URI according to RFC7512. The file should contain, or - the URI should identify, both the certificate and its corresponding - private key. +Provide the file name of a private key/certificate in PEM format, +or a PKCS#11 URI according to RFC7512. The file should contain, or +the URI should identify, both the certificate and its corresponding +private key. - If this option is unchanged from its default "certs/signing_key.pem", - then the kernel will automatically generate the private key and - certificate as described in Documentation/admin-guide/module-signing.rst +If this option is unchanged from its default "certs/signing_key.pem", +then the kernel will automatically generate the private key and +certificate as described in Documentation/admin-guide/module-signing.rst config SYSTEM_TRUSTED_KEYRING bool "Provide system-wide ring of trusted keys" diff --git a/init/Kconfig b/init/Kconfig index b4daad2bac23..e1a6f31da281 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -169,10 +169,10 @@ config BUILD_SALT string "Build ID Salt" default "" help - The build ID is used to link binaries and their debug info. Setting - this option will use the value in the calculation of the build id. - This is mostly useful for distributions which want to ensure the - build is unique between builds. It's safe to leave the default. + The build ID is used to link binaries and their debug info. Setting + this option will use the value in the calculation of the build id. + This is mostly useful for distributions which want to ensure the + build is unique between builds. It's safe to leave the default. config HAVE_KERNEL_GZIP bool @@ -1327,9 +1327,9 @@ menuconfig EXPERT select DEBUG_KERNEL help This option allows certain base kernel options and settings - to be disabled or tweaked. This is for specialized - environments which can tolerate a "non-standard" kernel. - Only use this if you really know what you are doing. + to be disabled or tweaked. This is for specialized + environments which can tolerate a "non-standard" kernel. + Only use this if you really know what you are doing. config UID16 bool "Enable 16-bit UID system calls" if EXPERT @@ -1439,11 +1439,11 @@ config BUG bool "BUG() support" if EXPERT default y help - Disabling this option eliminates support for BUG and WARN, reducing - the size of your kernel image and potentially quietly ignoring - numerous fatal conditions. You should only consider disabling this - option for embedded systems with no facilities for reporting errors. - Just say Y. + Disabling this option eliminates support for BUG and WARN, reducing + the size of your kernel image and potentially quietly ignoring + numerous fatal conditions. You should only consider disabling this + option for embedded systems with no facilities for reporting errors. + Just say Y. config ELF_CORE depends on COREDUMP @@ -1459,8 +1459,8 @@ config PCSPKR_PLATFORM select I8253_LOCK default y help - This option allows to disable the internal PC-Speaker - support, saving some memory. + This option allows to disable the internal PC-Speaker + support, saving some memory. config BASE_FULL default y diff --git a/kernel/trace/Kconfig b/kernel/tr
[PATCH 5/6] staging: rtl: Use existing define with polynomial
Do not define again the polynomial but use header with existing define. Signed-off-by: Krzysztof Kozlowski --- Not tested It would be nice to get some testing. Only generic lib/crc, bunzip, xz_crc32 and Freescale's Ethernet driver were tested on HW. Rest got just different builds. drivers/staging/rtl8712/rtl871x_security.c| 5 ++--- drivers/staging/rtl8723bs/core/rtw_security.c | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_security.c b/drivers/staging/rtl8712/rtl871x_security.c index 7bc74d7d8a3a..1075eacdb441 100644 --- a/drivers/staging/rtl8712/rtl871x_security.c +++ b/drivers/staging/rtl8712/rtl871x_security.c @@ -40,6 +40,7 @@ #include #include #include +#include #include #include "osdep_service.h" @@ -49,8 +50,6 @@ /* =WEP related= */ -#define CRC32_POLY 0x04c11db7 - struct arc4context { u32 x; u32 y; @@ -135,7 +134,7 @@ static void crc32_init(void) for (i = 0; i < 256; ++i) { k = crc32_reverseBit((u8)i); for (c = ((u32)k) << 24, j = 8; j > 0; --j) - c = c & 0x8000 ? (c << 1) ^ CRC32_POLY : (c << 1); + c = c & 0x8000 ? (c << 1) ^ CRC32_POLY_BE : (c << 1); p1 = (u8 *)&crc32_table[i]; p1[0] = crc32_reverseBit(p[3]); p1[1] = crc32_reverseBit(p[2]); diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c b/drivers/staging/rtl8723bs/core/rtw_security.c index 612277a555d2..6c8ac9e86c9f 100644 --- a/drivers/staging/rtl8723bs/core/rtw_security.c +++ b/drivers/staging/rtl8723bs/core/rtw_security.c @@ -6,6 +6,7 @@ **/ #define _RTW_SECURITY_C_ +#include #include #include @@ -87,8 +88,6 @@ const char *security_type_str(u8 value) /* WEP related = */ -#define CRC32_POLY 0x04c11db7 - struct arc4context { u32 x; u32 y; @@ -178,7 +177,7 @@ static void crc32_init(void) for (i = 0; i < 256; ++i) { k = crc32_reverseBit((u8)i); for (c = ((u32)k) << 24, j = 8; j > 0; --j) { - c = c & 0x8000 ? (c << 1) ^ CRC32_POLY : (c << 1); + c = c & 0x8000 ? (c << 1) ^ CRC32_POLY_BE : (c << 1); } p1 = (u8 *)&crc32_table[i]; -- 2.14.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 3/6] crypto: stm32_crc32 - Use existing define with polynomial
Do not define again the polynomial but use header with existing define. Signed-off-by: Krzysztof Kozlowski --- Not tested It would be nice to get some testing. Only generic lib/crc, bunzip, xz_crc32 and Freescale's Ethernet driver were tested on HW. Rest got just different builds. drivers/crypto/stm32/stm32_crc32.c | 11 --- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/crypto/stm32/stm32_crc32.c b/drivers/crypto/stm32/stm32_crc32.c index 040bed5e7725..29d2095d9dfd 100644 --- a/drivers/crypto/stm32/stm32_crc32.c +++ b/drivers/crypto/stm32/stm32_crc32.c @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -30,10 +31,6 @@ #define CRC_CR_REVERSE (BIT(7) | BIT(6) | BIT(5)) #define CRC_INIT_DEFAULT0x -/* Polynomial reversed */ -#define POLY_CRC32 0xEDB88320 -#define POLY_CRC32C 0x82F63B78 - #define CRC_AUTOSUSPEND_DELAY 50 struct stm32_crc { @@ -70,7 +67,7 @@ static int stm32_crc32_cra_init(struct crypto_tfm *tfm) struct stm32_crc_ctx *mctx = crypto_tfm_ctx(tfm); mctx->key = CRC_INIT_DEFAULT; - mctx->poly = POLY_CRC32; + mctx->poly = CRC32_POLY_LE; return 0; } @@ -79,7 +76,7 @@ static int stm32_crc32c_cra_init(struct crypto_tfm *tfm) struct stm32_crc_ctx *mctx = crypto_tfm_ctx(tfm); mctx->key = CRC_INIT_DEFAULT; - mctx->poly = POLY_CRC32C; + mctx->poly = CRC32C_POLY_LE; return 0; } @@ -188,7 +185,7 @@ static int stm32_crc_final(struct shash_desc *desc, u8 *out) struct stm32_crc_ctx *mctx = crypto_shash_ctx(desc->tfm); /* Send computed CRC */ - put_unaligned_le32(mctx->poly == POLY_CRC32C ? + put_unaligned_le32(mctx->poly == CRC32C_POLY_LE ? ~ctx->partial : ctx->partial, out); return 0; -- 2.14.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 1/6] lib/crc: Move polynomial definition to separate header
Allow other drivers and parts of kernel to use the same define for CRC32 polynomial, instead of duplicating it in many places. This code does not bring any functional changes, except moving existing code. Signed-off-by: Krzysztof Kozlowski --- include/linux/crc32poly.h | 20 lib/crc32.c | 1 + lib/crc32defs.h | 14 -- lib/gen_crc32table.c | 1 + 4 files changed, 22 insertions(+), 14 deletions(-) create mode 100644 include/linux/crc32poly.h diff --git a/include/linux/crc32poly.h b/include/linux/crc32poly.h new file mode 100644 index ..7ad5aa92d3c7 --- /dev/null +++ b/include/linux/crc32poly.h @@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_CRC32_POLY_H +#define _LINUX_CRC32_POLY_H + +/* + * There are multiple 16-bit CRC polynomials in common use, but this is + * *the* standard CRC-32 polynomial, first popularized by Ethernet. + * x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x^1+x^0 + */ +#define CRCPOLY_LE 0xedb88320 +#define CRCPOLY_BE 0x04c11db7 + +/* + * This is the CRC32c polynomial, as outlined by Castagnoli. + * x^32+x^28+x^27+x^26+x^25+x^23+x^22+x^20+x^19+x^18+x^14+x^13+x^11+x^10+x^9+ + * x^8+x^6+x^0 + */ +#define CRC32C_POLY_LE 0x82F63B78 + +#endif /* _LINUX_CRC32_POLY_H */ diff --git a/lib/crc32.c b/lib/crc32.c index 2ef20fe84b69..341c54cb4edf 100644 --- a/lib/crc32.c +++ b/lib/crc32.c @@ -27,6 +27,7 @@ /* see: Documentation/crc32.txt for a description of algorithms */ #include +#include #include #include #include diff --git a/lib/crc32defs.h b/lib/crc32defs.h index cb275a28a750..0c8fb5923e7e 100644 --- a/lib/crc32defs.h +++ b/lib/crc32defs.h @@ -1,18 +1,4 @@ /* SPDX-License-Identifier: GPL-2.0 */ -/* - * There are multiple 16-bit CRC polynomials in common use, but this is - * *the* standard CRC-32 polynomial, first popularized by Ethernet. - * x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x^1+x^0 - */ -#define CRCPOLY_LE 0xedb88320 -#define CRCPOLY_BE 0x04c11db7 - -/* - * This is the CRC32c polynomial, as outlined by Castagnoli. - * x^32+x^28+x^27+x^26+x^25+x^23+x^22+x^20+x^19+x^18+x^14+x^13+x^11+x^10+x^9+ - * x^8+x^6+x^0 - */ -#define CRC32C_POLY_LE 0x82F63B78 /* Try to choose an implementation variant via Kconfig */ #ifdef CONFIG_CRC32_SLICEBY8 diff --git a/lib/gen_crc32table.c b/lib/gen_crc32table.c index 8f26660ea10a..34c3bc826f45 100644 --- a/lib/gen_crc32table.c +++ b/lib/gen_crc32table.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 #include +#include "../include/linux/crc32poly.h" #include "../include/generated/autoconf.h" #include "crc32defs.h" #include -- 2.14.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 4/6] net: ethernet: Use existing define with polynomial
Do not define again the polynomial but use header with existing define. Signed-off-by: Krzysztof Kozlowski --- Only Freescale FEC was tested It would be nice to get some testing. Only generic lib/crc, bunzip, xz_crc32 and Freescale's Ethernet driver were tested on HW. Rest got just different builds. drivers/net/ethernet/amd/xgbe/xgbe-dev.c | 4 ++-- drivers/net/ethernet/apple/bmac.c| 8 ++-- drivers/net/ethernet/broadcom/tg3.c | 3 ++- drivers/net/ethernet/freescale/fec_main.c| 4 ++-- drivers/net/ethernet/freescale/fs_enet/fec.h | 3 --- drivers/net/ethernet/freescale/fs_enet/mac-fec.c | 3 ++- drivers/net/ethernet/micrel/ks8851_mll.c | 3 ++- drivers/net/ethernet/synopsys/dwc-xlgmac-hw.c| 4 ++-- 8 files changed, 14 insertions(+), 18 deletions(-) diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-dev.c b/drivers/net/ethernet/amd/xgbe/xgbe-dev.c index e107e180e2c8..1e929a1e4ca7 100644 --- a/drivers/net/ethernet/amd/xgbe/xgbe-dev.c +++ b/drivers/net/ethernet/amd/xgbe/xgbe-dev.c @@ -119,6 +119,7 @@ #include #include #include +#include #include "xgbe.h" #include "xgbe-common.h" @@ -887,7 +888,6 @@ static int xgbe_disable_rx_vlan_filtering(struct xgbe_prv_data *pdata) static u32 xgbe_vid_crc32_le(__le16 vid_le) { - u32 poly = 0xedb88320; /* CRCPOLY_LE */ u32 crc = ~0; u32 temp = 0; unsigned char *data = (unsigned char *)&vid_le; @@ -904,7 +904,7 @@ static u32 xgbe_vid_crc32_le(__le16 vid_le) data_byte >>= 1; if (temp) - crc ^= poly; + crc ^= CRC32_POLY_LE; } return crc; diff --git a/drivers/net/ethernet/apple/bmac.c b/drivers/net/ethernet/apple/bmac.c index 5a655d289dd5..024998d6d8c6 100644 --- a/drivers/net/ethernet/apple/bmac.c +++ b/drivers/net/ethernet/apple/bmac.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -37,11 +38,6 @@ #define trunc_page(x) ((void *)(((unsigned long)(x)) & ~((unsigned long)(PAGE_SIZE - 1 #define round_page(x) trunc_page(((unsigned long)(x)) + ((unsigned long)(PAGE_SIZE - 1))) -/* - * CRC polynomial - used in working out multicast filter bits. - */ -#define ENET_CRCPOLY 0x04c11db7 - /* switch to use multicast code lifted from sunhme driver */ #define SUNHME_MULTICAST @@ -838,7 +834,7 @@ crc416(unsigned int curval, unsigned short nxtval) next = next >> 1; /* do the XOR */ - if (high_crc_set ^ low_data_set) cur = cur ^ ENET_CRCPOLY; + if (high_crc_set ^ low_data_set) cur = cur ^ CRC32_POLY_BE; } return cur; } diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index 0a796d5ec893..3d526d99ac59 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c @@ -50,6 +50,7 @@ #include #include #include +#include #include #include @@ -9709,7 +9710,7 @@ static inline u32 calc_crc(unsigned char *buf, int len) reg >>= 1; if (tmp) - reg ^= 0xedb88320; + reg ^= CRC32_POLY_LE; } } diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index c729665107f5..a7cb378ef881 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -48,6 +48,7 @@ #include #include #include +#include #include #include #include @@ -2949,7 +2950,6 @@ fec_enet_close(struct net_device *ndev) */ #define FEC_HASH_BITS 6 /* #bits in hash */ -#define CRC32_POLY 0xEDB88320 static void set_multicast_list(struct net_device *ndev) { @@ -2989,7 +2989,7 @@ static void set_multicast_list(struct net_device *ndev) data = ha->addr[i]; for (bit = 0; bit < 8; bit++, data >>= 1) { crc = (crc >> 1) ^ - (((crc ^ data) & 1) ? CRC32_POLY : 0); + (((crc ^ data) & 1) ? CRC32_POLY_LE : 0); } } diff --git a/drivers/net/ethernet/freescale/fs_enet/fec.h b/drivers/net/ethernet/freescale/fs_enet/fec.h index 7832db71dcb9..1dbee5d898b3 100644 --- a/drivers/net/ethernet/freescale/fs_enet/fec.h +++ b/drivers/net/ethernet/freescale/fs_enet/fec.h @@ -2,9 +2,6 @@ #ifndef FS_ENET_FEC_H #define FS_ENET_FEC_H -/* CRC polynomium used by the FEC for the multicast group filtering */ -#define FEC_CRC_POLY 0x04C11DB7 - #define FEC_MAX_MULTICAST_ADDRS64 /* Interrupt events/masks. diff --git a/drivers/net/ethernet/freescale/fs_enet/mac-fec.c b/drivers/net/ethernet/freescale/fs_enet/mac-fec.c index 1
[PATCH 2/6] lib/crc: Use consistent naming for CRC-32 polynomials
Header was defining CRCPOLY_LE/BE and CRC32C_POLY_LE but in fact all of them are CRC-32 polynomials so use consistent naming. Signed-off-by: Krzysztof Kozlowski --- include/linux/crc32poly.h | 4 ++-- lib/crc32.c | 10 +- lib/gen_crc32table.c | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/linux/crc32poly.h b/include/linux/crc32poly.h index 7ad5aa92d3c7..62c4b7790a28 100644 --- a/include/linux/crc32poly.h +++ b/include/linux/crc32poly.h @@ -7,8 +7,8 @@ * *the* standard CRC-32 polynomial, first popularized by Ethernet. * x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x^1+x^0 */ -#define CRCPOLY_LE 0xedb88320 -#define CRCPOLY_BE 0x04c11db7 +#define CRC32_POLY_LE 0xedb88320 +#define CRC32_POLY_BE 0x04c11db7 /* * This is the CRC32c polynomial, as outlined by Castagnoli. diff --git a/lib/crc32.c b/lib/crc32.c index 341c54cb4edf..a6c9afafc8c8 100644 --- a/lib/crc32.c +++ b/lib/crc32.c @@ -185,7 +185,7 @@ static inline u32 __pure crc32_le_generic(u32 crc, unsigned char const *p, #if CRC_LE_BITS == 1 u32 __pure crc32_le(u32 crc, unsigned char const *p, size_t len) { - return crc32_le_generic(crc, p, len, NULL, CRCPOLY_LE); + return crc32_le_generic(crc, p, len, NULL, CRC32_POLY_LE); } u32 __pure __crc32c_le(u32 crc, unsigned char const *p, size_t len) { @@ -195,7 +195,7 @@ u32 __pure __crc32c_le(u32 crc, unsigned char const *p, size_t len) u32 __pure crc32_le(u32 crc, unsigned char const *p, size_t len) { return crc32_le_generic(crc, p, len, - (const u32 (*)[256])crc32table_le, CRCPOLY_LE); + (const u32 (*)[256])crc32table_le, CRC32_POLY_LE); } u32 __pure __crc32c_le(u32 crc, unsigned char const *p, size_t len) { @@ -269,7 +269,7 @@ static u32 __attribute_const__ crc32_generic_shift(u32 crc, size_t len, u32 __attribute_const__ crc32_le_shift(u32 crc, size_t len) { - return crc32_generic_shift(crc, len, CRCPOLY_LE); + return crc32_generic_shift(crc, len, CRC32_POLY_LE); } u32 __attribute_const__ __crc32c_le_shift(u32 crc, size_t len) @@ -331,13 +331,13 @@ static inline u32 __pure crc32_be_generic(u32 crc, unsigned char const *p, #if CRC_LE_BITS == 1 u32 __pure crc32_be(u32 crc, unsigned char const *p, size_t len) { - return crc32_be_generic(crc, p, len, NULL, CRCPOLY_BE); + return crc32_be_generic(crc, p, len, NULL, CRC32_POLY_BE); } #else u32 __pure crc32_be(u32 crc, unsigned char const *p, size_t len) { return crc32_be_generic(crc, p, len, - (const u32 (*)[256])crc32table_be, CRCPOLY_BE); + (const u32 (*)[256])crc32table_be, CRC32_POLY_BE); } #endif EXPORT_SYMBOL(crc32_be); diff --git a/lib/gen_crc32table.c b/lib/gen_crc32table.c index 34c3bc826f45..f755b997b967 100644 --- a/lib/gen_crc32table.c +++ b/lib/gen_crc32table.c @@ -58,7 +58,7 @@ static void crc32init_le_generic(const uint32_t polynomial, static void crc32init_le(void) { - crc32init_le_generic(CRCPOLY_LE, crc32table_le); + crc32init_le_generic(CRC32_POLY_LE, crc32table_le); } static void crc32cinit_le(void) @@ -77,7 +77,7 @@ static void crc32init_be(void) crc32table_be[0][0] = 0; for (i = 1; i < BE_TABLE_SIZE; i <<= 1) { - crc = (crc << 1) ^ ((crc & 0x8000) ? CRCPOLY_BE : 0); + crc = (crc << 1) ^ ((crc & 0x8000) ? CRC32_POLY_BE : 0); for (j = 0; j < i; j++) crc32table_be[0][i + j] = crc ^ crc32table_be[0][j]; } -- 2.14.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 0/6] lib/crc32: treewide: Use existing define with polynomial
Hi, Kernel defines same polynomial for CRC-32 in few places. This is unnecessary duplication of the same value. Also this might be error-prone for future code - every driver will define the polynomial again. This is an attempt to unify definition of polynomial. Few obvious hard-coded locations are fixed with define. All series depend on each 1/6 and 2/6. This could be merged in two different merge windows (1st lib/crc and then the rest) or taken through one tree. It would be nice to get some testing. Only generic lib/crc, bunzip, xz_crc32 and Freescale's Ethernet driver were tested on HW. Rest got just different builds. Best regards, Krzysztof Krzysztof Kozlowski (6): lib/crc: Move polynomial definition to separate header lib/crc: Use consistent naming for CRC-32 polynomials crypto: stm32_crc32 - Use existing define with polynomial net: ethernet: Use existing define with polynomial staging: rtl: Use existing define with polynomial lib: Use existing define with polynomial drivers/crypto/stm32/stm32_crc32.c | 11 --- drivers/net/ethernet/amd/xgbe/xgbe-dev.c | 4 ++-- drivers/net/ethernet/apple/bmac.c| 8 ++-- drivers/net/ethernet/broadcom/tg3.c | 3 ++- drivers/net/ethernet/freescale/fec_main.c| 4 ++-- drivers/net/ethernet/freescale/fs_enet/fec.h | 3 --- drivers/net/ethernet/freescale/fs_enet/mac-fec.c | 3 ++- drivers/net/ethernet/micrel/ks8851_mll.c | 3 ++- drivers/net/ethernet/synopsys/dwc-xlgmac-hw.c| 4 ++-- drivers/staging/rtl8712/rtl871x_security.c | 5 ++--- drivers/staging/rtl8723bs/core/rtw_security.c| 5 ++--- include/linux/crc32poly.h| 20 lib/crc32.c | 11 ++- lib/crc32defs.h | 14 -- lib/decompress_bunzip2.c | 3 ++- lib/gen_crc32table.c | 5 +++-- lib/xz/xz_crc32.c| 3 ++- 17 files changed, 55 insertions(+), 54 deletions(-) create mode 100644 include/linux/crc32poly.h -- 2.14.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 6/6] lib: Use existing define with polynomial
Do not define again the polynomial but use header with existing define. Signed-off-by: Krzysztof Kozlowski --- lib/decompress_bunzip2.c | 3 ++- lib/xz/xz_crc32.c| 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/decompress_bunzip2.c b/lib/decompress_bunzip2.c index 0234361b24b8..7c4932eed748 100644 --- a/lib/decompress_bunzip2.c +++ b/lib/decompress_bunzip2.c @@ -51,6 +51,7 @@ #endif /* STATIC */ #include +#include #ifndef INT_MAX #define INT_MAX 0x7fff @@ -654,7 +655,7 @@ static int INIT start_bunzip(struct bunzip_data **bdp, void *inbuf, long len, for (i = 0; i < 256; i++) { c = i << 24; for (j = 8; j; j--) - c = c&0x8000 ? (c << 1)^0x04c11db7 : (c << 1); + c = c&0x8000 ? (c << 1)^(CRC32_POLY_BE) : (c << 1); bd->crc32Table[i] = c; } diff --git a/lib/xz/xz_crc32.c b/lib/xz/xz_crc32.c index 34532d14fd4c..25a5d87e2e4c 100644 --- a/lib/xz/xz_crc32.c +++ b/lib/xz/xz_crc32.c @@ -15,6 +15,7 @@ * but they are bigger and use more memory for the lookup table. */ +#include #include "xz_private.h" /* @@ -29,7 +30,7 @@ STATIC_RW_DATA uint32_t xz_crc32_table[256]; XZ_EXTERN void xz_crc32_init(void) { - const uint32_t poly = 0xEDB88320; + const uint32_t poly = CRC32_POLY_LE; uint32_t i; uint32_t j; -- 2.14.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 0/6] lib/crc32: treewide: Use existing define with polynomial
On 18 July 2018 at 02:12, Eric Biggers wrote: > Hi Krzysztof, > > On Tue, Jul 17, 2018 at 06:05:35PM +0200, Krzysztof Kozlowski wrote: >> Hi, >> >> Kernel defines same polynomial for CRC-32 in few places. >> This is unnecessary duplication of the same value. Also this might >> be error-prone for future code - every driver will define the >> polynomial again. >> >> This is an attempt to unify definition of polynomial. Few obvious >> hard-coded locations are fixed with define. >> >> All series depend on each 1/6 and 2/6. >> >> This could be merged in two different merge windows (1st lib/crc and then >> the rest) or taken through one tree. >> >> It would be nice to get some testing. Only generic lib/crc, bunzip, xz_crc32 >> and Freescale's Ethernet driver were tested on HW. Rest got just different >> builds. >> >> Best regards, >> Krzysztof >> >> Krzysztof Kozlowski (6): >> lib/crc: Move polynomial definition to separate header >> lib/crc: Use consistent naming for CRC-32 polynomials >> crypto: stm32_crc32 - Use existing define with polynomial >> net: ethernet: Use existing define with polynomial >> staging: rtl: Use existing define with polynomial >> lib: Use existing define with polynomial >> >> drivers/crypto/stm32/stm32_crc32.c | 11 --- >> drivers/net/ethernet/amd/xgbe/xgbe-dev.c | 4 ++-- >> drivers/net/ethernet/apple/bmac.c| 8 ++-- >> drivers/net/ethernet/broadcom/tg3.c | 3 ++- >> drivers/net/ethernet/freescale/fec_main.c| 4 ++-- >> drivers/net/ethernet/freescale/fs_enet/fec.h | 3 --- >> drivers/net/ethernet/freescale/fs_enet/mac-fec.c | 3 ++- >> drivers/net/ethernet/micrel/ks8851_mll.c | 3 ++- >> drivers/net/ethernet/synopsys/dwc-xlgmac-hw.c| 4 ++-- >> drivers/staging/rtl8712/rtl871x_security.c | 5 ++--- >> drivers/staging/rtl8723bs/core/rtw_security.c| 5 ++--- >> include/linux/crc32poly.h| 20 >> lib/crc32.c | 11 ++- >> lib/crc32defs.h | 14 -- >> lib/decompress_bunzip2.c | 3 ++- >> lib/gen_crc32table.c | 5 +++-- >> lib/xz/xz_crc32.c| 3 ++- >> 17 files changed, 55 insertions(+), 54 deletions(-) >> create mode 100644 include/linux/crc32poly.h >> > > Did you check whether any of these users can be converted to use the CRC > implementations in lib/, so they wouldn't need the polynomial definition > themselves? I did not check but that's interesting point... The Ethernet drivers (xgbe, tg3, fec, ks8851, dwc-xlgmac) look like could be converted to generic implementation. The apple/bmac looks weird. The rtl WiFi drivers in long term can be converted to use generic lib80211 for encryption (see commit 0d4876f4e977 ("staging:r8188eu: Use lib80211 to encrypt (TKIP) tx frames")) but that is much bigger task. The remaining use the polynomials in different aspect: 1. XZ and BUNZIP use it to create CRC tables - probably generic gen_crc32table.c could be used, 2. stm32_crc32.c uses it to initialize HW CRC accelerator. I can work on Freescale FEC, xz and bunzip code because these I can test but I would prefer to do it as follow up. Best regards, Krzysztof ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: iio: ad7606_par: 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 --- drivers/staging/iio/adc/ad7606_par.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/adc/ad7606_par.c b/drivers/staging/iio/adc/ad7606_par.c index 9e24b4d4455f..1d48ae381d16 100644 --- a/drivers/staging/iio/adc/ad7606_par.c +++ b/drivers/staging/iio/adc/ad7606_par.c @@ -119,7 +119,7 @@ static const struct dev_pm_ops ad7606_pm_ops = { #define AD7606_PAR_PM_OPS NULL #endif /* CONFIG_PM */ -static struct platform_device_id ad7606_driver_ids[] = { +static const struct platform_device_id ad7606_driver_ids[] = { { .name = "ad7606-8", .driver_data= ID_AD7606_8, -- 2.1.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: media: omap4iss: 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 --- drivers/staging/media/omap4iss/iss.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/media/omap4iss/iss.c b/drivers/staging/media/omap4iss/iss.c index e0ad5e520e2d..68867f286afd 100644 --- a/drivers/staging/media/omap4iss/iss.c +++ b/drivers/staging/media/omap4iss/iss.c @@ -1478,7 +1478,7 @@ static int iss_remove(struct platform_device *pdev) return 0; } -static struct platform_device_id omap4iss_id_table[] = { +static const struct platform_device_id omap4iss_id_table[] = { { "omap4iss", 0 }, { }, }; -- 2.1.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: most: Fix Kconfig indentation
Adjust indentation from spaces to tab (+optional two spaces) as in coding style with command like: $ sed -e 's/^/\t/' -i */Kconfig Signed-off-by: Krzysztof Kozlowski --- drivers/staging/most/Kconfig | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/most/Kconfig b/drivers/staging/most/Kconfig index 8948d5246409..6262eb25c80b 100644 --- a/drivers/staging/most/Kconfig +++ b/drivers/staging/most/Kconfig @@ -1,9 +1,9 @@ # SPDX-License-Identifier: GPL-2.0 menuconfig MOST -tristate "MOST support" + tristate "MOST support" depends on HAS_DMA && CONFIGFS_FS -default n -help + default n + help Say Y here if you want to enable MOST support. This driver needs at least one additional component to enable the desired access from userspace (e.g. character devices) and one that @@ -12,7 +12,7 @@ menuconfig MOST To compile this driver as a module, choose M here: the module will be called most_core. - If in doubt, say N here. + If in doubt, say N here. -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: fbtft: Fix Kconfig indentation
Adjust indentation from spaces to tab (+optional two spaces) as in coding style with command like: $ sed -e 's/^/\t/' -i */Kconfig Signed-off-by: Krzysztof Kozlowski --- drivers/staging/fbtft/Kconfig | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/fbtft/Kconfig b/drivers/staging/fbtft/Kconfig index d994aea84b21..19d9d88e9150 100644 --- a/drivers/staging/fbtft/Kconfig +++ b/drivers/staging/fbtft/Kconfig @@ -95,8 +95,8 @@ config FB_TFT_PCD8544 Generic Framebuffer support for PCD8544 config FB_TFT_RA8875 -tristate "FB driver for the RA8875 LCD Controller" -depends on FB_TFT + tristate "FB driver for the RA8875 LCD Controller" + depends on FB_TFT help Generic Framebuffer support for RA8875 @@ -132,10 +132,10 @@ config FB_TFT_SSD1289 Framebuffer support for SSD1289 config FB_TFT_SSD1305 -tristate "FB driver for the SSD1305 OLED Controller" -depends on FB_TFT -help - Framebuffer support for SSD1305 + tristate "FB driver for the SSD1305 OLED Controller" + depends on FB_TFT + help + Framebuffer support for SSD1305 config FB_TFT_SSD1306 tristate "FB driver for the SSD1306 OLED Controller" -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: fwserial: Fix Kconfig indentation
Adjust indentation from spaces to tab (+optional two spaces) as in coding style with command like: $ sed -e 's/^/\t/' -i */Kconfig Signed-off-by: Krzysztof Kozlowski --- drivers/staging/fwserial/Kconfig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/fwserial/Kconfig b/drivers/staging/fwserial/Kconfig index 9543f8454af9..d21124a1a127 100644 --- a/drivers/staging/fwserial/Kconfig +++ b/drivers/staging/fwserial/Kconfig @@ -3,7 +3,7 @@ config FIREWIRE_SERIAL tristate "TTY over Firewire" depends on FIREWIRE && TTY help - This enables TTY over IEEE 1394, providing high-speed serial + This enables TTY over IEEE 1394, providing high-speed serial connectivity to cabled peers. This driver implements a ad-hoc transport protocol and is currently limited to Linux-to-Linux communication. @@ -17,7 +17,7 @@ config FWTTY_MAX_TOTAL_PORTS int "Maximum number of serial ports supported" default "64" help - Set this to the maximum number of serial ports you want the + Set this to the maximum number of serial ports you want the firewire-serial driver to support. config FWTTY_MAX_CARD_PORTS @@ -25,7 +25,7 @@ config FWTTY_MAX_CARD_PORTS range 0 FWTTY_MAX_TOTAL_PORTS default "32" help - Set this to the maximum number of serial ports each firewire + Set this to the maximum number of serial ports each firewire adapter supports. The actual number of serial ports registered is set with the module parameter "ttys". -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: vc04: Fix Kconfig indentation
Adjust indentation from spaces to tab (+optional two spaces) as in coding style with command like: $ sed -e 's/^/\t/' -i */Kconfig Signed-off-by: Krzysztof Kozlowski --- drivers/staging/vc04_services/bcm2835-audio/Kconfig | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-audio/Kconfig b/drivers/staging/vc04_services/bcm2835-audio/Kconfig index f66319512faf..d32ea348e846 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/Kconfig +++ b/drivers/staging/vc04_services/bcm2835-audio/Kconfig @@ -1,9 +1,9 @@ # SPDX-License-Identifier: GPL-2.0 config SND_BCM2835 -tristate "BCM2835 Audio" -depends on (ARCH_BCM2835 || COMPILE_TEST) && SND -select SND_PCM -select BCM2835_VCHIQ -help - Say Y or M if you want to support BCM2835 built in audio + tristate "BCM2835 Audio" + depends on (ARCH_BCM2835 || COMPILE_TEST) && SND + select SND_PCM + select BCM2835_VCHIQ + help + Say Y or M if you want to support BCM2835 built in audio -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: nvec: Fix Kconfig indentation
Adjust indentation from spaces to tab (+optional two spaces) as in coding style with command like: $ sed -e 's/^/\t/' -i */Kconfig Signed-off-by: Krzysztof Kozlowski --- drivers/staging/nvec/Kconfig | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/nvec/Kconfig b/drivers/staging/nvec/Kconfig index 5c12cacf75e1..9fa98c16f1d9 100644 --- a/drivers/staging/nvec/Kconfig +++ b/drivers/staging/nvec/Kconfig @@ -8,7 +8,7 @@ config MFD_NVEC controller. To compile this driver as a module, say M here: the module will be -called mfd-nvec + called mfd-nvec config KEYBOARD_NVEC tristate "Keyboard on nVidia compliant EC" @@ -18,7 +18,7 @@ config KEYBOARD_NVEC a nVidia compliant embedded controller. To compile this driver as a module, say M here: the module will be - called keyboard-nvec + called keyboard-nvec config SERIO_NVEC_PS2 tristate "PS2 on nVidia EC" @@ -28,7 +28,7 @@ config SERIO_NVEC_PS2 to a nVidia compliant embedded controller. To compile this driver as a module, say M here: the module will be - called serio-nvec-ps2 + called serio-nvec-ps2 config NVEC_POWER @@ -39,7 +39,7 @@ config NVEC_POWER nVidia compliant embedded controllers. To compile this driver as a module, say M here: the module will be - called nvec-power + called nvec-power config NVEC_PAZ00 @@ -50,5 +50,5 @@ config NVEC_PAZ00 devices, e.g. Toshbia AC100 and Dynabooks AZ netbooks. To compile this driver as a module, say M here: the module will be - called nvec-paz00 + called nvec-paz00 -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: pi433: Fix Kconfig indentation
Adjust indentation from spaces to tab (+optional two spaces) as in coding style with command like: $ sed -e 's/^/\t/' -i */Kconfig Signed-off-by: Krzysztof Kozlowski --- drivers/staging/pi433/Kconfig | 24 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/staging/pi433/Kconfig b/drivers/staging/pi433/Kconfig index 8acde0814206..dd9e4709d1a8 100644 --- a/drivers/staging/pi433/Kconfig +++ b/drivers/staging/pi433/Kconfig @@ -1,17 +1,17 @@ # SPDX-License-Identifier: GPL-2.0 config PI433 -tristate "Pi433 - a 433MHz radio module for Raspberry Pi" -depends on SPI -help - This option allows you to enable support for the radio module Pi433. + tristate "Pi433 - a 433MHz radio module for Raspberry Pi" + depends on SPI + help + This option allows you to enable support for the radio module Pi433. - Pi433 is a shield that fits onto the GPIO header of a Raspberry Pi - or compatible. It extends the Raspberry Pi with the option, to - send and receive data in the 433MHz ISM band - for example to - communicate between two systems without using ethernet or bluetooth - or for control or read sockets, actors, sensors, widely available - for low price. + Pi433 is a shield that fits onto the GPIO header of a Raspberry Pi + or compatible. It extends the Raspberry Pi with the option, to + send and receive data in the 433MHz ISM band - for example to + communicate between two systems without using ethernet or bluetooth + or for control or read sockets, actors, sensors, widely available + for low price. - For details or the option to buy, please visit https://pi433.de/en.html + For details or the option to buy, please visit https://pi433.de/en.html - If in doubt, say N here, but saying yes most probably won't hurt + If in doubt, say N here, but saying yes most probably won't hurt -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2] staging: fwserial: Fix Kconfig indentation
Adjust indentation from spaces to tab (+optional two spaces) as in coding style with command like: $ sed -e 's/^/\t/' -i */Kconfig Signed-off-by: Krzysztof Kozlowski --- Changes since v1: 1. Fix also 7-space and tab+1 space indentation issues. --- drivers/staging/fwserial/Kconfig | 26 +- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/staging/fwserial/Kconfig b/drivers/staging/fwserial/Kconfig index 9543f8454af9..6964aac2a7ed 100644 --- a/drivers/staging/fwserial/Kconfig +++ b/drivers/staging/fwserial/Kconfig @@ -1,9 +1,9 @@ # SPDX-License-Identifier: GPL-2.0 config FIREWIRE_SERIAL - tristate "TTY over Firewire" - depends on FIREWIRE && TTY - help - This enables TTY over IEEE 1394, providing high-speed serial + tristate "TTY over Firewire" + depends on FIREWIRE && TTY + help + This enables TTY over IEEE 1394, providing high-speed serial connectivity to cabled peers. This driver implements a ad-hoc transport protocol and is currently limited to Linux-to-Linux communication. @@ -14,18 +14,18 @@ config FIREWIRE_SERIAL if FIREWIRE_SERIAL config FWTTY_MAX_TOTAL_PORTS - int "Maximum number of serial ports supported" - default "64" - help - Set this to the maximum number of serial ports you want the + int "Maximum number of serial ports supported" + default "64" + help + Set this to the maximum number of serial ports you want the firewire-serial driver to support. config FWTTY_MAX_CARD_PORTS - int "Maximum number of serial ports supported per adapter" - range 0 FWTTY_MAX_TOTAL_PORTS - default "32" - help - Set this to the maximum number of serial ports each firewire + int "Maximum number of serial ports supported per adapter" + range 0 FWTTY_MAX_TOTAL_PORTS + default "32" + help + Set this to the maximum number of serial ports each firewire adapter supports. The actual number of serial ports registered is set with the module parameter "ttys". -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: fwserial: Fix Kconfig indentation (seven spaces)
Adjust indentation from seven spaces to tab (+optional two spaces) as in coding style with command like: $ sed -e 's/^ /\t/' -i */Kconfig Signed-off-by: Krzysztof Kozlowski --- drivers/staging/fwserial/Kconfig | 20 ++-- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/fwserial/Kconfig b/drivers/staging/fwserial/Kconfig index d21124a1a127..6964aac2a7ed 100644 --- a/drivers/staging/fwserial/Kconfig +++ b/drivers/staging/fwserial/Kconfig @@ -1,8 +1,8 @@ # SPDX-License-Identifier: GPL-2.0 config FIREWIRE_SERIAL - tristate "TTY over Firewire" - depends on FIREWIRE && TTY - help + tristate "TTY over Firewire" + depends on FIREWIRE && TTY + help This enables TTY over IEEE 1394, providing high-speed serial connectivity to cabled peers. This driver implements a ad-hoc transport protocol and is currently limited to @@ -14,17 +14,17 @@ config FIREWIRE_SERIAL if FIREWIRE_SERIAL config FWTTY_MAX_TOTAL_PORTS - int "Maximum number of serial ports supported" - default "64" - help + int "Maximum number of serial ports supported" + default "64" + help Set this to the maximum number of serial ports you want the firewire-serial driver to support. config FWTTY_MAX_CARD_PORTS - int "Maximum number of serial ports supported per adapter" - range 0 FWTTY_MAX_TOTAL_PORTS - default "32" - help + int "Maximum number of serial ports supported per adapter" + range 0 FWTTY_MAX_TOTAL_PORTS + default "32" + help Set this to the maximum number of serial ports each firewire adapter supports. The actual number of serial ports registered is set with the module parameter "ttys". -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v2 3/3] [media] include/media: move platform_data to linux/platform_data/media
W dniu 16.11.2015 o 20:00, Mauro Carvalho Chehab pisze: > Let's not mix platform_data headers with the core headers. Instead, let's > create a subdir at linux/platform_data and move the headers to that > common place, adding it to MAINTAINERS. > > The headers were moved with: > mkdir include/linux/platform_data/media/; git mv > include/media/gpio-ir-recv.h include/media/ir-rx51.h > include/media/mmp-camera.h include/media/omap1_camera.h > include/media/omap4iss.h include/media/s5p_hdmi.h include/media/si4713.h > include/media/sii9234.h include/media/smiapp.h include/media/soc_camera.h > include/media/soc_camera_platform.h include/media/timb_radio.h > include/media/timb_video.h include/linux/platform_data/media/ > > And the references fixed with this script: > MAIN_DIR="linux/platform_data/" > PREV_DIR="media/" > DIRS="media/" > > echo "Checking affected files" >&2 > for i in $DIRS; do > for j in $(find include/$MAIN_DIR/$i -type f -name '*.h'); do >n=`basename $j` > git grep -l $n > done > done|sort|uniq >files && ( > echo "Handling files..." >&2; > echo "for i in \$(cat files|grep -v Documentation); do cat \$i | \\"; > ( > cd include/$MAIN_DIR; > for j in $DIRS; do > for i in $(ls $j); do > echo "perl -ne 's,(include > [\\\"\\<])$PREV_DIR($i)([\\\"\\>]),\1$MAIN_DIR$j\2\3,; print \$_' |\\"; > done; > done; > echo "cat > a && mv a \$i; done"; > ); > echo "Handling documentation..." >&2; > echo "for i in MAINTAINERS \$(cat files); do cat \$i | \\"; > ( > cd include/$MAIN_DIR; > for j in $DIRS; do > for i in $(ls $j); do > echo " perl -ne > 's,include/$PREV_DIR($i)\b,include/$MAIN_DIR$j\1,; print \$_' |\\"; > done; > done; > echo "cat > a && mv a \$i; done" > ); > ) >script && . ./script > > Signed-off-by: Mauro Carvalho Chehab > --- > Documentation/video4linux/omap4_camera.txt | 2 +- > Documentation/video4linux/si4713.txt | 2 +- > MAINTAINERS | 1 + > arch/arm/mach-omap1/include/mach/camera.h | 2 +- > arch/arm/mach-omap2/board-rx51-peripherals.c | 4 ++-- > arch/arm/plat-samsung/devs.c | 2 +- Acked-by: Krzysztof Kozlowski Best regards, Krzysztof ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 04/23] mtd: nand: s3c2410: kill the ->ecc_layout field
On 08.12.2015 07:25, Boris Brezillon wrote: > The s3c2410 is allowing board data to overload the default ECC layout > defined inside the driver, but this feature is not used by board > specific definitions. > Kill this field so that we can easily move to a model where ecclayout > are dynamically allocated by the NAND controller driver. > > Signed-off-by: Boris Brezillon > --- > arch/arm/plat-samsung/devs.c | 9 - > drivers/mtd/nand/s3c2410.c | 3 --- > include/linux/platform_data/mtd-nand-s3c2410.h | 1 - > 3 files changed, 13 deletions(-) Acked-by: Krzysztof Kozlowski Best regards, Krzysztof ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v4 38/58] mtd: nand: s3c2410: use the mtd instance embedded in struct nand_chip
On 10.12.2015 17:00, Boris Brezillon wrote: > struct nand_chip now embeds an mtd device. Make use of this mtd instance. > > Signed-off-by: Boris Brezillon > --- > Changes generated with the following coccinelle script > > --->8--- > virtual patch > > @fix1@ > identifier __chipfield, __mtdfield; > type __type; > @@ > ( > __type { > ... > struct nand_chip __chipfield; > ... > - struct mtd_info __mtdfield; > ... > }; > | > __type { > ... > - struct mtd_info __mtdfield; > ... > struct nand_chip __chipfield; > ... > }; > ) > > @fix2 depends on fix1@ > identifier fix1.__chipfield, fix1.__mtdfield; > identifier __subfield; > type fix1.__type; > __type *__priv; > @@ > ( > - __priv->__mtdfield.__subfield > + nand_to_mtd(&__priv->__chipfield)->__subfield > | > - &(__priv->__mtdfield) > + nand_to_mtd(&__priv->__chipfield) > ) > --->8--- > --- > drivers/mtd/nand/s3c2410.c | 23 ++- > 1 file changed, 14 insertions(+), 9 deletions(-) > Looks correct: Reviewed-by: Krzysztof Kozlowski Best regards, Krzysztof ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[RFC 00/15] tree-wide: mfd: syscon: Fix unmet ioremap dependency
Hi, Building allyesconfig on ARCH=um fails with: drivers/mfd/syscon.c: In function ‘of_syscon_register’: drivers/mfd/syscon.c:67:9: error: implicit declaration of function ‘ioremap’ [-Werror=implicit-function-declaration] base = ioremap(res.start, resource_size(&res)); Since commit c89c0114955a ("mfd: syscon: Set regmap max_register in of_syscon_register") the syscon depends on HAS_IOMEM because it uses the ioremap(). However syscon is often directly selected... so first the dependency on HAS_IOMEM has to be added to all selecting symbols. Comments are welcomed whether this is appropriate approach. The last patch "mfd: syscon: Fix build of missing ioremap on UM" should enter all other to avoid kbuild complains like: warning: (ST_IRQCHIP && HIP04_ETH && STMMAC_PLATFORM && DWMAC_IPQ806X && DWMAC_LPC18XX && DWMAC_ROCKCHIP && DWMAC_SOCFPGA && DWMAC_STI && TI_CPSW && PINCTRL_ROCKCHIP && PINCTRL_DOVE && POWER_RESET_KEYSTONE && S3C2410_WATCHDOG && VIDEO_OMAP3 && VIDEO_S5P_FIMC && USB_XHCI_MTK && RTC_DRV_AT91SAM9 && LPC18XX_DMAMUX && VIDEO_OMAP4 && HWSPINLOCK_QCOM && ATMEL_ST && QCOM_GSBI && PHY_HI6220_USB) selects MFD_SYSCON which has unmet direct dependencies (HAS_IOMEM) Best regards, Krzysztof Krzysztof Kozlowski (15): clocksource: atmel: Add missing MFD_SYSCON dependency on HAS_IOMEM dmaengine: nxp: Add missing MFD_SYSCON dependency on HAS_IOMEM hwspinlock: qcom: Add missing MFD_SYSCON dependency on HAS_IOMEM irqchip: st: Add missing MFD_SYSCON dependency on HAS_IOMEM phy: hi6220: Add missing MFD_SYSCON dependency on HAS_IOMEM pinctrl: rockchip: Add missing MFD_SYSCON dependency on HAS_IOMEM pinctrl: mvebu: Add missing MFD_SYSCON dependency on HAS_IOMEM rtc: at91sam9: Add missing MFD_SYSCON dependency on HAS_IOMEM media: platform: Add missing MFD_SYSCON dependency on HAS_IOMEM net: ethernet: Add missing MFD_SYSCON dependency on HAS_IOMEM power: reset: keystone: Add missing MFD_SYSCON dependency on HAS_IOMEM soc: qcom: Add missing MFD_SYSCON dependency on HAS_IOMEM staging: media: omap4iss: Add missing MFD_SYSCON dependency on HAS_IOMEM usb: xhci: mtk: Add missing MFD_SYSCON dependency on HAS_IOMEM mfd: syscon: Fix build of missing ioremap on UM drivers/clocksource/Kconfig | 1 + drivers/dma/Kconfig | 1 + drivers/hwspinlock/Kconfig | 1 + drivers/irqchip/Kconfig | 1 + drivers/media/platform/Kconfig | 1 + drivers/media/platform/exynos4-is/Kconfig | 1 + drivers/mfd/Kconfig | 1 + drivers/net/ethernet/hisilicon/Kconfig | 1 + drivers/net/ethernet/stmicro/stmmac/Kconfig | 6 ++ drivers/net/ethernet/ti/Kconfig | 1 + drivers/phy/Kconfig | 1 + drivers/pinctrl/Kconfig | 1 + drivers/pinctrl/mvebu/Kconfig | 1 + drivers/power/reset/Kconfig | 1 + drivers/rtc/Kconfig | 1 + drivers/soc/qcom/Kconfig| 1 + drivers/staging/media/omap4iss/Kconfig | 1 + drivers/usb/host/Kconfig| 1 + 18 files changed, 23 insertions(+) -- 2.5.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[RFC 01/15] clocksource: atmel: Add missing MFD_SYSCON dependency on HAS_IOMEM
The MFD_SYSCON depends on HAS_IOMEM so when selecting it avoid unmet direct dependencies. Signed-off-by: Krzysztof Kozlowski --- drivers/clocksource/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig index c346be650892..5927944b46e0 100644 --- a/drivers/clocksource/Kconfig +++ b/drivers/clocksource/Kconfig @@ -239,6 +239,7 @@ config ATMEL_PIT config ATMEL_ST bool + depends on HAS_IOMEM# For MFD_SYSCON select CLKSRC_OF select MFD_SYSCON -- 2.5.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[RFC 05/15] phy: hi6220: Add missing MFD_SYSCON dependency on HAS_IOMEM
The MFD_SYSCON depends on HAS_IOMEM so when selecting it avoid unmet direct dependencies. Signed-off-by: Krzysztof Kozlowski --- drivers/phy/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index 0124d17bd9fe..cfdb3551a675 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -225,6 +225,7 @@ config PHY_MT65XX_USB3 config PHY_HI6220_USB tristate "hi6220 USB PHY support" depends on (ARCH_HISI && ARM64) || COMPILE_TEST + depends on HAS_IOMEM# For MFD_SYSCON select GENERIC_PHY select MFD_SYSCON help -- 2.5.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[RFC 02/15] dmaengine: nxp: Add missing MFD_SYSCON dependency on HAS_IOMEM
The MFD_SYSCON depends on HAS_IOMEM so when selecting it avoid unmet direct dependencies. Signed-off-by: Krzysztof Kozlowski --- drivers/dma/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig index c77f214c9466..7fbf96bff280 100644 --- a/drivers/dma/Kconfig +++ b/drivers/dma/Kconfig @@ -290,6 +290,7 @@ config LPC18XX_DMAMUX bool "NXP LPC18xx/43xx DMA MUX for PL080" depends on ARCH_LPC18XX || COMPILE_TEST depends on OF && AMBA_PL08X + depends on HAS_IOMEM# For MFD_SYSCON select MFD_SYSCON help Enable support for DMA on NXP LPC18xx/43xx platforms -- 2.5.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[RFC 03/15] hwspinlock: qcom: Add missing MFD_SYSCON dependency on HAS_IOMEM
The MFD_SYSCON depends on HAS_IOMEM so when selecting it avoid unmet direct dependencies. Signed-off-by: Krzysztof Kozlowski --- drivers/hwspinlock/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/hwspinlock/Kconfig b/drivers/hwspinlock/Kconfig index 73a401662853..5ab2d51dc147 100644 --- a/drivers/hwspinlock/Kconfig +++ b/drivers/hwspinlock/Kconfig @@ -21,6 +21,7 @@ config HWSPINLOCK_OMAP config HWSPINLOCK_QCOM tristate "Qualcomm Hardware Spinlock device" depends on ARCH_QCOM + depends on HAS_IOMEM# For MFD_SYSCON select HWSPINLOCK select MFD_SYSCON help -- 2.5.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[RFC 04/15] irqchip: st: Add missing MFD_SYSCON dependency on HAS_IOMEM
The MFD_SYSCON depends on HAS_IOMEM so when selecting it avoid unmet direct dependencies. Signed-off-by: Krzysztof Kozlowski --- drivers/irqchip/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig index 00bbec6eca0b..10775b099daa 100644 --- a/drivers/irqchip/Kconfig +++ b/drivers/irqchip/Kconfig @@ -157,6 +157,7 @@ config RENESAS_IRQC config ST_IRQCHIP bool select REGMAP + depends on HAS_IOMEM# For MFD_SYSCON select MFD_SYSCON help Enables SysCfg Controlled IRQs on STi based platforms. -- 2.5.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[RFC 06/15] pinctrl: rockchip: Add missing MFD_SYSCON dependency on HAS_IOMEM
The MFD_SYSCON depends on HAS_IOMEM so when selecting it avoid unmet direct dependencies. Signed-off-by: Krzysztof Kozlowski --- drivers/pinctrl/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig index fb8200b8e8ec..dc7ab58d4d74 100644 --- a/drivers/pinctrl/Kconfig +++ b/drivers/pinctrl/Kconfig @@ -131,6 +131,7 @@ config PINCTRL_MESON config PINCTRL_ROCKCHIP bool + depends on HAS_IOMEM# For MFD_SYSCON select PINMUX select GENERIC_PINCONF select GENERIC_IRQ_CHIP -- 2.5.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[RFC 07/15] pinctrl: mvebu: Add missing MFD_SYSCON dependency on HAS_IOMEM
The MFD_SYSCON depends on HAS_IOMEM so when selecting it avoid unmet direct dependencies. Signed-off-by: Krzysztof Kozlowski --- drivers/pinctrl/mvebu/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/pinctrl/mvebu/Kconfig b/drivers/pinctrl/mvebu/Kconfig index 170602407c0d..13685923729c 100644 --- a/drivers/pinctrl/mvebu/Kconfig +++ b/drivers/pinctrl/mvebu/Kconfig @@ -7,6 +7,7 @@ config PINCTRL_MVEBU config PINCTRL_DOVE bool + depends on HAS_IOMEM# For MFD_SYSCON select PINCTRL_MVEBU select MFD_SYSCON -- 2.5.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[RFC 08/15] rtc: at91sam9: Add missing MFD_SYSCON dependency on HAS_IOMEM
The MFD_SYSCON depends on HAS_IOMEM so when selecting it avoid unmet direct dependencies. Signed-off-by: Krzysztof Kozlowski --- drivers/rtc/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index 0da40e2e4280..5c530b6b125d 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig @@ -1302,6 +1302,7 @@ config RTC_DRV_AT91RM9200 config RTC_DRV_AT91SAM9 tristate "AT91SAM9 RTT as RTC" depends on ARCH_AT91 || COMPILE_TEST + depends on HAS_IOMEM# For MFD_SYSCON select MFD_SYSCON help Some AT91SAM9 SoCs provide an RTT (Real Time Timer) block which -- 2.5.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[RFC 14/15] usb: xhci: mtk: Add missing MFD_SYSCON dependency on HAS_IOMEM
The MFD_SYSCON depends on HAS_IOMEM so when selecting it avoid unmet direct dependencies. Signed-off-by: Krzysztof Kozlowski --- drivers/usb/host/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index 8c20ebbc049c..f759a778d606 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig @@ -45,6 +45,7 @@ config USB_XHCI_PLATFORM config USB_XHCI_MTK tristate "xHCI support for Mediatek MT65xx" + depends on HAS_IOMEM# For MFD_SYSCON select MFD_SYSCON depends on ARCH_MEDIATEK || COMPILE_TEST ---help--- -- 2.5.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[RFC 10/15] net: ethernet: Add missing MFD_SYSCON dependency on HAS_IOMEM
The MFD_SYSCON depends on HAS_IOMEM so when selecting it avoid unmet direct dependencies. Signed-off-by: Krzysztof Kozlowski --- drivers/net/ethernet/hisilicon/Kconfig | 1 + drivers/net/ethernet/stmicro/stmmac/Kconfig | 6 ++ drivers/net/ethernet/ti/Kconfig | 1 + 3 files changed, 8 insertions(+) diff --git a/drivers/net/ethernet/hisilicon/Kconfig b/drivers/net/ethernet/hisilicon/Kconfig index 74beb1867230..6a9c91781bf9 100644 --- a/drivers/net/ethernet/hisilicon/Kconfig +++ b/drivers/net/ethernet/hisilicon/Kconfig @@ -26,6 +26,7 @@ config HIX5HD2_GMAC config HIP04_ETH tristate "HISILICON P04 Ethernet support" select MARVELL_PHY + depends on HAS_IOMEM# For MFD_SYSCON select MFD_SYSCON select HNS_MDIO ---help--- diff --git a/drivers/net/ethernet/stmicro/stmmac/Kconfig b/drivers/net/ethernet/stmicro/stmmac/Kconfig index cec147d1d34f..d6902bf6e90f 100644 --- a/drivers/net/ethernet/stmicro/stmmac/Kconfig +++ b/drivers/net/ethernet/stmicro/stmmac/Kconfig @@ -16,6 +16,7 @@ if STMMAC_ETH config STMMAC_PLATFORM tristate "STMMAC Platform bus support" depends on STMMAC_ETH + depends on HAS_IOMEM# For MFD_SYSCON select MFD_SYSCON default y ---help--- @@ -41,6 +42,7 @@ config DWMAC_IPQ806X tristate "QCA IPQ806x DWMAC support" default ARCH_QCOM depends on OF + depends on HAS_IOMEM# For MFD_SYSCON select MFD_SYSCON help Support for QCA IPQ806X DWMAC Ethernet. @@ -54,6 +56,7 @@ config DWMAC_LPC18XX tristate "NXP LPC18xx/43xx DWMAC support" default ARCH_LPC18XX depends on OF + depends on HAS_IOMEM# For MFD_SYSCON select MFD_SYSCON ---help--- Support for NXP LPC18xx/43xx DWMAC Ethernet. @@ -73,6 +76,7 @@ config DWMAC_ROCKCHIP tristate "Rockchip dwmac support" default ARCH_ROCKCHIP depends on OF + depends on HAS_IOMEM# For MFD_SYSCON select MFD_SYSCON help Support for Ethernet controller on Rockchip RK3288 SoC. @@ -84,6 +88,7 @@ config DWMAC_SOCFPGA tristate "SOCFPGA dwmac support" default ARCH_SOCFPGA depends on OF + depends on HAS_IOMEM# For MFD_SYSCON select MFD_SYSCON help Support for ethernet controller on Altera SOCFPGA @@ -96,6 +101,7 @@ config DWMAC_STI tristate "STi GMAC support" default ARCH_STI depends on OF + depends on HAS_IOMEM# For MFD_SYSCON select MFD_SYSCON ---help--- Support for ethernet controller on STi SOCs. diff --git a/drivers/net/ethernet/ti/Kconfig b/drivers/net/ethernet/ti/Kconfig index e7f0b7d95b65..ec56cebe929d 100644 --- a/drivers/net/ethernet/ti/Kconfig +++ b/drivers/net/ethernet/ti/Kconfig @@ -62,6 +62,7 @@ config TI_CPSW_ALE config TI_CPSW tristate "TI CPSW Switch Support" depends on ARCH_DAVINCI || ARCH_OMAP2PLUS + depends on HAS_IOMEM# For MFD_SYSCON select TI_DAVINCI_CPDMA select TI_DAVINCI_MDIO select TI_CPSW_PHY_SEL -- 2.5.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[RFC 13/15] staging: media: omap4iss: Add missing MFD_SYSCON dependency on HAS_IOMEM
The MFD_SYSCON depends on HAS_IOMEM so when selecting it avoid unmet direct dependencies. Signed-off-by: Krzysztof Kozlowski --- drivers/staging/media/omap4iss/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/media/omap4iss/Kconfig b/drivers/staging/media/omap4iss/Kconfig index 46183464ee79..7dea072172aa 100644 --- a/drivers/staging/media/omap4iss/Kconfig +++ b/drivers/staging/media/omap4iss/Kconfig @@ -2,6 +2,7 @@ config VIDEO_OMAP4 tristate "OMAP 4 Camera support" depends on VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API && I2C && ARCH_OMAP4 depends on HAS_DMA + depends on HAS_IOMEM# For MFD_SYSCON select MFD_SYSCON select VIDEOBUF2_DMA_CONTIG ---help--- -- 2.5.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[RFC 11/15] power: reset: keystone: Add missing MFD_SYSCON dependency on HAS_IOMEM
The MFD_SYSCON depends on HAS_IOMEM so when selecting it avoid unmet direct dependencies. Signed-off-by: Krzysztof Kozlowski --- drivers/power/reset/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig index 0a6408a39c66..0f34846ae80d 100644 --- a/drivers/power/reset/Kconfig +++ b/drivers/power/reset/Kconfig @@ -141,6 +141,7 @@ config POWER_RESET_XGENE config POWER_RESET_KEYSTONE bool "Keystone reset driver" depends on ARCH_KEYSTONE + depends on HAS_IOMEM# For MFD_SYSCON select MFD_SYSCON help Reboot support for the KEYSTONE SoCs. -- 2.5.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[RFC 09/15] media: platform: Add missing MFD_SYSCON dependency on HAS_IOMEM
The MFD_SYSCON depends on HAS_IOMEM so when selecting it avoid unmet direct dependencies. Signed-off-by: Krzysztof Kozlowski --- drivers/media/platform/Kconfig| 1 + drivers/media/platform/exynos4-is/Kconfig | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig index 201f5c296a95..e5931e434fa2 100644 --- a/drivers/media/platform/Kconfig +++ b/drivers/media/platform/Kconfig @@ -79,6 +79,7 @@ config VIDEO_OMAP3 depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API && ARCH_OMAP3 depends on HAS_DMA && OF depends on OMAP_IOMMU + depends on HAS_IOMEM# For MFD_SYSCON select ARM_DMA_USE_IOMMU select VIDEOBUF2_DMA_CONTIG select MFD_SYSCON diff --git a/drivers/media/platform/exynos4-is/Kconfig b/drivers/media/platform/exynos4-is/Kconfig index 57d42c6172c5..c4317b99d257 100644 --- a/drivers/media/platform/exynos4-is/Kconfig +++ b/drivers/media/platform/exynos4-is/Kconfig @@ -17,6 +17,7 @@ config VIDEO_S5P_FIMC tristate "S5P/EXYNOS4 FIMC/CAMIF camera interface driver" depends on I2C depends on HAS_DMA + depends on HAS_IOMEM# For MFD_SYSCON select VIDEOBUF2_DMA_CONTIG select V4L2_MEM2MEM_DEV select MFD_SYSCON -- 2.5.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[RFC 12/15] soc: qcom: Add missing MFD_SYSCON dependency on HAS_IOMEM
The MFD_SYSCON depends on HAS_IOMEM so when selecting it avoid unmet direct dependencies. Signed-off-by: Krzysztof Kozlowski --- drivers/soc/qcom/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig index 461b387d03cc..24de48134c15 100644 --- a/drivers/soc/qcom/Kconfig +++ b/drivers/soc/qcom/Kconfig @@ -4,6 +4,7 @@ config QCOM_GSBI tristate "QCOM General Serial Bus Interface" depends on ARCH_QCOM +depends on HAS_IOMEM # For MFD_SYSCON select MFD_SYSCON help Say y here to enable GSBI support. The GSBI provides control -- 2.5.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[RFC 15/15] mfd: syscon: Fix build of missing ioremap on UM
Since commit c89c0114955a ("mfd: syscon: Set regmap max_register in of_syscon_register") the syscon uses ioremap so it fails on COMPILE_TEST without HAS_IOMEM: drivers/mfd/syscon.c: In function ‘of_syscon_register’: drivers/mfd/syscon.c:67:9: error: implicit declaration of function ‘ioremap’ [-Werror=implicit-function-declaration] base = ioremap(res.start, resource_size(&res)); ^ drivers/mfd/syscon.c:67:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion] base = ioremap(res.start, resource_size(&res)); ^ drivers/mfd/syscon.c:109:2: error: implicit declaration of function ‘iounmap’ [-Werror=implicit-function-declaration] iounmap(base); When selecting MFD_SYSCON, depend on HAS_IOMEM to avoid unmet direct dependencies. Reported-by: kbuild test robot Fixes: c89c0114955a ("mfd: syscon: Set regmap max_register in of_syscon_register") Signed-off-by: Krzysztof Kozlowski --- drivers/mfd/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index aa21dc55eb15..2e5b1e525a1d 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -1034,6 +1034,7 @@ config MFD_SUN6I_PRCM config MFD_SYSCON bool "System Controller Register R/W Based on Regmap" + depends on HAS_IOMEM select REGMAP_MMIO help Select this option to enable accessing system control registers -- 2.5.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [rtc-linux] Re: [RFC 04/15] irqchip: st: Add missing MFD_SYSCON dependency on HAS_IOMEM
2016-03-03 19:53 GMT+09:00 Arnd Bergmann : > On Thursday 03 March 2016 17:03:30 Krzysztof Kozlowski wrote: >> config ST_IRQCHIP >> bool >> select REGMAP >> + depends on HAS_IOMEM# For MFD_SYSCON >> select MFD_SYSCON >> help >> Enables SysCfg Controlled IRQs on STi based platforms. >> > > Not user visible. Hmmm... you are right (here and in other patches) but why am I getting all these errors: warning: (ST_IRQCHIP && HIP04_ETH && STMMAC_PLATFORM && DWMAC_IPQ806X && DWMAC_LPC18XX && DWMAC_ROCKCHIP && DWMAC_SOCFPGA && DWMAC_STI && TI_CPSW && PINCTRL_ROCKCHIP && PINCTRL_DOVE && POWER_RESET_KEYSTONE && S3C2410_WATCHDOG && VIDEO_OMAP3 && VIDEO_S5P_FIMC && USB_XHCI_MTK && RTC_DRV_AT91SAM9 && LPC18XX_DMAMUX && VIDEO_OMAP4 && HWSPINLOCK_QCOM && ATMEL_ST && QCOM_GSBI && PHY_HI6220_USB) selects MFD_SYSCON which has unmet direct dependencies (HAS_IOMEM) ? (ARCH=um, allyesconfig) Adding depends here (and in other places) really helps... but it should not have any impact... Thanks for comments, Krzysztof ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [rtc-linux] Re: [RFC 15/15] mfd: syscon: Fix build of missing ioremap on UM
2016-03-03 19:50 GMT+09:00 Arnd Bergmann : > On Thursday 03 March 2016 17:03:41 Krzysztof Kozlowski wrote: >> Since commit c89c0114955a ("mfd: syscon: Set regmap max_register in >> of_syscon_register") the syscon uses ioremap so it fails on COMPILE_TEST >> without HAS_IOMEM: >> >> drivers/mfd/syscon.c: In function ‘of_syscon_register’: >> drivers/mfd/syscon.c:67:9: error: implicit declaration of function ‘ioremap’ >> [-Werror=implicit-function-declaration] >> base = ioremap(res.start, resource_size(&res)); >> ^ >> drivers/mfd/syscon.c:67:7: warning: assignment makes pointer from integer >> without a cast [-Wint-conversion] >> base = ioremap(res.start, resource_size(&res)); >>^ >> drivers/mfd/syscon.c:109:2: error: implicit declaration of function >> ‘iounmap’ [-Werror=implicit-function-declaration] >> iounmap(base); >> >> When selecting MFD_SYSCON, depend on HAS_IOMEM to avoid unmet direct >> dependencies. >> >> Reported-by: kbuild test robot >> Fixes: c89c0114955a ("mfd: syscon: Set regmap max_register in >> of_syscon_register") >> Signed-off-by: Krzysztof Kozlowski >> --- > > Thanks for looking into this, the patches all look right to me, but > I fear we are forever playing catch-up here, as the number of syscon users > is only growing, and it's not obvious to the average driver developer > why they have to select this symbol. Actually I screwed something because entire MFD menuconfig (including MFD_SYSCON) is already guarded by if HAS_IOMEM. I was fixing the problem from the end (the build error) and then hit these unmet direct dependencies (mentioned this in other mail). I think this patch 15/15 is not needed. > > Interestingly, when I try to build an allmodconfig kernel for UML, > it seems to reject any driver calling ioremap/iounmap but not > the wrapper functions around that (of_iomap, devm_ioremap, > devm_ioremap_resource, ...) The declaration of devm-like functions is always there. However it should fail during linking stage (see my other patches like for thermal, nvram etc. this is still in progress because I did not manage to build allyesconfig on UML yet). > or the actual accessors that make no > sense without ioremap (readl, writel, inb, outb, iowrite32, ...). > > I've played with this a bit, and arrived at the patch below, is this > something we want as well? > > Arnd > >> diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig >> index aa21dc55eb15..2e5b1e525a1d 100644 >> --- a/drivers/mfd/Kconfig >> +++ b/drivers/mfd/Kconfig >> @@ -1034,6 +1034,7 @@ config MFD_SUN6I_PRCM >> >> config MFD_SYSCON >> bool "System Controller Register R/W Based on Regmap" >> + depends on HAS_IOMEM >> select REGMAP_MMIO >> help >> Select this option to enable accessing system control registers >> > > > arch/um/include/asm/io.h |1 + > drivers/char/Kconfig |3 +++ > drivers/char/mem.c | 16 > drivers/clocksource/Kconfig|3 +++ > drivers/fmc/Kconfig|1 + > drivers/fpga/Kconfig |1 + > drivers/hwtracing/intel_th/Kconfig |1 + > drivers/mfd/Kconfig|1 + > drivers/misc/altera-stapl/Kconfig |2 +- > drivers/mtd/chips/Kconfig |4 > drivers/mtd/lpddr/Kconfig |1 + > drivers/mtd/maps/Kconfig |3 ++- > drivers/mtd/nand/Kconfig |2 +- > drivers/mtd/spi-nor/Kconfig|1 + > drivers/net/can/Kconfig|1 + > drivers/net/hamradio/Kconfig |9 ++--- > drivers/nvmem/Kconfig |1 + > drivers/phy/Kconfig|9 +++-- > drivers/power/reset/Kconfig|4 +++- > drivers/staging/comedi/Kconfig |6 +- > drivers/thermal/Kconfig| 11 +-- For some of these I already started fixing: https://lkml.org/lkml/2016/3/3/147 http://comments.gmane.org/gmane.linux.kernel/2167664 > include/linux/irq.h|2 ++ > include/linux/mtd/cfi.h|2 ++ > include/linux/mtd/map.h|2 ++ > kernel/resource.c |2 ++ > lib/Kconfig|7 ++- > mm/bootmem.c |4 ++-- > 27 files changed, 85 insertions(+), 15 deletions(-) > > diff --git a/arch/um/include/asm/io.h b/arch/um/include/asm/io.h > new file mode 100644 > index 000..618ff13 > --- /dev/null > +++ b/arch/um/include/asm/io.h > @@ -0,0 +1 @@ > +/* no IOPORT or
Re: [rtc-linux] Re: [RFC 11/15] power: reset: keystone: Add missing MFD_SYSCON dependency on HAS_IOMEM
2016-03-03 21:33 GMT+09:00 Sebastian Reichel : > Hi, > > On Thu, Mar 03, 2016 at 12:00:14PM +0100, Arnd Bergmann wrote: >> On Thursday 03 March 2016 17:03:37 Krzysztof Kozlowski wrote: >> > diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig >> > index 0a6408a39c66..0f34846ae80d 100644 >> > --- a/drivers/power/reset/Kconfig >> > +++ b/drivers/power/reset/Kconfig >> > @@ -141,6 +141,7 @@ config POWER_RESET_XGENE >> > config POWER_RESET_KEYSTONE >> > bool "Keystone reset driver" >> > depends on ARCH_KEYSTONE >> > + depends on HAS_IOMEM# For MFD_SYSCON >> > select MFD_SYSCON >> > help >> > Reboot support for the KEYSTONE SoCs. >> > >> >> This is platform specific, but we should probably add || COMPILE_TEST >> along with the HAS_IOMEM dependency. > > Sounds sensible. Will you guys send an updated patch? > Sure, I'll make some compile tests and send a v2. Best regards, Krzysztof ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [rtc-linux] Re: [RFC 09/15] media: platform: Add missing MFD_SYSCON dependency on HAS_IOMEM
2016-03-03 19:57 GMT+09:00 Arnd Bergmann : > On Thursday 03 March 2016 17:03:35 Krzysztof Kozlowski wrote: >> diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig >> index 201f5c296a95..e5931e434fa2 100644 >> --- a/drivers/media/platform/Kconfig >> +++ b/drivers/media/platform/Kconfig >> @@ -79,6 +79,7 @@ config VIDEO_OMAP3 >> depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API && ARCH_OMAP3 >> depends on HAS_DMA && OF >> depends on OMAP_IOMMU >> + depends on HAS_IOMEM# For MFD_SYSCON >> select ARM_DMA_USE_IOMMU >> select VIDEOBUF2_DMA_CONTIG > > This is only built for OMAP3, so we won't get here without HAS_IOMEM Indeed. > >> select MFD_SYSCON >> diff --git a/drivers/media/platform/exynos4-is/Kconfig >> b/drivers/media/platform/exynos4-is/Kconfig >> index 57d42c6172c5..c4317b99d257 100644 >> --- a/drivers/media/platform/exynos4-is/Kconfig >> +++ b/drivers/media/platform/exynos4-is/Kconfig >> @@ -17,6 +17,7 @@ config VIDEO_S5P_FIMC >> tristate "S5P/EXYNOS4 FIMC/CAMIF camera interface driver" >> depends on I2C >> depends on HAS_DMA >> + depends on HAS_IOMEM# For MFD_SYSCON >> select VIDEOBUF2_DMA_CONTIG >> select V4L2_MEM2MEM_DEV > > This is guarded by HAS_DMA, which implies HAS_IOMEM afaik. Looking at Kconfigs - no, it is not implied (or am I missing something)... and sometimes dependency on HAS_IOMEM is next to HAS_DMA. BR, Krzysztof ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [rtc-linux] [RFC 13/15] staging: media: omap4iss: Add missing MFD_SYSCON dependency on HAS_IOMEM
2016-03-03 17:03 GMT+09:00 Krzysztof Kozlowski : > The MFD_SYSCON depends on HAS_IOMEM so when selecting it avoid unmet > direct dependencies. > > Signed-off-by: Krzysztof Kozlowski > --- > drivers/staging/media/omap4iss/Kconfig | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/staging/media/omap4iss/Kconfig > b/drivers/staging/media/omap4iss/Kconfig > index 46183464ee79..7dea072172aa 100644 > --- a/drivers/staging/media/omap4iss/Kconfig > +++ b/drivers/staging/media/omap4iss/Kconfig > @@ -2,6 +2,7 @@ config VIDEO_OMAP4 > tristate "OMAP 4 Camera support" > depends on VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API && I2C && ARCH_OMAP4 > depends on HAS_DMA > + depends on HAS_IOMEM# For MFD_SYSCON > select MFD_SYSCON > select VIDEOBUF2_DMA_CONTIG > ---help--- False alarm, no need for the patch (this depends on ARCH_OMAP4). Best regards, Krzysztof ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [rtc-linux] [RFC 12/15] soc: qcom: Add missing MFD_SYSCON dependency on HAS_IOMEM
2016-03-03 17:03 GMT+09:00 Krzysztof Kozlowski : > The MFD_SYSCON depends on HAS_IOMEM so when selecting it avoid unmet > direct dependencies. > > Signed-off-by: Krzysztof Kozlowski > --- > drivers/soc/qcom/Kconfig | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig > index 461b387d03cc..24de48134c15 100644 > --- a/drivers/soc/qcom/Kconfig > +++ b/drivers/soc/qcom/Kconfig > @@ -4,6 +4,7 @@ > config QCOM_GSBI > tristate "QCOM General Serial Bus Interface" > depends on ARCH_QCOM > +depends on HAS_IOMEM # For MFD_SYSCON > select MFD_SYSCON False alarm, no need for the patch (this depends on ARCH_QCOM). Best regards, Krzysztof ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [rtc-linux] [RFC 07/15] pinctrl: mvebu: Add missing MFD_SYSCON dependency on HAS_IOMEM
2016-03-03 17:03 GMT+09:00 Krzysztof Kozlowski : > The MFD_SYSCON depends on HAS_IOMEM so when selecting it avoid unmet > direct dependencies. > > Signed-off-by: Krzysztof Kozlowski > --- > drivers/pinctrl/mvebu/Kconfig | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/pinctrl/mvebu/Kconfig b/drivers/pinctrl/mvebu/Kconfig > index 170602407c0d..13685923729c 100644 > --- a/drivers/pinctrl/mvebu/Kconfig > +++ b/drivers/pinctrl/mvebu/Kconfig > @@ -7,6 +7,7 @@ config PINCTRL_MVEBU > > config PINCTRL_DOVE > bool > + depends on HAS_IOMEM# For MFD_SYSCON > select PINCTRL_MVEBU > select MFD_SYSCON False alarm, no need for the patch (non-selectable symbol) Best regards, Krzysztof ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [rtc-linux] [RFC 06/15] pinctrl: rockchip: Add missing MFD_SYSCON dependency on HAS_IOMEM
2016-03-03 17:03 GMT+09:00 Krzysztof Kozlowski : > The MFD_SYSCON depends on HAS_IOMEM so when selecting it avoid unmet > direct dependencies. > > Signed-off-by: Krzysztof Kozlowski > --- > drivers/pinctrl/Kconfig | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig > index fb8200b8e8ec..dc7ab58d4d74 100644 > --- a/drivers/pinctrl/Kconfig > +++ b/drivers/pinctrl/Kconfig > @@ -131,6 +131,7 @@ config PINCTRL_MESON > > config PINCTRL_ROCKCHIP > bool > + depends on HAS_IOMEM# For MFD_SYSCON > select PINMUX False alarm, no need for the patch (non-selectable symbol) Best regards, Krzysztof ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 3/3] staging: Drop owner assignment from i2c_driver
i2c_driver does not need to set an owner because i2c_register_driver() will set it. Signed-off-by: Krzysztof Kozlowski --- The coccinelle script which generated the patch was sent here: http://www.spinics.net/lists/kernel/msg2029903.html --- drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c b/drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c index 0f524bb7b41d..1f9ba8beb061 100644 --- a/drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c +++ b/drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c @@ -1126,7 +1126,6 @@ MODULE_DEVICE_TABLE(i2c, synaptics_rmi4_id_table); static struct i2c_driver synaptics_rmi4_driver = { .driver = { .name = DRIVER_NAME, - .owner = THIS_MODULE, .pm = &synaptics_rmi4_dev_pm_ops, }, .probe = synaptics_rmi4_probe, -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 1/3] staging: iio: Drop owner assignment from i2c_driver
i2c_driver does not need to set an owner because i2c_register_driver() will set it. Signed-off-by: Krzysztof Kozlowski --- The coccinelle script which generated the patch was sent here: http://www.spinics.net/lists/kernel/msg2029903.html --- drivers/staging/iio/addac/adt7316-i2c.c | 1 - drivers/staging/iio/light/isl29018.c| 1 - drivers/staging/iio/light/isl29028.c| 1 - 3 files changed, 3 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316-i2c.c b/drivers/staging/iio/addac/adt7316-i2c.c index 75ddd4f801a3..78fe0b557280 100644 --- a/drivers/staging/iio/addac/adt7316-i2c.c +++ b/drivers/staging/iio/addac/adt7316-i2c.c @@ -124,7 +124,6 @@ static struct i2c_driver adt7316_driver = { .driver = { .name = "adt7316", .pm = ADT7316_PM_OPS, - .owner = THIS_MODULE, }, .probe = adt7316_i2c_probe, .id_table = adt7316_i2c_id, diff --git a/drivers/staging/iio/light/isl29018.c b/drivers/staging/iio/light/isl29018.c index e646c5d24004..019ba5245c23 100644 --- a/drivers/staging/iio/light/isl29018.c +++ b/drivers/staging/iio/light/isl29018.c @@ -838,7 +838,6 @@ static struct i2c_driver isl29018_driver = { .name = "isl29018", .acpi_match_table = ACPI_PTR(isl29018_acpi_match), .pm = ISL29018_PM_OPS, - .owner = THIS_MODULE, .of_match_table = isl29018_of_match, }, .probe = isl29018_probe, diff --git a/drivers/staging/iio/light/isl29028.c b/drivers/staging/iio/light/isl29028.c index e5b2fdc2334b..cd6f2727aa58 100644 --- a/drivers/staging/iio/light/isl29028.c +++ b/drivers/staging/iio/light/isl29028.c @@ -547,7 +547,6 @@ static struct i2c_driver isl29028_driver = { .class = I2C_CLASS_HWMON, .driver = { .name = "isl29028", - .owner = THIS_MODULE, .of_match_table = isl29028_of_match, }, .probe = isl29028_probe, -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] Drop owner assignment from i2c_driver (and platform left-overs)
Hi, The i2c drivers also do not have to set 'owner' field because i2c_register_driver() will do it instead. 'owner' is removed from i2c drivers, which I was able to compile with allyesconfig (arm, arm64, i386, x86_64, ppc64). Only compile-tested. The coccinelle script which generated the patch was sent here: http://www.spinics.net/lists/kernel/msg2029903.html Best regards, Krzysztof Krzysztof Kozlowski (3): staging: iio: Drop owner assignment from i2c_driver staging: media: Drop owner assignment from i2c_driver staging: Drop owner assignment from i2c_driver drivers/staging/iio/addac/adt7316-i2c.c | 1 - drivers/staging/iio/light/isl29018.c | 1 - drivers/staging/iio/light/isl29028.c | 1 - drivers/staging/media/lirc/lirc_zilog.c | 1 - drivers/staging/media/mn88472/mn88472.c | 1 - drivers/staging/media/mn88473/mn88473.c | 1 - drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c | 1 - 7 files changed, 7 deletions(-) -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 2/3] staging: media: Drop owner assignment from i2c_driver
i2c_driver does not need to set an owner because i2c_register_driver() will set it. Signed-off-by: Krzysztof Kozlowski --- The coccinelle script which generated the patch was sent here: http://www.spinics.net/lists/kernel/msg2029903.html --- drivers/staging/media/lirc/lirc_zilog.c | 1 - drivers/staging/media/mn88472/mn88472.c | 1 - drivers/staging/media/mn88473/mn88473.c | 1 - 3 files changed, 3 deletions(-) diff --git a/drivers/staging/media/lirc/lirc_zilog.c b/drivers/staging/media/lirc/lirc_zilog.c index 261e27d6b054..d032745081ee 100644 --- a/drivers/staging/media/lirc/lirc_zilog.c +++ b/drivers/staging/media/lirc/lirc_zilog.c @@ -1367,7 +1367,6 @@ static const struct i2c_device_id ir_transceiver_id[] = { static struct i2c_driver driver = { .driver = { - .owner = THIS_MODULE, .name = "Zilog/Hauppauge i2c IR", }, .probe = ir_probe, diff --git a/drivers/staging/media/mn88472/mn88472.c b/drivers/staging/media/mn88472/mn88472.c index a8d45f44765c..cf2e96bcf395 100644 --- a/drivers/staging/media/mn88472/mn88472.c +++ b/drivers/staging/media/mn88472/mn88472.c @@ -561,7 +561,6 @@ MODULE_DEVICE_TABLE(i2c, mn88472_id_table); static struct i2c_driver mn88472_driver = { .driver = { - .owner = THIS_MODULE, .name = "mn88472", }, .probe = mn88472_probe, diff --git a/drivers/staging/media/mn88473/mn88473.c b/drivers/staging/media/mn88473/mn88473.c index f9146a146d07..a222e99935d2 100644 --- a/drivers/staging/media/mn88473/mn88473.c +++ b/drivers/staging/media/mn88473/mn88473.c @@ -507,7 +507,6 @@ MODULE_DEVICE_TABLE(i2c, mn88473_id_table); static struct i2c_driver mn88473_driver = { .driver = { - .owner = THIS_MODULE, .name = "mn88473", }, .probe = mn88473_probe, -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 00/20] power_supply: Allow safe usage of power supply
Hi, The patchset changes power supply API and drivers implementing power supply class. TLDR for driver and subsystem maintainers = Two patches of patchset change power_supply_register() function so in the same time they touch all drivers. I am kindly asking for acks, review and help in testing. Please look at: - patch 2: power_supply: Move run-time configuration to separate structure - patch 11: power_supply: Change ownership from driver to core These are huge. Introduction Patchset tries to fix following race scenario: Thread 1: charger manager, CONSUMER Thread 2: power supply driver, PROVIDER 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() To properly fix the race the patchset: 1. Moves ownership of power_supply structure from driver (provider) to power supply core. 2. Adds power_supply_get_property()-like API for safe access by consumer. 3. Adds power_supply_put() which will reclaim memory. Description === The patchset is quite big and touches power supply API so a lot of changes in drivers are needed. I modifed all drivers I found. However I only compile tested them (plus Smatch, Sparse and coccicheck). I did not test them on real hardware (except max14577, max77693, max17040, max17042 and charger-manager). This is a little different than my previous approaches [1][2] for fixing usage of power supply by some consumer, if driver implementing it is unbound. My previous approach [1][2] limited the race but did not close it. Still the consumer of power supply by calling power_supply_get_propert(psy...) may reference invalid memory because the producer freed it. Actually, because struct power_supply is exposed to consumers, the core should be the owner of it. This is accomplished in patch 11/20 ("power_supply: Change ownership from driver to core"). What the patchset does in steps === 1. Some preparation steps are necessary - patch 1 and 2. The driver implementing power supply won't be able to fill structure before calling power_supply_register(). So 'power_supply_config' is introduced in patch 2 ("power_supply: Move run-time configuration to separate structure"). Unfortunately this touches all drivers. *All drivers touched.* 2. Safe API wrappers (and usage counter) are added (power_supply_*()). 3. Patch 11: ownership of 'struct power_supply' is moved from driver to the core. *All drivers touched.* 4. power_supply_put() is added which reclaims resources. The patchset is rebased on next-20150129. Bisectability is preserved. All later patches depend on previous ones so it could be pulled in steps, but cherry-picking won't work. Changes since v2 1. Rewrite all drivers to new power_supply_register(). 2. Add reviewed-by Bartlomiej Zolnierkiewicz (internal review) 3. Add reviewed-by Sebastian Reichel [3] (to patches which I did not change in major way between v2 and v3). 4. Use atomic usage counter of power supply on each of: a. register/unregister, b. get/put. Changes since v1 1. Add new patches (1, 2, 11, 19). 2. Preserved ack-s where there weren't any changes. 3. Patch 3: Add use counter. 4. Patch 3: Don't add wrapper for set_charged() because already exists one. [1] https://lkml.org/lkml/2014/11/4/527 [2] https://lkml.org/lkml/2014/10/16/89 [3] https://lkml.org/lkml/2015/1/21/471 Best regards, Krzysztof Krzysztof Kozlowski (20): power_supply: Add driver private data power_supply: Move run-time configuration to separate structure power_supply: Add API for safe access of power supply function attrs power_supply: sysfs: Use power_supply_*() API for accessing function attrs power_supply: 88pm860x_charger: Use power_supply_*() API for accessing function attrs power_supply: ab8500: Use power_supply_*() API for accessing function attrs mfd: ab8500: Use power_supply_*() API for accessing function attrs power_supply: apm_power: Use power_supply_*() API for accessing function attrs power_supply: bq2415x_charger: Use power_supply_*() API for accessing function attrs power_supply: charger-manager: Use power_supply_*() API for accessing function attrs power_supply: Change ownership from driver to core power_supply: Add power_supply_put for decrementing device reference counter power_supply: Increment power supply use counter when obtaining references power_supply: charger-manager: Decrement the power supply's device reference counter x86/olpc/xo1/sci: Use newly added power_supp
[PATCH v3 01/20] power_supply: Add driver private data
Allow drivers to store private data inside power_supply structure for later usage in power supply operations. Usage of driver private data is necessary to access driver's state container object from power supply calls (like get_property()) if struct 'power_supply' is a stored there as a pointer, for example: struct some_driver_info { struct i2c_client *client; struct power_supply *power_supply; ... } In such case one cannot use container_of() and must store pointer to state container as private data. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Bartlomiej Zolnierkiewicz Reviewed-by: Sebastian Reichel --- drivers/power/power_supply_core.c | 6 ++ include/linux/power_supply.h | 4 2 files changed, 10 insertions(+) diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c index 694e8cddd5c1..84ef3f40e7bf 100644 --- a/drivers/power/power_supply_core.c +++ b/drivers/power/power_supply_core.c @@ -629,6 +629,12 @@ void power_supply_unregister(struct power_supply *psy) } EXPORT_SYMBOL_GPL(power_supply_unregister); +void *power_supply_get_drvdata(struct power_supply *psy) +{ + return psy->drv_data; +} +EXPORT_SYMBOL_GPL(power_supply_get_drvdata); + static int __init power_supply_class_init(void) { power_supply_class = class_create(THIS_MODULE, "power_supply"); diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index 096dbced02ac..a5743f24e03e 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -209,6 +209,9 @@ struct power_supply { /* For APM emulation, think legacy userspace. */ int use_for_apm; + /* Driver private data */ + void *drv_data; + /* private */ struct device *dev; struct work_struct changed_work; @@ -281,6 +284,7 @@ extern int power_supply_register_no_ws(struct device *parent, extern void power_supply_unregister(struct power_supply *psy); extern int power_supply_powers(struct power_supply *psy, struct device *dev); +extern void *power_supply_get_drvdata(struct power_supply *psy); /* For APM emulation, think legacy userspace. */ extern struct class *power_supply_class; -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 02/20] power_supply: Move run-time configuration to separate structure
Add new structure 'power_supply_config' for holding run-time initialization data like of_node, supplies and private driver data. The power_supply_register() function is changed so all power supply drivers need updating. When registering the power supply this new 'power_supply_config' should be used instead of directly initializing 'struct power_supply'. This allows changing the ownership of power_supply structure from driver to the power supply core in next patches. When a driver does not use of_node or supplies then it should use NULL as config. If driver uses of_node or supplies then it should allocate config on stack and initialize it with proper values. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Bartlomiej Zolnierkiewicz --- drivers/acpi/ac.c | 2 +- drivers/acpi/battery.c| 3 ++- drivers/acpi/sbs.c| 4 ++-- drivers/hid/hid-input.c | 2 +- drivers/hid/hid-sony.c| 2 +- drivers/hid/hid-wiimote-modules.c | 2 +- drivers/hid/wacom_sys.c | 5 +++-- drivers/platform/x86/compal-laptop.c | 2 +- drivers/power/88pm860x_battery.c | 2 +- drivers/power/88pm860x_charger.c | 7 --- drivers/power/ab8500_btemp.c | 7 --- drivers/power/ab8500_charger.c| 15 +-- drivers/power/ab8500_fg.c | 8 +--- drivers/power/abx500_chargalg.c | 8 +--- drivers/power/bq2415x_charger.c | 2 +- drivers/power/bq24190_charger.c | 4 ++-- drivers/power/bq24735-charger.c | 10 ++ drivers/power/bq27x00_battery.c | 2 +- drivers/power/charger-manager.c | 2 +- drivers/power/collie_battery.c| 4 ++-- drivers/power/da9030_battery.c| 2 +- drivers/power/da9052-battery.c| 2 +- drivers/power/ds2760_battery.c| 2 +- drivers/power/ds2780_battery.c| 2 +- drivers/power/ds2781_battery.c| 2 +- drivers/power/ds2782_battery.c| 2 +- drivers/power/generic-adc-battery.c | 2 +- drivers/power/goldfish_battery.c | 4 ++-- drivers/power/gpio-charger.c | 10 ++ drivers/power/intel_mid_battery.c | 4 ++-- drivers/power/ipaq_micro_battery.c| 4 ++-- drivers/power/isp1704_charger.c | 2 +- drivers/power/jz4740-battery.c| 2 +- drivers/power/lp8727_charger.c| 14 +++--- drivers/power/lp8788-charger.c| 11 +++ drivers/power/ltc2941-battery-gauge.c | 2 +- drivers/power/max14577_charger.c | 2 +- drivers/power/max17040_battery.c | 2 +- drivers/power/max17042_battery.c | 2 +- drivers/power/max77693_charger.c | 2 +- drivers/power/max8903_charger.c | 2 +- drivers/power/max8925_power.c | 14 +++--- drivers/power/max8997_charger.c | 2 +- drivers/power/max8998_charger.c | 2 +- drivers/power/olpc_battery.c | 4 ++-- drivers/power/pcf50633-charger.c | 16 +++- drivers/power/pda_power.c | 18 -- drivers/power/pm2301_charger.c| 8 +--- drivers/power/pmu_battery.c | 4 ++-- drivers/power/power_supply_core.c | 20 +++- drivers/power/rt5033_battery.c| 2 +- drivers/power/rx51_battery.c | 2 +- drivers/power/s3c_adc_battery.c | 4 ++-- drivers/power/sbs-battery.c | 6 -- drivers/power/smb347-charger.c| 13 ++--- drivers/power/test_power.c| 21 - drivers/power/tosa_battery.c | 6 +++--- drivers/power/tps65090-charger.c | 10 ++ drivers/power/twl4030_charger.c | 4 ++-- drivers/power/twl4030_madc_battery.c | 2 +- drivers/power/wm831x_backup.c | 2 +- drivers/power/wm831x_power.c | 6 +++--- drivers/power/wm8350_power.c | 6 +++--- drivers/power/wm97xx_battery.c| 2 +- drivers/power/z2_battery.c| 2 +- drivers/staging/nvec/nvec_power.c | 7 --- include/linux/power_supply.h | 16 ++-- 67 files changed, 211 insertions(+), 158 deletions(-) diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c index 36b0e61f9c09..8bf516885ede 100644 --- a/drivers/acpi/ac.c +++ b/drivers/acpi/ac.c @@ -351,7 +351,7 @@ static int acpi_ac_add(struct acpi_device *device) ac->charger.properties = ac_props; ac->charger.num_properties = ARRAY_SIZE(ac_props); ac->charger.get_property = get_ac_property; - result = power_supply_register(&ac->device->dev, &ac->charger); + result = power_supply_register(&ac->device->dev, &ac->charger, NULL); if (result) goto end; diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index d98ba4355819..fd8c06f492a1 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c @@ -
[PATCH v3 07/20] mfd: ab8500: Use power_supply_*() API for accessing function attrs
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 Signed-off-by: Krzysztof Kozlowski Acked-by: Jonghwa Lee Acked-by: Pavel Machek Acked-by: Lee Jones Reviewed-by: Bartlomiej Zolnierkiewicz Reviewed-by: Sebastian Reichel --- drivers/mfd/ab8500-sysctrl.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/mfd/ab8500-sysctrl.c b/drivers/mfd/ab8500-sysctrl.c index cfff0b643f1b..d4a4b24be7c6 100644 --- a/drivers/mfd/ab8500-sysctrl.c +++ b/drivers/mfd/ab8500-sysctrl.c @@ -49,7 +49,8 @@ static void ab8500_power_off(void) if (!psy) continue; - ret = psy->get_property(psy, POWER_SUPPLY_PROP_ONLINE, &val); + ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_ONLINE, + &val); if (!ret && val.intval) { charger_present = true; @@ -63,8 +64,8 @@ static void ab8500_power_off(void) /* Check if battery is known */ psy = power_supply_get_by_name("ab8500_btemp"); if (psy) { - ret = psy->get_property(psy, POWER_SUPPLY_PROP_TECHNOLOGY, - &val); + ret = power_supply_get_property(psy, + POWER_SUPPLY_PROP_TECHNOLOGY, &val); if (!ret && val.intval != POWER_SUPPLY_TECHNOLOGY_UNKNOWN) { printk(KERN_INFO "Charger \"%s\" is connected with known battery." -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 06/20] power_supply: ab8500: Use power_supply_*() API for accessing function attrs
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 Signed-off-by: Krzysztof Kozlowski Acked-by: Jonghwa Lee Acked-by: Pavel Machek Acked-by: Linus Walleij Reviewed-by: Bartlomiej Zolnierkiewicz Reviewed-by: Sebastian Reichel --- drivers/power/ab8500_btemp.c| 2 +- drivers/power/ab8500_charger.c | 2 +- drivers/power/ab8500_fg.c | 2 +- drivers/power/abx500_chargalg.c | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/power/ab8500_btemp.c b/drivers/power/ab8500_btemp.c index d5683f503a4e..4d18464d6400 100644 --- a/drivers/power/ab8500_btemp.c +++ b/drivers/power/ab8500_btemp.c @@ -938,7 +938,7 @@ static int ab8500_btemp_get_ext_psy_data(struct device *dev, void *data) enum power_supply_property prop; prop = ext->properties[j]; - if (ext->get_property(ext, prop, &ret)) + if (power_supply_get_property(ext, prop, &ret)) continue; switch (prop) { diff --git a/drivers/power/ab8500_charger.c b/drivers/power/ab8500_charger.c index cee9b9e46825..f9eb7fff1d65 100644 --- a/drivers/power/ab8500_charger.c +++ b/drivers/power/ab8500_charger.c @@ -1957,7 +1957,7 @@ static int ab8500_charger_get_ext_psy_data(struct device *dev, void *data) enum power_supply_property prop; prop = ext->properties[j]; - if (ext->get_property(ext, prop, &ret)) + if (power_supply_get_property(ext, prop, &ret)) continue; switch (prop) { diff --git a/drivers/power/ab8500_fg.c b/drivers/power/ab8500_fg.c index 0e2c9d592a53..c957e8a41847 100644 --- a/drivers/power/ab8500_fg.c +++ b/drivers/power/ab8500_fg.c @@ -2200,7 +2200,7 @@ static int ab8500_fg_get_ext_psy_data(struct device *dev, void *data) enum power_supply_property prop; prop = ext->properties[j]; - if (ext->get_property(ext, prop, &ret)) + if (power_supply_get_property(ext, prop, &ret)) continue; switch (prop) { diff --git a/drivers/power/abx500_chargalg.c b/drivers/power/abx500_chargalg.c index 0da4415cbc10..ac6f4a22f846 100644 --- a/drivers/power/abx500_chargalg.c +++ b/drivers/power/abx500_chargalg.c @@ -1001,7 +1001,7 @@ static int abx500_chargalg_get_ext_psy_data(struct device *dev, void *data) * property because of handling that sysfs entry on its own, this is * the place to get the battery capacity. */ - if (!ext->get_property(ext, POWER_SUPPLY_PROP_CAPACITY, &ret)) { + if (!power_supply_get_property(ext, POWER_SUPPLY_PROP_CAPACITY, &ret)) { di->batt_data.percent = ret.intval; capacity_updated = true; } @@ -1019,7 +1019,7 @@ static int abx500_chargalg_get_ext_psy_data(struct device *dev, void *data) ext->type == POWER_SUPPLY_TYPE_USB) di->usb_chg = psy_to_ux500_charger(ext); - if (ext->get_property(ext, prop, &ret)) + if (power_supply_get_property(ext, prop, &ret)) continue; switch (prop) { case POWER_SUPPLY_PROP_PRESENT: -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 04/20] power_supply: sysfs: Use power_supply_*() API for accessing function attrs
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 Acked-by: Jonghwa Lee Acked-by: Pavel Machek Reviewed-by: Bartlomiej Zolnierkiewicz Reviewed-by: Sebastian Reichel --- drivers/power/power_supply_sysfs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c index 62653f50a524..f817aab80813 100644 --- a/drivers/power/power_supply_sysfs.c +++ b/drivers/power/power_supply_sysfs.c @@ -76,7 +76,7 @@ static ssize_t power_supply_show_property(struct device *dev, if (off == POWER_SUPPLY_PROP_TYPE) { value.intval = psy->type; } else { - ret = psy->get_property(psy, off, &value); + ret = power_supply_get_property(psy, off, &value); if (ret < 0) { if (ret == -ENODATA) @@ -125,7 +125,7 @@ static ssize_t power_supply_store_property(struct device *dev, value.intval = long_val; - ret = psy->set_property(psy, off, &value); + ret = power_supply_set_property(psy, off, &value); if (ret < 0) return ret; @@ -223,7 +223,7 @@ static umode_t power_supply_attr_is_visible(struct kobject *kobj, if (property == attrno) { if (psy->property_is_writeable && - psy->property_is_writeable(psy, property) > 0) + power_supply_property_is_writeable(psy, property) > 0) mode |= S_IWUSR; return mode; -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 10/20] power_supply: charger-manager: Use power_supply_*() API for accessing function attrs
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 Signed-off-by: Krzysztof Kozlowski Acked-by: Jonghwa Lee Acked-by: Pavel Machek Reviewed-by: Bartlomiej Zolnierkiewicz Reviewed-by: Sebastian Reichel --- drivers/power/charger-manager.c | 37 - 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/drivers/power/charger-manager.c b/drivers/power/charger-manager.c index 1acb04629fa0..3a8ceacb1bee 100644 --- a/drivers/power/charger-manager.c +++ b/drivers/power/charger-manager.c @@ -103,8 +103,8 @@ static bool is_batt_present(struct charger_manager *cm) if (!psy) break; - ret = psy->get_property(psy, - POWER_SUPPLY_PROP_PRESENT, &val); + ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_PRESENT, + &val); if (ret == 0 && val.intval) present = true; break; @@ -118,8 +118,8 @@ static bool is_batt_present(struct charger_manager *cm) continue; } - ret = psy->get_property(psy, POWER_SUPPLY_PROP_PRESENT, - &val); + ret = power_supply_get_property(psy, + POWER_SUPPLY_PROP_PRESENT, &val); if (ret == 0 && val.intval) { present = true; break; @@ -155,7 +155,8 @@ static bool is_ext_pwr_online(struct charger_manager *cm) continue; } - ret = psy->get_property(psy, POWER_SUPPLY_PROP_ONLINE, &val); + ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_ONLINE, + &val); if (ret == 0 && val.intval) { online = true; break; @@ -183,7 +184,7 @@ static int get_batt_uV(struct charger_manager *cm, int *uV) if (!fuel_gauge) return -ENODEV; - ret = fuel_gauge->get_property(fuel_gauge, + ret = power_supply_get_property(fuel_gauge, POWER_SUPPLY_PROP_VOLTAGE_NOW, &val); if (ret) return ret; @@ -223,7 +224,8 @@ static bool is_charging(struct charger_manager *cm) } /* 2. The charger should be online (ext-power) */ - ret = psy->get_property(psy, POWER_SUPPLY_PROP_ONLINE, &val); + ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_ONLINE, + &val); if (ret) { dev_warn(cm->dev, "Cannot read ONLINE value from %s\n", cm->desc->psy_charger_stat[i]); @@ -236,7 +238,8 @@ static bool is_charging(struct charger_manager *cm) * 3. The charger should not be FULL, DISCHARGING, * or NOT_CHARGING. */ - ret = psy->get_property(psy, POWER_SUPPLY_PROP_STATUS, &val); + ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_STATUS, + &val); if (ret) { dev_warn(cm->dev, "Cannot read STATUS value from %s\n", cm->desc->psy_charger_stat[i]); @@ -279,7 +282,7 @@ static bool is_full_charged(struct charger_manager *cm) val.intval = 0; /* Not full if capacity of fuel gauge isn't full */ - ret = fuel_gauge->get_property(fuel_gauge, + ret = power_supply_get_property(fuel_gauge, POWER_SUPPLY_PROP_CHARGE_FULL, &val); if (!ret && val.intval > desc->fullbatt_full_capacity) return true; @@ -296,7 +299,7 @@ static bool is_full_charged(struct charger_manager *cm) if (desc->fullbatt_soc > 0) { val.intval = 0; - ret = fuel_gauge->get_property(fuel_gauge, + ret = power_supply_get_property(fuel_gauge, POWER_SUPPLY_PROP_CAPACITY, &val); if (!ret && val.intval >= desc->fullbatt_soc) return true; @@ -580,7 +583,7 @@ static int cm_get_battery_temperature_by_psy(struct charger_manager *cm, if (!fuel_gauge) return -ENODEV; - return fuel_gauge->get_property(fuel_gauge, + return power_supply_get_property(fuel_gauge,
[PATCH v3 08/20] power_supply: apm_power: Use power_supply_*() API for accessing function attrs
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 Signed-off-by: Krzysztof Kozlowski Acked-by: Jonghwa Lee Acked-by: Pavel Machek Reviewed-by: Bartlomiej Zolnierkiewicz Reviewed-by: Sebastian Reichel --- drivers/power/apm_power.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/power/apm_power.c b/drivers/power/apm_power.c index 39763015b360..2206f9ff6488 100644 --- a/drivers/power/apm_power.c +++ b/drivers/power/apm_power.c @@ -15,10 +15,10 @@ #include -#define PSY_PROP(psy, prop, val) (psy->get_property(psy, \ +#define PSY_PROP(psy, prop, val) (power_supply_get_property(psy, \ POWER_SUPPLY_PROP_##prop, val)) -#define _MPSY_PROP(prop, val) (main_battery->get_property(main_battery, \ +#define _MPSY_PROP(prop, val) (power_supply_get_property(main_battery, \ prop, val)) #define MPSY_PROP(prop, val) _MPSY_PROP(POWER_SUPPLY_PROP_##prop, val) -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 03/20] power_supply: Add API for safe access of power supply function attrs
Add simple wrappers for accessing power supply's function attributes: - get_property -> power_supply_get_property - set_property -> power_supply_set_property - property_is_writeable -> power_supply_property_is_writeable - external_power_changed -> power_supply_external_power_changed This API along with atomic usage counter adds a safe way of accessing a power supply from another driver. If power supply is unregistered after obtaining reference to it by some driver, then the API wrappers won't be executed in invalid (freed) context. Next patch changing the ownership of power supply class is still needed to fully fix race conditions in accessing freed power supply. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Bartlomiej Zolnierkiewicz Reviewed-by: Sebastian Reichel --- drivers/power/power_supply_core.c | 47 ++- include/linux/power_supply.h | 16 + 2 files changed, 62 insertions(+), 1 deletion(-) diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c index b748391c3e17..0521681b3674 100644 --- a/drivers/power/power_supply_core.c +++ b/drivers/power/power_supply_core.c @@ -314,7 +314,9 @@ EXPORT_SYMBOL_GPL(power_supply_is_system_supplied); int power_supply_set_battery_charged(struct power_supply *psy) { - if (psy->type == POWER_SUPPLY_TYPE_BATTERY && psy->set_charged) { + if (atomic_read(&psy->use_cnt) >= 0 && + psy->type == POWER_SUPPLY_TYPE_BATTERY && + psy->set_charged) { psy->set_charged(psy); return 0; } @@ -366,6 +368,47 @@ struct power_supply *power_supply_get_by_phandle(struct device_node *np, EXPORT_SYMBOL_GPL(power_supply_get_by_phandle); #endif /* CONFIG_OF */ +int power_supply_get_property(struct power_supply *psy, + enum power_supply_property psp, + union power_supply_propval *val) +{ + if (atomic_read(&psy->use_cnt) <= 0) + return -ENODEV; + + return psy->get_property(psy, psp, val); +} +EXPORT_SYMBOL_GPL(power_supply_get_property); + +int power_supply_set_property(struct power_supply *psy, + enum power_supply_property psp, + const union power_supply_propval *val) +{ + if (atomic_read(&psy->use_cnt) <= 0 || !psy->set_property) + return -ENODEV; + + return psy->set_property(psy, psp, val); +} +EXPORT_SYMBOL_GPL(power_supply_set_property); + +int power_supply_property_is_writeable(struct power_supply *psy, + enum power_supply_property psp) +{ + if (atomic_read(&psy->use_cnt) <= 0 || !psy->property_is_writeable) + return -ENODEV; + + return psy->property_is_writeable(psy, psp); +} +EXPORT_SYMBOL_GPL(power_supply_property_is_writeable); + +void power_supply_external_power_changed(struct power_supply *psy) +{ + if (atomic_read(&psy->use_cnt) <= 0 || !psy->external_power_changed) + return; + + psy->external_power_changed(psy); +} +EXPORT_SYMBOL_GPL(power_supply_external_power_changed); + int power_supply_powers(struct power_supply *psy, struct device *dev) { return sysfs_create_link(&psy->dev->kobj, &dev->kobj, "powers"); @@ -555,6 +598,7 @@ static int __power_supply_register(struct device *parent, dev->release = power_supply_dev_release; dev_set_drvdata(dev, psy); psy->dev = dev; + atomic_inc(&psy->use_cnt); if (cfg) { psy->drv_data = cfg->drv_data; psy->of_node = cfg->of_node; @@ -629,6 +673,7 @@ EXPORT_SYMBOL_GPL(power_supply_register_no_ws); void power_supply_unregister(struct power_supply *psy) { + WARN_ON(atomic_dec_return(&psy->use_cnt)); cancel_work_sync(&psy->changed_work); sysfs_remove_link(&psy->dev->kobj, "powers"); power_supply_remove_triggers(psy); diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index b203a26d5c54..5d460995f38d 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -199,6 +199,12 @@ struct power_supply { size_t num_supplies; struct device_node *of_node; + /* +* Functions for drivers implementing power supply class. +* These shouldn't be called directly by other drivers for accessing +* this power supply. Instead use power_supply_*() functions (for +* example power_supply_get_property()). +*/ int (*get_property)(struct power_supply *psy, enum power_supply_property psp, union power_supply_propval *val); @@ -227,6 +233,7 @@
[PATCH v3 05/20] power_supply: 88pm860x_charger: Use power_supply_*() API for accessing function attrs
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 Signed-off-by: Krzysztof Kozlowski Acked-by: Jonghwa Lee Acked-by: Pavel Machek Reviewed-by: Bartlomiej Zolnierkiewicz Reviewed-by: Sebastian Reichel --- drivers/power/88pm860x_charger.c | 13 - 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/power/88pm860x_charger.c b/drivers/power/88pm860x_charger.c index ac352a6c03ea..98e31419d9cf 100644 --- a/drivers/power/88pm860x_charger.c +++ b/drivers/power/88pm860x_charger.c @@ -296,12 +296,13 @@ static int set_charging_fsm(struct pm860x_charger_info *info) psy = power_supply_get_by_name(pm860x_supplied_to[0]); if (!psy) return -EINVAL; - ret = psy->get_property(psy, POWER_SUPPLY_PROP_VOLTAGE_NOW, &data); + ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_VOLTAGE_NOW, + &data); if (ret) return ret; vbatt = data.intval / 1000; - ret = psy->get_property(psy, POWER_SUPPLY_PROP_PRESENT, &data); + ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_PRESENT, &data); if (ret) return ret; @@ -430,7 +431,7 @@ static irqreturn_t pm860x_temp_handler(int irq, void *data) psy = power_supply_get_by_name(pm860x_supplied_to[0]); if (!psy) goto out; - ret = psy->get_property(psy, POWER_SUPPLY_PROP_TEMP, &temp); + ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_TEMP, &temp); if (ret) goto out; value = temp.intval / 10; @@ -485,7 +486,8 @@ static irqreturn_t pm860x_done_handler(int irq, void *data) psy = power_supply_get_by_name(pm860x_supplied_to[0]); if (!psy) goto out; - ret = psy->get_property(psy, POWER_SUPPLY_PROP_VOLTAGE_NOW, &val); + ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_VOLTAGE_NOW, + &val); if (ret) goto out; vbatt = val.intval / 1000; @@ -500,7 +502,8 @@ static irqreturn_t pm860x_done_handler(int irq, void *data) if (ret < 0) goto out; if (vbatt > CHARGE_THRESHOLD && ret & STATUS2_CHG) - psy->set_property(psy, POWER_SUPPLY_PROP_CHARGE_FULL, &val); + power_supply_set_property(psy, POWER_SUPPLY_PROP_CHARGE_FULL, + &val); out: mutex_unlock(&info->lock); -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 12/20] power_supply: Add power_supply_put for decrementing device reference counter
The power_supply_get_by_phandle() and power_supply_get_by_name() use function class_find_device() for obtaining the reference to power supply. Each use of class_find_device() increases the power supply's device reference counter. However the reference counter was not decreased by users of this API. Thus final device_unregister() call from power_supply_unregister() could not release the device and clean up its resources. This lead to memory leak if at least once power_supply_get_by_*() was called between registering and unregistering the power supply. Add and document new API power_supply_put() for decrementing the reference counter. Signed-off-by: Krzysztof Kozlowski Acked-by: Pavel Machek Reviewed-by: Bartlomiej Zolnierkiewicz Reviewed-by: Sebastian Reichel --- drivers/power/power_supply_core.c | 38 ++ include/linux/power_supply.h | 1 + 2 files changed, 39 insertions(+) diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c index 0dcf5ca0092e..95aeae44c34a 100644 --- a/drivers/power/power_supply_core.c +++ b/drivers/power/power_supply_core.c @@ -336,6 +336,17 @@ static int power_supply_match_device_by_name(struct device *dev, const void *dat return strcmp(psy->desc->name, name) == 0; } +/** + * power_supply_get_by_name() - Search for a power supply and returns its ref + * @name: Power supply name to fetch + * + * If power supply was found, it increases reference count for the + * internal power supply's device. The user should power_supply_put() + * after usage. + * + * Return: On success returns a reference to a power supply with + * matching name equals to @name, a NULL otherwise. + */ struct power_supply *power_supply_get_by_name(const char *name) { struct device *dev = class_find_device(power_supply_class, NULL, name, @@ -345,12 +356,39 @@ struct power_supply *power_supply_get_by_name(const char *name) } EXPORT_SYMBOL_GPL(power_supply_get_by_name); +/** + * power_supply_put() - Drop reference obtained with power_supply_get_by_name + * @psy: Reference to put + * + * The reference to power supply should be put before unregistering + * the power supply. + */ +void power_supply_put(struct power_supply *psy) +{ + might_sleep(); + + put_device(&psy->dev); +} +EXPORT_SYMBOL_GPL(power_supply_put); + #ifdef CONFIG_OF static int power_supply_match_device_node(struct device *dev, const void *data) { return dev->parent && dev->parent->of_node == data; } +/** + * power_supply_get_by_phandle() - Search for a power supply and returns its ref + * @np: Pointer to device node holding phandle property + * @phandle_name: Name of property holding a power supply name + * + * If power supply was found, it increases reference count for the + * internal power supply's device. The user should power_supply_put() + * after usage. + * + * Return: On success returns a reference to a power supply with + * matching name equals to value under @property, NULL or ERR_PTR otherwise. + */ struct power_supply *power_supply_get_by_phandle(struct device_node *np, const char *property) { diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index 54ebac5e3fe3..7000a4927ac8 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -282,6 +282,7 @@ extern struct atomic_notifier_head power_supply_notifier; extern int power_supply_reg_notifier(struct notifier_block *nb); extern void power_supply_unreg_notifier(struct notifier_block *nb); extern struct power_supply *power_supply_get_by_name(const char *name); +extern void power_supply_put(struct power_supply *psy); #ifdef CONFIG_OF extern struct power_supply *power_supply_get_by_phandle(struct device_node *np, const char *property); -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 09/20] power_supply: bq2415x_charger: Use power_supply_*() API for accessing function attrs
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 Signed-off-by: Krzysztof Kozlowski Acked-by: Jonghwa Lee Acked-by: Pavel Machek Reviewed-by: Bartlomiej Zolnierkiewicz Reviewed-by: Sebastian Reichel --- drivers/power/bq2415x_charger.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/power/bq2415x_charger.c b/drivers/power/bq2415x_charger.c index 73b0a8521803..bc47a265b304 100644 --- a/drivers/power/bq2415x_charger.c +++ b/drivers/power/bq2415x_charger.c @@ -816,7 +816,8 @@ static int bq2415x_notifier_call(struct notifier_block *nb, dev_dbg(bq->dev, "notifier call was called\n"); - ret = psy->get_property(psy, POWER_SUPPLY_PROP_CURRENT_MAX, &prop); + ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_CURRENT_MAX, + &prop); if (ret != 0) return NOTIFY_OK; -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 17/20] 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 Acked-by: Pavel Machek Reviewed-by: Bartlomiej Zolnierkiewicz Reviewed-by: Sebastian Reichel --- drivers/power/88pm860x_charger.c | 11 +-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/power/88pm860x_charger.c b/drivers/power/88pm860x_charger.c index a7f32a5b2299..bf822aa00c14 100644 --- a/drivers/power/88pm860x_charger.c +++ b/drivers/power/88pm860x_charger.c @@ -298,13 +298,18 @@ static int set_charging_fsm(struct pm860x_charger_info *info) return -EINVAL; ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_VOLTAGE_NOW, &data); - if (ret) + if (ret) { + power_supply_put(psy); return ret; + } vbatt = data.intval / 1000; ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_PRESENT, &data); - if (ret) + if (ret) { + power_supply_put(psy); return ret; + } + power_supply_put(psy); mutex_lock(&info->lock); info->present = data.intval; @@ -447,6 +452,7 @@ static irqreturn_t pm860x_temp_handler(int irq, void *data) set_charging_fsm(info); out: + power_supply_put(psy); return IRQ_HANDLED; } @@ -507,6 +513,7 @@ static irqreturn_t pm860x_done_handler(int irq, void *data) out: mutex_unlock(&info->lock); + power_supply_put(psy); dev_dbg(info->dev, "%s, Allowed: %d\n", __func__, info->allowed); set_charging_fsm(info); -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 14/20] power_supply: charger-manager: 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 Acked-by: Pavel Machek Reviewed-by: Bartlomiej Zolnierkiewicz Reviewed-by: Sebastian Reichel --- drivers/power/charger-manager.c | 70 +++-- 1 file changed, 47 insertions(+), 23 deletions(-) diff --git a/drivers/power/charger-manager.c b/drivers/power/charger-manager.c index 8aa780125dfa..c2aef7a5582b 100644 --- a/drivers/power/charger-manager.c +++ b/drivers/power/charger-manager.c @@ -107,6 +107,7 @@ static bool is_batt_present(struct charger_manager *cm) &val); if (ret == 0 && val.intval) present = true; + power_supply_put(psy); break; case CM_CHARGER_STAT: for (i = 0; cm->desc->psy_charger_stat[i]; i++) { @@ -120,6 +121,7 @@ static bool is_batt_present(struct charger_manager *cm) ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_PRESENT, &val); + power_supply_put(psy); if (ret == 0 && val.intval) { present = true; break; @@ -157,6 +159,7 @@ static bool is_ext_pwr_online(struct charger_manager *cm) ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_ONLINE, &val); + power_supply_put(psy); if (ret == 0 && val.intval) { online = true; break; @@ -186,6 +189,7 @@ static int get_batt_uV(struct charger_manager *cm, int *uV) ret = power_supply_get_property(fuel_gauge, POWER_SUPPLY_PROP_VOLTAGE_NOW, &val); + power_supply_put(fuel_gauge); if (ret) return ret; @@ -229,10 +233,13 @@ static bool is_charging(struct charger_manager *cm) if (ret) { dev_warn(cm->dev, "Cannot read ONLINE value from %s\n", cm->desc->psy_charger_stat[i]); + power_supply_put(psy); continue; } - if (val.intval == 0) + if (val.intval == 0) { + power_supply_put(psy); continue; + } /* * 3. The charger should not be FULL, DISCHARGING, @@ -240,6 +247,7 @@ static bool is_charging(struct charger_manager *cm) */ ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_STATUS, &val); + power_supply_put(psy); if (ret) { dev_warn(cm->dev, "Cannot read STATUS value from %s\n", cm->desc->psy_charger_stat[i]); @@ -267,6 +275,7 @@ static bool is_full_charged(struct charger_manager *cm) struct charger_desc *desc = cm->desc; union power_supply_propval val; struct power_supply *fuel_gauge; + bool is_full = false; int ret = 0; int uV; @@ -284,15 +293,19 @@ static bool is_full_charged(struct charger_manager *cm) /* Not full if capacity of fuel gauge isn't full */ ret = power_supply_get_property(fuel_gauge, POWER_SUPPLY_PROP_CHARGE_FULL, &val); - if (!ret && val.intval > desc->fullbatt_full_capacity) - return true; + if (!ret && val.intval > desc->fullbatt_full_capacity) { + is_full = true; + goto out; + } } /* Full, if it's over the fullbatt voltage */ if (desc->fullbatt_uV > 0) { ret = get_batt_uV(cm, &uV); - if (!ret && uV >= desc->fullbatt_uV) - return true; + if (!ret && uV >= desc->fullbatt_uV) { + is_full = true; + goto out; + } } /* Full, if the capacity is more than fullbatt_soc */ @@ -301,11 +314,15 @@ static bool is_full_charged(struct charger_manager *cm) ret = power_supply_get_property(fuel_gauge, POWER_SUPPLY_PROP_CAPACITY, &val); - if (!ret && val.intval >= desc->fullbatt_soc) - return true; + if (!ret && val.intval >= desc->fullbatt_soc) { + is_full = true; + goto out; + } } - return false; +out: + power_supply_put(fuel_gauge); +
[PATCH v3 15/20] x86/olpc/xo1/sci: Use newly added power_supply_put API
Replace direct usage of put_device() with new API: power_supply_put(). Signed-off-by: Krzysztof Kozlowski Acked-by: Pavel Machek Reviewed-by: Bartlomiej Zolnierkiewicz Reviewed-by: Sebastian Reichel --- arch/x86/platform/olpc/olpc-xo1-sci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/platform/olpc/olpc-xo1-sci.c b/arch/x86/platform/olpc/olpc-xo1-sci.c index 9a2e590dd202..7fa8b3b53bc0 100644 --- a/arch/x86/platform/olpc/olpc-xo1-sci.c +++ b/arch/x86/platform/olpc/olpc-xo1-sci.c @@ -61,7 +61,7 @@ static void battery_status_changed(void) if (psy) { power_supply_changed(psy); - put_device(psy->dev); + power_supply_put(psy); } } @@ -71,7 +71,7 @@ static void ac_status_changed(void) if (psy) { power_supply_changed(psy); - put_device(psy->dev); + power_supply_put(psy); } } -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 13/20] power_supply: Increment power supply use counter when obtaining references
Increment the power_supply.use_cnt usage counter on: - power_supply_get_by_phandle() - power_supply_get_by_name() and decrement it on power_supply_put() call. This helps tracking of valid usage of power supply instance by consumers. The usage counter itself also allows safe calling of power_supply_get_property-like functions even when driver unregisters this power supply. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Bartlomiej Zolnierkiewicz --- drivers/power/power_supply_core.c | 17 +++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c index 95aeae44c34a..acad7e87f754 100644 --- a/drivers/power/power_supply_core.c +++ b/drivers/power/power_supply_core.c @@ -349,10 +349,16 @@ static int power_supply_match_device_by_name(struct device *dev, const void *dat */ struct power_supply *power_supply_get_by_name(const char *name) { + struct power_supply *psy = NULL; struct device *dev = class_find_device(power_supply_class, NULL, name, power_supply_match_device_by_name); - return dev ? dev_get_drvdata(dev) : NULL; + if (dev) { + psy = dev_get_drvdata(dev); + atomic_inc(&psy->use_cnt); + } + + return psy; } EXPORT_SYMBOL_GPL(power_supply_get_by_name); @@ -367,6 +373,7 @@ void power_supply_put(struct power_supply *psy) { might_sleep(); + atomic_dec(&psy->use_cnt); put_device(&psy->dev); } EXPORT_SYMBOL_GPL(power_supply_put); @@ -393,6 +400,7 @@ struct power_supply *power_supply_get_by_phandle(struct device_node *np, const char *property) { struct device_node *power_supply_np; + struct power_supply *psy = NULL; struct device *dev; power_supply_np = of_parse_phandle(np, property, 0); @@ -404,7 +412,12 @@ struct power_supply *power_supply_get_by_phandle(struct device_node *np, of_node_put(power_supply_np); - return dev ? dev_get_drvdata(dev) : NULL; + if (dev) { + psy = dev_get_drvdata(dev); + atomic_inc(&psy->use_cnt); + } + + return psy; } EXPORT_SYMBOL_GPL(power_supply_get_by_phandle); #endif /* CONFIG_OF */ -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 19/20] mfd: ab8500: 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 Acked-by: Pavel Machek Acked-by: Linus Walleij Acked-by: Lee Jones Reviewed-by: Bartlomiej Zolnierkiewicz Reviewed-by: Sebastian Reichel --- drivers/mfd/ab8500-sysctrl.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/mfd/ab8500-sysctrl.c b/drivers/mfd/ab8500-sysctrl.c index d4a4b24be7c6..0d1825696153 100644 --- a/drivers/mfd/ab8500-sysctrl.c +++ b/drivers/mfd/ab8500-sysctrl.c @@ -51,6 +51,7 @@ static void ab8500_power_off(void) ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_ONLINE, &val); + power_supply_put(psy); if (!ret && val.intval) { charger_present = true; @@ -73,6 +74,7 @@ static void ab8500_power_off(void) pss[i]); machine_restart("charging"); } + power_supply_put(psy); } shutdown: -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 18/20] 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 Acked-by: Pavel Machek Reviewed-by: Bartlomiej Zolnierkiewicz Reviewed-by: Sebastian Reichel --- drivers/power/bq2415x_charger.c | 31 ++- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/drivers/power/bq2415x_charger.c b/drivers/power/bq2415x_charger.c index cb92022df8eb..4adcd65bef5b 100644 --- a/drivers/power/bq2415x_charger.c +++ b/drivers/power/bq2415x_charger.c @@ -1601,27 +1601,27 @@ static int bq2415x_probe(struct i2c_client *client, ret = of_property_read_u32(np, "ti,current-limit", &bq->init_data.current_limit); if (ret) - goto error_2; + goto error_3; ret = of_property_read_u32(np, "ti,weak-battery-voltage", &bq->init_data.weak_battery_voltage); if (ret) - goto error_2; + goto error_3; ret = of_property_read_u32(np, "ti,battery-regulation-voltage", &bq->init_data.battery_regulation_voltage); if (ret) - goto error_2; + goto error_3; ret = of_property_read_u32(np, "ti,charge-current", &bq->init_data.charge_current); if (ret) - goto error_2; + goto error_3; ret = of_property_read_u32(np, "ti,termination-current", &bq->init_data.termination_current); if (ret) - goto error_2; + goto error_3; ret = of_property_read_u32(np, "ti,resistor-sense", &bq->init_data.resistor_sense); if (ret) - goto error_2; + goto error_3; } else { memcpy(&bq->init_data, pdata, sizeof(bq->init_data)); } @@ -1631,19 +1631,19 @@ static int bq2415x_probe(struct i2c_client *client, ret = bq2415x_power_supply_init(bq); if (ret) { dev_err(bq->dev, "failed to register power supply: %d\n", ret); - goto error_2; + goto error_3; } ret = bq2415x_sysfs_init(bq); if (ret) { dev_err(bq->dev, "failed to create sysfs entries: %d\n", ret); - goto error_3; + goto error_4; } ret = bq2415x_set_defaults(bq); if (ret) { dev_err(bq->dev, "failed to set default values: %d\n", ret); - goto error_4; + goto error_5; } if (bq->notify_psy) { @@ -1651,7 +1651,7 @@ static int bq2415x_probe(struct i2c_client *client, ret = power_supply_reg_notifier(&bq->nb); if (ret) { dev_err(bq->dev, "failed to reg notifier: %d\n", ret); - goto error_5; + goto error_6; } /* Query for initial reported_mode and set it */ @@ -1671,11 +1671,14 @@ static int bq2415x_probe(struct i2c_client *client, dev_info(bq->dev, "driver registered\n"); return 0; +error_6: error_5: -error_4: bq2415x_sysfs_exit(bq); -error_3: +error_4: bq2415x_power_supply_exit(bq); +error_3: + if (!IS_ERR(bq->notify_psy)) + power_supply_put(bq->notify_psy); error_2: kfree(name); error_1: @@ -1692,8 +1695,10 @@ static int bq2415x_remove(struct i2c_client *client) { struct bq2415x_device *bq = i2c_get_clientdata(client); - if (bq->notify_psy) + if (bq->notify_psy) { power_supply_unreg_notifier(&bq->nb); + power_supply_put(bq->notify_psy); + } bq2415x_sysfs_exit(bq); bq2415x_power_supply_exit(bq); -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 16/20] x86/olpc/xo15/sci: Use newly added power_supply_put API
Replace direct usage of put_device() with new API: power_supply_put(). Signed-off-by: Krzysztof Kozlowski Acked-by: Pavel Machek Reviewed-by: Bartlomiej Zolnierkiewicz Reviewed-by: Sebastian Reichel --- arch/x86/platform/olpc/olpc-xo15-sci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/platform/olpc/olpc-xo15-sci.c b/arch/x86/platform/olpc/olpc-xo15-sci.c index 08e350e757dc..55130846ac87 100644 --- a/arch/x86/platform/olpc/olpc-xo15-sci.c +++ b/arch/x86/platform/olpc/olpc-xo15-sci.c @@ -83,7 +83,7 @@ static void battery_status_changed(void) if (psy) { power_supply_changed(psy); - put_device(psy->dev); + power_supply_put(psy); } } @@ -93,7 +93,7 @@ static void ac_status_changed(void) if (psy) { power_supply_changed(psy); - put_device(psy->dev); + power_supply_put(psy); } } -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 20/20] arm: mach-pxa: 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 Reviewed-by: Bartlomiej Zolnierkiewicz Reviewed-by: Sebastian Reichel --- arch/arm/mach-pxa/raumfeld.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-pxa/raumfeld.c b/arch/arm/mach-pxa/raumfeld.c index a762b23ac830..6dc4f025e674 100644 --- a/arch/arm/mach-pxa/raumfeld.c +++ b/arch/arm/mach-pxa/raumfeld.c @@ -758,8 +758,10 @@ static void raumfeld_power_signal_charged(void) struct power_supply *psy = power_supply_get_by_name(raumfeld_power_supplicants[0]); - if (psy) + if (psy) { power_supply_set_battery_charged(psy); + power_supply_put(psy); + } } static int raumfeld_power_resume(void) -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v3 20/20] arm: mach-pxa: Decrement the power supply's device reference counter
On pią, 2015-02-06 at 14:49 +0100, Pavel Machek wrote: > On Fri 2015-01-30 15:47:58, Krzysztof Kozlowski wrote: > > Use power_supply_put() to decrement the power supply's device reference > > counter. > > > > Signed-off-by: Krzysztof Kozlowski > > Reviewed-by: Bartlomiej Zolnierkiewicz > > Reviewed-by: Sebastian Reichel > > 11,13,20 nothing obviously wrong. But I'm not sure if I studied them > closely enough to warrant an ACK. > > It would be good to get this into kernel -- I seen no bad comments, > and it is not going to improve without merge into mainline. Thanks for looking at patchset. It would be really nice if this could be tested for some time in linux-next. Such testing would help a lot. But I need acks from various maintainers for that. Of course the patchset to big enough to go into 3.20. If needed this could be taken gradually in following steps: 1. Patches 1-2 (patch 2 touches *all drivers*), 2. Patches 3-10 (touch only individual drivers), 3. Patch 11 (again *everything* changed), 4. Patches 12-20 (individual changes). In such case I will refresh everything after each step so new drivers would be also updated. Thanks again Pavel for prompt replies. Best regards, Krzysztof ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v3 20/20] arm: mach-pxa: Decrement the power supply's device reference counter
On pią, 2015-02-06 at 15:59 +0100, Pavel Machek wrote: > On Fri 2015-02-06 15:43:08, Krzysztof Kozlowski wrote: > > On pią, 2015-02-06 at 14:49 +0100, Pavel Machek wrote: > > > On Fri 2015-01-30 15:47:58, Krzysztof Kozlowski wrote: > > > > Use power_supply_put() to decrement the power supply's device reference > > > > counter. > > > > > > > > Signed-off-by: Krzysztof Kozlowski > > > > Reviewed-by: Bartlomiej Zolnierkiewicz > > > > Reviewed-by: Sebastian Reichel > > > > > > 11,13,20 nothing obviously wrong. But I'm not sure if I studied them > > > closely enough to warrant an ACK. > > > > > > It would be good to get this into kernel -- I seen no bad comments, > > > and it is not going to improve without merge into mainline. > > > > Thanks for looking at patchset. It would be really nice if this could be > > tested for some time in linux-next. Such testing would help a lot. But I > > need acks from various maintainers for that. > > Actually, you don't. The various maintainers clearly don't care at > this point. They had enough time. So you select one maintainer you > want to push this through, and you push it. > > Someone may complain, so you'll solve the feedback... I am thinking also on another way of solving this huge-patch problem: 1. Mark all drivers broken (CONFIG_BROKEN). 2. Introduce change in power_supply_register() API. Broken drivers will fail to build. 3. Convert broken drivers to new API incrementally (one driver per patch) marking them also non-broken. This would be much easier to review but also this would break build-bisectability for drivers and some platforms using them (like OLPC, compal-laptop, ACPI). In case of important platforms (like ACPI) I could do the old-way: change the driver along with API change. What do you think about this? I pushed the patchset here: https://git.linaro.org/people/marek.szyprowski/linux-srpol.git/shortlog/refs/heads/v3.19-next-power-supply-core-ownership (actually this is v4: added acks/reviews and minor issue fixed; merge window has opened so I'll wait with sending this to LKML). Best regards, Krzysztof ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v3 04/20] power_supply: sysfs: Use power_supply_*() API for accessing function attrs
On pon, 2015-02-09 at 20:02 +0100, Stefan Wahren wrote: > Hi Krzysztof, > > > Krzysztof Kozlowski hat am 30. Januar 2015 um > > 15:47 > > geschrieben: > > > > > > 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 > > Acked-by: Jonghwa Lee > > just a nit. It looks like a typo in the mail address which is also in patch 5 > - > 10. Right, I copied it directly from Jonghwa's response. Thank you for noticing it. > > I applied patch 1 - 14 to my repo with a upcoming power driver (mxs_power) and > didn't see any problems with your patches. Great, thanks! Best regards, Krzysztof ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v4 01/20] power_supply: Add driver private data
Allow drivers to store private data inside power_supply structure for later usage in power supply operations. Usage of driver private data is necessary to access driver's state container object from power supply calls (like get_property()) if struct 'power_supply' is a stored there as a pointer, for example: struct some_driver_info { struct i2c_client *client; struct power_supply *power_supply; ... } In such case one cannot use container_of() and must store pointer to state container as private data. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Bartlomiej Zolnierkiewicz Reviewed-by: Sebastian Reichel Acked-by: Pavel Machek --- drivers/power/power_supply_core.c | 6 ++ include/linux/power_supply.h | 4 2 files changed, 10 insertions(+) diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c index 694e8cddd5c1..84ef3f40e7bf 100644 --- a/drivers/power/power_supply_core.c +++ b/drivers/power/power_supply_core.c @@ -629,6 +629,12 @@ void power_supply_unregister(struct power_supply *psy) } EXPORT_SYMBOL_GPL(power_supply_unregister); +void *power_supply_get_drvdata(struct power_supply *psy) +{ + return psy->drv_data; +} +EXPORT_SYMBOL_GPL(power_supply_get_drvdata); + static int __init power_supply_class_init(void) { power_supply_class = class_create(THIS_MODULE, "power_supply"); diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index 096dbced02ac..a5743f24e03e 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -209,6 +209,9 @@ struct power_supply { /* For APM emulation, think legacy userspace. */ int use_for_apm; + /* Driver private data */ + void *drv_data; + /* private */ struct device *dev; struct work_struct changed_work; @@ -281,6 +284,7 @@ extern int power_supply_register_no_ws(struct device *parent, extern void power_supply_unregister(struct power_supply *psy); extern int power_supply_powers(struct power_supply *psy, struct device *dev); +extern void *power_supply_get_drvdata(struct power_supply *psy); /* For APM emulation, think legacy userspace. */ extern struct class *power_supply_class; -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v4 03/20] power_supply: Add API for safe access of power supply function attrs
Add simple wrappers for accessing power supply's function attributes: - get_property -> power_supply_get_property - set_property -> power_supply_set_property - property_is_writeable -> power_supply_property_is_writeable - external_power_changed -> power_supply_external_power_changed This API along with atomic usage counter adds a safe way of accessing a power supply from another driver. If power supply is unregistered after obtaining reference to it by some driver, then the API wrappers won't be executed in invalid (freed) context. Next patch changing the ownership of power supply class is still needed to fully fix race conditions in accessing freed power supply. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Bartlomiej Zolnierkiewicz Reviewed-by: Sebastian Reichel Acked-by: Pavel Machek --- drivers/power/power_supply_core.c | 47 ++- include/linux/power_supply.h | 16 + 2 files changed, 62 insertions(+), 1 deletion(-) diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c index b748391c3e17..0521681b3674 100644 --- a/drivers/power/power_supply_core.c +++ b/drivers/power/power_supply_core.c @@ -314,7 +314,9 @@ EXPORT_SYMBOL_GPL(power_supply_is_system_supplied); int power_supply_set_battery_charged(struct power_supply *psy) { - if (psy->type == POWER_SUPPLY_TYPE_BATTERY && psy->set_charged) { + if (atomic_read(&psy->use_cnt) >= 0 && + psy->type == POWER_SUPPLY_TYPE_BATTERY && + psy->set_charged) { psy->set_charged(psy); return 0; } @@ -366,6 +368,47 @@ struct power_supply *power_supply_get_by_phandle(struct device_node *np, EXPORT_SYMBOL_GPL(power_supply_get_by_phandle); #endif /* CONFIG_OF */ +int power_supply_get_property(struct power_supply *psy, + enum power_supply_property psp, + union power_supply_propval *val) +{ + if (atomic_read(&psy->use_cnt) <= 0) + return -ENODEV; + + return psy->get_property(psy, psp, val); +} +EXPORT_SYMBOL_GPL(power_supply_get_property); + +int power_supply_set_property(struct power_supply *psy, + enum power_supply_property psp, + const union power_supply_propval *val) +{ + if (atomic_read(&psy->use_cnt) <= 0 || !psy->set_property) + return -ENODEV; + + return psy->set_property(psy, psp, val); +} +EXPORT_SYMBOL_GPL(power_supply_set_property); + +int power_supply_property_is_writeable(struct power_supply *psy, + enum power_supply_property psp) +{ + if (atomic_read(&psy->use_cnt) <= 0 || !psy->property_is_writeable) + return -ENODEV; + + return psy->property_is_writeable(psy, psp); +} +EXPORT_SYMBOL_GPL(power_supply_property_is_writeable); + +void power_supply_external_power_changed(struct power_supply *psy) +{ + if (atomic_read(&psy->use_cnt) <= 0 || !psy->external_power_changed) + return; + + psy->external_power_changed(psy); +} +EXPORT_SYMBOL_GPL(power_supply_external_power_changed); + int power_supply_powers(struct power_supply *psy, struct device *dev) { return sysfs_create_link(&psy->dev->kobj, &dev->kobj, "powers"); @@ -555,6 +598,7 @@ static int __power_supply_register(struct device *parent, dev->release = power_supply_dev_release; dev_set_drvdata(dev, psy); psy->dev = dev; + atomic_inc(&psy->use_cnt); if (cfg) { psy->drv_data = cfg->drv_data; psy->of_node = cfg->of_node; @@ -629,6 +673,7 @@ EXPORT_SYMBOL_GPL(power_supply_register_no_ws); void power_supply_unregister(struct power_supply *psy) { + WARN_ON(atomic_dec_return(&psy->use_cnt)); cancel_work_sync(&psy->changed_work); sysfs_remove_link(&psy->dev->kobj, "powers"); power_supply_remove_triggers(psy); diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index b203a26d5c54..5d460995f38d 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -199,6 +199,12 @@ struct power_supply { size_t num_supplies; struct device_node *of_node; + /* +* Functions for drivers implementing power supply class. +* These shouldn't be called directly by other drivers for accessing +* this power supply. Instead use power_supply_*() functions (for +* example power_supply_get_property()). +*/ int (*get_property)(struct power_supply *psy, enum power_supply_property psp, union power_supply_propval *val)
[PATCH v4 00/20] power_supply: Allow safe usage of power supply
Hi, The patchset fixes invalid memory accesses in certain race scenarios by moving ownership of struct power_supply to the core. All drivers are modified. TLDR for driver and subsystem maintainers = Two patches of patchset change power_supply_register() function so in the same time they touch all drivers. I am kindly asking for acks, review and help in testing. Especially please take a look at: - patch 2: power_supply: Move run-time configuration to separate structure - patch 11: power_supply: Change ownership from driver to core These are huge. Problem to fix == Patchset tries to fix invalid memory accesses occurring in following race scenario: Thread 1: charger manager, CONSUMER Thread 2: power supply driver, PROVIDER THREAD 1 (consumer)THREAD 2 (provider) ====== psy = power_supply_get_by_name() Driver unbind, .remove power_supply_unregister() Device fully removed psy->get_property() The consumer of power supply will reference invalid memory because the provider already freed it. The fix === To properly fix the race the patchset: 1. Moves ownership of power_supply structure from driver (provider) to power supply core. 2. Adds power_supply_get_property()-like API for safe access by consumer. 3. Adds power_supply_put() which will reclaim memory. I modifed all drivers I found. However I only compile tested them (plus Smatch, Sparse and coccicheck). I did not test them on real hardware (except max14577, max77693, max17040, max17042 and charger-manager). What the patchset does in steps === 1. Some preparation steps are necessary - patch 1 and 2. The driver implementing power supply won't be able to fill structure before calling power_supply_register(). So 'power_supply_config' is introduced in patch 2 ("power_supply: Move run-time configuration to separate structure"). Unfortunately this touches all drivers. *All drivers are touched.* 2. Safe API wrappers (and usage counter) are added (power_supply_*()). 3. Patch 11: ownership of 'struct power_supply' is moved from driver to the core. *All drivers are touched.* 4. power_supply_put() is added which reclaims resources. Dependencies The patchset is rebased on v4.0-rc1 and my latest power supply changes: 1. power_supply: ab8500_fg: Simplify creation and removal of sysfs entries [4] 2. compal-laptop: two fixes [5]. 3. twl4030_madc_battery, ipaq_micro_battery, lp8788-charger: fixes [6]. Bisect-ability is preserved. All later patches depend on previous ones so it could be pulled in steps, but cherry-picking won't work. Patchset is available also here: https://git.linaro.org/people/marek.szyprowski/linux-srpol.git branch: v4.0-rc1-power-supply-core-ownership Changes since v3 1. Fix Jonghwa's email in his ack (spotted by Stefan Wahren) 2. Update power_supply_register() documentation. 3. Fix putting the reference to power supply in bq2415x_charger.c (put it when it is non-NULL). 4. Add acks: Robert Jarzmik (patch 20), Darren Hart (p. 2), Pavel Machek (p. 1-3), Marc Dietrich (p. 2 and 11). Changes since v2 1. Rewrite all drivers to new power_supply_register(). 2. Add reviewed-by Bartlomiej Zolnierkiewicz (internal review) 3. Add reviewed-by Sebastian Reichel [3] (to patches which I did not change in major way between v2 and v3). 4. Use atomic usage counter of power supply on each of: a. register/unregister, b. get/put. Changes since v1 1. Add new patches (1, 2, 11, 19). 2. Preserved ack-s where there weren't any changes. 3. Patch 3: Add use counter. 4. Patch 3: Don't add wrapper for set_charged() because already exists one. [1] https://lkml.org/lkml/2014/11/4/527 [2] https://lkml.org/lkml/2014/10/16/89 [3] https://lkml.org/lkml/2015/1/21/471 [4] https://lkml.org/lkml/2015/1/29/612 [5] https://lkml.org/lkml/2015/2/20/150 [6] https://lkml.org/lkml/2015/2/20/170 Best regards, Krzysztof Krzysztof Kozlowski (20): power_supply: Add driver private data power_supply: Move run-time configuration to separate structure power_supply: Add API for safe access of power supply function attrs power_supply: sysfs: Use power_supply_*() API for accessing function attrs power_supply: 88pm860x_charger: Use power_supply_*() API for accessing function attrs power_supply: ab8500: Use power_supply_*() API for accessing function attrs mfd: ab8500: Use power_supply_*() API for accessing function attrs power_supply: apm_power: Use power_supply_*() API for accessing function attrs power_supply: bq2415x_charger: Use power_supply_*() API for accessing function attrs power_supply: charger-manager:
[PATCH v4 05/20] power_supply: 88pm860x_charger: Use power_supply_*() API for accessing function attrs
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 Signed-off-by: Krzysztof Kozlowski Acked-by: Jonghwa Lee Acked-by: Pavel Machek Reviewed-by: Bartlomiej Zolnierkiewicz Reviewed-by: Sebastian Reichel --- drivers/power/88pm860x_charger.c | 13 - 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/power/88pm860x_charger.c b/drivers/power/88pm860x_charger.c index ac352a6c03ea..98e31419d9cf 100644 --- a/drivers/power/88pm860x_charger.c +++ b/drivers/power/88pm860x_charger.c @@ -296,12 +296,13 @@ static int set_charging_fsm(struct pm860x_charger_info *info) psy = power_supply_get_by_name(pm860x_supplied_to[0]); if (!psy) return -EINVAL; - ret = psy->get_property(psy, POWER_SUPPLY_PROP_VOLTAGE_NOW, &data); + ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_VOLTAGE_NOW, + &data); if (ret) return ret; vbatt = data.intval / 1000; - ret = psy->get_property(psy, POWER_SUPPLY_PROP_PRESENT, &data); + ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_PRESENT, &data); if (ret) return ret; @@ -430,7 +431,7 @@ static irqreturn_t pm860x_temp_handler(int irq, void *data) psy = power_supply_get_by_name(pm860x_supplied_to[0]); if (!psy) goto out; - ret = psy->get_property(psy, POWER_SUPPLY_PROP_TEMP, &temp); + ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_TEMP, &temp); if (ret) goto out; value = temp.intval / 10; @@ -485,7 +486,8 @@ static irqreturn_t pm860x_done_handler(int irq, void *data) psy = power_supply_get_by_name(pm860x_supplied_to[0]); if (!psy) goto out; - ret = psy->get_property(psy, POWER_SUPPLY_PROP_VOLTAGE_NOW, &val); + ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_VOLTAGE_NOW, + &val); if (ret) goto out; vbatt = val.intval / 1000; @@ -500,7 +502,8 @@ static irqreturn_t pm860x_done_handler(int irq, void *data) if (ret < 0) goto out; if (vbatt > CHARGE_THRESHOLD && ret & STATUS2_CHG) - psy->set_property(psy, POWER_SUPPLY_PROP_CHARGE_FULL, &val); + power_supply_set_property(psy, POWER_SUPPLY_PROP_CHARGE_FULL, + &val); out: mutex_unlock(&info->lock); -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v4 08/20] power_supply: apm_power: Use power_supply_*() API for accessing function attrs
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 Signed-off-by: Krzysztof Kozlowski Acked-by: Jonghwa Lee Acked-by: Pavel Machek Reviewed-by: Bartlomiej Zolnierkiewicz Reviewed-by: Sebastian Reichel --- drivers/power/apm_power.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/power/apm_power.c b/drivers/power/apm_power.c index 39763015b360..2206f9ff6488 100644 --- a/drivers/power/apm_power.c +++ b/drivers/power/apm_power.c @@ -15,10 +15,10 @@ #include -#define PSY_PROP(psy, prop, val) (psy->get_property(psy, \ +#define PSY_PROP(psy, prop, val) (power_supply_get_property(psy, \ POWER_SUPPLY_PROP_##prop, val)) -#define _MPSY_PROP(prop, val) (main_battery->get_property(main_battery, \ +#define _MPSY_PROP(prop, val) (power_supply_get_property(main_battery, \ prop, val)) #define MPSY_PROP(prop, val) _MPSY_PROP(POWER_SUPPLY_PROP_##prop, val) -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v4 06/20] power_supply: ab8500: Use power_supply_*() API for accessing function attrs
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 Signed-off-by: Krzysztof Kozlowski Acked-by: Jonghwa Lee Acked-by: Pavel Machek Acked-by: Linus Walleij Reviewed-by: Bartlomiej Zolnierkiewicz Reviewed-by: Sebastian Reichel --- drivers/power/ab8500_btemp.c| 2 +- drivers/power/ab8500_charger.c | 2 +- drivers/power/ab8500_fg.c | 2 +- drivers/power/abx500_chargalg.c | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/power/ab8500_btemp.c b/drivers/power/ab8500_btemp.c index d5683f503a4e..4d18464d6400 100644 --- a/drivers/power/ab8500_btemp.c +++ b/drivers/power/ab8500_btemp.c @@ -938,7 +938,7 @@ static int ab8500_btemp_get_ext_psy_data(struct device *dev, void *data) enum power_supply_property prop; prop = ext->properties[j]; - if (ext->get_property(ext, prop, &ret)) + if (power_supply_get_property(ext, prop, &ret)) continue; switch (prop) { diff --git a/drivers/power/ab8500_charger.c b/drivers/power/ab8500_charger.c index cee9b9e46825..f9eb7fff1d65 100644 --- a/drivers/power/ab8500_charger.c +++ b/drivers/power/ab8500_charger.c @@ -1957,7 +1957,7 @@ static int ab8500_charger_get_ext_psy_data(struct device *dev, void *data) enum power_supply_property prop; prop = ext->properties[j]; - if (ext->get_property(ext, prop, &ret)) + if (power_supply_get_property(ext, prop, &ret)) continue; switch (prop) { diff --git a/drivers/power/ab8500_fg.c b/drivers/power/ab8500_fg.c index 0e2c9d592a53..c957e8a41847 100644 --- a/drivers/power/ab8500_fg.c +++ b/drivers/power/ab8500_fg.c @@ -2200,7 +2200,7 @@ static int ab8500_fg_get_ext_psy_data(struct device *dev, void *data) enum power_supply_property prop; prop = ext->properties[j]; - if (ext->get_property(ext, prop, &ret)) + if (power_supply_get_property(ext, prop, &ret)) continue; switch (prop) { diff --git a/drivers/power/abx500_chargalg.c b/drivers/power/abx500_chargalg.c index 0da4415cbc10..ac6f4a22f846 100644 --- a/drivers/power/abx500_chargalg.c +++ b/drivers/power/abx500_chargalg.c @@ -1001,7 +1001,7 @@ static int abx500_chargalg_get_ext_psy_data(struct device *dev, void *data) * property because of handling that sysfs entry on its own, this is * the place to get the battery capacity. */ - if (!ext->get_property(ext, POWER_SUPPLY_PROP_CAPACITY, &ret)) { + if (!power_supply_get_property(ext, POWER_SUPPLY_PROP_CAPACITY, &ret)) { di->batt_data.percent = ret.intval; capacity_updated = true; } @@ -1019,7 +1019,7 @@ static int abx500_chargalg_get_ext_psy_data(struct device *dev, void *data) ext->type == POWER_SUPPLY_TYPE_USB) di->usb_chg = psy_to_ux500_charger(ext); - if (ext->get_property(ext, prop, &ret)) + if (power_supply_get_property(ext, prop, &ret)) continue; switch (prop) { case POWER_SUPPLY_PROP_PRESENT: -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v4 04/20] power_supply: sysfs: Use power_supply_*() API for accessing function attrs
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 Acked-by: Jonghwa Lee Acked-by: Pavel Machek Reviewed-by: Bartlomiej Zolnierkiewicz Reviewed-by: Sebastian Reichel --- drivers/power/power_supply_sysfs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c index 62653f50a524..f817aab80813 100644 --- a/drivers/power/power_supply_sysfs.c +++ b/drivers/power/power_supply_sysfs.c @@ -76,7 +76,7 @@ static ssize_t power_supply_show_property(struct device *dev, if (off == POWER_SUPPLY_PROP_TYPE) { value.intval = psy->type; } else { - ret = psy->get_property(psy, off, &value); + ret = power_supply_get_property(psy, off, &value); if (ret < 0) { if (ret == -ENODATA) @@ -125,7 +125,7 @@ static ssize_t power_supply_store_property(struct device *dev, value.intval = long_val; - ret = psy->set_property(psy, off, &value); + ret = power_supply_set_property(psy, off, &value); if (ret < 0) return ret; @@ -223,7 +223,7 @@ static umode_t power_supply_attr_is_visible(struct kobject *kobj, if (property == attrno) { if (psy->property_is_writeable && - psy->property_is_writeable(psy, property) > 0) + power_supply_property_is_writeable(psy, property) > 0) mode |= S_IWUSR; return mode; -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v4 07/20] mfd: ab8500: Use power_supply_*() API for accessing function attrs
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 Signed-off-by: Krzysztof Kozlowski Acked-by: Jonghwa Lee Acked-by: Pavel Machek Acked-by: Lee Jones Reviewed-by: Bartlomiej Zolnierkiewicz Reviewed-by: Sebastian Reichel --- drivers/mfd/ab8500-sysctrl.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/mfd/ab8500-sysctrl.c b/drivers/mfd/ab8500-sysctrl.c index cfff0b643f1b..d4a4b24be7c6 100644 --- a/drivers/mfd/ab8500-sysctrl.c +++ b/drivers/mfd/ab8500-sysctrl.c @@ -49,7 +49,8 @@ static void ab8500_power_off(void) if (!psy) continue; - ret = psy->get_property(psy, POWER_SUPPLY_PROP_ONLINE, &val); + ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_ONLINE, + &val); if (!ret && val.intval) { charger_present = true; @@ -63,8 +64,8 @@ static void ab8500_power_off(void) /* Check if battery is known */ psy = power_supply_get_by_name("ab8500_btemp"); if (psy) { - ret = psy->get_property(psy, POWER_SUPPLY_PROP_TECHNOLOGY, - &val); + ret = power_supply_get_property(psy, + POWER_SUPPLY_PROP_TECHNOLOGY, &val); if (!ret && val.intval != POWER_SUPPLY_TECHNOLOGY_UNKNOWN) { printk(KERN_INFO "Charger \"%s\" is connected with known battery." -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v4 09/20] power_supply: bq2415x_charger: Use power_supply_*() API for accessing function attrs
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 Signed-off-by: Krzysztof Kozlowski Acked-by: Jonghwa Lee Acked-by: Pavel Machek Reviewed-by: Bartlomiej Zolnierkiewicz Reviewed-by: Sebastian Reichel --- drivers/power/bq2415x_charger.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/power/bq2415x_charger.c b/drivers/power/bq2415x_charger.c index 73b0a8521803..bc47a265b304 100644 --- a/drivers/power/bq2415x_charger.c +++ b/drivers/power/bq2415x_charger.c @@ -816,7 +816,8 @@ static int bq2415x_notifier_call(struct notifier_block *nb, dev_dbg(bq->dev, "notifier call was called\n"); - ret = psy->get_property(psy, POWER_SUPPLY_PROP_CURRENT_MAX, &prop); + ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_CURRENT_MAX, + &prop); if (ret != 0) return NOTIFY_OK; -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v4 12/20] power_supply: Add power_supply_put for decrementing device reference counter
The power_supply_get_by_phandle() and power_supply_get_by_name() use function class_find_device() for obtaining the reference to power supply. Each use of class_find_device() increases the power supply's device reference counter. However the reference counter was not decreased by users of this API. Thus final device_unregister() call from power_supply_unregister() could not release the device and clean up its resources. This lead to memory leak if at least once power_supply_get_by_*() was called between registering and unregistering the power supply. Add and document new API power_supply_put() for decrementing the reference counter. Signed-off-by: Krzysztof Kozlowski Acked-by: Pavel Machek Reviewed-by: Bartlomiej Zolnierkiewicz Reviewed-by: Sebastian Reichel --- drivers/power/power_supply_core.c | 38 ++ include/linux/power_supply.h | 1 + 2 files changed, 39 insertions(+) diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c index 7f437f66076c..a94f8c9d5e1e 100644 --- a/drivers/power/power_supply_core.c +++ b/drivers/power/power_supply_core.c @@ -336,6 +336,17 @@ static int power_supply_match_device_by_name(struct device *dev, const void *dat return strcmp(psy->desc->name, name) == 0; } +/** + * power_supply_get_by_name() - Search for a power supply and returns its ref + * @name: Power supply name to fetch + * + * If power supply was found, it increases reference count for the + * internal power supply's device. The user should power_supply_put() + * after usage. + * + * Return: On success returns a reference to a power supply with + * matching name equals to @name, a NULL otherwise. + */ struct power_supply *power_supply_get_by_name(const char *name) { struct device *dev = class_find_device(power_supply_class, NULL, name, @@ -345,12 +356,39 @@ struct power_supply *power_supply_get_by_name(const char *name) } EXPORT_SYMBOL_GPL(power_supply_get_by_name); +/** + * power_supply_put() - Drop reference obtained with power_supply_get_by_name + * @psy: Reference to put + * + * The reference to power supply should be put before unregistering + * the power supply. + */ +void power_supply_put(struct power_supply *psy) +{ + might_sleep(); + + put_device(&psy->dev); +} +EXPORT_SYMBOL_GPL(power_supply_put); + #ifdef CONFIG_OF static int power_supply_match_device_node(struct device *dev, const void *data) { return dev->parent && dev->parent->of_node == data; } +/** + * power_supply_get_by_phandle() - Search for a power supply and returns its ref + * @np: Pointer to device node holding phandle property + * @phandle_name: Name of property holding a power supply name + * + * If power supply was found, it increases reference count for the + * internal power supply's device. The user should power_supply_put() + * after usage. + * + * Return: On success returns a reference to a power supply with + * matching name equals to value under @property, NULL or ERR_PTR otherwise. + */ struct power_supply *power_supply_get_by_phandle(struct device_node *np, const char *property) { diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index 54ebac5e3fe3..7000a4927ac8 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -282,6 +282,7 @@ extern struct atomic_notifier_head power_supply_notifier; extern int power_supply_reg_notifier(struct notifier_block *nb); extern void power_supply_unreg_notifier(struct notifier_block *nb); extern struct power_supply *power_supply_get_by_name(const char *name); +extern void power_supply_put(struct power_supply *psy); #ifdef CONFIG_OF extern struct power_supply *power_supply_get_by_phandle(struct device_node *np, const char *property); -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v4 02/20] power_supply: Move run-time configuration to separate structure
Add new structure 'power_supply_config' for holding run-time initialization data like of_node, supplies and private driver data. The power_supply_register() function is changed so all power supply drivers need updating. When registering the power supply this new 'power_supply_config' should be used instead of directly initializing 'struct power_supply'. This allows changing the ownership of power_supply structure from driver to the power supply core in next patches. When a driver does not use of_node or supplies then it should use NULL as config. If driver uses of_node or supplies then it should allocate config on stack and initialize it with proper values. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Bartlomiej Zolnierkiewicz Acked-by: Pavel Machek [for the nvec part] Reviewed-by: Marc Dietrich [for drivers/platform/x86/compal-laptop.c] Reviewed-by: Darren Hart --- drivers/acpi/ac.c | 2 +- drivers/acpi/battery.c| 3 ++- drivers/acpi/sbs.c| 4 ++-- drivers/hid/hid-input.c | 2 +- drivers/hid/hid-sony.c| 2 +- drivers/hid/hid-wiimote-modules.c | 2 +- drivers/hid/wacom_sys.c | 5 +++-- drivers/platform/x86/compal-laptop.c | 2 +- drivers/power/88pm860x_battery.c | 2 +- drivers/power/88pm860x_charger.c | 7 --- drivers/power/ab8500_btemp.c | 7 --- drivers/power/ab8500_charger.c| 15 +-- drivers/power/ab8500_fg.c | 8 +--- drivers/power/abx500_chargalg.c | 8 +--- drivers/power/bq2415x_charger.c | 2 +- drivers/power/bq24190_charger.c | 4 ++-- drivers/power/bq24735-charger.c | 10 ++ drivers/power/bq27x00_battery.c | 2 +- drivers/power/charger-manager.c | 2 +- drivers/power/collie_battery.c| 4 ++-- drivers/power/da9030_battery.c| 2 +- drivers/power/da9052-battery.c| 2 +- drivers/power/ds2760_battery.c| 2 +- drivers/power/ds2780_battery.c| 2 +- drivers/power/ds2781_battery.c| 2 +- drivers/power/ds2782_battery.c| 2 +- drivers/power/generic-adc-battery.c | 2 +- drivers/power/goldfish_battery.c | 4 ++-- drivers/power/gpio-charger.c | 10 ++ drivers/power/intel_mid_battery.c | 4 ++-- drivers/power/ipaq_micro_battery.c| 4 ++-- drivers/power/isp1704_charger.c | 2 +- drivers/power/jz4740-battery.c| 2 +- drivers/power/lp8727_charger.c| 14 +++--- drivers/power/lp8788-charger.c| 11 +++ drivers/power/ltc2941-battery-gauge.c | 2 +- drivers/power/max14577_charger.c | 2 +- drivers/power/max17040_battery.c | 2 +- drivers/power/max17042_battery.c | 2 +- drivers/power/max77693_charger.c | 2 +- drivers/power/max8903_charger.c | 2 +- drivers/power/max8925_power.c | 14 +++--- drivers/power/max8997_charger.c | 2 +- drivers/power/max8998_charger.c | 2 +- drivers/power/olpc_battery.c | 4 ++-- drivers/power/pcf50633-charger.c | 16 +++- drivers/power/pda_power.c | 18 -- drivers/power/pm2301_charger.c| 8 +--- drivers/power/pmu_battery.c | 4 ++-- drivers/power/power_supply_core.c | 20 +++- drivers/power/rt5033_battery.c| 2 +- drivers/power/rx51_battery.c | 2 +- drivers/power/s3c_adc_battery.c | 4 ++-- drivers/power/sbs-battery.c | 6 -- drivers/power/smb347-charger.c| 13 ++--- drivers/power/test_power.c| 21 - drivers/power/tosa_battery.c | 6 +++--- drivers/power/tps65090-charger.c | 10 ++ drivers/power/twl4030_charger.c | 4 ++-- drivers/power/twl4030_madc_battery.c | 2 +- drivers/power/wm831x_backup.c | 2 +- drivers/power/wm831x_power.c | 6 +++--- drivers/power/wm8350_power.c | 6 +++--- drivers/power/wm97xx_battery.c| 2 +- drivers/power/z2_battery.c| 2 +- drivers/staging/nvec/nvec_power.c | 7 --- include/linux/power_supply.h | 16 ++-- 67 files changed, 211 insertions(+), 158 deletions(-) diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c index 36b0e61f9c09..8bf516885ede 100644 --- a/drivers/acpi/ac.c +++ b/drivers/acpi/ac.c @@ -351,7 +351,7 @@ static int acpi_ac_add(struct acpi_device *device) ac->charger.properties = ac_props; ac->charger.num_properties = ARRAY_SIZE(ac_props); ac->charger.get_property = get_ac_property; - result = power_supply_register(&ac->device->dev, &ac->charger); + result = power_supply_register(&ac->device->dev, &ac->charger, NULL); if (result) goto end; diff --git a/drivers/acpi/b