Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1668935
| From | Jeremy Kerr <jk@ozlabs.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 2/3] fsi/master-gpio: Add locking around gpio operations during break & link enable |
| Date | 2017-06-19 11:30 +0200 |
| Message-ID | <tU1aq-ON-21@gated-at.bofh.it> (permalink) |
| References | <tU1ap-ON-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Currently, we perform GPIO accesses in fsi_master_gpio_break and
fsi_master_link_enable, without holding cmd_lock. This change adds the
appropriate locking.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Reviewed-by: Joel Stanley <joel@jms.id.au>
Reviewed-by: Christopher Bostic <clbostic@linux.vnet.ibm.com>
---
drivers/fsi/fsi-master-gpio.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/fsi/fsi-master-gpio.c b/drivers/fsi/fsi-master-gpio.c
index ae26187..a6d602e 100644
--- a/drivers/fsi/fsi-master-gpio.c
+++ b/drivers/fsi/fsi-master-gpio.c
@@ -461,12 +461,14 @@ static int fsi_master_gpio_term(struct fsi_master *_master,
static int fsi_master_gpio_break(struct fsi_master *_master, int link)
{
struct fsi_master_gpio *master = to_fsi_master_gpio(_master);
+ unsigned long flags;
if (link != 0)
return -ENODEV;
trace_fsi_master_gpio_break(master);
+ spin_lock_irqsave(&master->cmd_lock, flags);
set_sda_output(master, 1);
sda_out(master, 1);
clock_toggle(master, FSI_PRE_BREAK_CLOCKS);
@@ -475,6 +477,7 @@ static int fsi_master_gpio_break(struct fsi_master *_master, int link)
echo_delay(master);
sda_out(master, 1);
clock_toggle(master, FSI_POST_BREAK_CLOCKS);
+ spin_unlock_irqrestore(&master->cmd_lock, flags);
/* Wait for logic reset to take effect */
udelay(200);
@@ -497,10 +500,14 @@ static void fsi_master_gpio_init(struct fsi_master_gpio *master)
static int fsi_master_gpio_link_enable(struct fsi_master *_master, int link)
{
struct fsi_master_gpio *master = to_fsi_master_gpio(_master);
+ unsigned long flags;
if (link != 0)
return -ENODEV;
+
+ spin_lock_irqsave(&master->cmd_lock, flags);
gpiod_set_value(master->gpio_enable, 1);
+ spin_unlock_irqrestore(&master->cmd_lock, flags);
return 0;
}
--
2.7.4
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 0/3] Add 'external mode' for GPIO-based FSI master Jeremy Kerr <jk@ozlabs.org> - 2017-06-19 11:30 +0200 [PATCH 2/3] fsi/master-gpio: Add locking around gpio operations during break & link enable Jeremy Kerr <jk@ozlabs.org> - 2017-06-19 11:30 +0200 [PATCH 3/3] fsi/master-gpio: Add external mode Jeremy Kerr <jk@ozlabs.org> - 2017-06-19 11:30 +0200
csiph-web