Discussion:
[ORLinux] [PATCH 0/3] jbtrivial fixes
Stefan Kristiansson
2013-08-19 02:59:34 UTC
Permalink
This series contains a couple of compile fixes, and a bug fix related to
the data direction register.

Stefan Kristiansson (3):
jbtrivial: remove __devinit
jbtrivial: include module.h
jbtrivial: fix data direction inversed logic bug

drivers/gpio/jbtrivial.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
--
1.8.1.2
Stefan Kristiansson
2013-08-19 02:59:35 UTC
Permalink
This is needed by the MODULE_ macros used in this driver

Signed-off-by: Stefan Kristiansson <stefan.kristiansson at saunalahti.fi>
---
drivers/gpio/jbtrivial.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/gpio/jbtrivial.c b/drivers/gpio/jbtrivial.c
index a6d592b..fd81146 100644
--- a/drivers/gpio/jbtrivial.c
+++ b/drivers/gpio/jbtrivial.c
@@ -23,6 +23,7 @@
#include <linux/io.h>
#include <linux/gpio.h>
#include <linux/slab.h>
+#include <linux/module.h>

struct jbgpio_instance {
struct of_mm_gpio_chip mmchip;
--
1.8.1.2
Stefan Kristiansson
2013-08-19 02:59:36 UTC
Permalink
Signed-off-by: Stefan Kristiansson <stefan.kristiansson at saunalahti.fi>
---
drivers/gpio/jbtrivial.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/jbtrivial.c b/drivers/gpio/jbtrivial.c
index dd81d62..a6d592b 100644
--- a/drivers/gpio/jbtrivial.c
+++ b/drivers/gpio/jbtrivial.c
@@ -186,7 +186,7 @@ static void jbgpio_save_regs(struct of_mm_gpio_chip *mm_gc)
* driver data structure. It returns 0, if the driver is bound to the GPIO
* device, or a negative value if there is an error.
*/
-static int __devinit jbgpio_of_probe(struct device_node *np)
+static int jbgpio_of_probe(struct device_node *np)
{
struct jbgpio_instance *chip;
int status = 0;
@@ -251,7 +251,7 @@ static int __devinit jbgpio_of_probe(struct device_node *np)
return 0;
}

-static struct of_device_id jbgpio_of_match[] __devinitdata = {
+static struct of_device_id jbgpio_of_match[] = {
{ .compatible = "opencores,jbtrivial" },
{ /* end of list */ },
};
--
1.8.1.2
Stefan Kristiansson
2013-08-19 02:59:37 UTC
Permalink
The data direction logic was inversed, the correct logic should be:
0 = input, 1 = output

Signed-off-by: Stefan Kristiansson <stefan.kristiansson at saunalahti.fi>
---
drivers/gpio/jbtrivial.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpio/jbtrivial.c b/drivers/gpio/jbtrivial.c
index fd81146..336c270 100644
--- a/drivers/gpio/jbtrivial.c
+++ b/drivers/gpio/jbtrivial.c
@@ -114,8 +114,8 @@ static int jbgpio_dir_in(struct gpio_chip *gc, unsigned int gpio)

spin_lock_irqsave(&chip->gpio_lock, flags);

- /* Set the GPIO bit in shadow register and set direction as input */
- chip->gpio_dir[bank] |= (1 << g);
+ /* Clear the GPIO bit in shadow register and set direction as input */
+ chip->gpio_dir[bank] &= ~(1 << g);
iowrite8(chip->gpio_dir[bank], mm_gc->regs + chip->tri_offset + bank);

spin_unlock_irqrestore(&chip->gpio_lock, flags);
@@ -154,8 +154,8 @@ static int jbgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
chip->gpio_state[bank] &= ~(1 << g);
iowrite8(chip->gpio_state[bank], mm_gc->regs + chip->data_offset + bank);

- /* Clear the GPIO bit in shadow register and set direction as output */
- chip->gpio_dir[bank] &= (~(1 << g));
+ /* Set the GPIO bit in shadow register and set direction as output */
+ chip->gpio_dir[bank] |= (1 << g);
iowrite8(chip->gpio_dir[bank], mm_gc->regs + chip->tri_offset + bank);

spin_unlock_irqrestore(&chip->gpio_lock, flags);
@@ -217,7 +217,7 @@ static int jbgpio_of_probe(struct device_node *np)
*/
/* Update GPIO direction shadow register with default value */
for (i=0; i<3; i++)
- chip->gpio_dir[i] = 0xFF; /* By default, all pins are inputs */
+ chip->gpio_dir[i] = 0x00; /* By default, all pins are inputs */
/* tree_info = of_get_property(np, "xlnx,tri-default", NULL);
if (tree_info)
chip->gpio_dir = *tree_info;
--
1.8.1.2
Stefan Kristiansson
2013-08-19 02:59:38 UTC
Permalink
This is needed by the MODULE_ macros used in this driver

Signed-off-by: Stefan Kristiansson <stefan.kristiansson at saunalahti.fi>
---
drivers/gpio/jbtrivial.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/gpio/jbtrivial.c b/drivers/gpio/jbtrivial.c
index a6d592b..fd81146 100644
--- a/drivers/gpio/jbtrivial.c
+++ b/drivers/gpio/jbtrivial.c
@@ -23,6 +23,7 @@
#include <linux/io.h>
#include <linux/gpio.h>
#include <linux/slab.h>
+#include <linux/module.h>

struct jbgpio_instance {
struct of_mm_gpio_chip mmchip;
--
1.8.1.2
Stefan Kristiansson
2013-08-19 02:59:39 UTC
Permalink
The data direction logic was inversed, the correct logic should be:
0 = input, 1 = output

Signed-off-by: Stefan Kristiansson <stefan.kristiansson at saunalahti.fi>
---
drivers/gpio/jbtrivial.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpio/jbtrivial.c b/drivers/gpio/jbtrivial.c
index fd81146..336c270 100644
--- a/drivers/gpio/jbtrivial.c
+++ b/drivers/gpio/jbtrivial.c
@@ -114,8 +114,8 @@ static int jbgpio_dir_in(struct gpio_chip *gc, unsigned int gpio)

spin_lock_irqsave(&chip->gpio_lock, flags);

- /* Set the GPIO bit in shadow register and set direction as input */
- chip->gpio_dir[bank] |= (1 << g);
+ /* Clear the GPIO bit in shadow register and set direction as input */
+ chip->gpio_dir[bank] &= ~(1 << g);
iowrite8(chip->gpio_dir[bank], mm_gc->regs + chip->tri_offset + bank);

spin_unlock_irqrestore(&chip->gpio_lock, flags);
@@ -154,8 +154,8 @@ static int jbgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
chip->gpio_state[bank] &= ~(1 << g);
iowrite8(chip->gpio_state[bank], mm_gc->regs + chip->data_offset + bank);

- /* Clear the GPIO bit in shadow register and set direction as output */
- chip->gpio_dir[bank] &= (~(1 << g));
+ /* Set the GPIO bit in shadow register and set direction as output */
+ chip->gpio_dir[bank] |= (1 << g);
iowrite8(chip->gpio_dir[bank], mm_gc->regs + chip->tri_offset + bank);

spin_unlock_irqrestore(&chip->gpio_lock, flags);
@@ -217,7 +217,7 @@ static int jbgpio_of_probe(struct device_node *np)
*/
/* Update GPIO direction shadow register with default value */
for (i=0; i<3; i++)
- chip->gpio_dir[i] = 0xFF; /* By default, all pins are inputs */
+ chip->gpio_dir[i] = 0x00; /* By default, all pins are inputs */
/* tree_info = of_get_property(np, "xlnx,tri-default", NULL);
if (tree_info)
chip->gpio_dir = *tree_info;
--
1.8.1.2
Loading...