* [PATCH 01/05] sh: pfc: Add gpio_read_bit() for data register access
@ 2011-12-13 16:00 Magnus Damm
0 siblings, 0 replies; only message in thread
From: Magnus Damm @ 2011-12-13 16:00 UTC (permalink / raw)
To: linux-sh
From: Magnus Damm <damm@opensource.se>
Introduce gpio_read_bit() for data register read access
and modify sh_gpio_get_value() to make use of the new
function instead of gpio_read_reg(). The purpose of
this change is to update the code to only use the
gpio_read_reg() function for config register access.
Signed-off-by: Magnus Damm <damm@opensource.se>
---
drivers/sh/pfc.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
--- 0013/drivers/sh/pfc.c
+++ work/drivers/sh/pfc.c 2011-12-12 18:33:48.000000000 +0900
@@ -135,6 +135,19 @@ static void gpio_write_raw_reg(void __io
BUG();
}
+static int gpio_read_bit(struct pinmux_data_reg *dr,
+ unsigned long in_pos)
+{
+ unsigned long pos;
+
+ pos = dr->reg_width - (in_pos + 1);
+
+ pr_debug("read_bit: addr = %lx, pos = %ld, "
+ "r_width = %ld\n", dr->reg, pos, dr->reg_width);
+
+ return (gpio_read_raw_reg(dr->mapped_reg, dr->reg_width) >> pos) & 1;
+}
+
static void gpio_write_bit(struct pinmux_data_reg *dr,
unsigned long in_pos, unsigned long value)
{
@@ -644,7 +657,7 @@ static int sh_gpio_get_value(struct pinm
if (!gpioc || get_data_reg(gpioc, gpio, &dr, &bit) != 0)
return -EINVAL;
- return gpio_read_reg(dr->mapped_reg, dr->reg_width, 1, bit, dr->reg);
+ return gpio_read_bit(dr, bit);
}
static int sh_gpio_get(struct gpio_chip *chip, unsigned offset)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2011-12-13 16:00 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-13 16:00 [PATCH 01/05] sh: pfc: Add gpio_read_bit() for data register access Magnus Damm
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).