Skip to contentSkip to conversation

can: sja1000: sja1000_platform.c fixes

PATCH Applied Yegor Yefremov 5 participants 8 messages Mar 19, 2010 – Mar 22, 2010 2 messages not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover can: sja1000: sja1000_platform.c fixes

Here are two sja1000_platform.c related fixes:

SJA1000: allow shared interrupt definition
SJA1000: add read/write routines for 8, 16 and 32-bit register access

Best regards,
Yegor

#1 lore raw

Re: [PATCH net-next-2.6 1/2] can: sja1000: allow shared interrupt definition

SJA1000: allow shared interrupt definition

extend the AND mask, so that IRQF_SHARED flag remains

drivers/net/can/sja1000/sja1000_platform.c +1 -1
index 628374c..bec0d3d 100644
@@ -90,7 +90,7 @@ static int sp_probe(struct platform_device *pdev)
 	priv = netdev_priv(dev);
 
 	dev->irq = res_irq->start;
-	priv->irq_flags = res_irq->flags & IRQF_TRIGGER_MASK;
+	priv->irq_flags = res_irq->flags & (IRQF_TRIGGER_MASK | IRQF_SHARED);
 	priv->reg_base = addr;
 	priv->read_reg = sp_read_reg;
 	priv->write_reg = sp_write_reg;

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw

Re: [PATCH net-next-2.6 2/2] can: sja1000: add read/write routines for 8, 16 and 32-bit register access

SJA1000: add read/write routines for 8, 16 and 32-bit register access

add routines for 8, 16 and 32-bit access like in
drivers/i2c/busses/i2c-pca-platform.c

drivers/net/can/sja1000/sja1000_platform.c +38 -4
Index: net-next-2.6/drivers/net/can/sja1000/sja1000_platform.c
===================================================================
@@ -37,16 +37,36 @@ MODULE_AUTHOR("Sascha Hauer <s.hauer@pen
 MODULE_DESCRIPTION("Socket-CAN driver for SJA1000 on the platform bus");
 MODULE_LICENSE("GPL v2");
 
-static u8 sp_read_reg(const struct sja1000_priv *priv, int reg)
+static u8 sp_read_reg8(const struct sja1000_priv *priv, int reg)
 {
 	return ioread8(priv->reg_base + reg);
 }
 
-static void sp_write_reg(const struct sja1000_priv *priv, int reg, u8 val)
+static void sp_write_reg8(const struct sja1000_priv *priv, int reg, u8 val)
 {
 	iowrite8(val, priv->reg_base + reg);
 }
 
+static u8 sp_read_reg16(const struct sja1000_priv *priv, int reg)
+{
+	return ioread8(priv->reg_base + reg * 2);
+}
+
+static void sp_write_reg16(const struct sja1000_priv *priv, int reg, u8 val)
+{
+	iowrite8(val, priv->reg_base + reg * 2);
+}
+
+static u8 sp_read_reg32(const struct sja1000_priv *priv, int reg)
+{
+	return ioread8(priv->reg_base + reg * 4);
+}
+
+static void sp_write_reg32(const struct sja1000_priv *priv, int reg, u8 val)
+{
+	iowrite8(val, priv->reg_base + reg * 4);
+}
+
 static int sp_probe(struct platform_device *pdev)
 {
 	int err;
@@ -92,12 +112,26 @@ static int sp_probe(struct platform_devi
 	dev->irq = res_irq->start;
 	priv->irq_flags = res_irq->flags & (IRQF_TRIGGER_MASK | IRQF_SHARED);
 	priv->reg_base = addr;
-	priv->read_reg = sp_read_reg;
-	priv->write_reg = sp_write_reg;
 	priv->can.clock.freq = pdata->clock;
 	priv->ocr = pdata->ocr;
 	priv->cdr = pdata->cdr;
 
+	switch (res_mem->flags & IORESOURCE_MEM_TYPE_MASK) {
+	case IORESOURCE_MEM_32BIT:
+		priv->read_reg = sp_read_reg32;
+		priv->write_reg = sp_write_reg32;
+		break;
+	case IORESOURCE_MEM_16BIT:
+		priv->read_reg = sp_read_reg16;
+		priv->write_reg = sp_write_reg16;
+		break;
+	case IORESOURCE_MEM_8BIT:
+	default:
+		priv->read_reg = sp_read_reg8;
+		priv->write_reg = sp_write_reg8;
+		break;
+	}
+
 	dev_set_drvdata(&pdev->dev, dev);
 	SET_NETDEV_DEV(dev, &pdev->dev);

A message that is not in the archive (sent off-list or not yet received): [email protected]

Acked-by
#6 lore raw

Re: [PATCH net-next-2.6 2/2] can: sja1000: add read/write routines for 8, 16 and 32-bit register access

In reply to a message not in the archive
Quoted 6 lines · Yegor Yefremov

SJA1000: add read/write routines for 8, 16 and 32-bit register access

add routines for 8, 16 and 32-bit access like in
drivers/i2c/busses/i2c-pca-platform.c

Signature · 2 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

_______________________________________________
Socketcan-core mailing list [email protected]
https://lists.berlios.de/mailman/listinfo/socketcan-core

maintainer Applied
#7 lore raw

Re: [PATCH net-next-2.6 2/2] can: sja1000: add read/write routines for 8, 16 and 32-bit register access

From: Wolfram Sang <[email protected]>
Date: Sat, 20 Mar 2010 04:56:39 +0100

Quoted 9 lines · Yegor Yefremov
Quoted 6 lines

SJA1000: add read/write routines for 8, 16 and 32-bit register access

add routines for 8, 16 and 32-bit access like in
drivers/i2c/busses/i2c-pca-platform.c

Applied.