public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: olpc_dcon: olpc_dcon_xo_1.c: Switch to the gpio descriptor interface
@ 2018-10-28  4:39 Nishad Kamdar
  2018-10-28  6:58 ` kbuild test robot
  0 siblings, 1 reply; 2+ messages in thread
From: Nishad Kamdar @ 2018-10-28  4:39 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jens Frederich, Daniel Drake, Jon Nettleton, devel, linux-kernel

Use the gpiod interface instead of the deprecated old non-descriptor
interface in olpc_dcon_xo_1.c.

Signed-off-by: Nishad Kamdar <nishadkamdar@gmail.com>
---
 drivers/staging/olpc_dcon/olpc_dcon.h      | 12 ++++
 drivers/staging/olpc_dcon/olpc_dcon_xo_1.c | 74 ++++++++++------------
 2 files changed, 44 insertions(+), 42 deletions(-)

diff --git a/drivers/staging/olpc_dcon/olpc_dcon.h b/drivers/staging/olpc_dcon/olpc_dcon.h
index c987aaf894e7..6590d251eb6e 100644
--- a/drivers/staging/olpc_dcon/olpc_dcon.h
+++ b/drivers/staging/olpc_dcon/olpc_dcon.h
@@ -57,6 +57,18 @@
 /* Interrupt */
 #define DCON_IRQ                6
 
+struct dcon_gpio {
+	struct gpio_desc **ptr;
+	const char *name;
+	unsigned long flags;
+};
+
+struct gpio_desc *dcon_stat0;
+struct gpio_desc *dcon_stat1;
+struct gpio_desc *dcon_irq;
+struct gpio_desc *dcon_load;
+struct gpio_desc *dcon_blank;
+
 struct dcon_priv {
 	struct i2c_client *client;
 	struct fb_info *fbinfo;
diff --git a/drivers/staging/olpc_dcon/olpc_dcon_xo_1.c b/drivers/staging/olpc_dcon/olpc_dcon_xo_1.c
index ff145d493e1b..83607efcb21f 100644
--- a/drivers/staging/olpc_dcon/olpc_dcon_xo_1.c
+++ b/drivers/staging/olpc_dcon/olpc_dcon_xo_1.c
@@ -11,7 +11,7 @@
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
 #include <linux/cs5535.h>
-#include <linux/gpio.h>
+#include <linux/gpio/consumer.h>
 #include <linux/delay.h>
 #include <asm/olpc.h>
 
@@ -20,26 +20,29 @@
 static int dcon_init_xo_1(struct dcon_priv *dcon)
 {
 	unsigned char lob;
-
-	if (gpio_request(OLPC_GPIO_DCON_STAT0, "OLPC-DCON")) {
-		pr_err("failed to request STAT0 GPIO\n");
-		return -EIO;
-	}
-	if (gpio_request(OLPC_GPIO_DCON_STAT1, "OLPC-DCON")) {
-		pr_err("failed to request STAT1 GPIO\n");
-		goto err_gp_stat1;
-	}
-	if (gpio_request(OLPC_GPIO_DCON_IRQ, "OLPC-DCON")) {
-		pr_err("failed to request IRQ GPIO\n");
-		goto err_gp_irq;
-	}
-	if (gpio_request(OLPC_GPIO_DCON_LOAD, "OLPC-DCON")) {
-		pr_err("failed to request LOAD GPIO\n");
-		goto err_gp_load;
-	}
-	if (gpio_request(OLPC_GPIO_DCON_BLANK, "OLPC-DCON")) {
-		pr_err("failed to request BLANK GPIO\n");
-		goto err_gp_blank;
+	int ret, i;
+	struct dcon_gpio *pin;
+	unsigned long flags = GPIOD_ASIS;
+
+	struct dcon_gpio gpios[] = {
+		{ .ptr = &dcon_stat0, .name = "dcon_stat0", .flags = flags },
+		{ .ptr = &dcon_stat1, .name = "dcon_stat1", .flags = flags },
+		{ .ptr = &dcon_irq, .name = "dcon_irq", .flags = flags },
+		{ .ptr = &dcon_load, .name = "dcon_load", .flags = flags },
+		{ .ptr = &dcon_blank, .name = "dcon_blank", .flags = flags },
+	};
+
+	for (i = 0; i < ARRAY_SIZE(gpios); i++) {
+		pin = &gpios[i];
+		*pin->ptr = devm_gpiod_get(&dcon->bl_dev->dev, pin->name,
+					   pin->flags);
+		if (IS_ERR(*pin->ptr)) {
+			ret = PTR_ERR(*pin->ptr);
+			dev_err(&dcon->bl_dev->dev,
+				"failed to request %s GPIO: %d\n",
+				pin->name, ret);
+			return ret;
+		}
 	}
 
 	/* Turn off the event enable for GPIO7 just to be safe */
@@ -61,12 +64,11 @@ static int dcon_init_xo_1(struct dcon_priv *dcon)
 	dcon->pending_src = dcon->curr_src;
 
 	/* Set the directions for the GPIO pins */
-	gpio_direction_input(OLPC_GPIO_DCON_STAT0);
-	gpio_direction_input(OLPC_GPIO_DCON_STAT1);
-	gpio_direction_input(OLPC_GPIO_DCON_IRQ);
-	gpio_direction_input(OLPC_GPIO_DCON_BLANK);
-	gpio_direction_output(OLPC_GPIO_DCON_LOAD,
-			      dcon->curr_src == DCON_SOURCE_CPU);
+	gpiod_direction_input(dcon_stat0);
+	gpiod_direction_input(dcon_stat1);
+	gpiod_direction_input(dcon_irq);
+	gpiod_direction_input(dcon_blank);
+	gpiod_direction_output(dcon_load, dcon->curr_src == DCON_SOURCE_CPU);
 
 	/* Set up the interrupt mappings */
 
@@ -125,18 +127,6 @@ static int dcon_init_xo_1(struct dcon_priv *dcon)
 	cs5535_gpio_set(OLPC_GPIO_DCON_BLANK, GPIO_EVENTS_ENABLE);
 
 	return 0;
-
-err_req_irq:
-	gpio_free(OLPC_GPIO_DCON_BLANK);
-err_gp_blank:
-	gpio_free(OLPC_GPIO_DCON_LOAD);
-err_gp_load:
-	gpio_free(OLPC_GPIO_DCON_IRQ);
-err_gp_irq:
-	gpio_free(OLPC_GPIO_DCON_STAT1);
-err_gp_stat1:
-	gpio_free(OLPC_GPIO_DCON_STAT0);
-	return -EIO;
 }
 
 static void dcon_wiggle_xo_1(void)
@@ -180,13 +170,13 @@ static void dcon_wiggle_xo_1(void)
 
 static void dcon_set_dconload_1(int val)
 {
-	gpio_set_value(OLPC_GPIO_DCON_LOAD, val);
+	gpiod_set_value(dcon_load, val);
 }
 
 static int dcon_read_status_xo_1(u8 *status)
 {
-	*status = gpio_get_value(OLPC_GPIO_DCON_STAT0);
-	*status |= gpio_get_value(OLPC_GPIO_DCON_STAT1) << 1;
+	*status = gpiod_get_value(dcon_stat0);
+	*status |= gpiod_get_value(dcon_stat1) << 1;
 
 	/* Clear the negative edge status for GPIO7 */
 	cs5535_gpio_set(OLPC_GPIO_DCON_IRQ, GPIO_NEGATIVE_EDGE_STS);
-- 
2.17.1


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

* Re: [PATCH] staging: olpc_dcon: olpc_dcon_xo_1.c: Switch to the gpio descriptor interface
  2018-10-28  4:39 [PATCH] staging: olpc_dcon: olpc_dcon_xo_1.c: Switch to the gpio descriptor interface Nishad Kamdar
@ 2018-10-28  6:58 ` kbuild test robot
  0 siblings, 0 replies; 2+ messages in thread
From: kbuild test robot @ 2018-10-28  6:58 UTC (permalink / raw)
  To: Nishad Kamdar
  Cc: kbuild-all, Greg Kroah-Hartman, devel, linux-kernel,
	Jon Nettleton, Daniel Drake, Jens Frederich

[-- Attachment #1: Type: text/plain, Size: 6163 bytes --]

Hi Nishad,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on staging/staging-testing]
[also build test ERROR on v4.19 next-20181019]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Nishad-Kamdar/staging-olpc_dcon-olpc_dcon_xo_1-c-Switch-to-the-gpio-descriptor-interface/20181028-124517
config: i386-allmodconfig (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All errors (new ones prefixed by >>):

   drivers/staging/olpc_dcon/olpc_dcon_xo_1.c: In function 'dcon_init_xo_1':
>> drivers/staging/olpc_dcon/olpc_dcon_xo_1.c:37:43: error: dereferencing pointer to incomplete type 'struct backlight_device'
      *pin->ptr = devm_gpiod_get(&dcon->bl_dev->dev, pin->name,
                                              ^~
>> drivers/staging/olpc_dcon/olpc_dcon_xo_1.c:41:4: error: implicit declaration of function 'dev_err'; did you mean 'pr_err'? [-Werror=implicit-function-declaration]
       dev_err(&dcon->bl_dev->dev,
       ^~~~~~~
       pr_err
>> drivers/staging/olpc_dcon/olpc_dcon_xo_1.c:89:3: error: label 'err_req_irq' used but not defined
      goto err_req_irq;
      ^~~~
   cc1: some warnings being treated as errors

vim +37 drivers/staging/olpc_dcon/olpc_dcon_xo_1.c

    19	
    20	static int dcon_init_xo_1(struct dcon_priv *dcon)
    21	{
    22		unsigned char lob;
    23		int ret, i;
    24		struct dcon_gpio *pin;
    25		unsigned long flags = GPIOD_ASIS;
    26	
    27		struct dcon_gpio gpios[] = {
    28			{ .ptr = &dcon_stat0, .name = "dcon_stat0", .flags = flags },
    29			{ .ptr = &dcon_stat1, .name = "dcon_stat1", .flags = flags },
    30			{ .ptr = &dcon_irq, .name = "dcon_irq", .flags = flags },
    31			{ .ptr = &dcon_load, .name = "dcon_load", .flags = flags },
    32			{ .ptr = &dcon_blank, .name = "dcon_blank", .flags = flags },
    33		};
    34	
    35		for (i = 0; i < ARRAY_SIZE(gpios); i++) {
    36			pin = &gpios[i];
  > 37			*pin->ptr = devm_gpiod_get(&dcon->bl_dev->dev, pin->name,
    38						   pin->flags);
    39			if (IS_ERR(*pin->ptr)) {
    40				ret = PTR_ERR(*pin->ptr);
  > 41				dev_err(&dcon->bl_dev->dev,
    42					"failed to request %s GPIO: %d\n",
    43					pin->name, ret);
    44				return ret;
    45			}
    46		}
    47	
    48		/* Turn off the event enable for GPIO7 just to be safe */
    49		cs5535_gpio_clear(OLPC_GPIO_DCON_IRQ, GPIO_EVENTS_ENABLE);
    50	
    51		/*
    52		 * Determine the current state by reading the GPIO bit; earlier
    53		 * stages of the boot process have established the state.
    54		 *
    55		 * Note that we read GPIO_OUTPUT_VAL rather than GPIO_READ_BACK here;
    56		 * this is because OFW will disable input for the pin and set a value..
    57		 * READ_BACK will only contain a valid value if input is enabled and
    58		 * then a value is set.  So, future readings of the pin can use
    59		 * READ_BACK, but the first one cannot.  Awesome, huh?
    60		 */
    61		dcon->curr_src = cs5535_gpio_isset(OLPC_GPIO_DCON_LOAD, GPIO_OUTPUT_VAL)
    62			? DCON_SOURCE_CPU
    63			: DCON_SOURCE_DCON;
    64		dcon->pending_src = dcon->curr_src;
    65	
    66		/* Set the directions for the GPIO pins */
    67		gpiod_direction_input(dcon_stat0);
    68		gpiod_direction_input(dcon_stat1);
    69		gpiod_direction_input(dcon_irq);
    70		gpiod_direction_input(dcon_blank);
    71		gpiod_direction_output(dcon_load, dcon->curr_src == DCON_SOURCE_CPU);
    72	
    73		/* Set up the interrupt mappings */
    74	
    75		/* Set the IRQ to pair 2 */
    76		cs5535_gpio_setup_event(OLPC_GPIO_DCON_IRQ, 2, 0);
    77	
    78		/* Enable group 2 to trigger the DCON interrupt */
    79		cs5535_gpio_set_irq(2, DCON_IRQ);
    80	
    81		/* Select edge level for interrupt (in PIC) */
    82		lob = inb(0x4d0);
    83		lob &= ~(1 << DCON_IRQ);
    84		outb(lob, 0x4d0);
    85	
    86		/* Register the interrupt handler */
    87		if (request_irq(DCON_IRQ, &dcon_interrupt, 0, "DCON", dcon)) {
    88			pr_err("failed to request DCON's irq\n");
  > 89			goto err_req_irq;
    90		}
    91	
    92		/* Clear INV_EN for GPIO7 (DCONIRQ) */
    93		cs5535_gpio_clear(OLPC_GPIO_DCON_IRQ, GPIO_INPUT_INVERT);
    94	
    95		/* Enable filter for GPIO12 (DCONBLANK) */
    96		cs5535_gpio_set(OLPC_GPIO_DCON_BLANK, GPIO_INPUT_FILTER);
    97	
    98		/* Disable filter for GPIO7 */
    99		cs5535_gpio_clear(OLPC_GPIO_DCON_IRQ, GPIO_INPUT_FILTER);
   100	
   101		/* Disable event counter for GPIO7 (DCONIRQ) and GPIO12 (DCONBLANK) */
   102		cs5535_gpio_clear(OLPC_GPIO_DCON_IRQ, GPIO_INPUT_EVENT_COUNT);
   103		cs5535_gpio_clear(OLPC_GPIO_DCON_BLANK, GPIO_INPUT_EVENT_COUNT);
   104	
   105		/* Add GPIO12 to the Filter Event Pair #7 */
   106		cs5535_gpio_set(OLPC_GPIO_DCON_BLANK, GPIO_FE7_SEL);
   107	
   108		/* Turn off negative Edge Enable for GPIO12 */
   109		cs5535_gpio_clear(OLPC_GPIO_DCON_BLANK, GPIO_NEGATIVE_EDGE_EN);
   110	
   111		/* Enable negative Edge Enable for GPIO7 */
   112		cs5535_gpio_set(OLPC_GPIO_DCON_IRQ, GPIO_NEGATIVE_EDGE_EN);
   113	
   114		/* Zero the filter amount for Filter Event Pair #7 */
   115		cs5535_gpio_set(0, GPIO_FLTR7_AMOUNT);
   116	
   117		/* Clear the negative edge status for GPIO7 and GPIO12 */
   118		cs5535_gpio_set(OLPC_GPIO_DCON_IRQ, GPIO_NEGATIVE_EDGE_STS);
   119		cs5535_gpio_set(OLPC_GPIO_DCON_BLANK, GPIO_NEGATIVE_EDGE_STS);
   120	
   121		/* FIXME:  Clear the positive status as well, just to be sure */
   122		cs5535_gpio_set(OLPC_GPIO_DCON_IRQ, GPIO_POSITIVE_EDGE_STS);
   123		cs5535_gpio_set(OLPC_GPIO_DCON_BLANK, GPIO_POSITIVE_EDGE_STS);
   124	
   125		/* Enable events for GPIO7 (DCONIRQ) and GPIO12 (DCONBLANK) */
   126		cs5535_gpio_set(OLPC_GPIO_DCON_IRQ, GPIO_EVENTS_ENABLE);
   127		cs5535_gpio_set(OLPC_GPIO_DCON_BLANK, GPIO_EVENTS_ENABLE);
   128	
   129		return 0;
   130	}
   131	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 65257 bytes --]

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

end of thread, other threads:[~2018-10-28  7:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-28  4:39 [PATCH] staging: olpc_dcon: olpc_dcon_xo_1.c: Switch to the gpio descriptor interface Nishad Kamdar
2018-10-28  6:58 ` kbuild test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox