* [PATCH] pinctrl: samsung: use 'int' for register masks in Exynos @ 2021-04-08 19:50 ` Krzysztof Kozlowski 2021-04-09 11:53 ` Sylwester Nawrocki 2021-04-10 0:07 ` Linus Walleij 0 siblings, 2 replies; 3+ messages in thread From: Krzysztof Kozlowski @ 2021-04-08 19:50 UTC (permalink / raw) To: Tomasz Figa, Krzysztof Kozlowski, Sylwester Nawrocki, Linus Walleij, linux-arm-kernel, linux-samsung-soc, linux-gpio, linux-kernel Cc: Marek Szyprowski, Bartlomiej Zolnierkiewicz The Special Function Registers on all Exynos SoC, including ARM64, are 32-bit wide, so entire driver uses matching functions like readl() or writel(). On 64-bit ARM using unsigned long for register masks: 1. makes little sense as immediately after bitwise operation it will be cast to 32-bit value when calling writel(), 2. is actually error-prone because it might promote other operands to 64-bit. Addresses-Coverity: Unintentional integer overflow Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> --- Not tested on ARM64. Dear Linus, Please apply it directly, I don't have any patches for Samsung pinctrl in my tree. --- drivers/pinctrl/samsung/pinctrl-exynos.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/pinctrl/samsung/pinctrl-exynos.c b/drivers/pinctrl/samsung/pinctrl-exynos.c index 0cd7f33cdf25..2b99f4130e1e 100644 --- a/drivers/pinctrl/samsung/pinctrl-exynos.c +++ b/drivers/pinctrl/samsung/pinctrl-exynos.c @@ -55,7 +55,7 @@ static void exynos_irq_mask(struct irq_data *irqd) struct exynos_irq_chip *our_chip = to_exynos_irq_chip(chip); struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(irqd); unsigned long reg_mask = our_chip->eint_mask + bank->eint_offset; - unsigned long mask; + unsigned int mask; unsigned long flags; raw_spin_lock_irqsave(&bank->slock, flags); @@ -83,7 +83,7 @@ static void exynos_irq_unmask(struct irq_data *irqd) struct exynos_irq_chip *our_chip = to_exynos_irq_chip(chip); struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(irqd); unsigned long reg_mask = our_chip->eint_mask + bank->eint_offset; - unsigned long mask; + unsigned int mask; unsigned long flags; /* @@ -483,7 +483,7 @@ static void exynos_irq_eint0_15(struct irq_desc *desc) chained_irq_exit(chip, desc); } -static inline void exynos_irq_demux_eint(unsigned long pend, +static inline void exynos_irq_demux_eint(unsigned int pend, struct irq_domain *domain) { unsigned int irq; @@ -500,8 +500,8 @@ static void exynos_irq_demux_eint16_31(struct irq_desc *desc) { struct irq_chip *chip = irq_desc_get_chip(desc); struct exynos_muxed_weint_data *eintd = irq_desc_get_handler_data(desc); - unsigned long pend; - unsigned long mask; + unsigned int pend; + unsigned int mask; int i; chained_irq_enter(chip, desc); -- 2.25.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] pinctrl: samsung: use 'int' for register masks in Exynos 2021-04-08 19:50 ` [PATCH] pinctrl: samsung: use 'int' for register masks in Exynos Krzysztof Kozlowski @ 2021-04-09 11:53 ` Sylwester Nawrocki 2021-04-10 0:07 ` Linus Walleij 1 sibling, 0 replies; 3+ messages in thread From: Sylwester Nawrocki @ 2021-04-09 11:53 UTC (permalink / raw) To: Krzysztof Kozlowski, linux-arm-kernel, linux-samsung-soc, linux-gpio, linux-kernel Cc: Marek Szyprowski, Bartlomiej Zolnierkiewicz, Tomasz Figa, Linus Walleij On 08.04.2021 21:50, Krzysztof Kozlowski wrote: > The Special Function Registers on all Exynos SoC, including ARM64, are > 32-bit wide, so entire driver uses matching functions like readl() or > writel(). On 64-bit ARM using unsigned long for register masks: > 1. makes little sense as immediately after bitwise operation it will be > cast to 32-bit value when calling writel(), > 2. is actually error-prone because it might promote other operands to > 64-bit. > > Addresses-Coverity: Unintentional integer overflow > Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> Reviewed-by: Sylwester Nawrocki <s.nawrocki@samsung.com> > --- > > Not tested on ARM64. I have tested it on exynos5433/tm2e and didn't notice any issues as we could expect. The patch looks good to me, however I would personally use u32 rather than "unsigned int", like in other places for the register value variables. -- Regards, Sylwester _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] pinctrl: samsung: use 'int' for register masks in Exynos 2021-04-08 19:50 ` [PATCH] pinctrl: samsung: use 'int' for register masks in Exynos Krzysztof Kozlowski 2021-04-09 11:53 ` Sylwester Nawrocki @ 2021-04-10 0:07 ` Linus Walleij 1 sibling, 0 replies; 3+ messages in thread From: Linus Walleij @ 2021-04-10 0:07 UTC (permalink / raw) To: Krzysztof Kozlowski Cc: Tomasz Figa, Sylwester Nawrocki, Linux ARM, linux-samsung-soc, open list:GPIO SUBSYSTEM, linux-kernel, Marek Szyprowski, Bartlomiej Zolnierkiewicz On Thu, Apr 8, 2021 at 9:50 PM Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> wrote: > The Special Function Registers on all Exynos SoC, including ARM64, are > 32-bit wide, so entire driver uses matching functions like readl() or > writel(). On 64-bit ARM using unsigned long for register masks: > 1. makes little sense as immediately after bitwise operation it will be > cast to 32-bit value when calling writel(), > 2. is actually error-prone because it might promote other operands to > 64-bit. > > Addresses-Coverity: Unintentional integer overflow > Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> (...) > Please apply it directly, I don't have any patches for Samsung pinctrl > in my tree. OK! Patch applied! Yours, Linus Walleij _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-04-10 0:10 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <CGME20210408195041eucas1p1b63616039af4e1156aa4cfd8101b1362@eucas1p1.samsung.com> 2021-04-08 19:50 ` [PATCH] pinctrl: samsung: use 'int' for register masks in Exynos Krzysztof Kozlowski 2021-04-09 11:53 ` Sylwester Nawrocki 2021-04-10 0:07 ` Linus Walleij
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).