Skip to content

Commit 7559d97

Browse files
committed
Merge branch 'for-davem' of git://gitorious.org/linux-can/linux-can-next
Marc Kleine-Budde says: =================== this is a pull-request for net-next/master. It consists of three patches by Lars-Peter Clausen to clean up the mcp251x spi-can driver, two patches from Ludovic Desroches to bring device tree support to the at91_can driver and a patch by me to fix a sparse warning in the blackfin driver. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents a33e611 + 21c11bc commit 7559d97

File tree

5 files changed

+88
-43
lines changed

5 files changed

+88
-43
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
* AT91 CAN *
2+
3+
Required properties:
4+
- compatible: Should be "atmel,at91sam9263-can" or "atmel,at91sam9x5-can"
5+
- reg: Should contain CAN controller registers location and length
6+
- interrupts: Should contain IRQ line for the CAN controller
7+
8+
Example:
9+
10+
can0: can@f000c000 {
11+
compatbile = "atmel,at91sam9x5-can";
12+
reg = <0xf000c000 0x300>;
13+
interrupts = <40 4 5>
14+
};

drivers/net/can/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ config CAN_LEDS
6565

6666
config CAN_AT91
6767
tristate "Atmel AT91 onchip CAN controller"
68-
depends on ARCH_AT91SAM9263 || ARCH_AT91SAM9X5
68+
depends on ARM
6969
---help---
7070
This is a driver for the SoC CAN controller in Atmel's AT91SAM9263
7171
and AT91SAM9X5 processors.

drivers/net/can/at91_can.c

Lines changed: 57 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <linux/kernel.h>
2828
#include <linux/module.h>
2929
#include <linux/netdevice.h>
30+
#include <linux/of.h>
3031
#include <linux/platform_device.h>
3132
#include <linux/rtnetlink.h>
3233
#include <linux/skbuff.h>
@@ -155,19 +156,20 @@ struct at91_priv {
155156
canid_t mb0_id;
156157
};
157158

158-
static const struct at91_devtype_data at91_devtype_data[] = {
159-
[AT91_DEVTYPE_SAM9263] = {
160-
.rx_first = 1,
161-
.rx_split = 8,
162-
.rx_last = 11,
163-
.tx_shift = 2,
164-
},
165-
[AT91_DEVTYPE_SAM9X5] = {
166-
.rx_first = 0,
167-
.rx_split = 4,
168-
.rx_last = 5,
169-
.tx_shift = 1,
170-
},
159+
static const struct at91_devtype_data at91_at91sam9263_data = {
160+
.rx_first = 1,
161+
.rx_split = 8,
162+
.rx_last = 11,
163+
.tx_shift = 2,
164+
.type = AT91_DEVTYPE_SAM9263,
165+
};
166+
167+
static const struct at91_devtype_data at91_at91sam9x5_data = {
168+
.rx_first = 0,
169+
.rx_split = 4,
170+
.rx_last = 5,
171+
.tx_shift = 1,
172+
.type = AT91_DEVTYPE_SAM9X5,
171173
};
172174

173175
static const struct can_bittiming_const at91_bittiming_const = {
@@ -1249,19 +1251,55 @@ static struct attribute_group at91_sysfs_attr_group = {
12491251
.attrs = at91_sysfs_attrs,
12501252
};
12511253

1254+
#if defined(CONFIG_OF)
1255+
static const struct of_device_id at91_can_dt_ids[] = {
1256+
{
1257+
.compatible = "atmel,at91sam9x5-can",
1258+
.data = &at91_at91sam9x5_data,
1259+
}, {
1260+
.compatible = "atmel,at91sam9263-can",
1261+
.data = &at91_at91sam9263_data,
1262+
}, {
1263+
/* sentinel */
1264+
}
1265+
};
1266+
MODULE_DEVICE_TABLE(of, at91_can_dt_ids);
1267+
#else
1268+
#define at91_can_dt_ids NULL
1269+
#endif
1270+
1271+
static const struct at91_devtype_data *at91_can_get_driver_data(struct platform_device *pdev)
1272+
{
1273+
if (pdev->dev.of_node) {
1274+
const struct of_device_id *match;
1275+
1276+
match = of_match_node(at91_can_dt_ids, pdev->dev.of_node);
1277+
if (!match) {
1278+
dev_err(&pdev->dev, "no matching node found in dtb\n");
1279+
return NULL;
1280+
}
1281+
return (const struct at91_devtype_data *)match->data;
1282+
}
1283+
return (const struct at91_devtype_data *)
1284+
platform_get_device_id(pdev)->driver_data;
1285+
}
1286+
12521287
static int at91_can_probe(struct platform_device *pdev)
12531288
{
12541289
const struct at91_devtype_data *devtype_data;
1255-
enum at91_devtype devtype;
12561290
struct net_device *dev;
12571291
struct at91_priv *priv;
12581292
struct resource *res;
12591293
struct clk *clk;
12601294
void __iomem *addr;
12611295
int err, irq;
12621296

1263-
devtype = pdev->id_entry->driver_data;
1264-
devtype_data = &at91_devtype_data[devtype];
1297+
devtype_data = at91_can_get_driver_data(pdev);
1298+
if (!devtype_data) {
1299+
dev_err(&pdev->dev, "no driver data\n");
1300+
err = -ENODEV;
1301+
goto exit;
1302+
}
12651303

12661304
clk = clk_get(&pdev->dev, "can_clk");
12671305
if (IS_ERR(clk)) {
@@ -1310,7 +1348,6 @@ static int at91_can_probe(struct platform_device *pdev)
13101348
priv->dev = dev;
13111349
priv->reg_base = addr;
13121350
priv->devtype_data = *devtype_data;
1313-
priv->devtype_data.type = devtype;
13141351
priv->clk = clk;
13151352
priv->pdata = pdev->dev.platform_data;
13161353
priv->mb0_id = 0x7ff;
@@ -1373,10 +1410,10 @@ static int at91_can_remove(struct platform_device *pdev)
13731410
static const struct platform_device_id at91_can_id_table[] = {
13741411
{
13751412
.name = "at91_can",
1376-
.driver_data = AT91_DEVTYPE_SAM9263,
1413+
.driver_data = (kernel_ulong_t)&at91_at91sam9x5_data,
13771414
}, {
13781415
.name = "at91sam9x5_can",
1379-
.driver_data = AT91_DEVTYPE_SAM9X5,
1416+
.driver_data = (kernel_ulong_t)&at91_at91sam9263_data,
13801417
}, {
13811418
/* sentinel */
13821419
}
@@ -1389,6 +1426,7 @@ static struct platform_driver at91_can_driver = {
13891426
.driver = {
13901427
.name = KBUILD_MODNAME,
13911428
.owner = THIS_MODULE,
1429+
.of_match_table = at91_can_dt_ids,
13921430
},
13931431
.id_table = at91_can_id_table,
13941432
};

drivers/net/can/bfin_can.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ static int bfin_can_err(struct net_device *dev, u16 isrc, u16 status)
412412
return 0;
413413
}
414414

415-
irqreturn_t bfin_can_interrupt(int irq, void *dev_id)
415+
static irqreturn_t bfin_can_interrupt(int irq, void *dev_id)
416416
{
417417
struct net_device *dev = dev_id;
418418
struct bfin_can_priv *priv = netdev_priv(dev);
@@ -504,7 +504,7 @@ static int bfin_can_close(struct net_device *dev)
504504
return 0;
505505
}
506506

507-
struct net_device *alloc_bfin_candev(void)
507+
static struct net_device *alloc_bfin_candev(void)
508508
{
509509
struct net_device *dev;
510510
struct bfin_can_priv *priv;

drivers/net/can/mcp251x.c

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,9 +1138,11 @@ static int mcp251x_can_remove(struct spi_device *spi)
11381138
return 0;
11391139
}
11401140

1141-
#ifdef CONFIG_PM
1142-
static int mcp251x_can_suspend(struct spi_device *spi, pm_message_t state)
1141+
#ifdef CONFIG_PM_SLEEP
1142+
1143+
static int mcp251x_can_suspend(struct device *dev)
11431144
{
1145+
struct spi_device *spi = to_spi_device(dev);
11441146
struct mcp251x_platform_data *pdata = spi->dev.platform_data;
11451147
struct mcp251x_priv *priv = dev_get_drvdata(&spi->dev);
11461148
struct net_device *net = priv->net;
@@ -1170,8 +1172,9 @@ static int mcp251x_can_suspend(struct spi_device *spi, pm_message_t state)
11701172
return 0;
11711173
}
11721174

1173-
static int mcp251x_can_resume(struct spi_device *spi)
1175+
static int mcp251x_can_resume(struct device *dev)
11741176
{
1177+
struct spi_device *spi = to_spi_device(dev);
11751178
struct mcp251x_platform_data *pdata = spi->dev.platform_data;
11761179
struct mcp251x_priv *priv = dev_get_drvdata(&spi->dev);
11771180

@@ -1191,9 +1194,13 @@ static int mcp251x_can_resume(struct spi_device *spi)
11911194
enable_irq(spi->irq);
11921195
return 0;
11931196
}
1197+
1198+
static SIMPLE_DEV_PM_OPS(mcp251x_can_pm_ops, mcp251x_can_suspend,
1199+
mcp251x_can_resume);
1200+
#define MCP251X_PM_OPS (&mcp251x_can_pm_ops)
1201+
11941202
#else
1195-
#define mcp251x_can_suspend NULL
1196-
#define mcp251x_can_resume NULL
1203+
#define MCP251X_PM_OPS NULL
11971204
#endif
11981205

11991206
static const struct spi_device_id mcp251x_id_table[] = {
@@ -1207,29 +1214,15 @@ MODULE_DEVICE_TABLE(spi, mcp251x_id_table);
12071214
static struct spi_driver mcp251x_can_driver = {
12081215
.driver = {
12091216
.name = DEVICE_NAME,
1210-
.bus = &spi_bus_type,
12111217
.owner = THIS_MODULE,
1218+
.pm = MCP251X_PM_OPS,
12121219
},
12131220

12141221
.id_table = mcp251x_id_table,
12151222
.probe = mcp251x_can_probe,
12161223
.remove = mcp251x_can_remove,
1217-
.suspend = mcp251x_can_suspend,
1218-
.resume = mcp251x_can_resume,
12191224
};
1220-
1221-
static int __init mcp251x_can_init(void)
1222-
{
1223-
return spi_register_driver(&mcp251x_can_driver);
1224-
}
1225-
1226-
static void __exit mcp251x_can_exit(void)
1227-
{
1228-
spi_unregister_driver(&mcp251x_can_driver);
1229-
}
1230-
1231-
module_init(mcp251x_can_init);
1232-
module_exit(mcp251x_can_exit);
1225+
module_spi_driver(mcp251x_can_driver);
12331226

12341227
MODULE_AUTHOR("Chris Elston <[email protected]>, "
12351228
"Christian Pellegrin <[email protected]>");

0 commit comments

Comments
 (0)