| 1 |
// SPDX-License-Identifier: GPL-2.0-only |
| 2 |
/* |
| 3 |
* CAN driver for "8 devices" USB2CAN converter |
| 4 |
* |
| 5 |
* Copyright (C) 2012 Bernd Krumboeck ([email protected]) |
| 6 |
* |
| 7 |
* This driver is inspired by the 3.2.0 version of drivers/net/can/usb/ems_usb.c |
| 8 |
* and drivers/net/can/usb/esd_usb2.c |
| 9 |
* |
| 10 |
* Many thanks to Gerhard Bertelsmann ([email protected]) |
| 11 |
* for testing and fixing this driver. Also many thanks to "8 devices", |
| 12 |
* who were very cooperative and answered my questions. |
| 13 |
*/ |
| 14 |
|
| 15 |
#include <linux/ethtool.h> |
| 16 |
#include <linux/signal.h> |
| 17 |
#include <linux/slab.h> |
| 18 |
#include <linux/module.h> |
| 19 |
#include <linux/netdevice.h> |
| 20 |
#include <linux/usb.h> |
| 21 |
|
| 22 |
#include <linux/can.h> |
| 23 |
#include <linux/can/dev.h> |
| 24 |
#include <linux/can/error.h> |
| 25 |
|
| 26 |
/* driver constants */ |
| 27 |
#define MAX_RX_URBS 20 |
| 28 |
#define MAX_TX_URBS 20 |
| 29 |
#define RX_BUFFER_SIZE 64 |
| 30 |
|
| 31 |
/* vendor and product id */ |
| 32 |
#define USB_8DEV_VENDOR_ID 0x0483 |
| 33 |
#define USB_8DEV_PRODUCT_ID 0x1234 |
| 34 |
|
| 35 |
/* endpoints */ |
| 36 |
enum usb_8dev_endpoint { |
| 37 |
USB_8DEV_ENDP_DATA_RX = 1, |
| 38 |
USB_8DEV_ENDP_DATA_TX, |
| 39 |
USB_8DEV_ENDP_CMD_RX, |
| 40 |
USB_8DEV_ENDP_CMD_TX |
| 41 |
}; |
| 42 |
|
| 43 |
/* device CAN clock */ |
| 44 |
#define USB_8DEV_ABP_CLOCK 32000000 |
| 45 |
|
| 46 |
/* setup flags */ |
| 47 |
#define USB_8DEV_SILENT 0x01 |
| 48 |
#define USB_8DEV_LOOPBACK 0x02 |
| 49 |
#define USB_8DEV_DISABLE_AUTO_RESTRANS 0x04 |
| 50 |
#define USB_8DEV_STATUS_FRAME 0x08 |
| 51 |
|
| 52 |
/* commands */ |
| 53 |
enum usb_8dev_cmd { |
| 54 |
USB_8DEV_RESET = 1, |
| 55 |
USB_8DEV_OPEN, |
| 56 |
USB_8DEV_CLOSE, |
| 57 |
USB_8DEV_SET_SPEED, |
| 58 |
USB_8DEV_SET_MASK_FILTER, |
| 59 |
USB_8DEV_GET_STATUS, |
| 60 |
USB_8DEV_GET_STATISTICS, |
| 61 |
USB_8DEV_GET_SERIAL, |
| 62 |
USB_8DEV_GET_SOFTW_VER, |
| 63 |
USB_8DEV_GET_HARDW_VER, |
| 64 |
USB_8DEV_RESET_TIMESTAMP, |
| 65 |
USB_8DEV_GET_SOFTW_HARDW_VER |
| 66 |
}; |
| 67 |
|
| 68 |
/* command options */ |
| 69 |
#define USB_8DEV_BAUD_MANUAL 0x09 |
| 70 |
#define USB_8DEV_CMD_START 0x11 |
| 71 |
#define USB_8DEV_CMD_END 0x22 |
| 72 |
|
| 73 |
#define USB_8DEV_CMD_SUCCESS 0 |
| 74 |
#define USB_8DEV_CMD_ERROR 255 |
| 75 |
|
| 76 |
#define USB_8DEV_CMD_TIMEOUT 1000 |
| 77 |
|
| 78 |
/* frames */ |
| 79 |
#define USB_8DEV_DATA_START 0x55 |
| 80 |
#define USB_8DEV_DATA_END 0xAA |
| 81 |
|
| 82 |
#define USB_8DEV_TYPE_CAN_FRAME 0 |
| 83 |
#define USB_8DEV_TYPE_ERROR_FRAME 3 |
| 84 |
|
| 85 |
#define USB_8DEV_EXTID 0x01 |
| 86 |
#define USB_8DEV_RTR 0x02 |
| 87 |
#define USB_8DEV_ERR_FLAG 0x04 |
| 88 |
|
| 89 |
/* status */ |
| 90 |
#define USB_8DEV_STATUSMSG_OK 0x00 /* Normal condition. */ |
| 91 |
#define USB_8DEV_STATUSMSG_OVERRUN 0x01 /* Overrun occurred when sending */ |
| 92 |
#define USB_8DEV_STATUSMSG_BUSLIGHT 0x02 /* Error counter has reached 96 */ |
| 93 |
#define USB_8DEV_STATUSMSG_BUSHEAVY 0x03 /* Error count. has reached 128 */ |
| 94 |
#define USB_8DEV_STATUSMSG_BUSOFF 0x04 /* Device is in BUSOFF */ |
| 95 |
#define USB_8DEV_STATUSMSG_STUFF 0x20 /* Stuff Error */ |
| 96 |
#define USB_8DEV_STATUSMSG_FORM 0x21 /* Form Error */ |
| 97 |
#define USB_8DEV_STATUSMSG_ACK 0x23 /* Ack Error */ |
| 98 |
#define USB_8DEV_STATUSMSG_BIT0 0x24 /* Bit1 Error */ |
| 99 |
#define USB_8DEV_STATUSMSG_BIT1 0x25 /* Bit0 Error */ |
| 100 |
#define USB_8DEV_STATUSMSG_CRC 0x27 /* CRC Error */ |
| 101 |
|
| 102 |
#define USB_8DEV_RP_MASK 0x7F /* Mask for Receive Error Bit */ |
| 103 |
|
| 104 |
|
| 105 |
/* table of devices that work with this driver */ |
| 106 |
static const struct usb_device_id usb_8dev_table[] = { |
| 107 |
{ USB_DEVICE(USB_8DEV_VENDOR_ID, USB_8DEV_PRODUCT_ID) }, |
| 108 |
{ } /* Terminating entry */ |
| 109 |
}; |
| 110 |
|
| 111 |
MODULE_DEVICE_TABLE(usb, usb_8dev_table); |
| 112 |
|
| 113 |
struct usb_8dev_tx_urb_context { |
| 114 |
struct usb_8dev_priv *priv; |
| 115 |
|
| 116 |
u32 echo_index; |
| 117 |
}; |
| 118 |
|
| 119 |
/* Structure to hold all of our device specific stuff */ |
| 120 |
struct usb_8dev_priv { |
| 121 |
struct can_priv can; /* must be the first member */ |
| 122 |
|
| 123 |
struct usb_device *udev; |
| 124 |
struct net_device *netdev; |
| 125 |
|
| 126 |
atomic_t active_tx_urbs; |
| 127 |
struct usb_anchor tx_submitted; |
| 128 |
struct usb_8dev_tx_urb_context tx_contexts[MAX_TX_URBS]; |
| 129 |
|
| 130 |
struct usb_anchor rx_submitted; |
| 131 |
|
| 132 |
struct can_berr_counter bec; |
| 133 |
|
| 134 |
u8 *cmd_msg_buffer; |
| 135 |
|
| 136 |
struct mutex usb_8dev_cmd_lock; |
| 137 |
void *rxbuf[MAX_RX_URBS]; |
| 138 |
dma_addr_t rxbuf_dma[MAX_RX_URBS]; |
| 139 |
}; |
| 140 |
|
| 141 |
/* tx frame */ |
| 142 |
struct __packed usb_8dev_tx_msg { |
| 143 |
u8 begin; |
| 144 |
u8 flags; /* RTR and EXT_ID flag */ |
| 145 |
__be32 id; /* upper 3 bits not used */ |
| 146 |
u8 dlc; /* data length code 0-8 bytes */ |
| 147 |
u8 data[8]; /* 64-bit data */ |
| 148 |
u8 end; |
| 149 |
}; |
| 150 |
|
| 151 |
/* rx frame */ |
| 152 |
struct __packed usb_8dev_rx_msg { |
| 153 |
u8 begin; |
| 154 |
u8 type; /* frame type */ |
| 155 |
u8 flags; /* RTR and EXT_ID flag */ |
| 156 |
__be32 id; /* upper 3 bits not used */ |
| 157 |
u8 dlc; /* data length code 0-8 bytes */ |
| 158 |
u8 data[8]; /* 64-bit data */ |
| 159 |
__be32 timestamp; /* 32-bit timestamp */ |
| 160 |
u8 end; |
| 161 |
}; |
| 162 |
|
| 163 |
/* command frame */ |
| 164 |
struct __packed usb_8dev_cmd_msg { |
| 165 |
u8 begin; |
| 166 |
u8 channel; /* unknown - always 0 */ |
| 167 |
u8 command; /* command to execute */ |
| 168 |
u8 opt1; /* optional parameter / return value */ |
| 169 |
u8 opt2; /* optional parameter 2 */ |
| 170 |
u8 data[10]; /* optional parameter and data */ |
| 171 |
u8 end; |
| 172 |
}; |
| 173 |
|
| 174 |
static int usb_8dev_send_cmd_msg(struct usb_8dev_priv *priv, u8 *msg, int size) |
| 175 |
{ |
| 176 |
int actual_length; |
| 177 |
|
| 178 |
return usb_bulk_msg(priv->udev, |
| 179 |
usb_sndbulkpipe(priv->udev, USB_8DEV_ENDP_CMD_TX), |
| 180 |
msg, size, &actual_length, USB_8DEV_CMD_TIMEOUT); |
| 181 |
} |
| 182 |
|
| 183 |
static int usb_8dev_wait_cmd_msg(struct usb_8dev_priv *priv, u8 *msg, int size, |
| 184 |
int *actual_length) |
| 185 |
{ |
| 186 |
return usb_bulk_msg(priv->udev, |
| 187 |
usb_rcvbulkpipe(priv->udev, USB_8DEV_ENDP_CMD_RX), |
| 188 |
msg, size, actual_length, USB_8DEV_CMD_TIMEOUT); |
| 189 |
} |
| 190 |
|
| 191 |
/* Send command to device and receive result. |
| 192 |
* Command was successful when opt1 = 0. |
| 193 |
*/ |
| 194 |
static int usb_8dev_send_cmd(struct usb_8dev_priv *priv, |
| 195 |
struct usb_8dev_cmd_msg *out, |
| 196 |
struct usb_8dev_cmd_msg *in) |
| 197 |
{ |
| 198 |
int err; |
| 199 |
int num_bytes_read; |
| 200 |
struct net_device *netdev; |
| 201 |
|
| 202 |
netdev = priv->netdev; |
| 203 |
|
| 204 |
out->begin = USB_8DEV_CMD_START; |
| 205 |
out->end = USB_8DEV_CMD_END; |
| 206 |
|
| 207 |
mutex_lock(&priv->usb_8dev_cmd_lock); |
| 208 |
|
| 209 |
memcpy(priv->cmd_msg_buffer, out, |
| 210 |
sizeof(struct usb_8dev_cmd_msg)); |
| 211 |
|
| 212 |
err = usb_8dev_send_cmd_msg(priv, priv->cmd_msg_buffer, |
| 213 |
sizeof(struct usb_8dev_cmd_msg)); |
| 214 |
if (err < 0) { |
| 215 |
netdev_err(netdev, "sending command message failed\n"); |
| 216 |
goto failed; |
| 217 |
} |
| 218 |
|
| 219 |
err = usb_8dev_wait_cmd_msg(priv, priv->cmd_msg_buffer, |
| 220 |
sizeof(struct usb_8dev_cmd_msg), |
| 221 |
&num_bytes_read); |
| 222 |
if (err < 0) { |
| 223 |
netdev_err(netdev, "no command message answer\n"); |
| 224 |
goto failed; |
| 225 |
} |
| 226 |
|
| 227 |
memcpy(in, priv->cmd_msg_buffer, sizeof(struct usb_8dev_cmd_msg)); |
| 228 |
|
| 229 |
if (in->begin != USB_8DEV_CMD_START || in->end != USB_8DEV_CMD_END || |
| 230 |
num_bytes_read != 16 || in->opt1 != 0) |
| 231 |
err = -EPROTO; |
| 232 |
|
| 233 |
failed: |
| 234 |
mutex_unlock(&priv->usb_8dev_cmd_lock); |
| 235 |
return err; |
| 236 |
} |
| 237 |
|
| 238 |
/* Send open command to device */ |
| 239 |
static int usb_8dev_cmd_open(struct usb_8dev_priv *priv) |
| 240 |
{ |
| 241 |
struct can_bittiming *bt = &priv->can.bittiming; |
| 242 |
struct usb_8dev_cmd_msg outmsg; |
| 243 |
struct usb_8dev_cmd_msg inmsg; |
| 244 |
u32 ctrlmode = priv->can.ctrlmode; |
| 245 |
u32 flags = USB_8DEV_STATUS_FRAME; |
| 246 |
__be32 beflags; |
| 247 |
__be16 bebrp; |
| 248 |
|
| 249 |
memset(&outmsg, 0, sizeof(outmsg)); |
| 250 |
outmsg.command = USB_8DEV_OPEN; |
| 251 |
outmsg.opt1 = USB_8DEV_BAUD_MANUAL; |
| 252 |
outmsg.data[0] = bt->prop_seg + bt->phase_seg1; |
| 253 |
outmsg.data[1] = bt->phase_seg2; |
| 254 |
outmsg.data[2] = bt->sjw; |
| 255 |
|
| 256 |
/* BRP */ |
| 257 |
bebrp = cpu_to_be16((u16)bt->brp); |
| 258 |
memcpy(&outmsg.data[3], &bebrp, sizeof(bebrp)); |
| 259 |
|
| 260 |
/* flags */ |
| 261 |
if (ctrlmode & CAN_CTRLMODE_LOOPBACK) |
| 262 |
flags |= USB_8DEV_LOOPBACK; |
| 263 |
if (ctrlmode & CAN_CTRLMODE_LISTENONLY) |
| 264 |
flags |= USB_8DEV_SILENT; |
| 265 |
if (ctrlmode & CAN_CTRLMODE_ONE_SHOT) |
| 266 |
flags |= USB_8DEV_DISABLE_AUTO_RESTRANS; |
| 267 |
|
| 268 |
beflags = cpu_to_be32(flags); |
| 269 |
memcpy(&outmsg.data[5], &beflags, sizeof(beflags)); |
| 270 |
|
| 271 |
return usb_8dev_send_cmd(priv, &outmsg, &inmsg); |
| 272 |
} |
| 273 |
|
| 274 |
/* Send close command to device */ |
| 275 |
static int usb_8dev_cmd_close(struct usb_8dev_priv *priv) |
| 276 |
{ |
| 277 |
struct usb_8dev_cmd_msg inmsg; |
| 278 |
struct usb_8dev_cmd_msg outmsg = { |
| 279 |
.channel = 0, |
| 280 |
.command = USB_8DEV_CLOSE, |
| 281 |
.opt1 = 0, |
| 282 |
.opt2 = 0 |
| 283 |
}; |
| 284 |
|
| 285 |
return usb_8dev_send_cmd(priv, &outmsg, &inmsg); |
| 286 |
} |
| 287 |
|
| 288 |
/* Get firmware and hardware version */ |
| 289 |
static int usb_8dev_cmd_version(struct usb_8dev_priv *priv, u32 *res) |
| 290 |
{ |
| 291 |
struct usb_8dev_cmd_msg inmsg; |
| 292 |
struct usb_8dev_cmd_msg outmsg = { |
| 293 |
.channel = 0, |
| 294 |
.command = USB_8DEV_GET_SOFTW_HARDW_VER, |
| 295 |
.opt1 = 0, |
| 296 |
.opt2 = 0 |
| 297 |
}; |
| 298 |
|
| 299 |
int err = usb_8dev_send_cmd(priv, &outmsg, &inmsg); |
| 300 |
if (err) |
| 301 |
return err; |
| 302 |
|
| 303 |
*res = be32_to_cpup((__be32 *)inmsg.data); |
| 304 |
|
| 305 |
return err; |
| 306 |
} |
| 307 |
|
| 308 |
/* Set network device mode |
| 309 |
* |
| 310 |
* Maybe we should leave this function empty, because the device |
| 311 |
* set mode variable with open command. |
| 312 |
*/ |
| 313 |
static int usb_8dev_set_mode(struct net_device *netdev, enum can_mode mode) |
| 314 |
{ |
| 315 |
struct usb_8dev_priv *priv = netdev_priv(netdev); |
| 316 |
int err = 0; |
| 317 |
|
| 318 |
switch (mode) { |
| 319 |
case CAN_MODE_START: |
| 320 |
err = usb_8dev_cmd_open(priv); |
| 321 |
if (err) |
| 322 |
netdev_warn(netdev, "couldn't start device"); |
| 323 |
break; |
| 324 |
|
| 325 |
default: |
| 326 |
return -EOPNOTSUPP; |
| 327 |
} |
| 328 |
|
| 329 |
return err; |
| 330 |
} |
| 331 |
|
| 332 |
/* Read error/status frames */ |
| 333 |
static void usb_8dev_rx_err_msg(struct usb_8dev_priv *priv, |
| 334 |
struct usb_8dev_rx_msg *msg) |
| 335 |
{ |
| 336 |
struct can_frame *cf; |
| 337 |
struct sk_buff *skb; |
| 338 |
struct net_device_stats *stats = &priv->netdev->stats; |
| 339 |
|
| 340 |
/* Error message: |
| 341 |
* byte 0: Status |
| 342 |
* byte 1: bit 7: Receive Passive |
| 343 |
* byte 1: bit 0-6: Receive Error Counter |
| 344 |
* byte 2: Transmit Error Counter |
| 345 |
* byte 3: Always 0 (maybe reserved for future use) |
| 346 |
*/ |
| 347 |
|
| 348 |
u8 state = msg->data[0]; |
| 349 |
u8 rxerr = msg->data[1] & USB_8DEV_RP_MASK; |
| 350 |
u8 txerr = msg->data[2]; |
| 351 |
int rx_errors = 0; |
| 352 |
int tx_errors = 0; |
| 353 |
|
| 354 |
skb = alloc_can_err_skb(priv->netdev, &cf); |
| 355 |
if (!skb) |
| 356 |
return; |
| 357 |
|
| 358 |
switch (state) { |
| 359 |
case USB_8DEV_STATUSMSG_OK: |
| 360 |
priv->can.state = CAN_STATE_ERROR_ACTIVE; |
| 361 |
cf->can_id |= CAN_ERR_PROT; |
| 362 |
cf->data[2] = CAN_ERR_PROT_ACTIVE; |
| 363 |
break; |
| 364 |
case USB_8DEV_STATUSMSG_BUSOFF: |
| 365 |
priv->can.state = CAN_STATE_BUS_OFF; |
| 366 |
cf->can_id |= CAN_ERR_BUSOFF; |
| 367 |
priv->can.can_stats.bus_off++; |
| 368 |
can_bus_off(priv->netdev); |
| 369 |
break; |
| 370 |
case USB_8DEV_STATUSMSG_OVERRUN: |
| 371 |
case USB_8DEV_STATUSMSG_BUSLIGHT: |
| 372 |
case USB_8DEV_STATUSMSG_BUSHEAVY: |
| 373 |
cf->can_id |= CAN_ERR_CRTL; |
| 374 |
break; |
| 375 |
default: |
| 376 |
priv->can.state = CAN_STATE_ERROR_WARNING; |
| 377 |
cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR; |
| 378 |
priv->can.can_stats.bus_error++; |
| 379 |
break; |
| 380 |
} |
| 381 |
|
| 382 |
switch (state) { |
| 383 |
case USB_8DEV_STATUSMSG_OK: |
| 384 |
case USB_8DEV_STATUSMSG_BUSOFF: |
| 385 |
break; |
| 386 |
case USB_8DEV_STATUSMSG_ACK: |
| 387 |
cf->can_id |= CAN_ERR_ACK; |
| 388 |
tx_errors = 1; |
| 389 |
break; |
| 390 |
case USB_8DEV_STATUSMSG_CRC: |
| 391 |
cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ; |
| 392 |
rx_errors = 1; |
| 393 |
break; |
| 394 |
case USB_8DEV_STATUSMSG_BIT0: |
| 395 |
cf->data[2] |= CAN_ERR_PROT_BIT0; |
| 396 |
tx_errors = 1; |
| 397 |
break; |
| 398 |
case USB_8DEV_STATUSMSG_BIT1: |
| 399 |
cf->data[2] |= CAN_ERR_PROT_BIT1; |
| 400 |
tx_errors = 1; |
| 401 |
break; |
| 402 |
case USB_8DEV_STATUSMSG_FORM: |
| 403 |
cf->data[2] |= CAN_ERR_PROT_FORM; |
| 404 |
rx_errors = 1; |
| 405 |
break; |
| 406 |
case USB_8DEV_STATUSMSG_STUFF: |
| 407 |
cf->data[2] |= CAN_ERR_PROT_STUFF; |
| 408 |
rx_errors = 1; |
| 409 |
break; |
| 410 |
case USB_8DEV_STATUSMSG_OVERRUN: |
| 411 |
cf->data[1] = CAN_ERR_CRTL_RX_OVERFLOW; |
| 412 |
stats->rx_over_errors++; |
| 413 |
rx_errors = 1; |
| 414 |
break; |
| 415 |
case USB_8DEV_STATUSMSG_BUSLIGHT: |
| 416 |
priv->can.state = CAN_STATE_ERROR_WARNING; |
| 417 |
cf->data[1] = (txerr > rxerr) ? |
| 418 |
CAN_ERR_CRTL_TX_WARNING : |
| 419 |
CAN_ERR_CRTL_RX_WARNING; |
| 420 |
priv->can.can_stats.error_warning++; |
| 421 |
break; |
| 422 |
case USB_8DEV_STATUSMSG_BUSHEAVY: |
| 423 |
priv->can.state = CAN_STATE_ERROR_PASSIVE; |
| 424 |
cf->data[1] = (txerr > rxerr) ? |
| 425 |
CAN_ERR_CRTL_TX_PASSIVE : |
| 426 |
CAN_ERR_CRTL_RX_PASSIVE; |
| 427 |
priv->can.can_stats.error_passive++; |
| 428 |
break; |
| 429 |
default: |
| 430 |
netdev_warn(priv->netdev, |
| 431 |
"Unknown status/error message (%d)\n", state); |
| 432 |
break; |
| 433 |
} |
| 434 |
|
| 435 |
if (tx_errors) { |
| 436 |
cf->data[2] |= CAN_ERR_PROT_TX; |
| 437 |
stats->tx_errors++; |
| 438 |
} |
| 439 |
|
| 440 |
if (rx_errors) |
| 441 |
stats->rx_errors++; |
| 442 |
if (priv->can.state != CAN_STATE_BUS_OFF) { |
| 443 |
cf->can_id |= CAN_ERR_CNT; |
| 444 |
cf->data[6] = txerr; |
| 445 |
cf->data[7] = rxerr; |
| 446 |
} |
| 447 |
|
| 448 |
priv->bec.txerr = txerr; |
| 449 |
priv->bec.rxerr = rxerr; |
| 450 |
|
| 451 |
netif_rx(skb); |
| 452 |
} |
| 453 |
|
| 454 |
/* Read data and status frames */ |
| 455 |
static void usb_8dev_rx_can_msg(struct usb_8dev_priv *priv, |
| 456 |
struct usb_8dev_rx_msg *msg) |
| 457 |
{ |
| 458 |
struct can_frame *cf; |
| 459 |
struct sk_buff *skb; |
| 460 |
struct net_device_stats *stats = &priv->netdev->stats; |
| 461 |
|
| 462 |
if (msg->type == USB_8DEV_TYPE_ERROR_FRAME && |
| 463 |
msg->flags == USB_8DEV_ERR_FLAG) { |
| 464 |
usb_8dev_rx_err_msg(priv, msg); |
| 465 |
} else if (msg->type == USB_8DEV_TYPE_CAN_FRAME) { |
| 466 |
skb = alloc_can_skb(priv->netdev, &cf); |
| 467 |
if (!skb) |
| 468 |
return; |
| 469 |
|
| 470 |
cf->can_id = be32_to_cpu(msg->id); |
| 471 |
can_frame_set_cc_len(cf, msg->dlc & 0xF, priv->can.ctrlmode); |
| 472 |
|
| 473 |
if (msg->flags & USB_8DEV_EXTID) |
| 474 |
cf->can_id |= CAN_EFF_FLAG; |
| 475 |
|
| 476 |
if (msg->flags & USB_8DEV_RTR) { |
| 477 |
cf->can_id |= CAN_RTR_FLAG; |
| 478 |
} else { |
| 479 |
memcpy(cf->data, msg->data, cf->len); |
| 480 |
stats->rx_bytes += cf->len; |
| 481 |
} |
| 482 |
stats->rx_packets++; |
| 483 |
|
| 484 |
netif_rx(skb); |
| 485 |
} else { |
| 486 |
netdev_warn(priv->netdev, "frame type %d unknown", |
| 487 |
msg->type); |
| 488 |
} |
| 489 |
|
| 490 |
} |
| 491 |
|
| 492 |
/* Callback for reading data from device |
| 493 |
* |
| 494 |
* Check urb status, call read function and resubmit urb read operation. |
| 495 |
*/ |
| 496 |
static void usb_8dev_read_bulk_callback(struct urb *urb) |
| 497 |
{ |
| 498 |
struct usb_8dev_priv *priv = urb->context; |
| 499 |
struct net_device *netdev; |
| 500 |
int retval; |
| 501 |
int pos = 0; |
| 502 |
|
| 503 |
netdev = priv->netdev; |
| 504 |
|
| 505 |
if (!netif_device_present(netdev)) |
| 506 |
return; |
| 507 |
|
| 508 |
switch (urb->status) { |
| 509 |
case 0: /* success */ |
| 510 |
break; |
| 511 |
|
| 512 |
case -ENOENT: |
| 513 |
case -EPIPE: |
| 514 |
case -EPROTO: |
| 515 |
case -ESHUTDOWN: |
| 516 |
return; |
| 517 |
|
| 518 |
default: |
| 519 |
netdev_info(netdev, "Rx URB aborted (%d)\n", |
| 520 |
urb->status); |
| 521 |
goto resubmit_urb; |
| 522 |
} |
| 523 |
|
| 524 |
while (pos < urb->actual_length) { |
| 525 |
struct usb_8dev_rx_msg *msg; |
| 526 |
|
| 527 |
if (pos + sizeof(struct usb_8dev_rx_msg) > urb->actual_length) { |
| 528 |
netdev_err(priv->netdev, "format error\n"); |
| 529 |
break; |
| 530 |
} |
| 531 |
|
| 532 |
msg = (struct usb_8dev_rx_msg *)(urb->transfer_buffer + pos); |
| 533 |
usb_8dev_rx_can_msg(priv, msg); |
| 534 |
|
| 535 |
pos += sizeof(struct usb_8dev_rx_msg); |
| 536 |
} |
| 537 |
|
| 538 |
resubmit_urb: |
| 539 |
usb_fill_bulk_urb(urb, priv->udev, |
| 540 |
usb_rcvbulkpipe(priv->udev, USB_8DEV_ENDP_DATA_RX), |
| 541 |
urb->transfer_buffer, RX_BUFFER_SIZE, |
| 542 |
usb_8dev_read_bulk_callback, priv); |
| 543 |
|
| 544 |
usb_anchor_urb(urb, &priv->rx_submitted); |
| 545 |
|
| 546 |
retval = usb_submit_urb(urb, GFP_ATOMIC); |
| 547 |
if (!retval) |
| 548 |
return; |
| 549 |
|
| 550 |
usb_unanchor_urb(urb); |
| 551 |
|
| 552 |
if (retval == -ENODEV) |
| 553 |
netif_device_detach(netdev); |
| 554 |
else |
| 555 |
netdev_err(netdev, |
| 556 |
"failed resubmitting read bulk urb: %d\n", retval); |
| 557 |
} |
| 558 |
|
| 559 |
/* Callback handler for write operations |
| 560 |
* |
| 561 |
* Free allocated buffers, check transmit status and |
| 562 |
* calculate statistic. |
| 563 |
*/ |
| 564 |
static void usb_8dev_write_bulk_callback(struct urb *urb) |
| 565 |
{ |
| 566 |
struct usb_8dev_tx_urb_context *context = urb->context; |
| 567 |
struct usb_8dev_priv *priv; |
| 568 |
struct net_device *netdev; |
| 569 |
|
| 570 |
BUG_ON(!context); |
| 571 |
|
| 572 |
priv = context->priv; |
| 573 |
netdev = priv->netdev; |
| 574 |
|
| 575 |
/* free up our allocated buffer */ |
| 576 |
usb_free_coherent(urb->dev, urb->transfer_buffer_length, |
| 577 |
urb->transfer_buffer, urb->transfer_dma); |
| 578 |
|
| 579 |
atomic_dec(&priv->active_tx_urbs); |
| 580 |
|
| 581 |
if (!netif_device_present(netdev)) |
| 582 |
return; |
| 583 |
|
| 584 |
if (urb->status) |
| 585 |
netdev_info(netdev, "Tx URB aborted (%d)\n", |
| 586 |
urb->status); |
| 587 |
|
| 588 |
netdev->stats.tx_packets++; |
| 589 |
netdev->stats.tx_bytes += can_get_echo_skb(netdev, context->echo_index, NULL); |
| 590 |
|
| 591 |
/* Release context */ |
| 592 |
context->echo_index = MAX_TX_URBS; |
| 593 |
|
| 594 |
netif_wake_queue(netdev); |
| 595 |
} |
| 596 |
|
| 597 |
/* Send data to device */ |
| 598 |
static netdev_tx_t usb_8dev_start_xmit(struct sk_buff *skb, |
| 599 |
struct net_device *netdev) |
| 600 |
{ |
| 601 |
struct usb_8dev_priv *priv = netdev_priv(netdev); |
| 602 |
struct net_device_stats *stats = &netdev->stats; |
| 603 |
struct can_frame *cf = (struct can_frame *) skb->data; |
| 604 |
struct usb_8dev_tx_msg *msg; |
| 605 |
struct urb *urb; |
| 606 |
struct usb_8dev_tx_urb_context *context = NULL; |
| 607 |
u8 *buf; |
| 608 |
int i, err; |
| 609 |
size_t size = sizeof(struct usb_8dev_tx_msg); |
| 610 |
|
| 611 |
if (can_dev_dropped_skb(netdev, skb)) |
| 612 |
return NETDEV_TX_OK; |
| 613 |
|
| 614 |
/* create a URB, and a buffer for it, and copy the data to the URB */ |
| 615 |
urb = usb_alloc_urb(0, GFP_ATOMIC); |
| 616 |
if (!urb) |
| 617 |
goto nomem; |
| 618 |
|
| 619 |
buf = usb_alloc_coherent(priv->udev, size, GFP_ATOMIC, |
| 620 |
&urb->transfer_dma); |
| 621 |
if (!buf) { |
| 622 |
netdev_err(netdev, "No memory left for USB buffer\n"); |
| 623 |
goto nomembuf; |
| 624 |
} |
| 625 |
|
| 626 |
memset(buf, 0, size); |
| 627 |
|
| 628 |
msg = (struct usb_8dev_tx_msg *)buf; |
| 629 |
msg->begin = USB_8DEV_DATA_START; |
| 630 |
msg->flags = 0x00; |
| 631 |
|
| 632 |
if (cf->can_id & CAN_RTR_FLAG) |
| 633 |
msg->flags |= USB_8DEV_RTR; |
| 634 |
|
| 635 |
if (cf->can_id & CAN_EFF_FLAG) |
| 636 |
msg->flags |= USB_8DEV_EXTID; |
| 637 |
|
| 638 |
msg->id = cpu_to_be32(cf->can_id & CAN_ERR_MASK); |
| 639 |
msg->dlc = can_get_cc_dlc(cf, priv->can.ctrlmode); |
| 640 |
memcpy(msg->data, cf->data, cf->len); |
| 641 |
msg->end = USB_8DEV_DATA_END; |
| 642 |
|
| 643 |
for (i = 0; i < MAX_TX_URBS; i++) { |
| 644 |
if (priv->tx_contexts[i].echo_index == MAX_TX_URBS) { |
| 645 |
context = &priv->tx_contexts[i]; |
| 646 |
break; |
| 647 |
} |
| 648 |
} |
| 649 |
|
| 650 |
/* May never happen! When this happens we'd more URBs in flight as |
| 651 |
* allowed (MAX_TX_URBS). |
| 652 |
*/ |
| 653 |
if (!context) |
| 654 |
goto nofreecontext; |
| 655 |
|
| 656 |
context->priv = priv; |
| 657 |
context->echo_index = i; |
| 658 |
|
| 659 |
usb_fill_bulk_urb(urb, priv->udev, |
| 660 |
usb_sndbulkpipe(priv->udev, USB_8DEV_ENDP_DATA_TX), |
| 661 |
buf, size, usb_8dev_write_bulk_callback, context); |
| 662 |
urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
| 663 |
usb_anchor_urb(urb, &priv->tx_submitted); |
| 664 |
|
| 665 |
can_put_echo_skb(skb, netdev, context->echo_index, 0); |
| 666 |
|
| 667 |
atomic_inc(&priv->active_tx_urbs); |
| 668 |
|
| 669 |
err = usb_submit_urb(urb, GFP_ATOMIC); |
| 670 |
if (unlikely(err)) { |
| 671 |
can_free_echo_skb(netdev, context->echo_index, NULL); |
| 672 |
|
| 673 |
usb_unanchor_urb(urb); |
| 674 |
usb_free_coherent(priv->udev, size, buf, urb->transfer_dma); |
| 675 |
|
| 676 |
atomic_dec(&priv->active_tx_urbs); |
| 677 |
|
| 678 |
if (err == -ENODEV) |
| 679 |
netif_device_detach(netdev); |
| 680 |
else |
| 681 |
netdev_warn(netdev, "failed tx_urb %d\n", err); |
| 682 |
stats->tx_dropped++; |
| 683 |
} else if (atomic_read(&priv->active_tx_urbs) >= MAX_TX_URBS) |
| 684 |
/* Slow down tx path */ |
| 685 |
netif_stop_queue(netdev); |
| 686 |
|
| 687 |
/* Release our reference to this URB, the USB core will eventually free |
| 688 |
* it entirely. |
| 689 |
*/ |
| 690 |
usb_free_urb(urb); |
| 691 |
|
| 692 |
return NETDEV_TX_OK; |
| 693 |
|
| 694 |
nofreecontext: |
| 695 |
usb_free_coherent(priv->udev, size, buf, urb->transfer_dma); |
| 696 |
usb_free_urb(urb); |
| 697 |
|
| 698 |
netdev_warn(netdev, "couldn't find free context"); |
| 699 |
|
| 700 |
return NETDEV_TX_BUSY; |
| 701 |
|
| 702 |
nomembuf: |
| 703 |
usb_free_urb(urb); |
| 704 |
|
| 705 |
nomem: |
| 706 |
dev_kfree_skb(skb); |
| 707 |
stats->tx_dropped++; |
| 708 |
|
| 709 |
return NETDEV_TX_OK; |
| 710 |
} |
| 711 |
|
| 712 |
static int usb_8dev_get_berr_counter(const struct net_device *netdev, |
| 713 |
struct can_berr_counter *bec) |
| 714 |
{ |
| 715 |
struct usb_8dev_priv *priv = netdev_priv(netdev); |
| 716 |
|
| 717 |
bec->txerr = priv->bec.txerr; |
| 718 |
bec->rxerr = priv->bec.rxerr; |
| 719 |
|
| 720 |
return 0; |
| 721 |
} |
| 722 |
|
| 723 |
/* Start USB device */ |
| 724 |
static int usb_8dev_start(struct usb_8dev_priv *priv) |
| 725 |
{ |
| 726 |
struct net_device *netdev = priv->netdev; |
| 727 |
int err, i; |
| 728 |
|
| 729 |
for (i = 0; i < MAX_RX_URBS; i++) { |
| 730 |
struct urb *urb = NULL; |
| 731 |
u8 *buf; |
| 732 |
dma_addr_t buf_dma; |
| 733 |
|
| 734 |
/* create a URB, and a buffer for it */ |
| 735 |
urb = usb_alloc_urb(0, GFP_KERNEL); |
| 736 |
if (!urb) { |
| 737 |
err = -ENOMEM; |
| 738 |
break; |
| 739 |
} |
| 740 |
|
| 741 |
buf = usb_alloc_coherent(priv->udev, RX_BUFFER_SIZE, GFP_KERNEL, |
| 742 |
&buf_dma); |
| 743 |
if (!buf) { |
| 744 |
netdev_err(netdev, "No memory left for USB buffer\n"); |
| 745 |
usb_free_urb(urb); |
| 746 |
err = -ENOMEM; |
| 747 |
break; |
| 748 |
} |
| 749 |
|
| 750 |
urb->transfer_dma = buf_dma; |
| 751 |
|
| 752 |
usb_fill_bulk_urb(urb, priv->udev, |
| 753 |
usb_rcvbulkpipe(priv->udev, |
| 754 |
USB_8DEV_ENDP_DATA_RX), |
| 755 |
buf, RX_BUFFER_SIZE, |
| 756 |
usb_8dev_read_bulk_callback, priv); |
| 757 |
urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
| 758 |
usb_anchor_urb(urb, &priv->rx_submitted); |
| 759 |
|
| 760 |
err = usb_submit_urb(urb, GFP_KERNEL); |
| 761 |
if (err) { |
| 762 |
usb_unanchor_urb(urb); |
| 763 |
usb_free_coherent(priv->udev, RX_BUFFER_SIZE, buf, |
| 764 |
urb->transfer_dma); |
| 765 |
usb_free_urb(urb); |
| 766 |
break; |
| 767 |
} |
| 768 |
|
| 769 |
priv->rxbuf[i] = buf; |
| 770 |
priv->rxbuf_dma[i] = buf_dma; |
| 771 |
|
| 772 |
/* Drop reference, USB core will take care of freeing it */ |
| 773 |
usb_free_urb(urb); |
| 774 |
} |
| 775 |
|
| 776 |
/* Did we submit any URBs */ |
| 777 |
if (i == 0) { |
| 778 |
netdev_warn(netdev, "couldn't setup read URBs\n"); |
| 779 |
return err; |
| 780 |
} |
| 781 |
|
| 782 |
/* Warn if we've couldn't transmit all the URBs */ |
| 783 |
if (i < MAX_RX_URBS) |
| 784 |
netdev_warn(netdev, "rx performance may be slow\n"); |
| 785 |
|
| 786 |
err = usb_8dev_cmd_open(priv); |
| 787 |
if (err) |
| 788 |
goto failed; |
| 789 |
|
| 790 |
priv->can.state = CAN_STATE_ERROR_ACTIVE; |
| 791 |
|
| 792 |
return 0; |
| 793 |
|
| 794 |
failed: |
| 795 |
if (err == -ENODEV) |
| 796 |
netif_device_detach(priv->netdev); |
| 797 |
|
| 798 |
netdev_warn(netdev, "couldn't submit control: %d\n", err); |
| 799 |
|
| 800 |
return err; |
| 801 |
} |
| 802 |
|
| 803 |
/* Open USB device */ |
| 804 |
static int usb_8dev_open(struct net_device *netdev) |
| 805 |
{ |
| 806 |
struct usb_8dev_priv *priv = netdev_priv(netdev); |
| 807 |
int err; |
| 808 |
|
| 809 |
/* common open */ |
| 810 |
err = open_candev(netdev); |
| 811 |
if (err) |
| 812 |
return err; |
| 813 |
|
| 814 |
/* finally start device */ |
| 815 |
err = usb_8dev_start(priv); |
| 816 |
if (err) { |
| 817 |
if (err == -ENODEV) |
| 818 |
netif_device_detach(priv->netdev); |
| 819 |
|
| 820 |
netdev_warn(netdev, "couldn't start device: %d\n", |
| 821 |
err); |
| 822 |
|
| 823 |
close_candev(netdev); |
| 824 |
|
| 825 |
return err; |
| 826 |
} |
| 827 |
|
| 828 |
netif_start_queue(netdev); |
| 829 |
|
| 830 |
return 0; |
| 831 |
} |
| 832 |
|
| 833 |
static void unlink_all_urbs(struct usb_8dev_priv *priv) |
| 834 |
{ |
| 835 |
int i; |
| 836 |
|
| 837 |
usb_kill_anchored_urbs(&priv->rx_submitted); |
| 838 |
|
| 839 |
for (i = 0; i < MAX_RX_URBS; ++i) |
| 840 |
usb_free_coherent(priv->udev, RX_BUFFER_SIZE, |
| 841 |
priv->rxbuf[i], priv->rxbuf_dma[i]); |
| 842 |
|
| 843 |
usb_kill_anchored_urbs(&priv->tx_submitted); |
| 844 |
atomic_set(&priv->active_tx_urbs, 0); |
| 845 |
|
| 846 |
for (i = 0; i < MAX_TX_URBS; i++) |
| 847 |
priv->tx_contexts[i].echo_index = MAX_TX_URBS; |
| 848 |
} |
| 849 |
|
| 850 |
/* Close USB device */ |
| 851 |
static int usb_8dev_close(struct net_device *netdev) |
| 852 |
{ |
| 853 |
struct usb_8dev_priv *priv = netdev_priv(netdev); |
| 854 |
int err = 0; |
| 855 |
|
| 856 |
/* Send CLOSE command to CAN controller */ |
| 857 |
err = usb_8dev_cmd_close(priv); |
| 858 |
if (err) |
| 859 |
netdev_warn(netdev, "couldn't stop device"); |
| 860 |
|
| 861 |
priv->can.state = CAN_STATE_STOPPED; |
| 862 |
|
| 863 |
netif_stop_queue(netdev); |
| 864 |
|
| 865 |
/* Stop polling */ |
| 866 |
unlink_all_urbs(priv); |
| 867 |
|
| 868 |
close_candev(netdev); |
| 869 |
|
| 870 |
return err; |
| 871 |
} |
| 872 |
|
| 873 |
static const struct net_device_ops usb_8dev_netdev_ops = { |
| 874 |
.ndo_open = usb_8dev_open, |
| 875 |
.ndo_stop = usb_8dev_close, |
| 876 |
.ndo_start_xmit = usb_8dev_start_xmit, |
| 877 |
}; |
| 878 |
|
| 879 |
static const struct ethtool_ops usb_8dev_ethtool_ops = { |
| 880 |
.get_ts_info = ethtool_op_get_ts_info, |
| 881 |
}; |
| 882 |
|
| 883 |
static const struct can_bittiming_const usb_8dev_bittiming_const = { |
| 884 |
.name = KBUILD_MODNAME, |
| 885 |
.tseg1_min = 1, |
| 886 |
.tseg1_max = 16, |
| 887 |
.tseg2_min = 1, |
| 888 |
.tseg2_max = 8, |
| 889 |
.sjw_max = 4, |
| 890 |
.brp_min = 1, |
| 891 |
.brp_max = 1024, |
| 892 |
.brp_inc = 1, |
| 893 |
}; |
| 894 |
|
| 895 |
/* Probe USB device |
| 896 |
* |
| 897 |
* Check device and firmware. |
| 898 |
* Set supported modes and bittiming constants. |
| 899 |
* Allocate some memory. |
| 900 |
*/ |
| 901 |
static int usb_8dev_probe(struct usb_interface *intf, |
| 902 |
const struct usb_device_id *id) |
| 903 |
{ |
| 904 |
struct net_device *netdev; |
| 905 |
struct usb_8dev_priv *priv; |
| 906 |
int i, err = -ENOMEM; |
| 907 |
u32 version; |
| 908 |
char buf[18]; |
| 909 |
struct usb_device *usbdev = interface_to_usbdev(intf); |
| 910 |
|
| 911 |
/* product id looks strange, better we also check iProduct string */ |
| 912 |
if (usb_string(usbdev, usbdev->descriptor.iProduct, buf, |
| 913 |
sizeof(buf)) > 0 && strcmp(buf, "USB2CAN converter")) { |
| 914 |
dev_info(&usbdev->dev, "ignoring: not an USB2CAN converter\n"); |
| 915 |
return -ENODEV; |
| 916 |
} |
| 917 |
|
| 918 |
netdev = alloc_candev(sizeof(struct usb_8dev_priv), MAX_TX_URBS); |
| 919 |
if (!netdev) { |
| 920 |
dev_err(&intf->dev, "Couldn't alloc candev\n"); |
| 921 |
return -ENOMEM; |
| 922 |
} |
| 923 |
|
| 924 |
priv = netdev_priv(netdev); |
| 925 |
|
| 926 |
priv->udev = usbdev; |
| 927 |
priv->netdev = netdev; |
| 928 |
|
| 929 |
priv->can.state = CAN_STATE_STOPPED; |
| 930 |
priv->can.clock.freq = USB_8DEV_ABP_CLOCK; |
| 931 |
priv->can.bittiming_const = &usb_8dev_bittiming_const; |
| 932 |
priv->can.do_set_mode = usb_8dev_set_mode; |
| 933 |
priv->can.do_get_berr_counter = usb_8dev_get_berr_counter; |
| 934 |
priv->can.ctrlmode_supported = CAN_CTRLMODE_LOOPBACK | |
| 935 |
CAN_CTRLMODE_LISTENONLY | |
| 936 |
CAN_CTRLMODE_ONE_SHOT | |
| 937 |
CAN_CTRLMODE_CC_LEN8_DLC; |
| 938 |
|
| 939 |
netdev->netdev_ops = &usb_8dev_netdev_ops; |
| 940 |
netdev->ethtool_ops = &usb_8dev_ethtool_ops; |
| 941 |
|
| 942 |
netdev->flags |= IFF_ECHO; /* we support local echo */ |
| 943 |
|
| 944 |
init_usb_anchor(&priv->rx_submitted); |
| 945 |
|
| 946 |
init_usb_anchor(&priv->tx_submitted); |
| 947 |
atomic_set(&priv->active_tx_urbs, 0); |
| 948 |
|
| 949 |
for (i = 0; i < MAX_TX_URBS; i++) |
| 950 |
priv->tx_contexts[i].echo_index = MAX_TX_URBS; |
| 951 |
|
| 952 |
priv->cmd_msg_buffer = devm_kzalloc(&intf->dev, sizeof(struct usb_8dev_cmd_msg), |
| 953 |
GFP_KERNEL); |
| 954 |
if (!priv->cmd_msg_buffer) |
| 955 |
goto cleanup_candev; |
| 956 |
|
| 957 |
usb_set_intfdata(intf, priv); |
| 958 |
|
| 959 |
SET_NETDEV_DEV(netdev, &intf->dev); |
| 960 |
|
| 961 |
mutex_init(&priv->usb_8dev_cmd_lock); |
| 962 |
|
| 963 |
err = register_candev(netdev); |
| 964 |
if (err) { |
| 965 |
netdev_err(netdev, |
| 966 |
"couldn't register CAN device: %d\n", err); |
| 967 |
goto cleanup_candev; |
| 968 |
} |
| 969 |
|
| 970 |
err = usb_8dev_cmd_version(priv, &version); |
| 971 |
if (err) { |
| 972 |
netdev_err(netdev, "can't get firmware version\n"); |
| 973 |
goto cleanup_unregister_candev; |
| 974 |
} else { |
| 975 |
netdev_info(netdev, |
| 976 |
"firmware: %d.%d, hardware: %d.%d\n", |
| 977 |
(version>>24) & 0xff, (version>>16) & 0xff, |
| 978 |
(version>>8) & 0xff, version & 0xff); |
| 979 |
} |
| 980 |
|
| 981 |
return 0; |
| 982 |
|
| 983 |
cleanup_unregister_candev: |
| 984 |
unregister_netdev(priv->netdev); |
| 985 |
|
| 986 |
cleanup_candev: |
| 987 |
free_candev(netdev); |
| 988 |
|
| 989 |
return err; |
| 990 |
|
| 991 |
} |
| 992 |
|
| 993 |
/* Called by the usb core when driver is unloaded or device is removed */ |
| 994 |
static void usb_8dev_disconnect(struct usb_interface *intf) |
| 995 |
{ |
| 996 |
struct usb_8dev_priv *priv = usb_get_intfdata(intf); |
| 997 |
|
| 998 |
usb_set_intfdata(intf, NULL); |
| 999 |
|
| 1000 |
if (priv) { |
| 1001 |
netdev_info(priv->netdev, "device disconnected\n"); |
| 1002 |
|
| 1003 |
unregister_netdev(priv->netdev); |
| 1004 |
unlink_all_urbs(priv); |
| 1005 |
free_candev(priv->netdev); |
| 1006 |
} |
| 1007 |
|
| 1008 |
} |
| 1009 |
|
| 1010 |
static struct usb_driver usb_8dev_driver = { |
| 1011 |
.name = KBUILD_MODNAME, |
| 1012 |
.probe = usb_8dev_probe, |
| 1013 |
.disconnect = usb_8dev_disconnect, |
| 1014 |
.id_table = usb_8dev_table, |
| 1015 |
}; |
| 1016 |
|
| 1017 |
module_usb_driver(usb_8dev_driver); |
| 1018 |
|
| 1019 |
MODULE_AUTHOR("Bernd Krumboeck <[email protected]>"); |
| 1020 |
MODULE_DESCRIPTION("CAN driver for 8 devices USB2CAN interfaces"); |
| 1021 |
MODULE_LICENSE("GPL v2"); |