fsi: master-gpio: Add locking during break and link enable

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 <[email protected]>
Reviewed-by: Joel Stanley <[email protected]>
Reviewed-by: Christopher Bostic <[email protected]>
Signed-off-by: Joel Stanley <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
This commit is contained in:
Jeremy Kerr 2018-02-12 15:45:41 +10:30 • committed by Greg Kroah-Hartman
commit 29d9b92711

View file

@ -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;
}