All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] gpio: tangier: calculate number of ctx using temporary variable
@ 2023-05-22  4:58 Raag Jadav
  2023-05-23  8:22 ` Bartosz Golaszewski
  0 siblings, 1 reply; 2+ messages in thread
From: Raag Jadav @ 2023-05-22  4:58 UTC (permalink / raw)
  To: linus.walleij, brgl, andriy.shevchenko
  Cc: linux-gpio, linux-kernel, mallikarjunappa.sangannavar, pandith.n,
	Raag Jadav

Utilize a temporary variable to calculate number of ctx from ngpio
inside ->probe() implementation.
While at it, include math.h for using DIV_ROUND_UP().

Signed-off-by: Raag Jadav <raag.jadav@intel.com>
---
 drivers/gpio/gpio-tangier.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-tangier.c b/drivers/gpio/gpio-tangier.c
index e990781935ba..7ce3eddaed25 100644
--- a/drivers/gpio/gpio-tangier.c
+++ b/drivers/gpio/gpio-tangier.c
@@ -16,6 +16,7 @@
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/irq.h>
+#include <linux/math.h>
 #include <linux/module.h>
 #include <linux/pinctrl/pinconf-generic.h>
 #include <linux/spinlock.h>
@@ -428,10 +429,11 @@ static int tng_gpio_add_pin_ranges(struct gpio_chip *chip)
 int devm_tng_gpio_probe(struct device *dev, struct tng_gpio *gpio)
 {
 	const struct tng_gpio_info *info = &gpio->info;
+	size_t nctx = DIV_ROUND_UP(info->ngpio, 32);
 	struct gpio_irq_chip *girq;
 	int ret;
 
-	gpio->ctx = devm_kcalloc(dev, DIV_ROUND_UP(info->ngpio, 32), sizeof(*gpio->ctx), GFP_KERNEL);
+	gpio->ctx = devm_kcalloc(dev, nctx, sizeof(*gpio->ctx), GFP_KERNEL);
 	if (!gpio->ctx)
 		return -ENOMEM;
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v1] gpio: tangier: calculate number of ctx using temporary variable
  2023-05-22  4:58 [PATCH v1] gpio: tangier: calculate number of ctx using temporary variable Raag Jadav
@ 2023-05-23  8:22 ` Bartosz Golaszewski
  0 siblings, 0 replies; 2+ messages in thread
From: Bartosz Golaszewski @ 2023-05-23  8:22 UTC (permalink / raw)
  To: Raag Jadav
  Cc: linus.walleij, andriy.shevchenko, linux-gpio, linux-kernel,
	mallikarjunappa.sangannavar, pandith.n

On Mon, May 22, 2023 at 6:58 AM Raag Jadav <raag.jadav@intel.com> wrote:
>
> Utilize a temporary variable to calculate number of ctx from ngpio
> inside ->probe() implementation.
> While at it, include math.h for using DIV_ROUND_UP().
>
> Signed-off-by: Raag Jadav <raag.jadav@intel.com>
> ---
>  drivers/gpio/gpio-tangier.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpio/gpio-tangier.c b/drivers/gpio/gpio-tangier.c
> index e990781935ba..7ce3eddaed25 100644
> --- a/drivers/gpio/gpio-tangier.c
> +++ b/drivers/gpio/gpio-tangier.c
> @@ -16,6 +16,7 @@
>  #include <linux/interrupt.h>
>  #include <linux/io.h>
>  #include <linux/irq.h>
> +#include <linux/math.h>
>  #include <linux/module.h>
>  #include <linux/pinctrl/pinconf-generic.h>
>  #include <linux/spinlock.h>
> @@ -428,10 +429,11 @@ static int tng_gpio_add_pin_ranges(struct gpio_chip *chip)
>  int devm_tng_gpio_probe(struct device *dev, struct tng_gpio *gpio)
>  {
>         const struct tng_gpio_info *info = &gpio->info;
> +       size_t nctx = DIV_ROUND_UP(info->ngpio, 32);
>         struct gpio_irq_chip *girq;
>         int ret;
>
> -       gpio->ctx = devm_kcalloc(dev, DIV_ROUND_UP(info->ngpio, 32), sizeof(*gpio->ctx), GFP_KERNEL);
> +       gpio->ctx = devm_kcalloc(dev, nctx, sizeof(*gpio->ctx), GFP_KERNEL);
>         if (!gpio->ctx)
>                 return -ENOMEM;
>
> --
> 2.17.1
>

Applied, thanks!

Bartosz

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-05-23  8:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-22  4:58 [PATCH v1] gpio: tangier: calculate number of ctx using temporary variable Raag Jadav
2023-05-23  8:22 ` Bartosz Golaszewski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.