* [PATCH V3 0/8] can: mcp251x: fix and optimize driver
@ 2010-10-18 13:31 Marc Kleine-Budde
[not found] ` <1287408674-15412-1-git-send-email-mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
` (4 more replies)
0 siblings, 5 replies; 12+ messages in thread
From: Marc Kleine-Budde @ 2010-10-18 13:31 UTC (permalink / raw)
To: socketcan-core-0fE9KPoRgkgATYTw5x5z8w; +Cc: netdev-u79uwXL29TY76Z2rM5mHXA
Moin,
this series of patches improves the mcp251x driver. It first fixes the
local_softirq_pending problem. Then the amount of SPI transfers is reduced
in order to optimise the driver. A further patch cleans up the chip model
selection.
This series has been tested with a mcp2515 on i.MX35.
Please review, test and consider to apply.
regards, Marc
--
The following changes since commit 724829b3ad8e8aeb0aec46de383d35bfa1ad3875:
David S. Miller (1):
tipc: Kill tipc_get_mode() completely.
are available in the git repository at:
git://git.pengutronix.de/git/mkl/linux-2.6.git can/mcp251x-for-net-next
Marc Kleine-Budde (5):
can: mcp251x: fix NOHZ local_softirq_pending 08 warning
can: mcp251x: write intf only when needed
can: mcp251x: Don't use pdata->model for chip selection anymore
can: mcp251x: define helper functions mcp251x_is_2510, mcp251x_is_2515
can: mcp251x: optimize 2515, rx int gets cleared automatically
Sascha Hauer (3):
can: mcp251x: increase rx_errors on overflow, not only rx_over_errors
can: mcp251x: allow to read two registers in one spi transfer
can: mcp251x: read-modify-write eflag only when needed
drivers/net/can/mcp251x.c | 95 +++++++++++++++++++++++++---------
include/linux/can/platform/mcp251x.h | 4 --
2 files changed, 70 insertions(+), 29 deletions(-)
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 1/8] can: mcp251x: fix NOHZ local_softirq_pending 08 warning
[not found] ` <1287408674-15412-1-git-send-email-mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
@ 2010-10-18 13:31 ` Marc Kleine-Budde
2010-10-18 13:31 ` [PATCH 2/8] can: mcp251x: increase rx_errors on overflow, not only rx_over_errors Marc Kleine-Budde
` (3 subsequent siblings)
4 siblings, 0 replies; 12+ messages in thread
From: Marc Kleine-Budde @ 2010-10-18 13:31 UTC (permalink / raw)
To: socketcan-core-0fE9KPoRgkgATYTw5x5z8w
Cc: netdev-u79uwXL29TY76Z2rM5mHXA, Marc Kleine-Budde
This patch replaces netif_rx() with netif_rx_ni() which has to be used
from the threaded interrupt i.e. process context context.
Thanks to Christian Pellegrin for pointing at the right fix:
481a8199142c050b72bff8a1956a49fd0a75bbe0 by Oliver Hartkopp.
Signed-off-by: Marc Kleine-Budde <mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
Acked-by: Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
---
drivers/net/can/mcp251x.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/can/mcp251x.c b/drivers/net/can/mcp251x.c
index b11a0cb..c06e023 100644
--- a/drivers/net/can/mcp251x.c
+++ b/drivers/net/can/mcp251x.c
@@ -451,7 +451,7 @@ static void mcp251x_hw_rx(struct spi_device *spi, int buf_idx)
priv->net->stats.rx_packets++;
priv->net->stats.rx_bytes += frame->can_dlc;
- netif_rx(skb);
+ netif_rx_ni(skb);
}
static void mcp251x_hw_sleep(struct spi_device *spi)
@@ -676,7 +676,7 @@ static void mcp251x_error_skb(struct net_device *net, int can_id, int data1)
if (skb) {
frame->can_id = can_id;
frame->data[1] = data1;
- netif_rx(skb);
+ netif_rx_ni(skb);
} else {
dev_err(&net->dev,
"cannot allocate error skb\n");
--
1.7.0.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 2/8] can: mcp251x: increase rx_errors on overflow, not only rx_over_errors
[not found] ` <1287408674-15412-1-git-send-email-mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2010-10-18 13:31 ` [PATCH 1/8] can: mcp251x: fix NOHZ local_softirq_pending 08 warning Marc Kleine-Budde
@ 2010-10-18 13:31 ` Marc Kleine-Budde
2010-10-18 13:31 ` [PATCH 3/8] can: mcp251x: allow to read two registers in one spi transfer Marc Kleine-Budde
` (2 subsequent siblings)
4 siblings, 0 replies; 12+ messages in thread
From: Marc Kleine-Budde @ 2010-10-18 13:31 UTC (permalink / raw)
To: socketcan-core-0fE9KPoRgkgATYTw5x5z8w
Cc: netdev-u79uwXL29TY76Z2rM5mHXA, Marc Kleine-Budde
From: Sascha Hauer <s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
Signed-off-by: Sascha Hauer <s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
Signed-off-by: Marc Kleine-Budde <mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
Acked-by: Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
---
drivers/net/can/mcp251x.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/net/can/mcp251x.c b/drivers/net/can/mcp251x.c
index c06e023..fdea752 100644
--- a/drivers/net/can/mcp251x.c
+++ b/drivers/net/can/mcp251x.c
@@ -816,10 +816,14 @@ static irqreturn_t mcp251x_can_ist(int irq, void *dev_id)
if (intf & CANINTF_ERRIF) {
/* Handle overflow counters */
if (eflag & (EFLG_RX0OVR | EFLG_RX1OVR)) {
- if (eflag & EFLG_RX0OVR)
+ if (eflag & EFLG_RX0OVR) {
net->stats.rx_over_errors++;
- if (eflag & EFLG_RX1OVR)
+ net->stats.rx_errors++;
+ }
+ if (eflag & EFLG_RX1OVR) {
net->stats.rx_over_errors++;
+ net->stats.rx_errors++;
+ }
can_id |= CAN_ERR_CRTL;
data1 |= CAN_ERR_CRTL_RX_OVERFLOW;
}
--
1.7.0.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 3/8] can: mcp251x: allow to read two registers in one spi transfer
[not found] ` <1287408674-15412-1-git-send-email-mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2010-10-18 13:31 ` [PATCH 1/8] can: mcp251x: fix NOHZ local_softirq_pending 08 warning Marc Kleine-Budde
2010-10-18 13:31 ` [PATCH 2/8] can: mcp251x: increase rx_errors on overflow, not only rx_over_errors Marc Kleine-Budde
@ 2010-10-18 13:31 ` Marc Kleine-Budde
2010-10-18 13:31 ` [PATCH 4/8] can: mcp251x: read-modify-write eflag only when needed Marc Kleine-Budde
2010-10-18 14:12 ` [PATCH V3 0/8] can: mcp251x: fix and optimize driver David Miller
4 siblings, 0 replies; 12+ messages in thread
From: Marc Kleine-Budde @ 2010-10-18 13:31 UTC (permalink / raw)
To: socketcan-core-0fE9KPoRgkgATYTw5x5z8w
Cc: netdev-u79uwXL29TY76Z2rM5mHXA, Marc Kleine-Budde,
Uwe Kleine-König
From: Sascha Hauer <s.hauer@pengutronix.de>
This patch bases on work done earlier by David Jander.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Acked-by: David Jander <david@protonic.nl>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Acked-by: Wolfgang Grandegger <wg@grandegger.com>
---
drivers/net/can/mcp251x.c | 20 +++++++++++++++++---
1 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/drivers/net/can/mcp251x.c b/drivers/net/can/mcp251x.c
index fdea752..9b3466a 100644
--- a/drivers/net/can/mcp251x.c
+++ b/drivers/net/can/mcp251x.c
@@ -319,6 +319,20 @@ static u8 mcp251x_read_reg(struct spi_device *spi, uint8_t reg)
return val;
}
+static void mcp251x_read_2regs(struct spi_device *spi, uint8_t reg,
+ uint8_t *v1, uint8_t *v2)
+{
+ struct mcp251x_priv *priv = dev_get_drvdata(&spi->dev);
+
+ priv->spi_tx_buf[0] = INSTRUCTION_READ;
+ priv->spi_tx_buf[1] = reg;
+
+ mcp251x_spi_trans(spi, 4);
+
+ *v1 = priv->spi_rx_buf[2];
+ *v2 = priv->spi_rx_buf[3];
+}
+
static void mcp251x_write_reg(struct spi_device *spi, u8 reg, uint8_t val)
{
struct mcp251x_priv *priv = dev_get_drvdata(&spi->dev);
@@ -754,10 +768,11 @@ static irqreturn_t mcp251x_can_ist(int irq, void *dev_id)
mutex_lock(&priv->mcp_lock);
while (!priv->force_quit) {
enum can_state new_state;
- u8 intf = mcp251x_read_reg(spi, CANINTF);
- u8 eflag;
+ u8 intf, eflag;
int can_id = 0, data1 = 0;
+ mcp251x_read_2regs(spi, CANINTF, &intf, &eflag);
+
if (intf & CANINTF_RX0IF) {
mcp251x_hw_rx(spi, 0);
/* Free one buffer ASAP */
@@ -770,7 +785,6 @@ static irqreturn_t mcp251x_can_ist(int irq, void *dev_id)
mcp251x_write_bits(spi, CANINTF, intf, 0x00);
- eflag = mcp251x_read_reg(spi, EFLG);
mcp251x_write_reg(spi, EFLG, 0x00);
/* Update can state */
--
1.7.0.4
_______________________________________________
Socketcan-core mailing list
Socketcan-core@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/socketcan-core
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 4/8] can: mcp251x: read-modify-write eflag only when needed
[not found] ` <1287408674-15412-1-git-send-email-mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
` (2 preceding siblings ...)
2010-10-18 13:31 ` [PATCH 3/8] can: mcp251x: allow to read two registers in one spi transfer Marc Kleine-Budde
@ 2010-10-18 13:31 ` Marc Kleine-Budde
2010-10-18 14:12 ` [PATCH V3 0/8] can: mcp251x: fix and optimize driver David Miller
4 siblings, 0 replies; 12+ messages in thread
From: Marc Kleine-Budde @ 2010-10-18 13:31 UTC (permalink / raw)
To: socketcan-core-0fE9KPoRgkgATYTw5x5z8w
Cc: netdev-u79uwXL29TY76Z2rM5mHXA, Marc Kleine-Budde
From: Sascha Hauer <s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
Use read-modify-write instead of a simple write to change the register
contents, to close existing the race window between the original manual
read and write.
Signed-off-by: Sascha Hauer <s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
Signed-off-by: Marc Kleine-Budde <mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
Acked-by: Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
---
drivers/net/can/mcp251x.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/drivers/net/can/mcp251x.c b/drivers/net/can/mcp251x.c
index 9b3466a..7e2f951 100644
--- a/drivers/net/can/mcp251x.c
+++ b/drivers/net/can/mcp251x.c
@@ -785,7 +785,8 @@ static irqreturn_t mcp251x_can_ist(int irq, void *dev_id)
mcp251x_write_bits(spi, CANINTF, intf, 0x00);
- mcp251x_write_reg(spi, EFLG, 0x00);
+ if (eflag)
+ mcp251x_write_bits(spi, EFLG, eflag, 0x00);
/* Update can state */
if (eflag & EFLG_TXBO) {
--
1.7.0.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 5/8] can: mcp251x: write intf only when needed
2010-10-18 13:31 [PATCH V3 0/8] can: mcp251x: fix and optimize driver Marc Kleine-Budde
[not found] ` <1287408674-15412-1-git-send-email-mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
@ 2010-10-18 13:31 ` Marc Kleine-Budde
2010-10-18 13:31 ` [PATCH 6/8] can: mcp251x: Don't use pdata->model for chip selection anymore Marc Kleine-Budde
` (2 subsequent siblings)
4 siblings, 0 replies; 12+ messages in thread
From: Marc Kleine-Budde @ 2010-10-18 13:31 UTC (permalink / raw)
To: socketcan-core; +Cc: netdev, Marc Kleine-Budde
This patch introduces a variable "clear_intf" that hold the bits that
should be cleared. Only read-modify-write register if "clear_intf"
is set.
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Acked-by: Wolfgang Grandegger <wg@grandegger.com>
---
drivers/net/can/mcp251x.c | 15 +++++++++++++--
1 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/drivers/net/can/mcp251x.c b/drivers/net/can/mcp251x.c
index 7e2f951..f5e2edd 100644
--- a/drivers/net/can/mcp251x.c
+++ b/drivers/net/can/mcp251x.c
@@ -125,6 +125,8 @@
# define CANINTF_TX0IF 0x04
# define CANINTF_RX1IF 0x02
# define CANINTF_RX0IF 0x01
+# define CANINTF_ERR_TX \
+ (CANINTF_ERRIF | CANINTF_TX2IF | CANINTF_TX1IF | CANINTF_TX0IF)
#define EFLG 0x2d
# define EFLG_EWARN 0x01
# define EFLG_RXWAR 0x02
@@ -769,10 +771,12 @@ static irqreturn_t mcp251x_can_ist(int irq, void *dev_id)
while (!priv->force_quit) {
enum can_state new_state;
u8 intf, eflag;
+ u8 clear_intf = 0;
int can_id = 0, data1 = 0;
mcp251x_read_2regs(spi, CANINTF, &intf, &eflag);
+ /* receive buffer 0 */
if (intf & CANINTF_RX0IF) {
mcp251x_hw_rx(spi, 0);
/* Free one buffer ASAP */
@@ -780,10 +784,17 @@ static irqreturn_t mcp251x_can_ist(int irq, void *dev_id)
0x00);
}
- if (intf & CANINTF_RX1IF)
+ /* receive buffer 1 */
+ if (intf & CANINTF_RX1IF) {
mcp251x_hw_rx(spi, 1);
+ clear_intf |= CANINTF_RX1IF;
+ }
- mcp251x_write_bits(spi, CANINTF, intf, 0x00);
+ /* any error or tx interrupt we need to clear? */
+ if (intf & CANINTF_ERR_TX)
+ clear_intf |= intf & CANINTF_ERR_TX;
+ if (clear_intf)
+ mcp251x_write_bits(spi, CANINTF, clear_intf, 0x00);
if (eflag)
mcp251x_write_bits(spi, EFLG, eflag, 0x00);
--
1.7.0.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 6/8] can: mcp251x: Don't use pdata->model for chip selection anymore
2010-10-18 13:31 [PATCH V3 0/8] can: mcp251x: fix and optimize driver Marc Kleine-Budde
[not found] ` <1287408674-15412-1-git-send-email-mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2010-10-18 13:31 ` [PATCH 5/8] can: mcp251x: write intf only when needed Marc Kleine-Budde
@ 2010-10-18 13:31 ` Marc Kleine-Budde
2010-10-18 13:49 ` Marc Zyngier
2010-10-18 13:31 ` [PATCH 7/8] can: mcp251x: define helper functions mcp251x_is_2510, mcp251x_is_2515 Marc Kleine-Budde
2010-10-18 13:31 ` [PATCH 8/8] can: mcp251x: optimize 2515, rx int gets cleared automatically Marc Kleine-Budde
4 siblings, 1 reply; 12+ messages in thread
From: Marc Kleine-Budde @ 2010-10-18 13:31 UTC (permalink / raw)
To: socketcan-core
Cc: netdev, Marc Kleine-Budde, Christian Pellegrin, Marc Zyngier
Since commit e446630c960946b5c1762e4eadb618becef599e7, i.e. v2.6.35-rc1,
the mcp251x chip model can be selected via the modalias member in the
struct spi_board_info. The driver stores the actual model in the
struct mcp251x_platform_data.
>From the driver point of view the platform_data should be read only.
Since all in-tree users of the mcp251x have already been converted to
the modalias method, this patch moves the "model" member from the
struct mcp251x_platform_data to the driver's private data structure.
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: Christian Pellegrin <chripell@fsfe.org>
Cc: Marc Zyngier <maz@misterjones.org>
---
drivers/net/can/mcp251x.c | 24 ++++++++++++------------
include/linux/can/platform/mcp251x.h | 4 ----
2 files changed, 12 insertions(+), 16 deletions(-)
diff --git a/drivers/net/can/mcp251x.c b/drivers/net/can/mcp251x.c
index f5e2edd..0386bed 100644
--- a/drivers/net/can/mcp251x.c
+++ b/drivers/net/can/mcp251x.c
@@ -38,14 +38,14 @@
* static struct mcp251x_platform_data mcp251x_info = {
* .oscillator_frequency = 8000000,
* .board_specific_setup = &mcp251x_setup,
- * .model = CAN_MCP251X_MCP2510,
* .power_enable = mcp251x_power_enable,
* .transceiver_enable = NULL,
* };
*
* static struct spi_board_info spi_board_info[] = {
* {
- * .modalias = "mcp251x",
+ * .modalias = "mcp2510",
+ * // or "mcp2515" depending on your controller
* .platform_data = &mcp251x_info,
* .irq = IRQ_EINT13,
* .max_speed_hz = 2*1000*1000,
@@ -224,10 +224,16 @@ static struct can_bittiming_const mcp251x_bittiming_const = {
.brp_inc = 1,
};
+enum mcp251x_model {
+ CAN_MCP251X_MCP2510 = 0x2510,
+ CAN_MCP251X_MCP2515 = 0x2515,
+};
+
struct mcp251x_priv {
struct can_priv can;
struct net_device *net;
struct spi_device *spi;
+ enum mcp251x_model model;
struct mutex mcp_lock; /* SPI device lock */
@@ -362,10 +368,9 @@ static void mcp251x_write_bits(struct spi_device *spi, u8 reg,
static void mcp251x_hw_tx_frame(struct spi_device *spi, u8 *buf,
int len, int tx_buf_idx)
{
- struct mcp251x_platform_data *pdata = spi->dev.platform_data;
struct mcp251x_priv *priv = dev_get_drvdata(&spi->dev);
- if (pdata->model == CAN_MCP251X_MCP2510) {
+ if (priv->model == CAN_MCP251X_MCP2510) {
int i;
for (i = 1; i < TXBDAT_OFF + len; i++)
@@ -408,9 +413,8 @@ static void mcp251x_hw_rx_frame(struct spi_device *spi, u8 *buf,
int buf_idx)
{
struct mcp251x_priv *priv = dev_get_drvdata(&spi->dev);
- struct mcp251x_platform_data *pdata = spi->dev.platform_data;
- if (pdata->model == CAN_MCP251X_MCP2510) {
+ if (priv->model == CAN_MCP251X_MCP2510) {
int i, len;
for (i = 1; i < RXBDAT_OFF; i++)
@@ -951,16 +955,12 @@ static int __devinit mcp251x_can_probe(struct spi_device *spi)
struct net_device *net;
struct mcp251x_priv *priv;
struct mcp251x_platform_data *pdata = spi->dev.platform_data;
- int model = spi_get_device_id(spi)->driver_data;
int ret = -ENODEV;
if (!pdata)
/* Platform data is required for osc freq */
goto error_out;
- if (model)
- pdata->model = model;
-
/* Allocate can/net device */
net = alloc_candev(sizeof(struct mcp251x_priv), TX_ECHO_SKB_MAX);
if (!net) {
@@ -977,6 +977,7 @@ static int __devinit mcp251x_can_probe(struct spi_device *spi)
priv->can.clock.freq = pdata->oscillator_frequency / 2;
priv->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES |
CAN_CTRLMODE_LOOPBACK | CAN_CTRLMODE_LISTENONLY;
+ priv->model = spi_get_device_id(spi)->driver_data;
priv->net = net;
dev_set_drvdata(&spi->dev, priv);
@@ -1150,8 +1151,7 @@ static int mcp251x_can_resume(struct spi_device *spi)
#define mcp251x_can_resume NULL
#endif
-static struct spi_device_id mcp251x_id_table[] = {
- { "mcp251x", 0 /* Use pdata.model */ },
+static const struct spi_device_id mcp251x_id_table[] = {
{ "mcp2510", CAN_MCP251X_MCP2510 },
{ "mcp2515", CAN_MCP251X_MCP2515 },
{ },
diff --git a/include/linux/can/platform/mcp251x.h b/include/linux/can/platform/mcp251x.h
index dba2826..8e20540 100644
--- a/include/linux/can/platform/mcp251x.h
+++ b/include/linux/can/platform/mcp251x.h
@@ -12,7 +12,6 @@
/**
* struct mcp251x_platform_data - MCP251X SPI CAN controller platform data
* @oscillator_frequency: - oscillator frequency in Hz
- * @model: - actual type of chip
* @board_specific_setup: - called before probing the chip (power,reset)
* @transceiver_enable: - called to power on/off the transceiver
* @power_enable: - called to power on/off the mcp *and* the
@@ -25,9 +24,6 @@
struct mcp251x_platform_data {
unsigned long oscillator_frequency;
- int model;
-#define CAN_MCP251X_MCP2510 0x2510
-#define CAN_MCP251X_MCP2515 0x2515
int (*board_specific_setup)(struct spi_device *spi);
int (*transceiver_enable)(int enable);
int (*power_enable) (int enable);
--
1.7.0.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 7/8] can: mcp251x: define helper functions mcp251x_is_2510, mcp251x_is_2515
2010-10-18 13:31 [PATCH V3 0/8] can: mcp251x: fix and optimize driver Marc Kleine-Budde
` (2 preceding siblings ...)
2010-10-18 13:31 ` [PATCH 6/8] can: mcp251x: Don't use pdata->model for chip selection anymore Marc Kleine-Budde
@ 2010-10-18 13:31 ` Marc Kleine-Budde
2010-10-18 13:31 ` [PATCH 8/8] can: mcp251x: optimize 2515, rx int gets cleared automatically Marc Kleine-Budde
4 siblings, 0 replies; 12+ messages in thread
From: Marc Kleine-Budde @ 2010-10-18 13:31 UTC (permalink / raw)
To: socketcan-core; +Cc: netdev, Marc Kleine-Budde
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Acked-by: Wolfgang Grandegger <wg@grandegger.com>
---
drivers/net/can/mcp251x.c | 14 ++++++++++++--
1 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/drivers/net/can/mcp251x.c b/drivers/net/can/mcp251x.c
index 0386bed..7f8aa4c 100644
--- a/drivers/net/can/mcp251x.c
+++ b/drivers/net/can/mcp251x.c
@@ -258,6 +258,16 @@ struct mcp251x_priv {
int restart_tx;
};
+#define MCP251X_IS(_model) \
+static inline int mcp251x_is_##_model(struct spi_device *spi) \
+{ \
+ struct mcp251x_priv *priv = dev_get_drvdata(&spi->dev); \
+ return priv->model == CAN_MCP251X_MCP##_model; \
+}
+
+MCP251X_IS(2510);
+MCP251X_IS(2515);
+
static void mcp251x_clean(struct net_device *net)
{
struct mcp251x_priv *priv = netdev_priv(net);
@@ -370,7 +380,7 @@ static void mcp251x_hw_tx_frame(struct spi_device *spi, u8 *buf,
{
struct mcp251x_priv *priv = dev_get_drvdata(&spi->dev);
- if (priv->model == CAN_MCP251X_MCP2510) {
+ if (mcp251x_is_2510(spi)) {
int i;
for (i = 1; i < TXBDAT_OFF + len; i++)
@@ -414,7 +424,7 @@ static void mcp251x_hw_rx_frame(struct spi_device *spi, u8 *buf,
{
struct mcp251x_priv *priv = dev_get_drvdata(&spi->dev);
- if (priv->model == CAN_MCP251X_MCP2510) {
+ if (mcp251x_is_2510(spi)) {
int i, len;
for (i = 1; i < RXBDAT_OFF; i++)
--
1.7.0.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 8/8] can: mcp251x: optimize 2515, rx int gets cleared automatically
2010-10-18 13:31 [PATCH V3 0/8] can: mcp251x: fix and optimize driver Marc Kleine-Budde
` (3 preceding siblings ...)
2010-10-18 13:31 ` [PATCH 7/8] can: mcp251x: define helper functions mcp251x_is_2510, mcp251x_is_2515 Marc Kleine-Budde
@ 2010-10-18 13:31 ` Marc Kleine-Budde
4 siblings, 0 replies; 12+ messages in thread
From: Marc Kleine-Budde @ 2010-10-18 13:31 UTC (permalink / raw)
To: socketcan-core; +Cc: netdev, Marc Kleine-Budde
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Acked-by: Wolfgang Grandegger <wg@grandegger.com>
---
drivers/net/can/mcp251x.c | 13 +++++++++----
1 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/drivers/net/can/mcp251x.c b/drivers/net/can/mcp251x.c
index 7f8aa4c..c664be2 100644
--- a/drivers/net/can/mcp251x.c
+++ b/drivers/net/can/mcp251x.c
@@ -793,15 +793,20 @@ static irqreturn_t mcp251x_can_ist(int irq, void *dev_id)
/* receive buffer 0 */
if (intf & CANINTF_RX0IF) {
mcp251x_hw_rx(spi, 0);
- /* Free one buffer ASAP */
- mcp251x_write_bits(spi, CANINTF, intf & CANINTF_RX0IF,
- 0x00);
+ /*
+ * Free one buffer ASAP
+ * (The MCP2515 does this automatically.)
+ */
+ if (mcp251x_is_2510(spi))
+ mcp251x_write_bits(spi, CANINTF, CANINTF_RX0IF, 0x00);
}
/* receive buffer 1 */
if (intf & CANINTF_RX1IF) {
mcp251x_hw_rx(spi, 1);
- clear_intf |= CANINTF_RX1IF;
+ /* the MCP2515 does this automatically */
+ if (mcp251x_is_2510(spi))
+ clear_intf |= CANINTF_RX1IF;
}
/* any error or tx interrupt we need to clear? */
--
1.7.0.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 6/8] can: mcp251x: Don't use pdata->model for chip selection anymore
2010-10-18 13:31 ` [PATCH 6/8] can: mcp251x: Don't use pdata->model for chip selection anymore Marc Kleine-Budde
@ 2010-10-18 13:49 ` Marc Zyngier
2010-10-18 14:14 ` Marc Kleine-Budde
0 siblings, 1 reply; 12+ messages in thread
From: Marc Zyngier @ 2010-10-18 13:49 UTC (permalink / raw)
To: Marc Kleine-Budde; +Cc: socketcan-core, netdev, Christian Pellegrin
On Mon, 18 Oct 2010 15:31:12 +0200, Marc Kleine-Budde <mkl@pengutronix.de>
wrote:
> Since commit e446630c960946b5c1762e4eadb618becef599e7, i.e. v2.6.35-rc1,
> the mcp251x chip model can be selected via the modalias member in the
> struct spi_board_info. The driver stores the actual model in the
> struct mcp251x_platform_data.
>
> From the driver point of view the platform_data should be read only.
> Since all in-tree users of the mcp251x have already been converted to
> the modalias method, this patch moves the "model" member from the
> struct mcp251x_platform_data to the driver's private data structure.
>
> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
> Cc: Christian Pellegrin <chripell@fsfe.org>
> Cc: Marc Zyngier <maz@misterjones.org>
Acked-by: Marc Zyngier <maz@misterjones.org>
--
Who you jivin' with that Cosmik Debris?
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH V3 0/8] can: mcp251x: fix and optimize driver
[not found] ` <1287408674-15412-1-git-send-email-mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
` (3 preceding siblings ...)
2010-10-18 13:31 ` [PATCH 4/8] can: mcp251x: read-modify-write eflag only when needed Marc Kleine-Budde
@ 2010-10-18 14:12 ` David Miller
4 siblings, 0 replies; 12+ messages in thread
From: David Miller @ 2010-10-18 14:12 UTC (permalink / raw)
To: mkl-bIcnvbaLZ9MEGnE8C9+IrQ
Cc: socketcan-core-0fE9KPoRgkgATYTw5x5z8w,
netdev-u79uwXL29TY76Z2rM5mHXA
From: Marc Kleine-Budde <mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
Date: Mon, 18 Oct 2010 15:31:06 +0200
> Moin,
>
> this series of patches improves the mcp251x driver. It first fixes the
> local_softirq_pending problem. Then the amount of SPI transfers is reduced
> in order to optimise the driver. A further patch cleans up the chip model
> selection.
>
> This series has been tested with a mcp2515 on i.MX35.
>
> Please review, test and consider to apply.
...
> git://git.pengutronix.de/git/mkl/linux-2.6.git can/mcp251x-for-net-next
Pulled, thanks.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 6/8] can: mcp251x: Don't use pdata->model for chip selection anymore
2010-10-18 13:49 ` Marc Zyngier
@ 2010-10-18 14:14 ` Marc Kleine-Budde
0 siblings, 0 replies; 12+ messages in thread
From: Marc Kleine-Budde @ 2010-10-18 14:14 UTC (permalink / raw)
To: Marc Zyngier
Cc: socketcan-core-0fE9KPoRgkgATYTw5x5z8w,
netdev-u79uwXL29TY76Z2rM5mHXA
[-- Attachment #1.1: Type: text/plain, Size: 1349 bytes --]
On 10/18/2010 03:49 PM, Marc Zyngier wrote:
>
> On Mon, 18 Oct 2010 15:31:12 +0200, Marc Kleine-Budde <mkl@pengutronix.de>
> wrote:
>> Since commit e446630c960946b5c1762e4eadb618becef599e7, i.e. v2.6.35-rc1,
>> the mcp251x chip model can be selected via the modalias member in the
>> struct spi_board_info. The driver stores the actual model in the
>> struct mcp251x_platform_data.
>>
>> From the driver point of view the platform_data should be read only.
>> Since all in-tree users of the mcp251x have already been converted to
>> the modalias method, this patch moves the "model" member from the
>> struct mcp251x_platform_data to the driver's private data structure.
>>
>> Signed-off-by: Marc Kleine-Budde <mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
>> Cc: Christian Pellegrin <chripell-VaTbYqLCNhc@public.gmane.org>
>> Cc: Marc Zyngier <maz-20xNzvSXLT6hUMvJH42dtQ@public.gmane.org>
>
> Acked-by: Marc Zyngier <maz-20xNzvSXLT6hUMvJH42dtQ@public.gmane.org>
Thanks, but I was to slow to push your Ack, David has pulled already.
cheers, Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]
[-- Attachment #2: Type: text/plain, Size: 188 bytes --]
_______________________________________________
Socketcan-core mailing list
Socketcan-core-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org
https://lists.berlios.de/mailman/listinfo/socketcan-core
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2010-10-18 14:14 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-18 13:31 [PATCH V3 0/8] can: mcp251x: fix and optimize driver Marc Kleine-Budde
[not found] ` <1287408674-15412-1-git-send-email-mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2010-10-18 13:31 ` [PATCH 1/8] can: mcp251x: fix NOHZ local_softirq_pending 08 warning Marc Kleine-Budde
2010-10-18 13:31 ` [PATCH 2/8] can: mcp251x: increase rx_errors on overflow, not only rx_over_errors Marc Kleine-Budde
2010-10-18 13:31 ` [PATCH 3/8] can: mcp251x: allow to read two registers in one spi transfer Marc Kleine-Budde
2010-10-18 13:31 ` [PATCH 4/8] can: mcp251x: read-modify-write eflag only when needed Marc Kleine-Budde
2010-10-18 14:12 ` [PATCH V3 0/8] can: mcp251x: fix and optimize driver David Miller
2010-10-18 13:31 ` [PATCH 5/8] can: mcp251x: write intf only when needed Marc Kleine-Budde
2010-10-18 13:31 ` [PATCH 6/8] can: mcp251x: Don't use pdata->model for chip selection anymore Marc Kleine-Budde
2010-10-18 13:49 ` Marc Zyngier
2010-10-18 14:14 ` Marc Kleine-Budde
2010-10-18 13:31 ` [PATCH 7/8] can: mcp251x: define helper functions mcp251x_is_2510, mcp251x_is_2515 Marc Kleine-Budde
2010-10-18 13:31 ` [PATCH 8/8] can: mcp251x: optimize 2515, rx int gets cleared automatically Marc Kleine-Budde
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).