aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/can
diff options
context:
space:
mode:
authorWolfgang Zarre <lkdev@essax.com>2012-01-15 07:21:34 -0500
committerMarc Kleine-Budde <mkl@pengutronix.de>2012-02-02 18:25:06 -0500
commit2d5091e08c684912ed6b9ca03d1f7b01501b7bf6 (patch)
tree62ae0aca80b9fd4d219e5ab4c7ba5ea37dc6613c /drivers/net/can
parent7bb4db93ae59e0faf810a83a8578f56bc968ab01 (diff)
can: cc770: Fix indirect access deadlock on ISA cards
This fix avoids a deadlock if an interrupt occurs during consecutive port operations on ISA cards utilising indirect access via address and data port. Tested on a B&R ISA card. Cc: linux-can@vger.kernel.org Cc: netdev@vger.kernel.org Signed-off-by: Wolfgang Zarre <lkdev@essax.com> Acked-by: Wolfgang Grandegger <wg@grandegger.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Diffstat (limited to 'drivers/net/can')
-rw-r--r--drivers/net/can/cc770/cc770_isa.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/drivers/net/can/cc770/cc770_isa.c b/drivers/net/can/cc770/cc770_isa.c
index 4be5fe2c40a5..9f3a25ccd665 100644
--- a/drivers/net/can/cc770/cc770_isa.c
+++ b/drivers/net/can/cc770/cc770_isa.c
@@ -110,6 +110,11 @@ MODULE_PARM_DESC(bcr, "Bus configuration register (default=0x40 [CBY])");
110#define CC770_IOSIZE 0x20 110#define CC770_IOSIZE 0x20
111#define CC770_IOSIZE_INDIRECT 0x02 111#define CC770_IOSIZE_INDIRECT 0x02
112 112
113/* Spinlock for cc770_isa_port_write_reg_indirect
114 * and cc770_isa_port_read_reg_indirect
115 */
116static DEFINE_SPINLOCK(cc770_isa_port_lock);
117
113static struct platform_device *cc770_isa_devs[MAXDEV]; 118static struct platform_device *cc770_isa_devs[MAXDEV];
114 119
115static u8 cc770_isa_mem_read_reg(const struct cc770_priv *priv, int reg) 120static u8 cc770_isa_mem_read_reg(const struct cc770_priv *priv, int reg)
@@ -138,18 +143,27 @@ static u8 cc770_isa_port_read_reg_indirect(const struct cc770_priv *priv,
138 int reg) 143 int reg)
139{ 144{
140 unsigned long base = (unsigned long)priv->reg_base; 145 unsigned long base = (unsigned long)priv->reg_base;
146 unsigned long flags;
147 u8 val;
141 148
149 spin_lock_irqsave(&cc770_isa_port_lock, flags);
142 outb(reg, base); 150 outb(reg, base);
143 return inb(base + 1); 151 val = inb(base + 1);
152 spin_unlock_irqrestore(&cc770_isa_port_lock, flags);
153
154 return val;
144} 155}
145 156
146static void cc770_isa_port_write_reg_indirect(const struct cc770_priv *priv, 157static void cc770_isa_port_write_reg_indirect(const struct cc770_priv *priv,
147 int reg, u8 val) 158 int reg, u8 val)
148{ 159{
149 unsigned long base = (unsigned long)priv->reg_base; 160 unsigned long base = (unsigned long)priv->reg_base;
161 unsigned long flags;
150 162
163 spin_lock_irqsave(&cc770_isa_port_lock, flags);
151 outb(reg, base); 164 outb(reg, base);
152 outb(val, base + 1); 165 outb(val, base + 1);
166 spin_unlock_irqrestore(&cc770_isa_port_lock, flags);
153} 167}
154 168
155static int __devinit cc770_isa_probe(struct platform_device *pdev) 169static int __devinit cc770_isa_probe(struct platform_device *pdev)