sja1000.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  1. /*
  2. * sja1000.c - Philips SJA1000 network device driver
  3. *
  4. * Copyright (c) 2003 Matthias Brukner, Trajet Gmbh, Rebenring 33,
  5. * 38106 Braunschweig, GERMANY
  6. *
  7. * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
  8. * All rights reserved.
  9. *
  10. * Redistribution and use in source and binary forms, with or without
  11. * modification, are permitted provided that the following conditions
  12. * are met:
  13. * 1. Redistributions of source code must retain the above copyright
  14. * notice, this list of conditions and the following disclaimer.
  15. * 2. Redistributions in binary form must reproduce the above copyright
  16. * notice, this list of conditions and the following disclaimer in the
  17. * documentation and/or other materials provided with the distribution.
  18. * 3. Neither the name of Volkswagen nor the names of its contributors
  19. * may be used to endorse or promote products derived from this software
  20. * without specific prior written permission.
  21. *
  22. * Alternatively, provided that this notice is retained in full, this
  23. * software may be distributed under the terms of the GNU General
  24. * Public License ("GPL") version 2, in which case the provisions of the
  25. * GPL apply INSTEAD OF those given above.
  26. *
  27. * The provided data structures and external interfaces from this code
  28. * are not restricted to be used by modules with a GPL compatible license.
  29. *
  30. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  31. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  32. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  33. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  34. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  35. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  36. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  37. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  38. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  39. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  40. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
  41. * DAMAGE.
  42. *
  43. * Send feedback to <socketcan-users@lists.berlios.de>
  44. *
  45. */
  46. #include <linux/module.h>
  47. #include <linux/init.h>
  48. #include <linux/kernel.h>
  49. #include <linux/sched.h>
  50. #include <linux/types.h>
  51. #include <linux/fcntl.h>
  52. #include <linux/interrupt.h>
  53. #include <linux/ptrace.h>
  54. #include <linux/string.h>
  55. #include <linux/errno.h>
  56. #include <linux/netdevice.h>
  57. #include <linux/if_arp.h>
  58. #include <linux/if_ether.h>
  59. #include <linux/skbuff.h>
  60. #include <linux/delay.h>
  61. #include <linux/can.h>
  62. #include <linux/can/dev.h>
  63. #include <linux/can/error.h>
  64. #include "sja1000.h"
  65. #define DRV_NAME "sja1000"
  66. MODULE_AUTHOR("Oliver Hartkopp <oliver.hartkopp@volkswagen.de>");
  67. MODULE_LICENSE("Dual BSD/GPL");
  68. MODULE_DESCRIPTION(DRV_NAME "CAN netdevice driver");
  69. static struct can_bittiming_const sja1000_bittiming_const = {
  70. .name = DRV_NAME,
  71. .tseg1_min = 1,
  72. .tseg1_max = 16,
  73. .tseg2_min = 1,
  74. .tseg2_max = 8,
  75. .sjw_max = 4,
  76. .brp_min = 1,
  77. .brp_max = 64,
  78. .brp_inc = 1,
  79. };
  80. static int sja1000_probe_chip(struct net_device *dev)
  81. {
  82. struct sja1000_priv *priv = netdev_priv(dev);
  83. if (priv->reg_base && (priv->read_reg(priv, 0) == 0xFF)) {
  84. printk(KERN_INFO "%s: probing @0x%lX failed\n",
  85. DRV_NAME, dev->base_addr);
  86. return 0;
  87. }
  88. return -1;
  89. }
  90. static void set_reset_mode(struct net_device *dev)
  91. {
  92. struct sja1000_priv *priv = netdev_priv(dev);
  93. unsigned char status = priv->read_reg(priv, REG_MOD);
  94. int i;
  95. /* disable interrupts */
  96. priv->write_reg(priv, REG_IER, IRQ_OFF);
  97. for (i = 0; i < 100; i++) {
  98. /* check reset bit */
  99. if (status & MOD_RM) {
  100. priv->can.state = CAN_STATE_STOPPED;
  101. return;
  102. }
  103. priv->write_reg(priv, REG_MOD, MOD_RM); /* reset chip */
  104. udelay(10);
  105. status = priv->read_reg(priv, REG_MOD);
  106. }
  107. dev_err(dev->dev.parent, "setting SJA1000 into reset mode failed!\n");
  108. }
  109. static void set_normal_mode(struct net_device *dev)
  110. {
  111. struct sja1000_priv *priv = netdev_priv(dev);
  112. unsigned char status = priv->read_reg(priv, REG_MOD);
  113. int i;
  114. for (i = 0; i < 100; i++) {
  115. /* check reset bit */
  116. if ((status & MOD_RM) == 0) {
  117. priv->can.state = CAN_STATE_ERROR_ACTIVE;
  118. /* enable all interrupts */
  119. priv->write_reg(priv, REG_IER, IRQ_ALL);
  120. return;
  121. }
  122. /* set chip to normal mode */
  123. priv->write_reg(priv, REG_MOD, 0x00);
  124. udelay(10);
  125. status = priv->read_reg(priv, REG_MOD);
  126. }
  127. dev_err(dev->dev.parent, "setting SJA1000 into normal mode failed!\n");
  128. }
  129. static void sja1000_start(struct net_device *dev)
  130. {
  131. struct sja1000_priv *priv = netdev_priv(dev);
  132. /* leave reset mode */
  133. if (priv->can.state != CAN_STATE_STOPPED)
  134. set_reset_mode(dev);
  135. /* Clear error counters and error code capture */
  136. priv->write_reg(priv, REG_TXERR, 0x0);
  137. priv->write_reg(priv, REG_RXERR, 0x0);
  138. priv->read_reg(priv, REG_ECC);
  139. /* leave reset mode */
  140. set_normal_mode(dev);
  141. }
  142. static int sja1000_set_mode(struct net_device *dev, enum can_mode mode)
  143. {
  144. struct sja1000_priv *priv = netdev_priv(dev);
  145. if (!priv->open_time)
  146. return -EINVAL;
  147. switch (mode) {
  148. case CAN_MODE_START:
  149. sja1000_start(dev);
  150. if (netif_queue_stopped(dev))
  151. netif_wake_queue(dev);
  152. break;
  153. default:
  154. return -EOPNOTSUPP;
  155. }
  156. return 0;
  157. }
  158. static int sja1000_set_bittiming(struct net_device *dev)
  159. {
  160. struct sja1000_priv *priv = netdev_priv(dev);
  161. struct can_bittiming *bt = &priv->can.bittiming;
  162. u8 btr0, btr1;
  163. btr0 = ((bt->brp - 1) & 0x3f) | (((bt->sjw - 1) & 0x3) << 6);
  164. btr1 = ((bt->prop_seg + bt->phase_seg1 - 1) & 0xf) |
  165. (((bt->phase_seg2 - 1) & 0x7) << 4);
  166. if (priv->can.ctrlmode & CAN_CTRLMODE_3_SAMPLES)
  167. btr1 |= 0x80;
  168. dev_info(dev->dev.parent,
  169. "setting BTR0=0x%02x BTR1=0x%02x\n", btr0, btr1);
  170. priv->write_reg(priv, REG_BTR0, btr0);
  171. priv->write_reg(priv, REG_BTR1, btr1);
  172. return 0;
  173. }
  174. /*
  175. * initialize SJA1000 chip:
  176. * - reset chip
  177. * - set output mode
  178. * - set baudrate
  179. * - enable interrupts
  180. * - start operating mode
  181. */
  182. static void chipset_init(struct net_device *dev)
  183. {
  184. struct sja1000_priv *priv = netdev_priv(dev);
  185. /* set clock divider and output control register */
  186. priv->write_reg(priv, REG_CDR, priv->cdr | CDR_PELICAN);
  187. /* set acceptance filter (accept all) */
  188. priv->write_reg(priv, REG_ACCC0, 0x00);
  189. priv->write_reg(priv, REG_ACCC1, 0x00);
  190. priv->write_reg(priv, REG_ACCC2, 0x00);
  191. priv->write_reg(priv, REG_ACCC3, 0x00);
  192. priv->write_reg(priv, REG_ACCM0, 0xFF);
  193. priv->write_reg(priv, REG_ACCM1, 0xFF);
  194. priv->write_reg(priv, REG_ACCM2, 0xFF);
  195. priv->write_reg(priv, REG_ACCM3, 0xFF);
  196. priv->write_reg(priv, REG_OCR, priv->ocr | OCR_MODE_NORMAL);
  197. }
  198. /*
  199. * transmit a CAN message
  200. * message layout in the sk_buff should be like this:
  201. * xx xx xx xx ff ll 00 11 22 33 44 55 66 77
  202. * [ can-id ] [flags] [len] [can data (up to 8 bytes]
  203. */
  204. static netdev_tx_t sja1000_start_xmit(struct sk_buff *skb,
  205. struct net_device *dev)
  206. {
  207. struct sja1000_priv *priv = netdev_priv(dev);
  208. struct can_frame *cf = (struct can_frame *)skb->data;
  209. uint8_t fi;
  210. uint8_t dlc;
  211. canid_t id;
  212. uint8_t dreg;
  213. int i;
  214. if (can_dropped_invalid_skb(dev, skb))
  215. return NETDEV_TX_OK;
  216. netif_stop_queue(dev);
  217. fi = dlc = cf->can_dlc;
  218. id = cf->can_id;
  219. if (id & CAN_RTR_FLAG)
  220. fi |= FI_RTR;
  221. if (id & CAN_EFF_FLAG) {
  222. fi |= FI_FF;
  223. dreg = EFF_BUF;
  224. priv->write_reg(priv, REG_FI, fi);
  225. priv->write_reg(priv, REG_ID1, (id & 0x1fe00000) >> (5 + 16));
  226. priv->write_reg(priv, REG_ID2, (id & 0x001fe000) >> (5 + 8));
  227. priv->write_reg(priv, REG_ID3, (id & 0x00001fe0) >> 5);
  228. priv->write_reg(priv, REG_ID4, (id & 0x0000001f) << 3);
  229. } else {
  230. dreg = SFF_BUF;
  231. priv->write_reg(priv, REG_FI, fi);
  232. priv->write_reg(priv, REG_ID1, (id & 0x000007f8) >> 3);
  233. priv->write_reg(priv, REG_ID2, (id & 0x00000007) << 5);
  234. }
  235. for (i = 0; i < dlc; i++)
  236. priv->write_reg(priv, dreg++, cf->data[i]);
  237. dev->trans_start = jiffies;
  238. can_put_echo_skb(skb, dev, 0);
  239. priv->write_reg(priv, REG_CMR, CMD_TR);
  240. return NETDEV_TX_OK;
  241. }
  242. static void sja1000_rx(struct net_device *dev)
  243. {
  244. struct sja1000_priv *priv = netdev_priv(dev);
  245. struct net_device_stats *stats = &dev->stats;
  246. struct can_frame *cf;
  247. struct sk_buff *skb;
  248. uint8_t fi;
  249. uint8_t dreg;
  250. canid_t id;
  251. int i;
  252. /* create zero'ed CAN frame buffer */
  253. skb = alloc_can_skb(dev, &cf);
  254. if (skb == NULL)
  255. return;
  256. fi = priv->read_reg(priv, REG_FI);
  257. if (fi & FI_FF) {
  258. /* extended frame format (EFF) */
  259. dreg = EFF_BUF;
  260. id = (priv->read_reg(priv, REG_ID1) << (5 + 16))
  261. | (priv->read_reg(priv, REG_ID2) << (5 + 8))
  262. | (priv->read_reg(priv, REG_ID3) << 5)
  263. | (priv->read_reg(priv, REG_ID4) >> 3);
  264. id |= CAN_EFF_FLAG;
  265. } else {
  266. /* standard frame format (SFF) */
  267. dreg = SFF_BUF;
  268. id = (priv->read_reg(priv, REG_ID1) << 3)
  269. | (priv->read_reg(priv, REG_ID2) >> 5);
  270. }
  271. if (fi & FI_RTR) {
  272. id |= CAN_RTR_FLAG;
  273. } else {
  274. cf->can_dlc = get_can_dlc(fi & 0x0F);
  275. for (i = 0; i < cf->can_dlc; i++)
  276. cf->data[i] = priv->read_reg(priv, dreg++);
  277. }
  278. cf->can_id = id;
  279. /* release receive buffer */
  280. priv->write_reg(priv, REG_CMR, CMD_RRB);
  281. netif_rx(skb);
  282. stats->rx_packets++;
  283. stats->rx_bytes += cf->can_dlc;
  284. }
  285. static int sja1000_err(struct net_device *dev, uint8_t isrc, uint8_t status)
  286. {
  287. struct sja1000_priv *priv = netdev_priv(dev);
  288. struct net_device_stats *stats = &dev->stats;
  289. struct can_frame *cf;
  290. struct sk_buff *skb;
  291. enum can_state state = priv->can.state;
  292. uint8_t ecc, alc;
  293. skb = alloc_can_err_skb(dev, &cf);
  294. if (skb == NULL)
  295. return -ENOMEM;
  296. if (isrc & IRQ_DOI) {
  297. /* data overrun interrupt */
  298. dev_dbg(dev->dev.parent, "data overrun interrupt\n");
  299. cf->can_id |= CAN_ERR_CRTL;
  300. cf->data[1] = CAN_ERR_CRTL_RX_OVERFLOW;
  301. stats->rx_over_errors++;
  302. stats->rx_errors++;
  303. priv->write_reg(priv, REG_CMR, CMD_CDO); /* clear bit */
  304. }
  305. if (isrc & IRQ_EI) {
  306. /* error warning interrupt */
  307. dev_dbg(dev->dev.parent, "error warning interrupt\n");
  308. if (status & SR_BS) {
  309. state = CAN_STATE_BUS_OFF;
  310. cf->can_id |= CAN_ERR_BUSOFF;
  311. can_bus_off(dev);
  312. } else if (status & SR_ES) {
  313. state = CAN_STATE_ERROR_WARNING;
  314. } else
  315. state = CAN_STATE_ERROR_ACTIVE;
  316. }
  317. if (isrc & IRQ_BEI) {
  318. /* bus error interrupt */
  319. priv->can.can_stats.bus_error++;
  320. stats->rx_errors++;
  321. ecc = priv->read_reg(priv, REG_ECC);
  322. cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR;
  323. switch (ecc & ECC_MASK) {
  324. case ECC_BIT:
  325. cf->data[2] |= CAN_ERR_PROT_BIT;
  326. break;
  327. case ECC_FORM:
  328. cf->data[2] |= CAN_ERR_PROT_FORM;
  329. break;
  330. case ECC_STUFF:
  331. cf->data[2] |= CAN_ERR_PROT_STUFF;
  332. break;
  333. default:
  334. cf->data[2] |= CAN_ERR_PROT_UNSPEC;
  335. cf->data[3] = ecc & ECC_SEG;
  336. break;
  337. }
  338. /* Error occured during transmission? */
  339. if ((ecc & ECC_DIR) == 0)
  340. cf->data[2] |= CAN_ERR_PROT_TX;
  341. }
  342. if (isrc & IRQ_EPI) {
  343. /* error passive interrupt */
  344. dev_dbg(dev->dev.parent, "error passive interrupt\n");
  345. if (status & SR_ES)
  346. state = CAN_STATE_ERROR_PASSIVE;
  347. else
  348. state = CAN_STATE_ERROR_ACTIVE;
  349. }
  350. if (isrc & IRQ_ALI) {
  351. /* arbitration lost interrupt */
  352. dev_dbg(dev->dev.parent, "arbitration lost interrupt\n");
  353. alc = priv->read_reg(priv, REG_ALC);
  354. priv->can.can_stats.arbitration_lost++;
  355. stats->tx_errors++;
  356. cf->can_id |= CAN_ERR_LOSTARB;
  357. cf->data[0] = alc & 0x1f;
  358. }
  359. if (state != priv->can.state && (state == CAN_STATE_ERROR_WARNING ||
  360. state == CAN_STATE_ERROR_PASSIVE)) {
  361. uint8_t rxerr = priv->read_reg(priv, REG_RXERR);
  362. uint8_t txerr = priv->read_reg(priv, REG_TXERR);
  363. cf->can_id |= CAN_ERR_CRTL;
  364. if (state == CAN_STATE_ERROR_WARNING) {
  365. priv->can.can_stats.error_warning++;
  366. cf->data[1] = (txerr > rxerr) ?
  367. CAN_ERR_CRTL_TX_WARNING :
  368. CAN_ERR_CRTL_RX_WARNING;
  369. } else {
  370. priv->can.can_stats.error_passive++;
  371. cf->data[1] = (txerr > rxerr) ?
  372. CAN_ERR_CRTL_TX_PASSIVE :
  373. CAN_ERR_CRTL_RX_PASSIVE;
  374. }
  375. }
  376. priv->can.state = state;
  377. netif_rx(skb);
  378. stats->rx_packets++;
  379. stats->rx_bytes += cf->can_dlc;
  380. return 0;
  381. }
  382. irqreturn_t sja1000_interrupt(int irq, void *dev_id)
  383. {
  384. struct net_device *dev = (struct net_device *)dev_id;
  385. struct sja1000_priv *priv = netdev_priv(dev);
  386. struct net_device_stats *stats = &dev->stats;
  387. uint8_t isrc, status;
  388. int n = 0;
  389. /* Shared interrupts and IRQ off? */
  390. if (priv->read_reg(priv, REG_IER) == IRQ_OFF)
  391. return IRQ_NONE;
  392. if (priv->pre_irq)
  393. priv->pre_irq(priv);
  394. while ((isrc = priv->read_reg(priv, REG_IR)) && (n < SJA1000_MAX_IRQ)) {
  395. n++;
  396. status = priv->read_reg(priv, REG_SR);
  397. if (isrc & IRQ_WUI)
  398. dev_warn(dev->dev.parent, "wakeup interrupt\n");
  399. if (isrc & IRQ_TI) {
  400. /* transmission complete interrupt */
  401. stats->tx_bytes += priv->read_reg(priv, REG_FI) & 0xf;
  402. stats->tx_packets++;
  403. can_get_echo_skb(dev, 0);
  404. netif_wake_queue(dev);
  405. }
  406. if (isrc & IRQ_RI) {
  407. /* receive interrupt */
  408. while (status & SR_RBS) {
  409. sja1000_rx(dev);
  410. status = priv->read_reg(priv, REG_SR);
  411. }
  412. }
  413. if (isrc & (IRQ_DOI | IRQ_EI | IRQ_BEI | IRQ_EPI | IRQ_ALI)) {
  414. /* error interrupt */
  415. if (sja1000_err(dev, isrc, status))
  416. break;
  417. }
  418. }
  419. if (priv->post_irq)
  420. priv->post_irq(priv);
  421. if (n >= SJA1000_MAX_IRQ)
  422. dev_dbg(dev->dev.parent, "%d messages handled in ISR", n);
  423. return (n) ? IRQ_HANDLED : IRQ_NONE;
  424. }
  425. EXPORT_SYMBOL_GPL(sja1000_interrupt);
  426. static int sja1000_open(struct net_device *dev)
  427. {
  428. struct sja1000_priv *priv = netdev_priv(dev);
  429. int err;
  430. /* set chip into reset mode */
  431. set_reset_mode(dev);
  432. /* common open */
  433. err = open_candev(dev);
  434. if (err)
  435. return err;
  436. /* register interrupt handler, if not done by the device driver */
  437. if (!(priv->flags & SJA1000_CUSTOM_IRQ_HANDLER)) {
  438. err = request_irq(dev->irq, sja1000_interrupt, priv->irq_flags,
  439. dev->name, (void *)dev);
  440. if (err) {
  441. close_candev(dev);
  442. return -EAGAIN;
  443. }
  444. }
  445. /* init and start chi */
  446. sja1000_start(dev);
  447. priv->open_time = jiffies;
  448. netif_start_queue(dev);
  449. return 0;
  450. }
  451. static int sja1000_close(struct net_device *dev)
  452. {
  453. struct sja1000_priv *priv = netdev_priv(dev);
  454. netif_stop_queue(dev);
  455. set_reset_mode(dev);
  456. if (!(priv->flags & SJA1000_CUSTOM_IRQ_HANDLER))
  457. free_irq(dev->irq, (void *)dev);
  458. close_candev(dev);
  459. priv->open_time = 0;
  460. return 0;
  461. }
  462. struct net_device *alloc_sja1000dev(int sizeof_priv)
  463. {
  464. struct net_device *dev;
  465. struct sja1000_priv *priv;
  466. dev = alloc_candev(sizeof(struct sja1000_priv) + sizeof_priv,
  467. SJA1000_ECHO_SKB_MAX);
  468. if (!dev)
  469. return NULL;
  470. priv = netdev_priv(dev);
  471. priv->dev = dev;
  472. priv->can.bittiming_const = &sja1000_bittiming_const;
  473. priv->can.do_set_bittiming = sja1000_set_bittiming;
  474. priv->can.do_set_mode = sja1000_set_mode;
  475. priv->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES;
  476. if (sizeof_priv)
  477. priv->priv = (void *)priv + sizeof(struct sja1000_priv);
  478. return dev;
  479. }
  480. EXPORT_SYMBOL_GPL(alloc_sja1000dev);
  481. void free_sja1000dev(struct net_device *dev)
  482. {
  483. free_candev(dev);
  484. }
  485. EXPORT_SYMBOL_GPL(free_sja1000dev);
  486. static const struct net_device_ops sja1000_netdev_ops = {
  487. .ndo_open = sja1000_open,
  488. .ndo_stop = sja1000_close,
  489. .ndo_start_xmit = sja1000_start_xmit,
  490. };
  491. int register_sja1000dev(struct net_device *dev)
  492. {
  493. if (!sja1000_probe_chip(dev))
  494. return -ENODEV;
  495. dev->flags |= IFF_ECHO; /* we support local echo */
  496. dev->netdev_ops = &sja1000_netdev_ops;
  497. set_reset_mode(dev);
  498. chipset_init(dev);
  499. return register_candev(dev);
  500. }
  501. EXPORT_SYMBOL_GPL(register_sja1000dev);
  502. void unregister_sja1000dev(struct net_device *dev)
  503. {
  504. set_reset_mode(dev);
  505. unregister_candev(dev);
  506. }
  507. EXPORT_SYMBOL_GPL(unregister_sja1000dev);
  508. static __init int sja1000_init(void)
  509. {
  510. printk(KERN_INFO "%s CAN netdevice driver\n", DRV_NAME);
  511. return 0;
  512. }
  513. module_init(sja1000_init);
  514. static __exit void sja1000_exit(void)
  515. {
  516. printk(KERN_INFO "%s: driver removed\n", DRV_NAME);
  517. }
  518. module_exit(sja1000_exit);