From: Stephen Boyd <swboyd@chromium.org>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org,
linux-arm-msm@vger.kernel.org, Timur Tabi <timur@codeaurora.org>,
Bjorn Andersson <bjorn.andersson@linaro.org>,
Grant Likely <grant.likely@secretlab.ca>,
linux-gpio@vger.kernel.org,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH v4 2/5] gpiolib: Extract mask allocation into subroutine
Date: Fri, 23 Mar 2018 09:34:50 -0700 [thread overview]
Message-ID: <20180323163453.96495-3-swboyd@chromium.org> (raw)
In-Reply-To: <20180323163453.96495-1-swboyd@chromium.org>
We're going to use similar code to allocate and set all the bits in a
mask for valid gpios to use. Extract the code from the irqchip version
so it can be reused.
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
---
drivers/gpio/gpiolib.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index d66de67ef307..cc0e1519da45 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -337,6 +337,20 @@ static int gpiochip_set_desc_names(struct gpio_chip *gc)
return 0;
}
+static unsigned long *gpiochip_allocate_mask(struct gpio_chip *chip)
+{
+ unsigned long *p;
+
+ p = kcalloc(BITS_TO_LONGS(chip->ngpio), sizeof(long), GFP_KERNEL);
+ if (!p)
+ return NULL;
+
+ /* Assume by default all GPIOs are valid */
+ bitmap_fill(p, chip->ngpio);
+
+ return p;
+}
+
/*
* GPIO line handle management
*/
@@ -1506,14 +1520,10 @@ static int gpiochip_irqchip_init_valid_mask(struct gpio_chip *gpiochip)
if (!gpiochip->irq.need_valid_mask)
return 0;
- gpiochip->irq.valid_mask = kcalloc(BITS_TO_LONGS(gpiochip->ngpio),
- sizeof(long), GFP_KERNEL);
+ gpiochip->irq.valid_mask = gpiochip_allocate_mask(gpiochip);
if (!gpiochip->irq.valid_mask)
return -ENOMEM;
- /* Assume by default all GPIOs are valid */
- bitmap_fill(gpiochip->irq.valid_mask, gpiochip->ngpio);
-
return 0;
}
--
Sent by a computer through tubes
next prev parent reply other threads:[~2018-03-23 16:34 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-23 16:34 [PATCH v4 0/5] Support qcom pinctrl protected pins Stephen Boyd
2018-03-23 16:34 ` [PATCH v4 1/5] dt-bindings: gpio: Add a gpio-reserved-ranges property Stephen Boyd
2018-03-26 22:25 ` Rob Herring
2018-03-23 16:34 ` Stephen Boyd [this message]
2018-03-23 16:34 ` [PATCH v4 3/5] gpiolib: Change bitmap allocation to kmalloc_array Stephen Boyd
2018-03-23 16:34 ` [PATCH v4 4/5] gpiolib: Support 'gpio-reserved-ranges' property Stephen Boyd
2018-03-23 16:34 ` [PATCH v4 5/5] pinctrl: qcom: Don't allow protected pins to be requested Stephen Boyd
2018-03-23 23:50 ` [PATCH v4 0/5] Support qcom pinctrl protected pins Timur Tabi
2018-03-26 8:39 ` Andy Shevchenko
2018-03-27 13:35 ` Linus Walleij
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180323163453.96495-3-swboyd@chromium.org \
--to=swboyd@chromium.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=bjorn.andersson@linaro.org \
--cc=devicetree@vger.kernel.org \
--cc=grant.likely@secretlab.ca \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=timur@codeaurora.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).