Thread (75 messages) 75 messages, 12 authors, 2018-10-01

Re: [PATCH v7 1/4] gpiolib: Pass bitmaps, not integer arrays, to get/set array

From: Matthew Wilcox <willy@infradead.org>
Date: 2018-09-03 04:31:57
Also in: linux-doc, linux-gpio, linux-i2c, linux-iio, linux-mmc, linux-serial, linuxppc-dev, lkml

quoted hunk ↗ jump to hunk
+++ b/drivers/auxdisplay/hd44780.c
@@ -62,17 +62,12 @@ static void hd44780_strobe_gpio(struct hd44780 *hd)
 /* write to an LCD panel register in 8 bit GPIO mode */
 static void hd44780_write_gpio8(struct hd44780 *hd, u8 val, unsigned int rs)
 {
-	int values[10];	/* for DATA[0-7], RS, RW */
-	unsigned int i, n;
-
-	for (i = 0; i < 8; i++)
-		values[PIN_DATA0 + i] = !!(val & BIT(i));
-	values[PIN_CTRL_RS] = rs;
-	n = 9;
-	if (hd->pins[PIN_CTRL_RW]) {
-		values[PIN_CTRL_RW] = 0;
-		n++;
-	}
+	DECLARE_BITMAP(values, 10); /* for DATA[0-7], RS, RW */
+	unsigned int n;
+
+	*values = val;
+	__assign_bit(8, values, rs);
+	n = hd->pins[PIN_CTRL_RW] ? 10 : 9;
Doesn't this assume little endian bitmaps?  Has anyone tested this on
big-endian machines?
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help