lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 14 Nov 2007 09:02:40 +0800
From:	"eric miao" <eric.y.miao@...il.com>
To:	"David Brownell" <david-b@...bell.net>
Cc:	"Linux Kernel list" <linux-kernel@...r.kernel.org>,
	"Felipe Balbi" <felipebalbi@...rs.sourceforge.net>,
	"Bill Gatliff" <bgat@...lgatliff.com>,
	"Haavard Skinnemoen" <hskinnemoen@...el.com>,
	"Andrew Victor" <andrew@...people.com>,
	"Tony Lindgren" <tony@...mide.com>,
	"Jean Delvare" <khali@...ux-fr.org>,
	"Kevin Hilman" <khilman@...sta.com>,
	"Paul Mundt" <lethal@...ux-sh.org>,
	"Ben Dooks" <ben@...nity.fluff.org>
Subject: Re: [patch/rfc 1/4] GPIO implementation framework

so that requested will always be used, only *requested_str will be used
for DEBUG_FS tracking assistance

Subject: [PATCH 2/5] define gpio_chip.requested_str as a debugfs tracking string

---
 include/asm-generic/gpio.h |   11 ++---------
 lib/gpiolib.c              |   34 ++++++++++++++--------------------
 2 files changed, 16 insertions(+), 29 deletions(-)

diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
index d00a287..ba3e336 100644
--- a/include/asm-generic/gpio.h
+++ b/include/asm-generic/gpio.h
@@ -73,13 +73,10 @@ struct gpio_chip {

 	/* other fields are modified by the gpio library only */
 	DECLARE_BITMAP(is_out, ARCH_GPIOS_PER_CHIP);
+	DECLARE_BITMAP(requested, ARCH_GPIOS_PER_CHIP);

 #ifdef CONFIG_DEBUG_FS
-	/* fat bits */
-	const char		*requested[ARCH_GPIOS_PER_CHIP];
-#else
-	/* thin bits */
-	DECLARE_BITMAP(requested, ARCH_GPIOS_PER_CHIP);
+	const char		*requested_str[ARCH_GPIOS_PER_CHIP];
 #endif
 };

@@ -89,11 +86,7 @@ struct gpio_chip {
 static inline int
 gpiochip_is_requested(struct gpio_chip *chip, unsigned offset)
 {
-#ifdef CONFIG_DEBUG_FS
-	return chip->requested[offset] != NULL;
-#else
 	return test_bit(offset, chip->requested);
-#endif
 }

 /* add/remove chips */
diff --git a/lib/gpiolib.c b/lib/gpiolib.c
index c627efb..d52c7f1 100644
--- a/lib/gpiolib.c
+++ b/lib/gpiolib.c
@@ -48,12 +48,11 @@ static void gpio_ensure_requested(struct gpio_chip
*chip, unsigned offset)
 {
 	int		requested;

+	requested = test_and_set_bit(offset, chip->requested);
+
 #ifdef CONFIG_DEBUG_FS
-	requested = (int) chip->requested[offset];
 	if (!requested)
-		chip->requested[offset] = "(auto)";
-#else
-	requested = test_and_set_bit(offset, chip->requested);
+		chip->requested_str[offset] = "(auto)";
 #endif

 	if (!requested)
@@ -158,16 +157,13 @@ int gpio_request(unsigned gpio, const char *label)
 	 */

 	status = 0;
-#ifdef CONFIG_DEBUG_FS
-	if (!label)
-		label = "?";
-	if (chip->requested[gpio])
-		status = -EBUSY;
-	else
-		chip->requested[gpio] = label;
-#else
+
 	if (test_and_set_bit(gpio, chip->requested))
 		status = -EBUSY;
+
+#ifdef CONFIG_DEBUG_FS
+	if (status == 0)
+		chip->requested_str[gpio] = (label == NULL) ? "?" : label;
 #endif

 done:
@@ -190,14 +186,12 @@ void gpio_free(unsigned gpio)

 	gpio -= chip->base;

-#ifdef CONFIG_DEBUG_FS
-	if (chip->requested[gpio])
-		chip->requested[gpio] = NULL;
-	else
-		chip = NULL;
-#else
 	if (!test_and_clear_bit(gpio, chip->requested))
 		chip = NULL;
+
+#ifdef CONFIG_DEBUG_FS
+	if (chip != NULL)
+		chip->requested_str[gpio] = NULL;
 #endif
 	WARN_ON(extra_checks && chip == NULL);
 done:
@@ -400,14 +394,14 @@ static void gpiolib_dbg_show(struct seq_file *s,
struct gpio_chip *chip)
 		unsigned	gpio;
 		int		is_out;

-		if (!chip->requested[i])
+		if (!chip->requested_str[i])
 			continue;

 		gpio = chip->base + i;
 		is_out = test_bit(i, chip->is_out);

 		seq_printf(s, " gpio-%-3d (%-12s) %s %s",
-			gpio, chip->requested[i],
+			gpio, chip->requested_str[i],
 			is_out ? "out" : "in ",
 			chip->get
 				? (chip->get(chip, i) ? "hi" : "lo")
-- 
1.5.2.5.GIT
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists