diff mbox

[V8,3/8] MIPS: Cleanup Loongson-2F's gpio driver

Message ID 1426213595-28454-1-git-send-email-chenhc@lemote.com
State New
Headers show

Commit Message

Huacai Chen March 13, 2015, 2:26 a.m. UTC
This cleanup is prepare to move the driver to drivers/gpio. Custom
definitions of gpio_get_value()/gpio_set_value() are dropped.

Signed-off-by: Huacai Chen <chenhc@lemote.com>
---
 arch/mips/include/asm/mach-loongson/gpio.h |   15 +++---
 arch/mips/loongson/common/gpio.c           |   80 ++++++++--------------------
 2 files changed, 31 insertions(+), 64 deletions(-)

Comments

Alexandre Courbot March 23, 2015, 6:29 a.m. UTC | #1
On Fri, Mar 13, 2015 at 11:26 AM, Huacai Chen <chenhc@lemote.com> wrote:
> This cleanup is prepare to move the driver to drivers/gpio. Custom
> definitions of gpio_get_value()/gpio_set_value() are dropped.

I suppose this is starting to look ok, at least patches 3, 4 and 5
which are of interest for GPIO. I wonder which tree they should be
merged through, MIPS or GPIO? Not seeing the rest of the series, I
cannot make a suggestion.
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Huacai Chen March 25, 2015, 1:15 a.m. UTC | #2
I think these three patches can go to GPIO tree, because it has no
relationship with others in this series.

Huacai

On Mon, Mar 23, 2015 at 2:29 PM, Alexandre Courbot <gnurou@gmail.com> wrote:
> On Fri, Mar 13, 2015 at 11:26 AM, Huacai Chen <chenhc@lemote.com> wrote:
>> This cleanup is prepare to move the driver to drivers/gpio. Custom
>> definitions of gpio_get_value()/gpio_set_value() are dropped.
>
> I suppose this is starting to look ok, at least patches 3, 4 and 5
> which are of interest for GPIO. I wonder which tree they should be
> merged through, MIPS or GPIO? Not seeing the rest of the series, I
> cannot make a suggestion.
>
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Alexandre Courbot March 25, 2015, 2:19 a.m. UTC | #3
On Wed, Mar 25, 2015 at 10:15 AM, Huacai Chen <chenhc@lemote.com> wrote:
> I think these three patches can go to GPIO tree, because it has no
> relationship with others in this series.

In that case we would need a ack from the MIPS maintainers to move the
code into drivers/gpio/.

>
> Huacai
>
> On Mon, Mar 23, 2015 at 2:29 PM, Alexandre Courbot <gnurou@gmail.com> wrote:
>> On Fri, Mar 13, 2015 at 11:26 AM, Huacai Chen <chenhc@lemote.com> wrote:
>>> This cleanup is prepare to move the driver to drivers/gpio. Custom
>>> definitions of gpio_get_value()/gpio_set_value() are dropped.
>>
>> I suppose this is starting to look ok, at least patches 3, 4 and 5
>> which are of interest for GPIO. I wonder which tree they should be
>> merged through, MIPS or GPIO? Not seeing the rest of the series, I
>> cannot make a suggestion.
>>
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Huacai Chen March 25, 2015, 3:12 a.m. UTC | #4
It seems Ralf is very very busy, I have some bugfixing patches queued
for a long time and no response. Maybe Steven can give a ACK for this?

Huacai

On Wed, Mar 25, 2015 at 10:19 AM, Alexandre Courbot <gnurou@gmail.com> wrote:
> On Wed, Mar 25, 2015 at 10:15 AM, Huacai Chen <chenhc@lemote.com> wrote:
>> I think these three patches can go to GPIO tree, because it has no
>> relationship with others in this series.
>
> In that case we would need a ack from the MIPS maintainers to move the
> code into drivers/gpio/.
>
>>
>> Huacai
>>
>> On Mon, Mar 23, 2015 at 2:29 PM, Alexandre Courbot <gnurou@gmail.com> wrote:
>>> On Fri, Mar 13, 2015 at 11:26 AM, Huacai Chen <chenhc@lemote.com> wrote:
>>>> This cleanup is prepare to move the driver to drivers/gpio. Custom
>>>> definitions of gpio_get_value()/gpio_set_value() are dropped.
>>>
>>> I suppose this is starting to look ok, at least patches 3, 4 and 5
>>> which are of interest for GPIO. I wonder which tree they should be
>>> merged through, MIPS or GPIO? Not seeing the rest of the series, I
>>> cannot make a suggestion.
>>>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Ralf Baechle March 25, 2015, 6:09 p.m. UTC | #5
On Wed, Mar 25, 2015 at 11:19:01AM +0900, Alexandre Courbot wrote:

> On Wed, Mar 25, 2015 at 10:15 AM, Huacai Chen <chenhc@lemote.com> wrote:
> > I think these three patches can go to GPIO tree, because it has no
> > relationship with others in this series.
> 
> In that case we would need a ack from the MIPS maintainers to move the
> code into drivers/gpio/.

Yes, please.  For all three patches:

Acked-by: Ralf Baechle <ralf@linux-mips.org>

  Ralf
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Alexandre Courbot March 26, 2015, 2:12 a.m. UTC | #6
Thanks Ralf!

Huacai, since these 3 patches are standalone, would you mind
re-sending them in their own series to Linus Walleij, myself and the
linux-gpio list along with Ralf's ack? It will improve their
visibility and make it easier to merge them. I will give my ack/review
tag on this new series.

Thanks!

On Thu, Mar 26, 2015 at 3:09 AM, Ralf Baechle <ralf@linux-mips.org> wrote:
> On Wed, Mar 25, 2015 at 11:19:01AM +0900, Alexandre Courbot wrote:
>
>> On Wed, Mar 25, 2015 at 10:15 AM, Huacai Chen <chenhc@lemote.com> wrote:
>> > I think these three patches can go to GPIO tree, because it has no
>> > relationship with others in this series.
>>
>> In that case we would need a ack from the MIPS maintainers to move the
>> code into drivers/gpio/.
>
> Yes, please.  For all three patches:
>
> Acked-by: Ralf Baechle <ralf@linux-mips.org>
>
>   Ralf
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/mips/include/asm/mach-loongson/gpio.h b/arch/mips/include/asm/mach-loongson/gpio.h
index 211a7b7..b3b2169 100644
--- a/arch/mips/include/asm/mach-loongson/gpio.h
+++ b/arch/mips/include/asm/mach-loongson/gpio.h
@@ -1,8 +1,9 @@ 
 /*
- * STLS2F GPIO Support
+ * Loongson GPIO Support
  *
  * Copyright (c) 2008  Richard Liu, STMicroelectronics <richard.liu@st.com>
  * Copyright (c) 2008-2010  Arnaud Patard <apatard@mandriva.com>
+ * Copyright (c) 2014  Huacai Chen <chenhc@lemote.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -10,14 +11,14 @@ 
  * (at your option) any later version.
  */
 
-#ifndef __STLS2F_GPIO_H
-#define __STLS2F_GPIO_H
+#ifndef __LOONGSON_GPIO_H
+#define __LOONGSON_GPIO_H
 
 #include <asm-generic/gpio.h>
 
-extern void gpio_set_value(unsigned gpio, int value);
-extern int gpio_get_value(unsigned gpio);
-extern int gpio_cansleep(unsigned gpio);
+#define gpio_get_value __gpio_get_value
+#define gpio_set_value __gpio_set_value
+#define gpio_cansleep __gpio_cansleep
 
 /* The chip can do interrupt
  * but it has not been tested and doc not clear
@@ -32,4 +33,4 @@  static inline int irq_to_gpio(int gpio)
 	return -EINVAL;
 }
 
-#endif				/* __STLS2F_GPIO_H */
+#endif	/* __LOONGSON_GPIO_H */
diff --git a/arch/mips/loongson/common/gpio.c b/arch/mips/loongson/common/gpio.c
index 29dbaa2..b4e69e0 100644
--- a/arch/mips/loongson/common/gpio.c
+++ b/arch/mips/loongson/common/gpio.c
@@ -24,63 +24,11 @@ 
 
 static DEFINE_SPINLOCK(gpio_lock);
 
-int gpio_get_value(unsigned gpio)
-{
-	u32 val;
-	u32 mask;
-
-	if (gpio >= STLS2F_N_GPIO)
-		return __gpio_get_value(gpio);
-
-	mask = 1 << (gpio + STLS2F_GPIO_IN_OFFSET);
-	spin_lock(&gpio_lock);
-	val = LOONGSON_GPIODATA;
-	spin_unlock(&gpio_lock);
-
-	return (val & mask) != 0;
-}
-EXPORT_SYMBOL(gpio_get_value);
-
-void gpio_set_value(unsigned gpio, int state)
-{
-	u32 val;
-	u32 mask;
-
-	if (gpio >= STLS2F_N_GPIO) {
-		__gpio_set_value(gpio, state);
-		return ;
-	}
-
-	mask = 1 << gpio;
-
-	spin_lock(&gpio_lock);
-	val = LOONGSON_GPIODATA;
-	if (state)
-		val |= mask;
-	else
-		val &= (~mask);
-	LOONGSON_GPIODATA = val;
-	spin_unlock(&gpio_lock);
-}
-EXPORT_SYMBOL(gpio_set_value);
-
-int gpio_cansleep(unsigned gpio)
-{
-	if (gpio < STLS2F_N_GPIO)
-		return 0;
-	else
-		return __gpio_cansleep(gpio);
-}
-EXPORT_SYMBOL(gpio_cansleep);
-
 static int ls2f_gpio_direction_input(struct gpio_chip *chip, unsigned gpio)
 {
 	u32 temp;
 	u32 mask;
 
-	if (gpio >= STLS2F_N_GPIO)
-		return -EINVAL;
-
 	spin_lock(&gpio_lock);
 	mask = 1 << gpio;
 	temp = LOONGSON_GPIOIE;
@@ -97,9 +45,6 @@  static int ls2f_gpio_direction_output(struct gpio_chip *chip,
 	u32 temp;
 	u32 mask;
 
-	if (gpio >= STLS2F_N_GPIO)
-		return -EINVAL;
-
 	gpio_set_value(gpio, level);
 	spin_lock(&gpio_lock);
 	mask = 1 << gpio;
@@ -113,13 +58,33 @@  static int ls2f_gpio_direction_output(struct gpio_chip *chip,
 
 static int ls2f_gpio_get_value(struct gpio_chip *chip, unsigned gpio)
 {
-	return gpio_get_value(gpio);
+	u32 val;
+	u32 mask;
+
+	mask = 1 << (gpio + STLS2F_GPIO_IN_OFFSET);
+	spin_lock(&gpio_lock);
+	val = LOONGSON_GPIODATA;
+	spin_unlock(&gpio_lock);
+
+	return (val & mask) != 0;
 }
 
 static void ls2f_gpio_set_value(struct gpio_chip *chip,
 		unsigned gpio, int value)
 {
-	gpio_set_value(gpio, value);
+	u32 val;
+	u32 mask;
+
+	mask = 1 << gpio;
+
+	spin_lock(&gpio_lock);
+	val = LOONGSON_GPIODATA;
+	if (value)
+		val |= mask;
+	else
+		val &= (~mask);
+	LOONGSON_GPIODATA = val;
+	spin_unlock(&gpio_lock);
 }
 
 static struct gpio_chip ls2f_chip = {
@@ -130,6 +95,7 @@  static struct gpio_chip ls2f_chip = {
 	.set			= ls2f_gpio_set_value,
 	.base			= 0,
 	.ngpio			= STLS2F_N_GPIO,
+	.can_sleep		= false,
 };
 
 static int __init ls2f_gpio_setup(void)