From 00e6baae5519941731259503539389e45b8efde3 Mon Sep 17 00:00:00 2001 From: Russell King Date: Sat, 21 Jan 2012 18:21:50 +0000 Subject: [PATCH] --- yaml --- r: 286911 b: refs/heads/master c: c23bb602af24a635d0894aa7091e184385bf8a9f h: refs/heads/master i: 286909: 2131246e7902317a72fdb1091027239f9ddd7fa6 286907: 3dec0dbccd65c04542018711faeaa7440663cb48 286903: 50291bce0d95bb414933886ee00d3457f608f255 286895: 1cf0ecec2eb72334c7e8fe68d227aca4560fc174 286879: b5ea6f52299bcff7a78e18cd108f2b49f42c3388 286847: db1b22e2de903c41ece86166a0c73ae8bcbc5796 v: v3 --- [refs] | 2 +- trunk/drivers/mfd/ucb1x00-core.c | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/[refs] b/[refs] index 81b43dd2ba6e..6dc12128959c 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 2e95e51e184bd107380881502ea0f483c4500706 +refs/heads/master: c23bb602af24a635d0894aa7091e184385bf8a9f diff --git a/trunk/drivers/mfd/ucb1x00-core.c b/trunk/drivers/mfd/ucb1x00-core.c index 8ebda97981e1..febc90cdef7e 100644 --- a/trunk/drivers/mfd/ucb1x00-core.c +++ b/trunk/drivers/mfd/ucb1x00-core.c @@ -148,16 +148,22 @@ static int ucb1x00_gpio_direction_output(struct gpio_chip *chip, unsigned offset { struct ucb1x00 *ucb = container_of(chip, struct ucb1x00, gpio); unsigned long flags; + unsigned old, mask = 1 << offset; spin_lock_irqsave(&ucb->io_lock, flags); - ucb->io_dir |= (1 << offset); - ucb1x00_reg_write(ucb, UCB_IO_DIR, ucb->io_dir); - + old = ucb->io_out; if (value) - ucb->io_out |= 1 << offset; + ucb->io_out |= mask; else - ucb->io_out &= ~(1 << offset); - ucb1x00_reg_write(ucb, UCB_IO_DATA, ucb->io_out); + ucb->io_out &= ~mask; + + if (old != ucb->io_out) + ucb1x00_reg_write(ucb, UCB_IO_DATA, ucb->io_out); + + if (!(ucb->io_dir & mask)) { + ucb->io_dir |= mask; + ucb1x00_reg_write(ucb, UCB_IO_DIR, ucb->io_dir); + } spin_unlock_irqrestore(&ucb->io_lock, flags); return 0;