linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] gpio: pca953x: Reduce stack usage in couple of functions
@ 2019-10-23 15:30 Andy Shevchenko
  0 siblings, 0 replies; only message in thread
From: Andy Shevchenko @ 2019-10-23 15:30 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, linux-gpio, Rasmus Villemoes,
	Yury Norov, linux-kernel, Andrew Morton, William Breathitt Gray
  Cc: Andy Shevchenko

Simple bitmap operations are safe against in-place modifications.
Due to above we may get rid of temporary variables in some cases.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---

Andrew, it can be folded into "gpio: pca953x: Convert to use bitmap API"

 drivers/gpio/gpio-pca953x.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
index f80ed5a43614..b9e326dfed23 100644
--- a/drivers/gpio/gpio-pca953x.c
+++ b/drivers/gpio/gpio-pca953x.c
@@ -468,7 +468,6 @@ static void pca953x_gpio_set_multiple(struct gpio_chip *gc,
 {
 	struct pca953x_chip *chip = gpiochip_get_data(gc);
 	DECLARE_BITMAP(reg_val, MAX_LINE);
-	DECLARE_BITMAP(new_val, MAX_LINE);
 	int ret;
 
 	mutex_lock(&chip->i2c_lock);
@@ -476,9 +475,9 @@ static void pca953x_gpio_set_multiple(struct gpio_chip *gc,
 	if (ret)
 		goto exit;
 
-	bitmap_replace(new_val, reg_val, bits, mask, gc->ngpio);
+	bitmap_replace(reg_val, reg_val, bits, mask, gc->ngpio);
 
-	pca953x_write_regs(chip, chip->regs->output, new_val);
+	pca953x_write_regs(chip, chip->regs->output, reg_val);
 exit:
 	mutex_unlock(&chip->i2c_lock);
 }
@@ -605,7 +604,6 @@ static void pca953x_irq_bus_sync_unlock(struct irq_data *d)
 	struct pca953x_chip *chip = gpiochip_get_data(gc);
 	DECLARE_BITMAP(irq_mask, MAX_LINE);
 	DECLARE_BITMAP(reg_direction, MAX_LINE);
-	DECLARE_BITMAP(new_irqs, MAX_LINE);
 	int level;
 
 	pca953x_read_regs(chip, chip->regs->direction, reg_direction);
@@ -620,8 +618,8 @@ static void pca953x_irq_bus_sync_unlock(struct irq_data *d)
 		pca953x_write_regs(chip, PCAL953X_INT_MASK, irq_mask);
 	}
 
-	bitmap_or(new_irqs, chip->irq_trig_fall, chip->irq_trig_raise, gc->ngpio);
-	bitmap_and(irq_mask, new_irqs, reg_direction, gc->ngpio);
+	bitmap_or(irq_mask, chip->irq_trig_fall, chip->irq_trig_raise, gc->ngpio);
+	bitmap_and(irq_mask, irq_mask, reg_direction, gc->ngpio);
 
 	/* Look for any newly setup interrupt */
 	for_each_set_bit(level, irq_mask, gc->ngpio)
-- 
2.23.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2019-10-23 15:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-10-23 15:30 [PATCH v1] gpio: pca953x: Reduce stack usage in couple of functions Andy Shevchenko

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).