2 * Copyright (C) 2008-2010
4 * - Kurt Van Dijck, EIA Electronics
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the version 2 of the GNU General Public License
8 * as published by the Free Software Foundation
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, see <http://www.gnu.org/licenses/>.
19 #include <linux/module.h>
20 #include <linux/interrupt.h>
25 #define TX_ECHO_SKB_MAX (((TXMAX+1)/2)-1)
28 * test is a specific CAN netdev
29 * is online (ie. up 'n running, not sleeping, not busoff
31 static inline int canif_is_active(struct net_device
*netdev
)
33 struct can_priv
*can
= netdev_priv(netdev
);
35 if (!netif_running(netdev
))
37 return (can
->state
<= CAN_STATE_ERROR_PASSIVE
);
41 static inline void softing_set_reset_dpram(struct softing
*card
)
43 if (card
->pdat
->generation
>= 2) {
44 spin_lock_bh(&card
->spin
);
45 iowrite8(ioread8(&card
->dpram
[DPRAM_V2_RESET
]) & ~1,
46 &card
->dpram
[DPRAM_V2_RESET
]);
47 spin_unlock_bh(&card
->spin
);
51 static inline void softing_clr_reset_dpram(struct softing
*card
)
53 if (card
->pdat
->generation
>= 2) {
54 spin_lock_bh(&card
->spin
);
55 iowrite8(ioread8(&card
->dpram
[DPRAM_V2_RESET
]) | 1,
56 &card
->dpram
[DPRAM_V2_RESET
]);
57 spin_unlock_bh(&card
->spin
);
61 /* trigger the tx queue-ing */
62 static netdev_tx_t
softing_netdev_start_xmit(struct sk_buff
*skb
,
63 struct net_device
*dev
)
65 struct softing_priv
*priv
= netdev_priv(dev
);
66 struct softing
*card
= priv
->card
;
69 uint8_t fifo_wr
, fifo_rd
;
70 struct can_frame
*cf
= (struct can_frame
*)skb
->data
;
71 uint8_t buf
[DPRAM_TX_SIZE
];
73 if (can_dropped_invalid_skb(dev
, skb
))
76 spin_lock(&card
->spin
);
80 (card
->tx
.pending
>= TXMAX
) ||
81 (priv
->tx
.pending
>= TX_ECHO_SKB_MAX
))
83 fifo_wr
= ioread8(&card
->dpram
[DPRAM_TX_WR
]);
84 fifo_rd
= ioread8(&card
->dpram
[DPRAM_TX_RD
]);
85 if (fifo_wr
== fifo_rd
)
88 memset(buf
, 0, sizeof(buf
));
91 if (cf
->can_id
& CAN_RTR_FLAG
)
93 if (cf
->can_id
& CAN_EFF_FLAG
)
99 *ptr
++ = (cf
->can_id
>> 0);
100 *ptr
++ = (cf
->can_id
>> 8);
101 if (cf
->can_id
& CAN_EFF_FLAG
) {
102 *ptr
++ = (cf
->can_id
>> 16);
103 *ptr
++ = (cf
->can_id
>> 24);
105 /* increment 1, not 2 as you might think */
108 if (!(cf
->can_id
& CAN_RTR_FLAG
))
109 memcpy(ptr
, &cf
->data
[0], cf
->can_dlc
);
110 memcpy_toio(&card
->dpram
[DPRAM_TX
+ DPRAM_TX_SIZE
* fifo_wr
],
112 if (++fifo_wr
>= DPRAM_TX_CNT
)
114 iowrite8(fifo_wr
, &card
->dpram
[DPRAM_TX_WR
]);
115 card
->tx
.last_bus
= priv
->index
;
118 can_put_echo_skb(skb
, dev
, priv
->tx
.echo_put
);
120 if (priv
->tx
.echo_put
>= TX_ECHO_SKB_MAX
)
121 priv
->tx
.echo_put
= 0;
122 /* can_put_echo_skb() saves the skb, safe to return TX_OK */
125 spin_unlock(&card
->spin
);
126 if (card
->tx
.pending
>= TXMAX
) {
128 for (j
= 0; j
< ARRAY_SIZE(card
->net
); ++j
) {
130 netif_stop_queue(card
->net
[j
]);
133 if (ret
!= NETDEV_TX_OK
)
134 netif_stop_queue(dev
);
140 * shortcut for skb delivery
142 int softing_netdev_rx(struct net_device
*netdev
, const struct can_frame
*msg
,
146 struct can_frame
*cf
;
148 skb
= alloc_can_skb(netdev
, &cf
);
151 memcpy(cf
, msg
, sizeof(*msg
));
153 return netif_rx(skb
);
158 * pop 1 entry from the DPRAM queue, and process
160 static int softing_handle_1(struct softing
*card
)
162 struct net_device
*netdev
;
163 struct softing_priv
*priv
;
165 struct can_frame msg
;
166 int cnt
= 0, lost_msg
;
167 uint8_t fifo_rd
, fifo_wr
, cmd
;
170 uint8_t buf
[DPRAM_RX_SIZE
];
172 memset(&msg
, 0, sizeof(msg
));
173 /* test for lost msgs */
174 lost_msg
= ioread8(&card
->dpram
[DPRAM_RX_LOST
]);
177 /* reset condition */
178 iowrite8(0, &card
->dpram
[DPRAM_RX_LOST
]);
180 msg
.can_id
= CAN_ERR_FLAG
| CAN_ERR_CRTL
;
181 msg
.can_dlc
= CAN_ERR_DLC
;
182 msg
.data
[1] = CAN_ERR_CRTL_RX_OVERFLOW
;
184 * service to all busses, we don't know which it was applicable
185 * but only service busses that are online
187 for (j
= 0; j
< ARRAY_SIZE(card
->net
); ++j
) {
188 netdev
= card
->net
[j
];
191 if (!canif_is_active(netdev
))
192 /* a dead bus has no overflows */
194 ++netdev
->stats
.rx_over_errors
;
195 softing_netdev_rx(netdev
, &msg
, ktime_set(0, 0));
197 /* prepare for other use */
198 memset(&msg
, 0, sizeof(msg
));
202 fifo_rd
= ioread8(&card
->dpram
[DPRAM_RX_RD
]);
203 fifo_wr
= ioread8(&card
->dpram
[DPRAM_RX_WR
]);
205 if (++fifo_rd
>= DPRAM_RX_CNT
)
207 if (fifo_wr
== fifo_rd
)
210 memcpy_fromio(buf
, &card
->dpram
[DPRAM_RX
+ DPRAM_RX_SIZE
*fifo_rd
],
213 /* trigger dual port RAM */
214 iowrite8(fifo_rd
, &card
->dpram
[DPRAM_RX_RD
]);
219 /* not quite useful, probably the card has got out */
221 netdev
= card
->net
[0];
223 netdev
= card
->net
[1];
224 priv
= netdev_priv(netdev
);
227 uint8_t can_state
, state
;
231 msg
.can_id
= CAN_ERR_FLAG
;
232 msg
.can_dlc
= CAN_ERR_DLC
;
234 if (state
& SF_MASK_BUSOFF
) {
235 can_state
= CAN_STATE_BUS_OFF
;
236 msg
.can_id
|= CAN_ERR_BUSOFF
;
237 state
= STATE_BUSOFF
;
238 } else if (state
& SF_MASK_EPASSIVE
) {
239 can_state
= CAN_STATE_ERROR_PASSIVE
;
240 msg
.can_id
|= CAN_ERR_CRTL
;
241 msg
.data
[1] = CAN_ERR_CRTL_TX_PASSIVE
;
242 state
= STATE_EPASSIVE
;
244 can_state
= CAN_STATE_ERROR_ACTIVE
;
245 msg
.can_id
|= CAN_ERR_CRTL
;
246 state
= STATE_EACTIVE
;
249 iowrite8(state
, &card
->dpram
[priv
->index
?
250 DPRAM_INFO_BUSSTATE2
: DPRAM_INFO_BUSSTATE
]);
252 tmp_u32
= le32_to_cpup((void *)ptr
);
254 ktime
= softing_raw2ktime(card
, tmp_u32
);
256 ++netdev
->stats
.rx_errors
;
257 /* update internal status */
258 if (can_state
!= priv
->can
.state
) {
259 priv
->can
.state
= can_state
;
260 if (can_state
== CAN_STATE_ERROR_PASSIVE
)
261 ++priv
->can
.can_stats
.error_passive
;
262 else if (can_state
== CAN_STATE_BUS_OFF
) {
263 /* this calls can_close_cleanup() */
265 netif_stop_queue(netdev
);
267 /* trigger socketcan */
268 softing_netdev_rx(netdev
, &msg
, ktime
);
273 msg
.can_id
|= CAN_RTR_FLAG
;
274 msg
.can_dlc
= get_can_dlc(*ptr
++);
276 msg
.can_id
|= CAN_EFF_FLAG
;
277 msg
.can_id
|= le32_to_cpup((void *)ptr
);
280 msg
.can_id
|= le16_to_cpup((void *)ptr
);
284 tmp_u32
= le32_to_cpup((void *)ptr
);
286 ktime
= softing_raw2ktime(card
, tmp_u32
);
287 if (!(msg
.can_id
& CAN_RTR_FLAG
))
288 memcpy(&msg
.data
[0], ptr
, 8);
292 /* acknowledge, was tx msg */
294 skb
= priv
->can
.echo_skb
[priv
->tx
.echo_get
];
297 can_get_echo_skb(netdev
, priv
->tx
.echo_get
);
299 if (priv
->tx
.echo_get
>= TX_ECHO_SKB_MAX
)
300 priv
->tx
.echo_get
= 0;
301 if (priv
->tx
.pending
)
303 if (card
->tx
.pending
)
305 ++netdev
->stats
.tx_packets
;
306 if (!(msg
.can_id
& CAN_RTR_FLAG
))
307 netdev
->stats
.tx_bytes
+= msg
.can_dlc
;
311 ret
= softing_netdev_rx(netdev
, &msg
, ktime
);
312 if (ret
== NET_RX_SUCCESS
) {
313 ++netdev
->stats
.rx_packets
;
314 if (!(msg
.can_id
& CAN_RTR_FLAG
))
315 netdev
->stats
.rx_bytes
+= msg
.can_dlc
;
317 ++netdev
->stats
.rx_dropped
;
326 * real interrupt handler
328 static irqreturn_t
softing_irq_thread(int irq
, void *dev_id
)
330 struct softing
*card
= (struct softing
*)dev_id
;
331 struct net_device
*netdev
;
332 struct softing_priv
*priv
;
333 int j
, offset
, work_done
;
336 spin_lock_bh(&card
->spin
);
337 while (softing_handle_1(card
) > 0) {
338 ++card
->irq
.svc_count
;
341 spin_unlock_bh(&card
->spin
);
342 /* resume tx queue's */
343 offset
= card
->tx
.last_bus
;
344 for (j
= 0; j
< ARRAY_SIZE(card
->net
); ++j
) {
345 if (card
->tx
.pending
>= TXMAX
)
347 netdev
= card
->net
[(j
+ offset
+ 1) % card
->pdat
->nbus
];
350 priv
= netdev_priv(netdev
);
351 if (!canif_is_active(netdev
))
352 /* it makes no sense to wake dead busses */
354 if (priv
->tx
.pending
>= TX_ECHO_SKB_MAX
)
357 netif_wake_queue(netdev
);
359 return work_done
? IRQ_HANDLED
: IRQ_NONE
;
363 * interrupt routines:
364 * schedule the 'real interrupt handler'
366 static irqreturn_t
softing_irq_v2(int irq
, void *dev_id
)
368 struct softing
*card
= (struct softing
*)dev_id
;
371 ir
= ioread8(&card
->dpram
[DPRAM_V2_IRQ_TOHOST
]);
372 iowrite8(0, &card
->dpram
[DPRAM_V2_IRQ_TOHOST
]);
373 return (1 == ir
) ? IRQ_WAKE_THREAD
: IRQ_NONE
;
376 static irqreturn_t
softing_irq_v1(int irq
, void *dev_id
)
378 struct softing
*card
= (struct softing
*)dev_id
;
381 ir
= ioread8(&card
->dpram
[DPRAM_IRQ_TOHOST
]);
382 iowrite8(0, &card
->dpram
[DPRAM_IRQ_TOHOST
]);
383 return ir
? IRQ_WAKE_THREAD
: IRQ_NONE
;
387 * netdev/candev inter-operability
389 static int softing_netdev_open(struct net_device
*ndev
)
393 /* check or determine and set bittime */
394 ret
= open_candev(ndev
);
396 ret
= softing_startstop(ndev
, 1);
400 static int softing_netdev_stop(struct net_device
*ndev
)
404 netif_stop_queue(ndev
);
406 /* softing cycle does close_candev() */
407 ret
= softing_startstop(ndev
, 0);
411 static int softing_candev_set_mode(struct net_device
*ndev
, enum can_mode mode
)
417 /* softing_startstop does close_candev() */
418 ret
= softing_startstop(ndev
, 1);
428 * Softing device management helpers
430 int softing_enable_irq(struct softing
*card
, int enable
)
436 } else if (card
->irq
.requested
&& !enable
) {
437 free_irq(card
->irq
.nr
, card
);
438 card
->irq
.requested
= 0;
439 } else if (!card
->irq
.requested
&& enable
) {
440 ret
= request_threaded_irq(card
->irq
.nr
,
441 (card
->pdat
->generation
>= 2) ?
442 softing_irq_v2
: softing_irq_v1
,
443 softing_irq_thread
, IRQF_SHARED
,
444 dev_name(&card
->pdev
->dev
), card
);
446 dev_alert(&card
->pdev
->dev
,
447 "request_threaded_irq(%u) failed\n",
451 card
->irq
.requested
= 1;
456 static void softing_card_shutdown(struct softing
*card
)
460 if (mutex_lock_interruptible(&card
->fw
.lock
))
461 /* return -ERESTARTSYS */;
465 if (card
->irq
.requested
&& card
->irq
.nr
) {
466 free_irq(card
->irq
.nr
, card
);
467 card
->irq
.requested
= 0;
470 if (card
->pdat
->enable_irq
)
471 card
->pdat
->enable_irq(card
->pdev
, 0);
472 softing_set_reset_dpram(card
);
473 if (card
->pdat
->reset
)
474 card
->pdat
->reset(card
->pdev
, 1);
476 mutex_unlock(&card
->fw
.lock
);
479 static int softing_card_boot(struct softing
*card
)
482 static const uint8_t stream
[] = {
483 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, };
484 unsigned char back
[sizeof(stream
)];
486 if (mutex_lock_interruptible(&card
->fw
.lock
))
489 mutex_unlock(&card
->fw
.lock
);
493 if (card
->pdat
->enable_irq
)
494 card
->pdat
->enable_irq(card
->pdev
, 1);
496 softing_set_reset_dpram(card
);
497 if (card
->pdat
->reset
)
498 card
->pdat
->reset(card
->pdev
, 1);
499 for (j
= 0; (j
+ sizeof(stream
)) < card
->dpram_size
;
500 j
+= sizeof(stream
)) {
502 memcpy_toio(&card
->dpram
[j
], stream
, sizeof(stream
));
505 memcpy_fromio(back
, &card
->dpram
[j
], sizeof(stream
));
507 if (!memcmp(back
, stream
, sizeof(stream
)))
509 /* memory is not equal */
510 dev_alert(&card
->pdev
->dev
, "dpram failed at 0x%04x\n", j
);
515 /* load boot firmware */
516 ret
= softing_load_fw(card
->pdat
->boot
.fw
, card
, card
->dpram
,
518 card
->pdat
->boot
.offs
- card
->pdat
->boot
.addr
);
521 /* load loader firmware */
522 ret
= softing_load_fw(card
->pdat
->load
.fw
, card
, card
->dpram
,
524 card
->pdat
->load
.offs
- card
->pdat
->load
.addr
);
528 if (card
->pdat
->reset
)
529 card
->pdat
->reset(card
->pdev
, 0);
530 softing_clr_reset_dpram(card
);
531 ret
= softing_bootloader_command(card
, 0, "card boot");
534 ret
= softing_load_app_fw(card
->pdat
->app
.fw
, card
);
538 ret
= softing_chip_poweron(card
);
543 mutex_unlock(&card
->fw
.lock
);
547 if (card
->pdat
->enable_irq
)
548 card
->pdat
->enable_irq(card
->pdev
, 0);
549 softing_set_reset_dpram(card
);
550 if (card
->pdat
->reset
)
551 card
->pdat
->reset(card
->pdev
, 1);
552 mutex_unlock(&card
->fw
.lock
);
559 static ssize_t
show_chip(struct device
*dev
, struct device_attribute
*attr
,
562 struct net_device
*ndev
= to_net_dev(dev
);
563 struct softing_priv
*priv
= netdev2softing(ndev
);
565 return sprintf(buf
, "%i\n", priv
->chip
);
568 static ssize_t
show_output(struct device
*dev
, struct device_attribute
*attr
,
571 struct net_device
*ndev
= to_net_dev(dev
);
572 struct softing_priv
*priv
= netdev2softing(ndev
);
574 return sprintf(buf
, "0x%02x\n", priv
->output
);
577 static ssize_t
store_output(struct device
*dev
, struct device_attribute
*attr
,
578 const char *buf
, size_t count
)
580 struct net_device
*ndev
= to_net_dev(dev
);
581 struct softing_priv
*priv
= netdev2softing(ndev
);
582 struct softing
*card
= priv
->card
;
586 ret
= kstrtoul(buf
, 0, &val
);
591 ret
= mutex_lock_interruptible(&card
->fw
.lock
);
594 if (netif_running(ndev
)) {
595 mutex_unlock(&card
->fw
.lock
);
599 mutex_unlock(&card
->fw
.lock
);
603 static const DEVICE_ATTR(chip
, S_IRUGO
, show_chip
, NULL
);
604 static const DEVICE_ATTR(output
, S_IRUGO
| S_IWUSR
, show_output
, store_output
);
606 static const struct attribute
*const netdev_sysfs_attrs
[] = {
608 &dev_attr_output
.attr
,
611 static const struct attribute_group netdev_sysfs_group
= {
613 .attrs
= (struct attribute
**)netdev_sysfs_attrs
,
616 static const struct net_device_ops softing_netdev_ops
= {
617 .ndo_open
= softing_netdev_open
,
618 .ndo_stop
= softing_netdev_stop
,
619 .ndo_start_xmit
= softing_netdev_start_xmit
,
620 .ndo_change_mtu
= can_change_mtu
,
623 static const struct can_bittiming_const softing_btr_const
= {
629 .sjw_max
= 4, /* overruled */
631 .brp_max
= 32, /* overruled */
636 static struct net_device
*softing_netdev_create(struct softing
*card
,
639 struct net_device
*netdev
;
640 struct softing_priv
*priv
;
642 netdev
= alloc_candev(sizeof(*priv
), TX_ECHO_SKB_MAX
);
644 dev_alert(&card
->pdev
->dev
, "alloc_candev failed\n");
647 priv
= netdev_priv(netdev
);
648 priv
->netdev
= netdev
;
650 memcpy(&priv
->btr_const
, &softing_btr_const
, sizeof(priv
->btr_const
));
651 priv
->btr_const
.brp_max
= card
->pdat
->max_brp
;
652 priv
->btr_const
.sjw_max
= card
->pdat
->max_sjw
;
653 priv
->can
.bittiming_const
= &priv
->btr_const
;
654 priv
->can
.clock
.freq
= 8000000;
655 priv
->chip
= chip_id
;
656 priv
->output
= softing_default_output(netdev
);
657 SET_NETDEV_DEV(netdev
, &card
->pdev
->dev
);
659 netdev
->flags
|= IFF_ECHO
;
660 netdev
->netdev_ops
= &softing_netdev_ops
;
661 priv
->can
.do_set_mode
= softing_candev_set_mode
;
662 priv
->can
.ctrlmode_supported
= CAN_CTRLMODE_3_SAMPLES
;
667 static int softing_netdev_register(struct net_device
*netdev
)
671 ret
= register_candev(netdev
);
673 dev_alert(&netdev
->dev
, "register failed\n");
676 if (sysfs_create_group(&netdev
->dev
.kobj
, &netdev_sysfs_group
) < 0)
677 netdev_alert(netdev
, "sysfs group failed\n");
682 static void softing_netdev_cleanup(struct net_device
*netdev
)
684 sysfs_remove_group(&netdev
->dev
.kobj
, &netdev_sysfs_group
);
685 unregister_candev(netdev
);
690 * sysfs for Platform device
692 #define DEV_ATTR_RO(name, member) \
693 static ssize_t show_##name(struct device *dev, \
694 struct device_attribute *attr, char *buf) \
696 struct softing *card = platform_get_drvdata(to_platform_device(dev)); \
697 return sprintf(buf, "%u\n", card->member); \
699 static DEVICE_ATTR(name, 0444, show_##name, NULL)
701 #define DEV_ATTR_RO_STR(name, member) \
702 static ssize_t show_##name(struct device *dev, \
703 struct device_attribute *attr, char *buf) \
705 struct softing *card = platform_get_drvdata(to_platform_device(dev)); \
706 return sprintf(buf, "%s\n", card->member); \
708 static DEVICE_ATTR(name, 0444, show_##name, NULL)
710 DEV_ATTR_RO(serial
, id
.serial
);
711 DEV_ATTR_RO_STR(firmware
, pdat
->app
.fw
);
712 DEV_ATTR_RO(firmware_version
, id
.fw_version
);
713 DEV_ATTR_RO_STR(hardware
, pdat
->name
);
714 DEV_ATTR_RO(hardware_version
, id
.hw_version
);
715 DEV_ATTR_RO(license
, id
.license
);
717 static struct attribute
*softing_pdev_attrs
[] = {
718 &dev_attr_serial
.attr
,
719 &dev_attr_firmware
.attr
,
720 &dev_attr_firmware_version
.attr
,
721 &dev_attr_hardware
.attr
,
722 &dev_attr_hardware_version
.attr
,
723 &dev_attr_license
.attr
,
727 static const struct attribute_group softing_pdev_group
= {
729 .attrs
= softing_pdev_attrs
,
735 static int softing_pdev_remove(struct platform_device
*pdev
)
737 struct softing
*card
= platform_get_drvdata(pdev
);
740 /* first, disable card*/
741 softing_card_shutdown(card
);
743 for (j
= 0; j
< ARRAY_SIZE(card
->net
); ++j
) {
746 softing_netdev_cleanup(card
->net
[j
]);
749 sysfs_remove_group(&pdev
->dev
.kobj
, &softing_pdev_group
);
751 iounmap(card
->dpram
);
756 static int softing_pdev_probe(struct platform_device
*pdev
)
758 const struct softing_platform_data
*pdat
= dev_get_platdata(&pdev
->dev
);
759 struct softing
*card
;
760 struct net_device
*netdev
;
761 struct softing_priv
*priv
;
762 struct resource
*pres
;
767 dev_warn(&pdev
->dev
, "no platform data\n");
770 if (pdat
->nbus
> ARRAY_SIZE(card
->net
)) {
771 dev_warn(&pdev
->dev
, "%u nets??\n", pdat
->nbus
);
775 card
= kzalloc(sizeof(*card
), GFP_KERNEL
);
780 platform_set_drvdata(pdev
, card
);
781 mutex_init(&card
->fw
.lock
);
782 spin_lock_init(&card
->spin
);
785 pres
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
787 goto platform_resource_failed
;
788 card
->dpram_phys
= pres
->start
;
789 card
->dpram_size
= resource_size(pres
);
790 card
->dpram
= ioremap_nocache(card
->dpram_phys
, card
->dpram_size
);
792 dev_alert(&card
->pdev
->dev
, "dpram ioremap failed\n");
796 pres
= platform_get_resource(pdev
, IORESOURCE_IRQ
, 0);
798 card
->irq
.nr
= pres
->start
;
801 ret
= softing_card_boot(card
);
803 dev_alert(&pdev
->dev
, "failed to boot\n");
807 /* only now, the chip's are known */
808 card
->id
.freq
= card
->pdat
->freq
;
810 ret
= sysfs_create_group(&pdev
->dev
.kobj
, &softing_pdev_group
);
812 dev_alert(&card
->pdev
->dev
, "sysfs failed\n");
816 for (j
= 0; j
< ARRAY_SIZE(card
->net
); ++j
) {
817 card
->net
[j
] = netdev
=
818 softing_netdev_create(card
, card
->id
.chip
[j
]);
820 dev_alert(&pdev
->dev
, "failed to make can[%i]", j
);
825 priv
= netdev_priv(card
->net
[j
]);
827 ret
= softing_netdev_register(netdev
);
831 dev_alert(&card
->pdev
->dev
,
832 "failed to register can[%i]\n", j
);
836 dev_info(&card
->pdev
->dev
, "%s ready.\n", card
->pdat
->name
);
840 for (j
= 0; j
< ARRAY_SIZE(card
->net
); ++j
) {
843 softing_netdev_cleanup(card
->net
[j
]);
845 sysfs_remove_group(&pdev
->dev
.kobj
, &softing_pdev_group
);
847 softing_card_shutdown(card
);
849 iounmap(card
->dpram
);
851 platform_resource_failed
:
856 static struct platform_driver softing_driver
= {
860 .probe
= softing_pdev_probe
,
861 .remove
= softing_pdev_remove
,
864 module_platform_driver(softing_driver
);
866 MODULE_ALIAS("platform:softing");
867 MODULE_DESCRIPTION("Softing DPRAM CAN driver");
868 MODULE_AUTHOR("Kurt Van Dijck <kurt.van.dijck@eia.be>");
869 MODULE_LICENSE("GPL v2");