Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 215213
b: refs/heads/master
c: f1f8c6c
h: refs/heads/master
i:
  215211: 061959d
v: v3
  • Loading branch information
Marc Kleine-Budde committed Oct 18, 2010
1 parent 9b9031f commit e454a19
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 17 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d3cd15657516141adce387810be8cb377baf020e
refs/heads/master: f1f8c6cbe6f08f93ac2a4ca19625891d8a82b7f8
24 changes: 12 additions & 12 deletions trunk/drivers/net/can/mcp251x.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 */

Expand Down Expand Up @@ -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++)
Expand Down Expand Up @@ -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++)
Expand Down Expand Up @@ -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) {
Expand All @@ -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);

Expand Down Expand Up @@ -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 },
{ },
Expand Down
4 changes: 0 additions & 4 deletions trunk/include/linux/can/platform/mcp251x.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand Down

0 comments on commit e454a19

Please sign in to comment.