diff options
Diffstat (limited to 'drivers/net')
42 files changed, 2143 insertions, 230 deletions
diff --git a/drivers/net/can/Kconfig b/drivers/net/can/Kconfig index 05b751719bd5..2c5227c02fa0 100644 --- a/drivers/net/can/Kconfig +++ b/drivers/net/can/Kconfig | |||
| @@ -63,6 +63,16 @@ config CAN_BFIN | |||
| 63 | To compile this driver as a module, choose M here: the | 63 | To compile this driver as a module, choose M here: the |
| 64 | module will be called bfin_can. | 64 | module will be called bfin_can. |
| 65 | 65 | ||
| 66 | config CAN_JANZ_ICAN3 | ||
| 67 | tristate "Janz VMOD-ICAN3 Intelligent CAN controller" | ||
| 68 | depends on CAN_DEV && MFD_JANZ_CMODIO | ||
| 69 | ---help--- | ||
| 70 | Driver for Janz VMOD-ICAN3 Intelligent CAN controller module, which | ||
| 71 | connects to a MODULbus carrier board. | ||
| 72 | |||
| 73 | This driver can also be built as a module. If so, the module will be | ||
| 74 | called janz-ican3.ko. | ||
| 75 | |||
| 66 | source "drivers/net/can/mscan/Kconfig" | 76 | source "drivers/net/can/mscan/Kconfig" |
| 67 | 77 | ||
| 68 | source "drivers/net/can/sja1000/Kconfig" | 78 | source "drivers/net/can/sja1000/Kconfig" |
diff --git a/drivers/net/can/Makefile b/drivers/net/can/Makefile index 7a702f28d01c..9047cd066fea 100644 --- a/drivers/net/can/Makefile +++ b/drivers/net/can/Makefile | |||
| @@ -15,5 +15,6 @@ obj-$(CONFIG_CAN_AT91) += at91_can.o | |||
| 15 | obj-$(CONFIG_CAN_TI_HECC) += ti_hecc.o | 15 | obj-$(CONFIG_CAN_TI_HECC) += ti_hecc.o |
| 16 | obj-$(CONFIG_CAN_MCP251X) += mcp251x.o | 16 | obj-$(CONFIG_CAN_MCP251X) += mcp251x.o |
| 17 | obj-$(CONFIG_CAN_BFIN) += bfin_can.o | 17 | obj-$(CONFIG_CAN_BFIN) += bfin_can.o |
| 18 | obj-$(CONFIG_CAN_JANZ_ICAN3) += janz-ican3.o | ||
| 18 | 19 | ||
| 19 | ccflags-$(CONFIG_CAN_DEBUG_DEVICES) := -DDEBUG | 20 | ccflags-$(CONFIG_CAN_DEBUG_DEVICES) := -DDEBUG |
diff --git a/drivers/net/can/janz-ican3.c b/drivers/net/can/janz-ican3.c new file mode 100644 index 000000000000..6e533dcc36c0 --- /dev/null +++ b/drivers/net/can/janz-ican3.c | |||
| @@ -0,0 +1,1830 @@ | |||
| 1 | /* | ||
| 2 | * Janz MODULbus VMOD-ICAN3 CAN Interface Driver | ||
| 3 | * | ||
| 4 | * Copyright (c) 2010 Ira W. Snyder <iws@ovro.caltech.edu> | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or modify it | ||
| 7 | * under the terms of the GNU General Public License as published by the | ||
| 8 | * Free Software Foundation; either version 2 of the License, or (at your | ||
| 9 | * option) any later version. | ||
| 10 | */ | ||
| 11 | |||
| 12 | #include <linux/kernel.h> | ||
| 13 | #include <linux/module.h> | ||
| 14 | #include <linux/init.h> | ||
| 15 | #include <linux/interrupt.h> | ||
| 16 | #include <linux/delay.h> | ||
| 17 | #include <linux/platform_device.h> | ||
| 18 | |||
| 19 | #include <linux/netdevice.h> | ||
| 20 | #include <linux/can.h> | ||
| 21 | #include <linux/can/dev.h> | ||
| 22 | #include <linux/can/error.h> | ||
| 23 | |||
| 24 | #include <linux/mfd/janz.h> | ||
| 25 | |||
| 26 | /* the DPM has 64k of memory, organized into 256x 256 byte pages */ | ||
| 27 | #define DPM_NUM_PAGES 256 | ||
| 28 | #define DPM_PAGE_SIZE 256 | ||
| 29 | #define DPM_PAGE_ADDR(p) ((p) * DPM_PAGE_SIZE) | ||
| 30 | |||
| 31 | /* JANZ ICAN3 "old-style" host interface queue page numbers */ | ||
| 32 | #define QUEUE_OLD_CONTROL 0 | ||
| 33 | #define QUEUE_OLD_RB0 1 | ||
| 34 | #define QUEUE_OLD_RB1 2 | ||
| 35 | #define QUEUE_OLD_WB0 3 | ||
| 36 | #define QUEUE_OLD_WB1 4 | ||
| 37 | |||
| 38 | /* Janz ICAN3 "old-style" host interface control registers */ | ||
| 39 | #define MSYNC_PEER 0x00 /* ICAN only */ | ||
| 40 | #define MSYNC_LOCL 0x01 /* host only */ | ||
| 41 | #define TARGET_RUNNING 0x02 | ||
| 42 | |||
| 43 | #define MSYNC_RB0 0x01 | ||
| 44 | #define MSYNC_RB1 0x02 | ||
| 45 | #define MSYNC_RBLW 0x04 | ||
| 46 | #define MSYNC_RB_MASK (MSYNC_RB0 | MSYNC_RB1) | ||
| 47 | |||
| 48 | #define MSYNC_WB0 0x10 | ||
| 49 | #define MSYNC_WB1 0x20 | ||
| 50 | #define MSYNC_WBLW 0x40 | ||
| 51 | #define MSYNC_WB_MASK (MSYNC_WB0 | MSYNC_WB1) | ||
| 52 | |||
| 53 | /* Janz ICAN3 "new-style" host interface queue page numbers */ | ||
| 54 | #define QUEUE_TOHOST 5 | ||
| 55 | #define QUEUE_FROMHOST_MID 6 | ||
| 56 | #define QUEUE_FROMHOST_HIGH 7 | ||
| 57 | #define QUEUE_FROMHOST_LOW 8 | ||
| 58 | |||
| 59 | /* The first free page in the DPM is #9 */ | ||
| 60 | #define DPM_FREE_START 9 | ||
| 61 | |||
| 62 | /* Janz ICAN3 "new-style" and "fast" host interface descriptor flags */ | ||
| 63 | #define DESC_VALID 0x80 | ||
| 64 | #define DESC_WRAP 0x40 | ||
| 65 | #define DESC_INTERRUPT 0x20 | ||
| 66 | #define DESC_IVALID 0x10 | ||
| 67 | #define DESC_LEN(len) (len) | ||
| 68 | |||
| 69 | /* Janz ICAN3 Firmware Messages */ | ||
| 70 | #define MSG_CONNECTI 0x02 | ||
| 71 | #define MSG_DISCONNECT 0x03 | ||
| 72 | #define MSG_IDVERS 0x04 | ||
| 73 | #define MSG_MSGLOST 0x05 | ||
| 74 | #define MSG_NEWHOSTIF 0x08 | ||
| 75 | #define MSG_INQUIRY 0x0a | ||
| 76 | #define MSG_SETAFILMASK 0x10 | ||
| 77 | #define MSG_INITFDPMQUEUE 0x11 | ||
| 78 | #define MSG_HWCONF 0x12 | ||
| 79 | #define MSG_FMSGLOST 0x15 | ||
| 80 | #define MSG_CEVTIND 0x37 | ||
| 81 | #define MSG_CBTRREQ 0x41 | ||
| 82 | #define MSG_COFFREQ 0x42 | ||
| 83 | #define MSG_CONREQ 0x43 | ||
| 84 | #define MSG_CCONFREQ 0x47 | ||
| 85 | |||
| 86 | /* | ||
| 87 | * Janz ICAN3 CAN Inquiry Message Types | ||
| 88 | * | ||
| 89 | * NOTE: there appears to be a firmware bug here. You must send | ||
| 90 | * NOTE: INQUIRY_STATUS and expect to receive an INQUIRY_EXTENDED | ||
| 91 | * NOTE: response. The controller never responds to a message with | ||
| 92 | * NOTE: the INQUIRY_EXTENDED subspec :( | ||
| 93 | */ | ||
| 94 | #define INQUIRY_STATUS 0x00 | ||
| 95 | #define INQUIRY_TERMINATION 0x01 | ||
| 96 | #define INQUIRY_EXTENDED 0x04 | ||
| 97 | |||
| 98 | /* Janz ICAN3 CAN Set Acceptance Filter Mask Message Types */ | ||
| 99 | #define SETAFILMASK_REJECT 0x00 | ||
| 100 | #define SETAFILMASK_FASTIF 0x02 | ||
| 101 | |||
| 102 | /* Janz ICAN3 CAN Hardware Configuration Message Types */ | ||
| 103 | #define HWCONF_TERMINATE_ON 0x01 | ||
| 104 | #define HWCONF_TERMINATE_OFF 0x00 | ||
| 105 | |||
| 106 | /* Janz ICAN3 CAN Event Indication Message Types */ | ||
| 107 | #define CEVTIND_EI 0x01 | ||
| 108 | #define CEVTIND_DOI 0x02 | ||
| 109 | #define CEVTIND_LOST 0x04 | ||
| 110 | #define CEVTIND_FULL 0x08 | ||
| 111 | #define CEVTIND_BEI 0x10 | ||
| 112 | |||
| 113 | #define CEVTIND_CHIP_SJA1000 0x02 | ||
| 114 | |||
| 115 | #define ICAN3_BUSERR_QUOTA_MAX 255 | ||
| 116 | |||
| 117 | /* Janz ICAN3 CAN Frame Conversion */ | ||
| 118 | #define ICAN3_ECHO 0x10 | ||
| 119 | #define ICAN3_EFF_RTR 0x40 | ||
| 120 | #define ICAN3_SFF_RTR 0x10 | ||
| 121 | #define ICAN3_EFF 0x80 | ||
| 122 | |||
| 123 | #define ICAN3_CAN_TYPE_MASK 0x0f | ||
| 124 | #define ICAN3_CAN_TYPE_SFF 0x00 | ||
| 125 | #define ICAN3_CAN_TYPE_EFF 0x01 | ||
| 126 | |||
| 127 | #define ICAN3_CAN_DLC_MASK 0x0f | ||
| 128 | |||
| 129 | /* | ||
| 130 | * SJA1000 Status and Error Register Definitions | ||
| 131 | * | ||
| 132 | * Copied from drivers/net/can/sja1000/sja1000.h | ||
| 133 | */ | ||
| 134 | |||
| 135 | /* status register content */ | ||
| 136 | #define SR_BS 0x80 | ||
| 137 | #define SR_ES 0x40 | ||
| 138 | #define SR_TS 0x20 | ||
| 139 | #define SR_RS 0x10 | ||
| 140 | #define SR_TCS 0x08 | ||
| 141 | #define SR_TBS 0x04 | ||
| 142 | #define SR_DOS 0x02 | ||
| 143 | #define SR_RBS 0x01 | ||
| 144 | |||
| 145 | #define SR_CRIT (SR_BS|SR_ES) | ||
| 146 | |||
| 147 | /* ECC register */ | ||
| 148 | #define ECC_SEG 0x1F | ||
| 149 | #define ECC_DIR 0x20 | ||
| 150 | #define ECC_ERR 6 | ||
| 151 | #define ECC_BIT 0x00 | ||
| 152 | #define ECC_FORM 0x40 | ||
| 153 | #define ECC_STUFF 0x80 | ||
| 154 | #define ECC_MASK 0xc0 | ||
| 155 | |||
| 156 | /* Number of buffers for use in the "new-style" host interface */ | ||
| 157 | #define ICAN3_NEW_BUFFERS 16 | ||
| 158 | |||
| 159 | /* Number of buffers for use in the "fast" host interface */ | ||
| 160 | #define ICAN3_TX_BUFFERS 512 | ||
| 161 | #define ICAN3_RX_BUFFERS 1024 | ||
| 162 | |||
| 163 | /* SJA1000 Clock Input */ | ||
| 164 | #define ICAN3_CAN_CLOCK 8000000 | ||
| 165 | |||
| 166 | /* Driver Name */ | ||
| 167 | #define DRV_NAME "janz-ican3" | ||
| 168 | |||
| 169 | /* DPM Control Registers -- starts at offset 0x100 in the MODULbus registers */ | ||
| 170 | struct ican3_dpm_control { | ||
| 171 | /* window address register */ | ||
| 172 | u8 window_address; | ||
| 173 | u8 unused1; | ||
| 174 | |||
| 175 | /* | ||
| 176 | * Read access: clear interrupt from microcontroller | ||
| 177 | * Write access: send interrupt to microcontroller | ||
| 178 | */ | ||
| 179 | u8 interrupt; | ||
| 180 | u8 unused2; | ||
| 181 | |||
| 182 | /* write-only: reset all hardware on the module */ | ||
| 183 | u8 hwreset; | ||
| 184 | u8 unused3; | ||
| 185 | |||
| 186 | /* write-only: generate an interrupt to the TPU */ | ||
| 187 | u8 tpuinterrupt; | ||
| 188 | }; | ||
| 189 | |||
| 190 | struct ican3_dev { | ||
| 191 | |||
| 192 | /* must be the first member */ | ||
| 193 | struct can_priv can; | ||
| 194 | |||
| 195 | /* CAN network device */ | ||
| 196 | struct net_device *ndev; | ||
| 197 | struct napi_struct napi; | ||
| 198 | |||
| 199 | /* Device for printing */ | ||
| 200 | struct device *dev; | ||
| 201 | |||
| 202 | /* module number */ | ||
| 203 | unsigned int num; | ||
| 204 | |||
| 205 | /* base address of registers and IRQ */ | ||
| 206 | struct janz_cmodio_onboard_regs __iomem *ctrl; | ||
| 207 | struct ican3_dpm_control __iomem *dpmctrl; | ||
| 208 | void __iomem *dpm; | ||
| 209 | int irq; | ||
| 210 | |||
| 211 | /* CAN bus termination status */ | ||
| 212 | struct completion termination_comp; | ||
| 213 | bool termination_enabled; | ||
| 214 | |||
| 215 | /* CAN bus error status registers */ | ||
| 216 | struct completion buserror_comp; | ||
| 217 | struct can_berr_counter bec; | ||
| 218 | |||
| 219 | /* old and new style host interface */ | ||
| 220 | unsigned int iftype; | ||
| 221 | |||
| 222 | /* | ||
| 223 | * Any function which changes the current DPM page must hold this | ||
| 224 | * lock while it is performing data accesses. This ensures that the | ||
| 225 | * function will not be preempted and end up reading data from a | ||
| 226 | * different DPM page than it expects. | ||
| 227 | */ | ||
| 228 | spinlock_t lock; | ||
| 229 | |||
| 230 | /* new host interface */ | ||
| 231 | unsigned int rx_int; | ||
| 232 | unsigned int rx_num; | ||
| 233 | unsigned int tx_num; | ||
| 234 | |||
| 235 | /* fast host interface */ | ||
| 236 | unsigned int fastrx_start; | ||
| 237 | unsigned int fastrx_int; | ||
| 238 | unsigned int fastrx_num; | ||
| 239 | unsigned int fasttx_start; | ||
| 240 | unsigned int fasttx_num; | ||
| 241 | |||
| 242 | /* first free DPM page */ | ||
| 243 | unsigned int free_page; | ||
| 244 | }; | ||
| 245 | |||
| 246 | struct ican3_msg { | ||
| 247 | u8 control; | ||
| 248 | u8 spec; | ||
| 249 | __le16 len; | ||
| 250 | u8 data[252]; | ||
| 251 | }; | ||
| 252 | |||
| 253 | struct ican3_new_desc { | ||
| 254 | u8 control; | ||
| 255 | u8 pointer; | ||
| 256 | }; | ||
| 257 | |||
| 258 | struct ican3_fast_desc { | ||
| 259 | u8 control; | ||
| 260 | u8 command; | ||
| 261 | u8 data[14]; | ||
| 262 | }; | ||
| 263 | |||
| 264 | /* write to the window basic address register */ | ||
| 265 | static inline void ican3_set_page(struct ican3_dev *mod, unsigned int page) | ||
| 266 | { | ||
| 267 | BUG_ON(page >= DPM_NUM_PAGES); | ||
| 268 | iowrite8(page, &mod->dpmctrl->window_address); | ||
| 269 | } | ||
| 270 | |||
| 271 | /* | ||
| 272 | * ICAN3 "old-style" host interface | ||
| 273 | */ | ||
| 274 | |||
| 275 | /* | ||
| 276 | * Recieve a message from the ICAN3 "old-style" firmware interface | ||
| 277 | * | ||
| 278 | * LOCKING: must hold mod->lock | ||
| 279 | * | ||
| 280 | * returns 0 on success, -ENOMEM when no message exists | ||
| 281 | */ | ||
| 282 | static int ican3_old_recv_msg(struct ican3_dev *mod, struct ican3_msg *msg) | ||
| 283 | { | ||
| 284 | unsigned int mbox, mbox_page; | ||
| 285 | u8 locl, peer, xord; | ||
| 286 | |||
| 287 | /* get the MSYNC registers */ | ||
| 288 | ican3_set_page(mod, QUEUE_OLD_CONTROL); | ||
| 289 | peer = ioread8(mod->dpm + MSYNC_PEER); | ||
| 290 | locl = ioread8(mod->dpm + MSYNC_LOCL); | ||
| 291 | xord = locl ^ peer; | ||
| 292 | |||
| 293 | if ((xord & MSYNC_RB_MASK) == 0x00) { | ||
| 294 | dev_dbg(mod->dev, "no mbox for reading\n"); | ||
| 295 | return -ENOMEM; | ||
| 296 | } | ||
| 297 | |||
| 298 | /* find the first free mbox to read */ | ||
| 299 | if ((xord & MSYNC_RB_MASK) == MSYNC_RB_MASK) | ||
| 300 | mbox = (xord & MSYNC_RBLW) ? MSYNC_RB0 : MSYNC_RB1; | ||
| 301 | else | ||
| 302 | mbox = (xord & MSYNC_RB0) ? MSYNC_RB0 : MSYNC_RB1; | ||
| 303 | |||
| 304 | /* copy the message */ | ||
| 305 | mbox_page = (mbox == MSYNC_RB0) ? QUEUE_OLD_RB0 : QUEUE_OLD_RB1; | ||
| 306 | ican3_set_page(mod, mbox_page); | ||
| 307 | memcpy_fromio(msg, mod->dpm, sizeof(*msg)); | ||
| 308 | |||
| 309 | /* | ||
| 310 | * notify the firmware that the read buffer is available | ||
| 311 | * for it to fill again | ||
| 312 | */ | ||
| 313 | locl ^= mbox; | ||
| 314 | |||
| 315 | ican3_set_page(mod, QUEUE_OLD_CONTROL); | ||
| 316 | iowrite8(locl, mod->dpm + MSYNC_LOCL); | ||
| 317 | return 0; | ||
| 318 | } | ||
| 319 | |||
| 320 | /* | ||
| 321 | * Send a message through the "old-style" firmware interface | ||
| 322 | * | ||
| 323 | * LOCKING: must hold mod->lock | ||
| 324 | * | ||
| 325 | * returns 0 on success, -ENOMEM when no free space exists | ||
| 326 | */ | ||
| 327 | static int ican3_old_send_msg(struct ican3_dev *mod, struct ican3_msg *msg) | ||
| 328 | { | ||
| 329 | unsigned int mbox, mbox_page; | ||
| 330 | u8 locl, peer, xord; | ||
| 331 | |||
| 332 | /* get the MSYNC registers */ | ||
| 333 | ican3_set_page(mod, QUEUE_OLD_CONTROL); | ||
| 334 | peer = ioread8(mod->dpm + MSYNC_PEER); | ||
| 335 | locl = ioread8(mod->dpm + MSYNC_LOCL); | ||
| 336 | xord = locl ^ peer; | ||
| 337 | |||
| 338 | if ((xord & MSYNC_WB_MASK) == MSYNC_WB_MASK) { | ||
| 339 | dev_err(mod->dev, "no mbox for writing\n"); | ||
| 340 | return -ENOMEM; | ||
| 341 | } | ||
| 342 | |||
| 343 | /* calculate a free mbox to use */ | ||
| 344 | mbox = (xord & MSYNC_WB0) ? MSYNC_WB1 : MSYNC_WB0; | ||
| 345 | |||
| 346 | /* copy the message to the DPM */ | ||
| 347 | mbox_page = (mbox == MSYNC_WB0) ? QUEUE_OLD_WB0 : QUEUE_OLD_WB1; | ||
| 348 | ican3_set_page(mod, mbox_page); | ||
| 349 | memcpy_toio(mod->dpm, msg, sizeof(*msg)); | ||
| 350 | |||
| 351 | locl ^= mbox; | ||
| 352 | if (mbox == MSYNC_WB1) | ||
| 353 | locl |= MSYNC_WBLW; | ||
| 354 | |||
| 355 | ican3_set_page(mod, QUEUE_OLD_CONTROL); | ||
| 356 | iowrite8(locl, mod->dpm + MSYNC_LOCL); | ||
| 357 | return 0; | ||
| 358 | } | ||
| 359 | |||
| 360 | /* | ||
| 361 | * ICAN3 "new-style" Host Interface Setup | ||
| 362 | */ | ||
| 363 | |||
| 364 | static void __devinit ican3_init_new_host_interface(struct ican3_dev *mod) | ||
| 365 | { | ||
| 366 | struct ican3_new_desc desc; | ||
| 367 | unsigned long flags; | ||
| 368 | void __iomem *dst; | ||
| 369 | int i; | ||
| 370 | |||
| 371 | spin_lock_irqsave(&mod->lock, flags); | ||
| 372 | |||
| 373 | /* setup the internal datastructures for RX */ | ||
| 374 | mod->rx_num = 0; | ||
| 375 | mod->rx_int = 0; | ||
| 376 | |||
| 377 | /* tohost queue descriptors are in page 5 */ | ||
| 378 | ican3_set_page(mod, QUEUE_TOHOST); | ||
| 379 | dst = mod->dpm; | ||
| 380 | |||
| 381 | /* initialize the tohost (rx) queue descriptors: pages 9-24 */ | ||
| 382 | for (i = 0; i < ICAN3_NEW_BUFFERS; i++) { | ||
| 383 | desc.control = DESC_INTERRUPT | DESC_LEN(1); /* I L=1 */ | ||
| 384 | desc.pointer = mod->free_page; | ||
| 385 | |||
| 386 | /* set wrap flag on last buffer */ | ||
| 387 | if (i == ICAN3_NEW_BUFFERS - 1) | ||
| 388 | desc.control |= DESC_WRAP; | ||
| 389 | |||
| 390 | memcpy_toio(dst, &desc, sizeof(desc)); | ||
| 391 | dst += sizeof(desc); | ||
| 392 | mod->free_page++; | ||
| 393 | } | ||
| 394 | |||
| 395 | /* fromhost (tx) mid queue descriptors are in page 6 */ | ||
| 396 | ican3_set_page(mod, QUEUE_FROMHOST_MID); | ||
| 397 | dst = mod->dpm; | ||
| 398 | |||
| 399 | /* setup the internal datastructures for TX */ | ||
| 400 | mod->tx_num = 0; | ||
| 401 | |||
| 402 | /* initialize the fromhost mid queue descriptors: pages 25-40 */ | ||
| 403 | for (i = 0; i < ICAN3_NEW_BUFFERS; i++) { | ||
| 404 | desc.control = DESC_VALID | DESC_LEN(1); /* V L=1 */ | ||
| 405 | desc.pointer = mod->free_page; | ||
| 406 | |||
| 407 | /* set wrap flag on last buffer */ | ||
| 408 | if (i == ICAN3_NEW_BUFFERS - 1) | ||
| 409 | desc.control |= DESC_WRAP; | ||
| 410 | |||
| 411 | memcpy_toio(dst, &desc, sizeof(desc)); | ||
| 412 | dst += sizeof(desc); | ||
| 413 | mod->free_page++; | ||
| 414 | } | ||
| 415 | |||
| 416 | /* fromhost hi queue descriptors are in page 7 */ | ||
| 417 | ican3_set_page(mod, QUEUE_FROMHOST_HIGH); | ||
| 418 | dst = mod->dpm; | ||
| 419 | |||
| 420 | /* initialize only a single buffer in the fromhost hi queue (unused) */ | ||
| 421 | desc.control = DESC_VALID | DESC_WRAP | DESC_LEN(1); /* VW L=1 */ | ||
| 422 | desc.pointer = mod->free_page; | ||
| 423 | memcpy_toio(dst, &desc, sizeof(desc)); | ||
| 424 | mod->free_page++; | ||
| 425 | |||
| 426 | /* fromhost low queue descriptors are in page 8 */ | ||
| 427 | ican3_set_page(mod, QUEUE_FROMHOST_LOW); | ||
| 428 | dst = mod->dpm; | ||
| 429 | |||
| 430 | /* initialize only a single buffer in the fromhost low queue (unused) */ | ||
| 431 | desc.control = DESC_VALID | DESC_WRAP | DESC_LEN(1); /* VW L=1 */ | ||
| 432 | desc.pointer = mod->free_page; | ||
| 433 | memcpy_toio(dst, &desc, sizeof(desc)); | ||
| 434 | mod->free_page++; | ||
| 435 | |||
| 436 | spin_unlock_irqrestore(&mod->lock, flags); | ||
| 437 | } | ||
| 438 | |||
| 439 | /* | ||
| 440 | * ICAN3 Fast Host Interface Setup | ||
| 441 | */ | ||
| 442 | |||
| 443 | static void __devinit ican3_init_fast_host_interface(struct ican3_dev *mod) | ||
| 444 | { | ||
| 445 | struct ican3_fast_desc desc; | ||
| 446 | unsigned long flags; | ||
| 447 | unsigned int addr; | ||
| 448 | void __iomem *dst; | ||
| 449 | int i; | ||
| 450 | |||
| 451 | spin_lock_irqsave(&mod->lock, flags); | ||
| 452 | |||
| 453 | /* save the start recv page */ | ||
| 454 | mod->fastrx_start = mod->free_page; | ||
| 455 | mod->fastrx_num = 0; | ||
| 456 | mod->fastrx_int = 0; | ||
| 457 | |||
| 458 | /* build a single fast tohost queue descriptor */ | ||
| 459 | memset(&desc, 0, sizeof(desc)); | ||
| 460 | desc.control = 0x00; | ||
| 461 | desc.command = 1; | ||
| 462 | |||
| 463 | /* build the tohost queue descriptor ring in memory */ | ||
| 464 | addr = 0; | ||
| 465 | for (i = 0; i < ICAN3_RX_BUFFERS; i++) { | ||
| 466 | |||
| 467 | /* set the wrap bit on the last buffer */ | ||
| 468 | if (i == ICAN3_RX_BUFFERS - 1) | ||
| 469 | desc.control |= DESC_WRAP; | ||
| 470 | |||
| 471 | /* switch to the correct page */ | ||
| 472 | ican3_set_page(mod, mod->free_page); | ||
| 473 | |||
| 474 | /* copy the descriptor to the DPM */ | ||
| 475 | dst = mod->dpm + addr; | ||
| 476 | memcpy_toio(dst, &desc, sizeof(desc)); | ||
| 477 | addr += sizeof(desc); | ||
| 478 | |||
| 479 | /* move to the next page if necessary */ | ||
| 480 | if (addr >= DPM_PAGE_SIZE) { | ||
| 481 | addr = 0; | ||
| 482 | mod->free_page++; | ||
| 483 | } | ||
| 484 | } | ||
| 485 | |||
| 486 | /* make sure we page-align the next queue */ | ||
| 487 | if (addr != 0) | ||
| 488 | mod->free_page++; | ||
| 489 | |||
| 490 | /* save the start xmit page */ | ||
| 491 | mod->fasttx_start = mod->free_page; | ||
| 492 | mod->fasttx_num = 0; | ||
| 493 | |||
| 494 | /* build a single fast fromhost queue descriptor */ | ||
| 495 | memset(&desc, 0, sizeof(desc)); | ||
| 496 | desc.control = DESC_VALID; | ||
| 497 | desc.command = 1; | ||
| 498 | |||
| 499 | /* build the fromhost queue descriptor ring in memory */ | ||
| 500 | addr = 0; | ||
| 501 | for (i = 0; i < ICAN3_TX_BUFFERS; i++) { | ||
| 502 | |||
| 503 | /* set the wrap bit on the last buffer */ | ||
| 504 | if (i == ICAN3_TX_BUFFERS - 1) | ||
| 505 | desc.control |= DESC_WRAP; | ||
| 506 | |||
| 507 | /* switch to the correct page */ | ||
| 508 | ican3_set_page(mod, mod->free_page); | ||
| 509 | |||
| 510 | /* copy the descriptor to the DPM */ | ||
| 511 | dst = mod->dpm + addr; | ||
| 512 | memcpy_toio(dst, &desc, sizeof(desc)); | ||
| 513 | addr += sizeof(desc); | ||
| 514 | |||
| 515 | /* move to the next page if necessary */ | ||
| 516 | if (addr >= DPM_PAGE_SIZE) { | ||
| 517 | addr = 0; | ||
| 518 | mod->free_page++; | ||
| 519 | } | ||
| 520 | } | ||
| 521 | |||
| 522 | spin_unlock_irqrestore(&mod->lock, flags); | ||
| 523 | } | ||
| 524 | |||
| 525 | /* | ||
| 526 | * ICAN3 "new-style" Host Interface Message Helpers | ||
| 527 | */ | ||
| 528 | |||
| 529 | /* | ||
| 530 | * LOCKING: must hold mod->lock | ||
| 531 | */ | ||
| 532 | static int ican3_new_send_msg(struct ican3_dev *mod, struct ican3_msg *msg) | ||
| 533 | { | ||
| 534 | struct ican3_new_desc desc; | ||
| 535 | void __iomem *desc_addr = mod->dpm + (mod->tx_num * sizeof(desc)); | ||
| 536 | |||
| 537 | /* switch to the fromhost mid queue, and read the buffer descriptor */ | ||
| 538 | ican3_set_page(mod, QUEUE_FROMHOST_MID); | ||
| 539 | memcpy_fromio(&desc, desc_addr, sizeof(desc)); | ||
| 540 | |||
| 541 | if (!(desc.control & DESC_VALID)) { | ||
| 542 | dev_dbg(mod->dev, "%s: no free buffers\n", __func__); | ||
| 543 | return -ENOMEM; | ||
| 544 | } | ||
| 545 | |||
| 546 | /* switch to the data page, copy the data */ | ||
| 547 | ican3_set_page(mod, desc.pointer); | ||
| 548 | memcpy_toio(mod->dpm, msg, sizeof(*msg)); | ||
| 549 | |||
| 550 | /* switch back to the descriptor, set the valid bit, write it back */ | ||
| 551 | ican3_set_page(mod, QUEUE_FROMHOST_MID); | ||
| 552 | desc.control ^= DESC_VALID; | ||
| 553 | memcpy_toio(desc_addr, &desc, sizeof(desc)); | ||
| 554 | |||
| 555 | /* update the tx number */ | ||
| 556 | mod->tx_num = (desc.control & DESC_WRAP) ? 0 : (mod->tx_num + 1); | ||
| 557 | return 0; | ||
| 558 | } | ||
| 559 | |||
| 560 | /* | ||
| 561 | * LOCKING: must hold mod->lock | ||
| 562 | */ | ||
| 563 | static int ican3_new_recv_msg(struct ican3_dev *mod, struct ican3_msg *msg) | ||
| 564 | { | ||
| 565 | struct ican3_new_desc desc; | ||
| 566 | void __iomem *desc_addr = mod->dpm + (mod->rx_num * sizeof(desc)); | ||
| 567 | |||
| 568 | /* switch to the tohost queue, and read the buffer descriptor */ | ||
| 569 | ican3_set_page(mod, QUEUE_TOHOST); | ||
| 570 | memcpy_fromio(&desc, desc_addr, sizeof(desc)); | ||
| 571 | |||
| 572 | if (!(desc.control & DESC_VALID)) { | ||
| 573 | dev_dbg(mod->dev, "%s: no buffers to recv\n", __func__); | ||
| 574 | return -ENOMEM; | ||
| 575 | } | ||
| 576 | |||
| 577 | /* switch to the data page, copy the data */ | ||
| 578 | ican3_set_page(mod, desc.pointer); | ||
| 579 | memcpy_fromio(msg, mod->dpm, sizeof(*msg)); | ||
| 580 | |||
| 581 | /* switch back to the descriptor, toggle the valid bit, write it back */ | ||
| 582 | ican3_set_page(mod, QUEUE_TOHOST); | ||
| 583 | desc.control ^= DESC_VALID; | ||
| 584 | memcpy_toio(desc_addr, &desc, sizeof(desc)); | ||
| 585 | |||
| 586 | /* update the rx number */ | ||
| 587 | mod->rx_num = (desc.control & DESC_WRAP) ? 0 : (mod->rx_num + 1); | ||
| 588 | return 0; | ||
| 589 | } | ||
| 590 | |||
| 591 | /* | ||
| 592 | * Message Send / Recv Helpers | ||
| 593 | */ | ||
| 594 | |||
| 595 | static int ican3_send_msg(struct ican3_dev *mod, struct ican3_msg *msg) | ||
| 596 | { | ||
| 597 | unsigned long flags; | ||
| 598 | int ret; | ||
| 599 | |||
| 600 | spin_lock_irqsave(&mod->lock, flags); | ||
| 601 | |||
| 602 | if (mod->iftype == 0) | ||
| 603 | ret = ican3_old_send_msg(mod, msg); | ||
| 604 | else | ||
| 605 | ret = ican3_new_send_msg(mod, msg); | ||
| 606 | |||
| 607 | spin_unlock_irqrestore(&mod->lock, flags); | ||
| 608 | return ret; | ||
| 609 | } | ||
| 610 | |||
| 611 | static int ican3_recv_msg(struct ican3_dev *mod, struct ican3_msg *msg) | ||
| 612 | { | ||
| 613 | unsigned long flags; | ||
| 614 | int ret; | ||
| 615 | |||
| 616 | spin_lock_irqsave(&mod->lock, flags); | ||
| 617 | |||
| 618 | if (mod->iftype == 0) | ||
| 619 | ret = ican3_old_recv_msg(mod, msg); | ||
| 620 | else | ||
| 621 | ret = ican3_new_recv_msg(mod, msg); | ||
| 622 | |||
| 623 | spin_unlock_irqrestore(&mod->lock, flags); | ||
| 624 | return ret; | ||
| 625 | } | ||
| 626 | |||
| 627 | /* | ||
| 628 | * Quick Pre-constructed Messages | ||
| 629 | */ | ||
| 630 | |||
| 631 | static int __devinit ican3_msg_connect(struct ican3_dev *mod) | ||
| 632 | { | ||
| 633 | struct ican3_msg msg; | ||
| 634 | |||
| 635 | memset(&msg, 0, sizeof(msg)); | ||
| 636 | msg.spec = MSG_CONNECTI; | ||
| 637 | msg.len = cpu_to_le16(0); | ||
| 638 | |||
| 639 | return ican3_send_msg(mod, &msg); | ||
| 640 | } | ||
| 641 | |||
| 642 | static int __devexit ican3_msg_disconnect(struct ican3_dev *mod) | ||
| 643 | { | ||
| 644 | struct ican3_msg msg; | ||
| 645 | |||
| 646 | memset(&msg, 0, sizeof(msg)); | ||
| 647 | msg.spec = MSG_DISCONNECT; | ||
| 648 | msg.len = cpu_to_le16(0); | ||
| 649 | |||
| 650 | return ican3_send_msg(mod, &msg); | ||
| 651 | } | ||
| 652 | |||
| 653 | static int __devinit ican3_msg_newhostif(struct ican3_dev *mod) | ||
| 654 | { | ||
| 655 | struct ican3_msg msg; | ||
| 656 | int ret; | ||
| 657 | |||
| 658 | memset(&msg, 0, sizeof(msg)); | ||
| 659 | msg.spec = MSG_NEWHOSTIF; | ||
| 660 | msg.len = cpu_to_le16(0); | ||
| 661 | |||
| 662 | /* If we're not using the old interface, switching seems bogus */ | ||
| 663 | WARN_ON(mod->iftype != 0); | ||
| 664 | |||
| 665 | ret = ican3_send_msg(mod, &msg); | ||
| 666 | if (ret) | ||
| 667 | return ret; | ||
| 668 | |||
| 669 | /* mark the module as using the new host interface */ | ||
| 670 | mod->iftype = 1; | ||
| 671 | return 0; | ||
| 672 | } | ||
| 673 | |||
| 674 | static int __devinit ican3_msg_fasthostif(struct ican3_dev *mod) | ||
| 675 | { | ||
| 676 | struct ican3_msg msg; | ||
| 677 | unsigned int addr; | ||
| 678 | |||
| 679 | memset(&msg, 0, sizeof(msg)); | ||
| 680 | msg.spec = MSG_INITFDPMQUEUE; | ||
| 681 | msg.len = cpu_to_le16(8); | ||
| 682 | |||
| 683 | /* write the tohost queue start address */ | ||
| 684 | addr = DPM_PAGE_ADDR(mod->fastrx_start); | ||
| 685 | msg.data[0] = addr & 0xff; | ||
| 686 | msg.data[1] = (addr >> 8) & 0xff; | ||
| 687 | msg.data[2] = (addr >> 16) & 0xff; | ||
| 688 | msg.data[3] = (addr >> 24) & 0xff; | ||
| 689 | |||
| 690 | /* write the fromhost queue start address */ | ||
| 691 | addr = DPM_PAGE_ADDR(mod->fasttx_start); | ||
| 692 | msg.data[4] = addr & 0xff; | ||
| 693 | msg.data[5] = (addr >> 8) & 0xff; | ||
| 694 | msg.data[6] = (addr >> 16) & 0xff; | ||
| 695 | msg.data[7] = (addr >> 24) & 0xff; | ||
| 696 | |||
| 697 | /* If we're not using the new interface yet, we cannot do this */ | ||
| 698 | WARN_ON(mod->iftype != 1); | ||
| 699 | |||
| 700 | return ican3_send_msg(mod, &msg); | ||
| 701 | } | ||
| 702 | |||
| 703 | /* | ||
| 704 | * Setup the CAN filter to either accept or reject all | ||
| 705 | * messages from the CAN bus. | ||
| 706 | */ | ||
| 707 | static int __devinit ican3_set_id_filter(struct ican3_dev *mod, bool accept) | ||
| 708 | { | ||
| 709 | struct ican3_msg msg; | ||
| 710 | int ret; | ||
| 711 | |||
| 712 | /* Standard Frame Format */ | ||
| 713 | memset(&msg, 0, sizeof(msg)); | ||
| 714 | msg.spec = MSG_SETAFILMASK; | ||
| 715 | msg.len = cpu_to_le16(5); | ||
| 716 | msg.data[0] = 0x00; /* IDLo LSB */ | ||
| 717 | msg.data[1] = 0x00; /* IDLo MSB */ | ||
| 718 | msg.data[2] = 0xff; /* IDHi LSB */ | ||
| 719 | msg.data[3] = 0x07; /* IDHi MSB */ | ||
| 720 | |||
| 721 | /* accept all frames for fast host if, or reject all frames */ | ||
| 722 | msg.data[4] = accept ? SETAFILMASK_FASTIF : SETAFILMASK_REJECT; | ||
| 723 | |||
| 724 | ret = ican3_send_msg(mod, &msg); | ||
| 725 | if (ret) | ||
| 726 | return ret; | ||
| 727 | |||
| 728 | /* Extended Frame Format */ | ||
| 729 | memset(&msg, 0, sizeof(msg)); | ||
| 730 | msg.spec = MSG_SETAFILMASK; | ||
| 731 | msg.len = cpu_to_le16(13); | ||
| 732 | msg.data[0] = 0; /* MUX = 0 */ | ||
| 733 | msg.data[1] = 0x00; /* IDLo LSB */ | ||
| 734 | msg.data[2] = 0x00; | ||
| 735 | msg.data[3] = 0x00; | ||
| 736 | msg.data[4] = 0x20; /* IDLo MSB */ | ||
| 737 | msg.data[5] = 0xff; /* IDHi LSB */ | ||
| 738 | msg.data[6] = 0xff; | ||
| 739 | msg.data[7] = 0xff; | ||
| 740 | msg.data[8] = 0x3f; /* IDHi MSB */ | ||
| 741 | |||
| 742 | /* accept all frames for fast host if, or reject all frames */ | ||
| 743 | msg.data[9] = accept ? SETAFILMASK_FASTIF : SETAFILMASK_REJECT; | ||
| 744 | |||
| 745 | return ican3_send_msg(mod, &msg); | ||
| 746 | } | ||
| 747 | |||
| 748 | /* | ||
| 749 | * Bring the CAN bus online or offline | ||
| 750 | */ | ||
| 751 | static int ican3_set_bus_state(struct ican3_dev *mod, bool on) | ||
| 752 | { | ||
| 753 | struct ican3_msg msg; | ||
| 754 | |||
| 755 | memset(&msg, 0, sizeof(msg)); | ||
| 756 | msg.spec = on ? MSG_CONREQ : MSG_COFFREQ; | ||
| 757 | msg.len = cpu_to_le16(0); | ||
| 758 | |||
| 759 | return ican3_send_msg(mod, &msg); | ||
| 760 | } | ||
| 761 | |||
| 762 | static int ican3_set_termination(struct ican3_dev *mod, bool on) | ||
| 763 | { | ||
| 764 | struct ican3_msg msg; | ||
| 765 | |||
| 766 | memset(&msg, 0, sizeof(msg)); | ||
| 767 | msg.spec = MSG_HWCONF; | ||
| 768 | msg.len = cpu_to_le16(2); | ||
| 769 | msg.data[0] = 0x00; | ||
| 770 | msg.data[1] = on ? HWCONF_TERMINATE_ON : HWCONF_TERMINATE_OFF; | ||
| 771 | |||
| 772 | return ican3_send_msg(mod, &msg); | ||
| 773 | } | ||
| 774 | |||
| 775 | static int ican3_send_inquiry(struct ican3_dev *mod, u8 subspec) | ||
| 776 | { | ||
| 777 | struct ican3_msg msg; | ||
| 778 | |||
| 779 | memset(&msg, 0, sizeof(msg)); | ||
| 780 | msg.spec = MSG_INQUIRY; | ||
| 781 | msg.len = cpu_to_le16(2); | ||
| 782 | msg.data[0] = subspec; | ||
| 783 | msg.data[1] = 0x00; | ||
| 784 | |||
| 785 | return ican3_send_msg(mod, &msg); | ||
| 786 | } | ||
| 787 | |||
| 788 | static int ican3_set_buserror(struct ican3_dev *mod, u8 quota) | ||
| 789 | { | ||
| 790 | struct ican3_msg msg; | ||
| 791 | |||
| 792 | memset(&msg, 0, sizeof(msg)); | ||
| 793 | msg.spec = MSG_CCONFREQ; | ||
| 794 | msg.len = cpu_to_le16(2); | ||
| 795 | msg.data[0] = 0x00; | ||
| 796 | msg.data[1] = quota; | ||
| 797 | |||
| 798 | return ican3_send_msg(mod, &msg); | ||
| 799 | } | ||
| 800 | |||
| 801 | /* | ||
| 802 | * ICAN3 to Linux CAN Frame Conversion | ||
| 803 | */ | ||
| 804 | |||
| 805 | static void ican3_to_can_frame(struct ican3_dev *mod, | ||
| 806 | struct ican3_fast_desc *desc, | ||
| 807 | struct can_frame *cf) | ||
| 808 | { | ||
| 809 | if ((desc->command & ICAN3_CAN_TYPE_MASK) == ICAN3_CAN_TYPE_SFF) { | ||
| 810 | if (desc->data[1] & ICAN3_SFF_RTR) | ||
| 811 | cf->can_id |= CAN_RTR_FLAG; | ||
| 812 | |||
| 813 | cf->can_id |= desc->data[0] << 3; | ||
| 814 | cf->can_id |= (desc->data[1] & 0xe0) >> 5; | ||
| 815 | cf->can_dlc = desc->data[1] & ICAN3_CAN_DLC_MASK; | ||
| 816 | memcpy(cf->data, &desc->data[2], sizeof(cf->data)); | ||
| 817 | } else { | ||
| 818 | cf->can_dlc = desc->data[0] & ICAN3_CAN_DLC_MASK; | ||
| 819 | if (desc->data[0] & ICAN3_EFF_RTR) | ||
| 820 | cf->can_id |= CAN_RTR_FLAG; | ||
| 821 | |||
| 822 | if (desc->data[0] & ICAN3_EFF) { | ||
| 823 | cf->can_id |= CAN_EFF_FLAG; | ||
| 824 | cf->can_id |= desc->data[2] << 21; /* 28-21 */ | ||
| 825 | cf->can_id |= desc->data[3] << 13; /* 20-13 */ | ||
| 826 | cf->can_id |= desc->data[4] << 5; /* 12-5 */ | ||
| 827 | cf->can_id |= (desc->data[5] & 0xf8) >> 3; | ||
| 828 | } else { | ||
| 829 | cf->can_id |= desc->data[2] << 3; /* 10-3 */ | ||
| 830 | cf->can_id |= desc->data[3] >> 5; /* 2-0 */ | ||
| 831 | } | ||
| 832 | |||
| 833 | memcpy(cf->data, &desc->data[6], sizeof(cf->data)); | ||
| 834 | } | ||
| 835 | } | ||
| 836 | |||
| 837 | static void can_frame_to_ican3(struct ican3_dev *mod, | ||
| 838 | struct can_frame *cf, | ||
| 839 | struct ican3_fast_desc *desc) | ||
| 840 | { | ||
| 841 | /* clear out any stale data in the descriptor */ | ||
| 842 | memset(desc->data, 0, sizeof(desc->data)); | ||
| 843 | |||
| 844 | /* we always use the extended format, with the ECHO flag set */ | ||
| 845 | desc->command = ICAN3_CAN_TYPE_EFF; | ||
| 846 | desc->data[0] |= cf->can_dlc; | ||
| 847 | desc->data[1] |= ICAN3_ECHO; | ||
| 848 | |||
| 849 | if (cf->can_id & CAN_RTR_FLAG) | ||
| 850 | desc->data[0] |= ICAN3_EFF_RTR; | ||
| 851 | |||
| 852 | /* pack the id into the correct places */ | ||
| 853 | if (cf->can_id & CAN_EFF_FLAG) { | ||
| 854 | desc->data[0] |= ICAN3_EFF; | ||
| 855 | desc->data[2] = (cf->can_id & 0x1fe00000) >> 21; /* 28-21 */ | ||
| 856 | desc->data[3] = (cf->can_id & 0x001fe000) >> 13; /* 20-13 */ | ||
| 857 | desc->data[4] = (cf->can_id & 0x00001fe0) >> 5; /* 12-5 */ | ||
| 858 | desc->data[5] = (cf->can_id & 0x0000001f) << 3; /* 4-0 */ | ||
| 859 | } else { | ||
| 860 | desc->data[2] = (cf->can_id & 0x7F8) >> 3; /* bits 10-3 */ | ||
| 861 | desc->data[3] = (cf->can_id & 0x007) << 5; /* bits 2-0 */ | ||
| 862 | } | ||
| 863 | |||
| 864 | /* copy the data bits into the descriptor */ | ||
| 865 | memcpy(&desc->data[6], cf->data, sizeof(cf->data)); | ||
| 866 | } | ||
| 867 | |||
| 868 | /* | ||
| 869 | * Interrupt Handling | ||
| 870 | */ | ||
| 871 | |||
| 872 | /* | ||
| 873 | * Handle an ID + Version message response from the firmware. We never generate | ||
| 874 | * this message in production code, but it is very useful when debugging to be | ||
| 875 | * able to display this message. | ||
| 876 | */ | ||
| 877 | static void ican3_handle_idvers(struct ican3_dev *mod, struct ican3_msg *msg) | ||
| 878 | { | ||
| 879 | dev_dbg(mod->dev, "IDVERS response: %s\n", msg->data); | ||
| 880 | } | ||
| 881 | |||
| 882 | static void ican3_handle_msglost(struct ican3_dev *mod, struct ican3_msg *msg) | ||
| 883 | { | ||
| 884 | struct net_device *dev = mod->ndev; | ||
| 885 | struct net_device_stats *stats = &dev->stats; | ||
| 886 | struct can_frame *cf; | ||
| 887 | struct sk_buff *skb; | ||
| 888 | |||
| 889 | /* | ||
| 890 | * Report that communication messages with the microcontroller firmware | ||
| 891 | * are being lost. These are never CAN frames, so we do not generate an | ||
| 892 | * error frame for userspace | ||
| 893 | */ | ||
| 894 | if (msg->spec == MSG_MSGLOST) { | ||
| 895 | dev_err(mod->dev, "lost %d control messages\n", msg->data[0]); | ||
| 896 | return; | ||
| 897 | } | ||
| 898 | |||
| 899 | /* | ||
| 900 | * Oops, this indicates that we have lost messages in the fast queue, | ||
| 901 | * which are exclusively CAN messages. Our driver isn't reading CAN | ||
| 902 | * frames fast enough. | ||
| 903 | * | ||
| 904 | * We'll pretend that the SJA1000 told us that it ran out of buffer | ||
| 905 | * space, because there is not a better message for this. | ||
| 906 | */ | ||
| 907 | skb = alloc_can_err_skb(dev, &cf); | ||
| 908 | if (skb) { | ||
| 909 | cf->can_id |= CAN_ERR_CRTL; | ||
| 910 | cf->data[1] = CAN_ERR_CRTL_RX_OVERFLOW; | ||
| 911 | stats->rx_errors++; | ||
| 912 | stats->rx_bytes += cf->can_dlc; | ||
| 913 | netif_rx(skb); | ||
| 914 | } | ||
| 915 | } | ||
| 916 | |||
| 917 | /* | ||
| 918 | * Handle CAN Event Indication Messages from the firmware | ||
| 919 | * | ||
| 920 | * The ICAN3 firmware provides the values of some SJA1000 registers when it | ||
| 921 | * generates this message. The code below is largely copied from the | ||
| 922 | * drivers/net/can/sja1000/sja1000.c file, and adapted as necessary | ||
| 923 | */ | ||
| 924 | static int ican3_handle_cevtind(struct ican3_dev *mod, struct ican3_msg *msg) | ||
| 925 | { | ||
| 926 | struct net_device *dev = mod->ndev; | ||
| 927 | struct net_device_stats *stats = &dev->stats; | ||
| 928 | enum can_state state = mod->can.state; | ||
| 929 | u8 status, isrc, rxerr, txerr; | ||
| 930 | struct can_frame *cf; | ||
| 931 | struct sk_buff *skb; | ||
| 932 | |||
| 933 | /* we can only handle the SJA1000 part */ | ||
| 934 | if (msg->data[1] != CEVTIND_CHIP_SJA1000) { | ||
| 935 | dev_err(mod->dev, "unable to handle errors on non-SJA1000\n"); | ||
| 936 | return -ENODEV; | ||
| 937 | } | ||
| 938 | |||
| 939 | /* check the message length for sanity */ | ||
| 940 | if (le16_to_cpu(msg->len) < 6) { | ||
| 941 | dev_err(mod->dev, "error message too short\n"); | ||
| 942 | return -EINVAL; | ||
| 943 | } | ||
| 944 | |||
| 945 | skb = alloc_can_err_skb(dev, &cf); | ||
| 946 | if (skb == NULL) | ||
| 947 | return -ENOMEM; | ||
| 948 | |||
| 949 | isrc = msg->data[0]; | ||
| 950 | status = msg->data[3]; | ||
| 951 | rxerr = msg->data[4]; | ||
| 952 | txerr = msg->data[5]; | ||
| 953 | |||
| 954 | /* data overrun interrupt */ | ||
| 955 | if (isrc == CEVTIND_DOI || isrc == CEVTIND_LOST) { | ||
| 956 | dev_dbg(mod->dev, "data overrun interrupt\n"); | ||
| 957 | cf->can_id |= CAN_ERR_CRTL; | ||
| 958 | cf->data[1] = CAN_ERR_CRTL_RX_OVERFLOW; | ||
| 959 | stats->rx_over_errors++; | ||
| 960 | stats->rx_errors++; | ||
| 961 | } | ||
| 962 | |||
| 963 | /* error warning + passive interrupt */ | ||
| 964 | if (isrc == CEVTIND_EI) { | ||
| 965 | dev_dbg(mod->dev, "error warning + passive interrupt\n"); | ||
| 966 | if (status & SR_BS) { | ||
| 967 | state = CAN_STATE_BUS_OFF; | ||
| 968 | cf->can_id |= CAN_ERR_BUSOFF; | ||
| 969 | can_bus_off(dev); | ||
| 970 | } else if (status & SR_ES) { | ||
| 971 | if (rxerr >= 128 || txerr >= 128) | ||
| 972 | state = CAN_STATE_ERROR_PASSIVE; | ||
| 973 | else | ||
| 974 | state = CAN_STATE_ERROR_WARNING; | ||
| 975 | } else { | ||
| 976 | state = CAN_STATE_ERROR_ACTIVE; | ||
| 977 | } | ||
| 978 | } | ||
| 979 | |||
| 980 | /* bus error interrupt */ | ||
| 981 | if (isrc == CEVTIND_BEI) { | ||
| 982 | u8 ecc = msg->data[2]; | ||
| 983 | |||
| 984 | dev_dbg(mod->dev, "bus error interrupt\n"); | ||
| 985 | mod->can.can_stats.bus_error++; | ||
| 986 | stats->rx_errors++; | ||
| 987 | cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR; | ||
| 988 | |||
| 989 | switch (ecc & ECC_MASK) { | ||
| 990 | case ECC_BIT: | ||
| 991 | cf->data[2] |= CAN_ERR_PROT_BIT; | ||
| 992 | break; | ||
| 993 | case ECC_FORM: | ||
| 994 | cf->data[2] |= CAN_ERR_PROT_FORM; | ||
| 995 | break; | ||
| 996 | case ECC_STUFF: | ||
| 997 | cf->data[2] |= CAN_ERR_PROT_STUFF; | ||
| 998 | break; | ||
| 999 | default: | ||
| 1000 | cf->data[2] |= CAN_ERR_PROT_UNSPEC; | ||
| 1001 | cf->data[3] = ecc & ECC_SEG; | ||
| 1002 | break; | ||
| 1003 | } | ||
| 1004 | |||
| 1005 | if ((ecc & ECC_DIR) == 0) | ||
| 1006 | cf->data[2] |= CAN_ERR_PROT_TX; | ||
| 1007 | |||
| 1008 | cf->data[6] = txerr; | ||
| 1009 | cf->data[7] = rxerr; | ||
| 1010 | } | ||
| 1011 | |||
| 1012 | if (state != mod->can.state && (state == CAN_STATE_ERROR_WARNING || | ||
| 1013 | state == CAN_STATE_ERROR_PASSIVE)) { | ||
| 1014 | cf->can_id |= CAN_ERR_CRTL; | ||
| 1015 | if (state == CAN_STATE_ERROR_WARNING) { | ||
| 1016 | mod->can.can_stats.error_warning++; | ||
| 1017 | cf->data[1] = (txerr > rxerr) ? | ||
| 1018 | CAN_ERR_CRTL_TX_WARNING : | ||
| 1019 | CAN_ERR_CRTL_RX_WARNING; | ||
| 1020 | } else { | ||
| 1021 | mod->can.can_stats.error_passive++; | ||
| 1022 | cf->data[1] = (txerr > rxerr) ? | ||
| 1023 | CAN_ERR_CRTL_TX_PASSIVE : | ||
| 1024 | CAN_ERR_CRTL_RX_PASSIVE; | ||
| 1025 | } | ||
| 1026 | |||
| 1027 | cf->data[6] = txerr; | ||
| 1028 | cf->data[7] = rxerr; | ||
| 1029 | } | ||
| 1030 | |||
| 1031 | mod->can.state = state; | ||
| 1032 | stats->rx_errors++; | ||
| 1033 | stats->rx_bytes += cf->can_dlc; | ||
| 1034 | netif_rx(skb); | ||
| 1035 | return 0; | ||
| 1036 | } | ||
| 1037 | |||
| 1038 | static void ican3_handle_inquiry(struct ican3_dev *mod, struct ican3_msg *msg) | ||
| 1039 | { | ||
| 1040 | switch (msg->data[0]) { | ||
| 1041 | case INQUIRY_STATUS: | ||
| 1042 | case INQUIRY_EXTENDED: | ||
| 1043 | mod->bec.rxerr = msg->data[5]; | ||
| 1044 | mod->bec.txerr = msg->data[6]; | ||
| 1045 | complete(&mod->buserror_comp); | ||
| 1046 | break; | ||
| 1047 | case INQUIRY_TERMINATION: | ||
| 1048 | mod->termination_enabled = msg->data[6] & HWCONF_TERMINATE_ON; | ||
| 1049 | complete(&mod->termination_comp); | ||
| 1050 | break; | ||
| 1051 | default: | ||
| 1052 | dev_err(mod->dev, "recieved an unknown inquiry response\n"); | ||
| 1053 | break; | ||
| 1054 | } | ||
| 1055 | } | ||
| 1056 | |||
| 1057 | static void ican3_handle_unknown_message(struct ican3_dev *mod, | ||
| 1058 | struct ican3_msg *msg) | ||
| 1059 | { | ||
| 1060 | dev_warn(mod->dev, "recieved unknown message: spec 0x%.2x length %d\n", | ||
| 1061 | msg->spec, le16_to_cpu(msg->len)); | ||
| 1062 | } | ||
| 1063 | |||
| 1064 | /* | ||
| 1065 | * Handle a control message from the firmware | ||
| 1066 | */ | ||
| 1067 | static void ican3_handle_message(struct ican3_dev *mod, struct ican3_msg *msg) | ||
| 1068 | { | ||
| 1069 | dev_dbg(mod->dev, "%s: modno %d spec 0x%.2x len %d bytes\n", __func__, | ||
| 1070 | mod->num, msg->spec, le16_to_cpu(msg->len)); | ||
| 1071 | |||
| 1072 | switch (msg->spec) { | ||
| 1073 | case MSG_IDVERS: | ||
| 1074 | ican3_handle_idvers(mod, msg); | ||
| 1075 | break; | ||
| 1076 | case MSG_MSGLOST: | ||
| 1077 | case MSG_FMSGLOST: | ||
| 1078 | ican3_handle_msglost(mod, msg); | ||
| 1079 | break; | ||
| 1080 | case MSG_CEVTIND: | ||
| 1081 | ican3_handle_cevtind(mod, msg); | ||
| 1082 | break; | ||
| 1083 | case MSG_INQUIRY: | ||
| 1084 | ican3_handle_inquiry(mod, msg); | ||
| 1085 | break; | ||
| 1086 | default: | ||
| 1087 | ican3_handle_unknown_message(mod, msg); | ||
| 1088 | break; | ||
| 1089 | } | ||
| 1090 | } | ||
| 1091 | |||
| 1092 | /* | ||
| 1093 | * Check that there is room in the TX ring to transmit another skb | ||
| 1094 | * | ||
| 1095 | * LOCKING: must hold mod->lock | ||
| 1096 | */ | ||
| 1097 | static bool ican3_txok(struct ican3_dev *mod) | ||
| 1098 | { | ||
| 1099 | struct ican3_fast_desc __iomem *desc; | ||
| 1100 | u8 control; | ||
| 1101 | |||
| 1102 | /* copy the control bits of the descriptor */ | ||
| 1103 | ican3_set_page(mod, mod->fasttx_start + (mod->fasttx_num / 16)); | ||
| 1104 | desc = mod->dpm + ((mod->fasttx_num % 16) * sizeof(*desc)); | ||
| 1105 | control = ioread8(&desc->control); | ||
| 1106 | |||
| 1107 | /* if the control bits are not valid, then we have no more space */ | ||
| 1108 | if (!(control & DESC_VALID)) | ||
| 1109 | return false; | ||
| 1110 | |||
| 1111 | return true; | ||
| 1112 | } | ||
| 1113 | |||
| 1114 | /* | ||
| 1115 | * Recieve one CAN frame from the hardware | ||
| 1116 | * | ||
| 1117 | * This works like the core of a NAPI function, but is intended to be called | ||
| 1118 | * from workqueue context instead. This driver already needs a workqueue to | ||
| 1119 | * process control messages, so we use the workqueue instead of using NAPI. | ||
| 1120 | * This was done to simplify locking. | ||
| 1121 | * | ||
| 1122 | * CONTEXT: must be called from user context | ||
| 1123 | */ | ||
| 1124 | static int ican3_recv_skb(struct ican3_dev *mod) | ||
| 1125 | { | ||
| 1126 | struct net_device *ndev = mod->ndev; | ||
| 1127 | struct net_device_stats *stats = &ndev->stats; | ||
| 1128 | struct ican3_fast_desc desc; | ||
| 1129 | void __iomem *desc_addr; | ||
| 1130 | struct can_frame *cf; | ||
| 1131 | struct sk_buff *skb; | ||
| 1132 | unsigned long flags; | ||
| 1133 | |||
| 1134 | spin_lock_irqsave(&mod->lock, flags); | ||
| 1135 | |||
| 1136 | /* copy the whole descriptor */ | ||
| 1137 | ican3_set_page(mod, mod->fastrx_start + (mod->fastrx_num / 16)); | ||
| 1138 | desc_addr = mod->dpm + ((mod->fastrx_num % 16) * sizeof(desc)); | ||
| 1139 | memcpy_fromio(&desc, desc_addr, sizeof(desc)); | ||
| 1140 | |||
| 1141 | spin_unlock_irqrestore(&mod->lock, flags); | ||
| 1142 | |||
| 1143 | /* check that we actually have a CAN frame */ | ||
| 1144 | if (!(desc.control & DESC_VALID)) | ||
| 1145 | return -ENOBUFS; | ||
| 1146 | |||
| 1147 | /* allocate an skb */ | ||
| 1148 | skb = alloc_can_skb(ndev, &cf); | ||
| 1149 | if (unlikely(skb == NULL)) { | ||
| 1150 | stats->rx_dropped++; | ||
| 1151 | goto err_noalloc; | ||
| 1152 | } | ||
| 1153 | |||
| 1154 | /* convert the ICAN3 frame into Linux CAN format */ | ||
| 1155 | ican3_to_can_frame(mod, &desc, cf); | ||
| 1156 | |||
| 1157 | /* receive the skb, update statistics */ | ||
| 1158 | netif_receive_skb(skb); | ||
| 1159 | stats->rx_packets++; | ||
| 1160 | stats->rx_bytes += cf->can_dlc; | ||
| 1161 | |||
| 1162 | err_noalloc: | ||
| 1163 | /* toggle the valid bit and return the descriptor to the ring */ | ||
| 1164 | desc.control ^= DESC_VALID; | ||
| 1165 | |||
| 1166 | spin_lock_irqsave(&mod->lock, flags); | ||
| 1167 | |||
| 1168 | ican3_set_page(mod, mod->fastrx_start + (mod->fastrx_num / 16)); | ||
| 1169 | memcpy_toio(desc_addr, &desc, 1); | ||
| 1170 | |||
| 1171 | /* update the next buffer pointer */ | ||
| 1172 | mod->fastrx_num = (desc.control & DESC_WRAP) ? 0 | ||
| 1173 | : (mod->fastrx_num + 1); | ||
| 1174 | |||
| 1175 | /* there are still more buffers to process */ | ||
| 1176 | spin_unlock_irqrestore(&mod->lock, flags); | ||
| 1177 | return 0; | ||
| 1178 | } | ||
| 1179 | |||
| 1180 | static int ican3_napi(struct napi_struct *napi, int budget) | ||
| 1181 | { | ||
| 1182 | struct ican3_dev *mod = container_of(napi, struct ican3_dev, napi); | ||
| 1183 | struct ican3_msg msg; | ||
| 1184 | unsigned long flags; | ||
| 1185 | int received = 0; | ||
| 1186 | int ret; | ||
| 1187 | |||
| 1188 | /* process all communication messages */ | ||
| 1189 | while (true) { | ||
| 1190 | ret = ican3_recv_msg(mod, &msg); | ||
| 1191 | if (ret) | ||
| 1192 | break; | ||
| 1193 | |||
| 1194 | ican3_handle_message(mod, &msg); | ||
| 1195 | } | ||
| 1196 | |||
| 1197 | /* process all CAN frames from the fast interface */ | ||
| 1198 | while (received < budget) { | ||
| 1199 | ret = ican3_recv_skb(mod); | ||
| 1200 | if (ret) | ||
| 1201 | break; | ||
| 1202 | |||
| 1203 | received++; | ||
| 1204 | } | ||
| 1205 | |||
| 1206 | /* We have processed all packets that the adapter had, but it | ||
| 1207 | * was less than our budget, stop polling */ | ||
| 1208 | if (received < budget) | ||
| 1209 | napi_complete(napi); | ||
| 1210 | |||
| 1211 | spin_lock_irqsave(&mod->lock, flags); | ||
| 1212 | |||
| 1213 | /* Wake up the transmit queue if necessary */ | ||
| 1214 | if (netif_queue_stopped(mod->ndev) && ican3_txok(mod)) | ||
| 1215 | netif_wake_queue(mod->ndev); | ||
| 1216 | |||
| 1217 | spin_unlock_irqrestore(&mod->lock, flags); | ||
| 1218 | |||
| 1219 | /* re-enable interrupt generation */ | ||
| 1220 | iowrite8(1 << mod->num, &mod->ctrl->int_enable); | ||
| 1221 | return received; | ||
| 1222 | } | ||
| 1223 | |||
| 1224 | static irqreturn_t ican3_irq(int irq, void *dev_id) | ||
| 1225 | { | ||
| 1226 | struct ican3_dev *mod = dev_id; | ||
| 1227 | u8 stat; | ||
| 1228 | |||
| 1229 | /* | ||
| 1230 | * The interrupt status register on this device reports interrupts | ||
| 1231 | * as zeroes instead of using ones like most other devices | ||
| 1232 | */ | ||
| 1233 | stat = ioread8(&mod->ctrl->int_disable) & (1 << mod->num); | ||
| 1234 | if (stat == (1 << mod->num)) | ||
| 1235 | return IRQ_NONE; | ||
| 1236 | |||
| 1237 | /* clear the MODULbus interrupt from the microcontroller */ | ||
| 1238 | ioread8(&mod->dpmctrl->interrupt); | ||
| 1239 | |||
| 1240 | /* disable interrupt generation, schedule the NAPI poller */ | ||
| 1241 | iowrite8(1 << mod->num, &mod->ctrl->int_disable); | ||
| 1242 | napi_schedule(&mod->napi); | ||
| 1243 | return IRQ_HANDLED; | ||
| 1244 | } | ||
| 1245 | |||
| 1246 | /* | ||
| 1247 | * Firmware reset, startup, and shutdown | ||
| 1248 | */ | ||
| 1249 | |||
| 1250 | /* | ||
| 1251 | * Reset an ICAN module to its power-on state | ||
| 1252 | * | ||
| 1253 | * CONTEXT: no network device registered | ||
| 1254 | * LOCKING: work function disabled | ||
| 1255 | */ | ||
| 1256 | static int ican3_reset_module(struct ican3_dev *mod) | ||
| 1257 | { | ||
| 1258 | u8 val = 1 << mod->num; | ||
| 1259 | unsigned long start; | ||
| 1260 | u8 runold, runnew; | ||
| 1261 | |||
| 1262 | /* disable interrupts so no more work is scheduled */ | ||
| 1263 | iowrite8(1 << mod->num, &mod->ctrl->int_disable); | ||
| 1264 | |||
| 1265 | /* flush any pending work */ | ||
| 1266 | flush_scheduled_work(); | ||
| 1267 | |||
| 1268 | /* the first unallocated page in the DPM is #9 */ | ||
| 1269 | mod->free_page = DPM_FREE_START; | ||
| 1270 | |||
| 1271 | ican3_set_page(mod, QUEUE_OLD_CONTROL); | ||
| 1272 | runold = ioread8(mod->dpm + TARGET_RUNNING); | ||
| 1273 | |||
| 1274 | /* reset the module */ | ||
| 1275 | iowrite8(val, &mod->ctrl->reset_assert); | ||
| 1276 | iowrite8(val, &mod->ctrl->reset_deassert); | ||
| 1277 | |||
| 1278 | /* wait until the module has finished resetting and is running */ | ||
| 1279 | start = jiffies; | ||
| 1280 | do { | ||
| 1281 | ican3_set_page(mod, QUEUE_OLD_CONTROL); | ||
| 1282 | runnew = ioread8(mod->dpm + TARGET_RUNNING); | ||
| 1283 | if (runnew == (runold ^ 0xff)) | ||
| 1284 | return 0; | ||
| 1285 | |||
| 1286 | msleep(10); | ||
| 1287 | } while (time_before(jiffies, start + HZ / 4)); | ||
| 1288 | |||
| 1289 | dev_err(mod->dev, "failed to reset CAN module\n"); | ||
| 1290 | return -ETIMEDOUT; | ||
| 1291 | } | ||
| 1292 | |||
| 1293 | static void __devexit ican3_shutdown_module(struct ican3_dev *mod) | ||
| 1294 | { | ||
| 1295 | ican3_msg_disconnect(mod); | ||
| 1296 | ican3_reset_module(mod); | ||
| 1297 | } | ||
| 1298 | |||
| 1299 | /* | ||
| 1300 | * Startup an ICAN module, bringing it into fast mode | ||
| 1301 | */ | ||
| 1302 | static int __devinit ican3_startup_module(struct ican3_dev *mod) | ||
| 1303 | { | ||
| 1304 | int ret; | ||
| 1305 | |||
| 1306 | ret = ican3_reset_module(mod); | ||
| 1307 | if (ret) { | ||
| 1308 | dev_err(mod->dev, "unable to reset module\n"); | ||
| 1309 | return ret; | ||
| 1310 | } | ||
| 1311 | |||
| 1312 | /* re-enable interrupts so we can send messages */ | ||
| 1313 | iowrite8(1 << mod->num, &mod->ctrl->int_enable); | ||
| 1314 | |||
| 1315 | ret = ican3_msg_connect(mod); | ||
| 1316 | if (ret) { | ||
| 1317 | dev_err(mod->dev, "unable to connect to module\n"); | ||
| 1318 | return ret; | ||
| 1319 | } | ||
| 1320 | |||
| 1321 | ican3_init_new_host_interface(mod); | ||
| 1322 | ret = ican3_msg_newhostif(mod); | ||
| 1323 | if (ret) { | ||
| 1324 | dev_err(mod->dev, "unable to switch to new-style interface\n"); | ||
| 1325 | return ret; | ||
| 1326 | } | ||
| 1327 | |||
| 1328 | /* default to "termination on" */ | ||
| 1329 | ret = ican3_set_termination(mod, true); | ||
| 1330 | if (ret) { | ||
| 1331 | dev_err(mod->dev, "unable to enable termination\n"); | ||
| 1332 | return ret; | ||
| 1333 | } | ||
| 1334 | |||
| 1335 | /* default to "bus errors enabled" */ | ||
| 1336 | ret = ican3_set_buserror(mod, ICAN3_BUSERR_QUOTA_MAX); | ||
| 1337 | if (ret) { | ||
| 1338 | dev_err(mod->dev, "unable to set bus-error\n"); | ||
| 1339 | return ret; | ||
| 1340 | } | ||
| 1341 | |||
| 1342 | ican3_init_fast_host_interface(mod); | ||
| 1343 | ret = ican3_msg_fasthostif(mod); | ||
| 1344 | if (ret) { | ||
| 1345 | dev_err(mod->dev, "unable to switch to fast host interface\n"); | ||
| 1346 | return ret; | ||
| 1347 | } | ||
| 1348 | |||
| 1349 | ret = ican3_set_id_filter(mod, true); | ||
| 1350 | if (ret) { | ||
| 1351 | dev_err(mod->dev, "unable to set acceptance filter\n"); | ||
| 1352 | return ret; | ||
| 1353 | } | ||
| 1354 | |||
| 1355 | return 0; | ||
| 1356 | } | ||
| 1357 | |||
| 1358 | /* | ||
| 1359 | * CAN Network Device | ||
| 1360 | */ | ||
| 1361 | |||
| 1362 | static int ican3_open(struct net_device *ndev) | ||
| 1363 | { | ||
| 1364 | struct ican3_dev *mod = netdev_priv(ndev); | ||
| 1365 | u8 quota; | ||
| 1366 | int ret; | ||
| 1367 | |||
| 1368 | /* open the CAN layer */ | ||
| 1369 | ret = open_candev(ndev); | ||
| 1370 | if (ret) { | ||
| 1371 | dev_err(mod->dev, "unable to start CAN layer\n"); | ||
| 1372 | return ret; | ||
| 1373 | } | ||
| 1374 | |||
| 1375 | /* set the bus error generation state appropriately */ | ||
| 1376 | if (mod->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING) | ||
| 1377 | quota = ICAN3_BUSERR_QUOTA_MAX; | ||
| 1378 | else | ||
| 1379 | quota = 0; | ||
| 1380 | |||
| 1381 | ret = ican3_set_buserror(mod, quota); | ||
| 1382 | if (ret) { | ||
| 1383 | dev_err(mod->dev, "unable to set bus-error\n"); | ||
| 1384 | close_candev(ndev); | ||
| 1385 | return ret; | ||
| 1386 | } | ||
| 1387 | |||
| 1388 | /* bring the bus online */ | ||
| 1389 | ret = ican3_set_bus_state(mod, true); | ||
| 1390 | if (ret) { | ||
| 1391 | dev_err(mod->dev, "unable to set bus-on\n"); | ||
| 1392 | close_candev(ndev); | ||
| 1393 | return ret; | ||
| 1394 | } | ||
| 1395 | |||
| 1396 | /* start up the network device */ | ||
| 1397 | mod->can.state = CAN_STATE_ERROR_ACTIVE; | ||
| 1398 | netif_start_queue(ndev); | ||
| 1399 | |||
| 1400 | return 0; | ||
| 1401 | } | ||
| 1402 | |||
| 1403 | static int ican3_stop(struct net_device *ndev) | ||
| 1404 | { | ||
| 1405 | struct ican3_dev *mod = netdev_priv(ndev); | ||
| 1406 | int ret; | ||
| 1407 | |||
| 1408 | /* stop the network device xmit routine */ | ||
| 1409 | netif_stop_queue(ndev); | ||
| 1410 | mod->can.state = CAN_STATE_STOPPED; | ||
| 1411 | |||
| 1412 | /* bring the bus offline, stop receiving packets */ | ||
| 1413 | ret = ican3_set_bus_state(mod, false); | ||
| 1414 | if (ret) { | ||
| 1415 | dev_err(mod->dev, "unable to set bus-off\n"); | ||
| 1416 | return ret; | ||
| 1417 | } | ||
| 1418 | |||
| 1419 | /* close the CAN layer */ | ||
| 1420 | close_candev(ndev); | ||
| 1421 | return 0; | ||
| 1422 | } | ||
| 1423 | |||
| 1424 | static int ican3_xmit(struct sk_buff *skb, struct net_device *ndev) | ||
| 1425 | { | ||
| 1426 | struct ican3_dev *mod = netdev_priv(ndev); | ||
| 1427 | struct net_device_stats *stats = &ndev->stats; | ||
| 1428 | struct can_frame *cf = (struct can_frame *)skb->data; | ||
| 1429 | struct ican3_fast_desc desc; | ||
| 1430 | void __iomem *desc_addr; | ||
| 1431 | unsigned long flags; | ||
| 1432 | |||
| 1433 | spin_lock_irqsave(&mod->lock, flags); | ||
| 1434 | |||
| 1435 | /* check that we can actually transmit */ | ||
| 1436 | if (!ican3_txok(mod)) { | ||
| 1437 | dev_err(mod->dev, "no free descriptors, stopping queue\n"); | ||
| 1438 | netif_stop_queue(ndev); | ||
| 1439 | spin_unlock_irqrestore(&mod->lock, flags); | ||
| 1440 | return NETDEV_TX_BUSY; | ||
| 1441 | } | ||
| 1442 | |||
| 1443 | /* copy the control bits of the descriptor */ | ||
| 1444 | ican3_set_page(mod, mod->fasttx_start + (mod->fasttx_num / 16)); | ||
| 1445 | desc_addr = mod->dpm + ((mod->fasttx_num % 16) * sizeof(desc)); | ||
| 1446 | memset(&desc, 0, sizeof(desc)); | ||
| 1447 | memcpy_fromio(&desc, desc_addr, 1); | ||
| 1448 | |||
| 1449 | /* convert the Linux CAN frame into ICAN3 format */ | ||
| 1450 | can_frame_to_ican3(mod, cf, &desc); | ||
| 1451 | |||
| 1452 | /* | ||
| 1453 | * the programming manual says that you must set the IVALID bit, then | ||
| 1454 | * interrupt, then set the valid bit. Quite weird, but it seems to be | ||
| 1455 | * required for this to work | ||
| 1456 | */ | ||
| 1457 | desc.control |= DESC_IVALID; | ||
| 1458 | memcpy_toio(desc_addr, &desc, sizeof(desc)); | ||
| 1459 | |||
| 1460 | /* generate a MODULbus interrupt to the microcontroller */ | ||
| 1461 | iowrite8(0x01, &mod->dpmctrl->interrupt); | ||
| 1462 | |||
| 1463 | desc.control ^= DESC_VALID; | ||
| 1464 | memcpy_toio(desc_addr, &desc, sizeof(desc)); | ||
| 1465 | |||
| 1466 | /* update the next buffer pointer */ | ||
| 1467 | mod->fasttx_num = (desc.control & DESC_WRAP) ? 0 | ||
| 1468 | : (mod->fasttx_num + 1); | ||
| 1469 | |||
| 1470 | /* update statistics */ | ||
| 1471 | stats->tx_packets++; | ||
| 1472 | stats->tx_bytes += cf->can_dlc; | ||
| 1473 | kfree_skb(skb); | ||
| 1474 | |||
| 1475 | /* | ||
| 1476 | * This hardware doesn't have TX-done notifications, so we'll try and | ||
| 1477 | * emulate it the best we can using ECHO skbs. Get the next TX | ||
| 1478 | * descriptor, and see if we have room to send. If not, stop the queue. | ||
| 1479 | * It will be woken when the ECHO skb for the current packet is recv'd. | ||
| 1480 | */ | ||
| 1481 | |||
| 1482 | /* copy the control bits of the descriptor */ | ||
| 1483 | if (!ican3_txok(mod)) | ||
| 1484 | netif_stop_queue(ndev); | ||
| 1485 | |||
| 1486 | spin_unlock_irqrestore(&mod->lock, flags); | ||
| 1487 | return NETDEV_TX_OK; | ||
| 1488 | } | ||
| 1489 | |||
| 1490 | static const struct net_device_ops ican3_netdev_ops = { | ||
| 1491 | .ndo_open = ican3_open, | ||
| 1492 | .ndo_stop = ican3_stop, | ||
| 1493 | .ndo_start_xmit = ican3_xmit, | ||
| 1494 | }; | ||
| 1495 | |||
| 1496 | /* | ||
| 1497 | * Low-level CAN Device | ||
| 1498 | */ | ||
| 1499 | |||
| 1500 | /* This structure was stolen from drivers/net/can/sja1000/sja1000.c */ | ||
| 1501 | static struct can_bittiming_const ican3_bittiming_const = { | ||
| 1502 | .name = DRV_NAME, | ||
| 1503 | .tseg1_min = 1, | ||
| 1504 | .tseg1_max = 16, | ||
| 1505 | .tseg2_min = 1, | ||
| 1506 | .tseg2_max = 8, | ||
| 1507 | .sjw_max = 4, | ||
| 1508 | .brp_min = 1, | ||
| 1509 | .brp_max = 64, | ||
| 1510 | .brp_inc = 1, | ||
| 1511 | }; | ||
| 1512 | |||
| 1513 | /* | ||
| 1514 | * This routine was stolen from drivers/net/can/sja1000/sja1000.c | ||
| 1515 | * | ||
| 1516 | * The bittiming register command for the ICAN3 just sets the bit timing | ||
| 1517 | * registers on the SJA1000 chip directly | ||
| 1518 | */ | ||
| 1519 | static int ican3_set_bittiming(struct net_device *ndev) | ||
| 1520 | { | ||
| 1521 | struct ican3_dev *mod = netdev_priv(ndev); | ||
| 1522 | struct can_bittiming *bt = &mod->can.bittiming; | ||
| 1523 | struct ican3_msg msg; | ||
| 1524 | u8 btr0, btr1; | ||
| 1525 | |||
| 1526 | btr0 = ((bt->brp - 1) & 0x3f) | (((bt->sjw - 1) & 0x3) << 6); | ||
| 1527 | btr1 = ((bt->prop_seg + bt->phase_seg1 - 1) & 0xf) | | ||
| 1528 | (((bt->phase_seg2 - 1) & 0x7) << 4); | ||
| 1529 | if (mod->can.ctrlmode & CAN_CTRLMODE_3_SAMPLES) | ||
| 1530 | btr1 |= 0x80; | ||
| 1531 | |||
| 1532 | memset(&msg, 0, sizeof(msg)); | ||
| 1533 | msg.spec = MSG_CBTRREQ; | ||
| 1534 | msg.len = cpu_to_le16(4); | ||
| 1535 | msg.data[0] = 0x00; | ||
| 1536 | msg.data[1] = 0x00; | ||
| 1537 | msg.data[2] = btr0; | ||
| 1538 | msg.data[3] = btr1; | ||
| 1539 | |||
| 1540 | return ican3_send_msg(mod, &msg); | ||
| 1541 | } | ||
| 1542 | |||
| 1543 | static int ican3_set_mode(struct net_device *ndev, enum can_mode mode) | ||
| 1544 | { | ||
| 1545 | struct ican3_dev *mod = netdev_priv(ndev); | ||
| 1546 | int ret; | ||
| 1547 | |||
| 1548 | if (mode != CAN_MODE_START) | ||
| 1549 | return -ENOTSUPP; | ||
| 1550 | |||
| 1551 | /* bring the bus online */ | ||
| 1552 | ret = ican3_set_bus_state(mod, true); | ||
| 1553 | if (ret) { | ||
| 1554 | dev_err(mod->dev, "unable to set bus-on\n"); | ||
| 1555 | return ret; | ||
| 1556 | } | ||
| 1557 | |||
| 1558 | /* start up the network device */ | ||
| 1559 | mod->can.state = CAN_STATE_ERROR_ACTIVE; | ||
| 1560 | |||
| 1561 | if (netif_queue_stopped(ndev)) | ||
| 1562 | netif_wake_queue(ndev); | ||
| 1563 | |||
| 1564 | return 0; | ||
| 1565 | } | ||
| 1566 | |||
| 1567 | static int ican3_get_berr_counter(const struct net_device *ndev, | ||
| 1568 | struct can_berr_counter *bec) | ||
| 1569 | { | ||
| 1570 | struct ican3_dev *mod = netdev_priv(ndev); | ||
| 1571 | int ret; | ||
| 1572 | |||
| 1573 | ret = ican3_send_inquiry(mod, INQUIRY_STATUS); | ||
| 1574 | if (ret) | ||
| 1575 | return ret; | ||
| 1576 | |||
| 1577 | ret = wait_for_completion_timeout(&mod->buserror_comp, HZ); | ||
| 1578 | if (ret <= 0) { | ||
| 1579 | dev_info(mod->dev, "%s timed out\n", __func__); | ||
| 1580 | return -ETIMEDOUT; | ||
| 1581 | } | ||
| 1582 | |||
| 1583 | bec->rxerr = mod->bec.rxerr; | ||
| 1584 | bec->txerr = mod->bec.txerr; | ||
| 1585 | return 0; | ||
| 1586 | } | ||
| 1587 | |||
| 1588 | /* | ||
| 1589 | * Sysfs Attributes | ||
| 1590 | */ | ||
| 1591 | |||
| 1592 | static ssize_t ican3_sysfs_show_term(struct device *dev, | ||
| 1593 | struct device_attribute *attr, | ||
| 1594 | char *buf) | ||
| 1595 | { | ||
| 1596 | struct ican3_dev *mod = netdev_priv(to_net_dev(dev)); | ||
| 1597 | int ret; | ||
| 1598 | |||
| 1599 | ret = ican3_send_inquiry(mod, INQUIRY_TERMINATION); | ||
| 1600 | if (ret) | ||
| 1601 | return ret; | ||
| 1602 | |||
| 1603 | ret = wait_for_completion_timeout(&mod->termination_comp, HZ); | ||
| 1604 | if (ret <= 0) { | ||
| 1605 | dev_info(mod->dev, "%s timed out\n", __func__); | ||
| 1606 | return -ETIMEDOUT; | ||
| 1607 | } | ||
| 1608 | |||
| 1609 | return snprintf(buf, PAGE_SIZE, "%u\n", mod->termination_enabled); | ||
| 1610 | } | ||
| 1611 | |||
| 1612 | static ssize_t ican3_sysfs_set_term(struct device *dev, | ||
| 1613 | struct device_attribute *attr, | ||
| 1614 | const char *buf, size_t count) | ||
| 1615 | { | ||
| 1616 | struct ican3_dev *mod = netdev_priv(to_net_dev(dev)); | ||
| 1617 | unsigned long enable; | ||
| 1618 | int ret; | ||
| 1619 | |||
| 1620 | if (strict_strtoul(buf, 0, &enable)) | ||
| 1621 | return -EINVAL; | ||
| 1622 | |||
| 1623 | ret = ican3_set_termination(mod, enable); | ||
| 1624 | if (ret) | ||
| 1625 | return ret; | ||
| 1626 | |||
| 1627 | return count; | ||
| 1628 | } | ||
| 1629 | |||
| 1630 | static DEVICE_ATTR(termination, S_IWUGO | S_IRUGO, ican3_sysfs_show_term, | ||
| 1631 | ican3_sysfs_set_term); | ||
| 1632 | |||
| 1633 | static struct attribute *ican3_sysfs_attrs[] = { | ||
| 1634 | &dev_attr_termination.attr, | ||
| 1635 | NULL, | ||
| 1636 | }; | ||
| 1637 | |||
| 1638 | static struct attribute_group ican3_sysfs_attr_group = { | ||
| 1639 | .attrs = ican3_sysfs_attrs, | ||
| 1640 | }; | ||
| 1641 | |||
| 1642 | /* | ||
| 1643 | * PCI Subsystem | ||
| 1644 | */ | ||
| 1645 | |||
| 1646 | static int __devinit ican3_probe(struct platform_device *pdev) | ||
| 1647 | { | ||
| 1648 | struct janz_platform_data *pdata; | ||
| 1649 | struct net_device *ndev; | ||
| 1650 | struct ican3_dev *mod; | ||
| 1651 | struct resource *res; | ||
| 1652 | struct device *dev; | ||
| 1653 | int ret; | ||
| 1654 | |||
| 1655 | pdata = pdev->dev.platform_data; | ||
| 1656 | if (!pdata) | ||
| 1657 | return -ENXIO; | ||
| 1658 | |||
| 1659 | dev_dbg(&pdev->dev, "probe: module number %d\n", pdata->modno); | ||
| 1660 | |||
| 1661 | /* save the struct device for printing */ | ||
| 1662 | dev = &pdev->dev; | ||
| 1663 | |||
| 1664 | /* allocate the CAN device and private data */ | ||
| 1665 | ndev = alloc_candev(sizeof(*mod), 0); | ||
| 1666 | if (!ndev) { | ||
| 1667 | dev_err(dev, "unable to allocate CANdev\n"); | ||
| 1668 | ret = -ENOMEM; | ||
| 1669 | goto out_return; | ||
| 1670 | } | ||
| 1671 | |||
| 1672 | platform_set_drvdata(pdev, ndev); | ||
| 1673 | mod = netdev_priv(ndev); | ||
| 1674 | mod->ndev = ndev; | ||
| 1675 | mod->dev = &pdev->dev; | ||
| 1676 | mod->num = pdata->modno; | ||
| 1677 | netif_napi_add(ndev, &mod->napi, ican3_napi, ICAN3_RX_BUFFERS); | ||
| 1678 | spin_lock_init(&mod->lock); | ||
| 1679 | init_completion(&mod->termination_comp); | ||
| 1680 | init_completion(&mod->buserror_comp); | ||
| 1681 | |||
| 1682 | /* setup device-specific sysfs attributes */ | ||
| 1683 | ndev->sysfs_groups[0] = &ican3_sysfs_attr_group; | ||
| 1684 | |||
| 1685 | /* the first unallocated page in the DPM is 9 */ | ||
| 1686 | mod->free_page = DPM_FREE_START; | ||
| 1687 | |||
| 1688 | ndev->netdev_ops = &ican3_netdev_ops; | ||
| 1689 | ndev->flags |= IFF_ECHO; | ||
| 1690 | SET_NETDEV_DEV(ndev, &pdev->dev); | ||
| 1691 | |||
| 1692 | mod->can.clock.freq = ICAN3_CAN_CLOCK; | ||
| 1693 | mod->can.bittiming_const = &ican3_bittiming_const; | ||
| 1694 | mod->can.do_set_bittiming = ican3_set_bittiming; | ||
| 1695 | mod->can.do_set_mode = ican3_set_mode; | ||
| 1696 | mod->can.do_get_berr_counter = ican3_get_berr_counter; | ||
| 1697 | mod->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES | ||
| 1698 | | CAN_CTRLMODE_BERR_REPORTING; | ||
| 1699 | |||
| 1700 | /* find our IRQ number */ | ||
| 1701 | mod->irq = platform_get_irq(pdev, 0); | ||
| 1702 | if (mod->irq < 0) { | ||
| 1703 | dev_err(dev, "IRQ line not found\n"); | ||
| 1704 | ret = -ENODEV; | ||
| 1705 | goto out_free_ndev; | ||
| 1706 | } | ||
| 1707 | |||
| 1708 | ndev->irq = mod->irq; | ||
| 1709 | |||
| 1710 | /* get access to the MODULbus registers for this module */ | ||
| 1711 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
| 1712 | if (!res) { | ||
| 1713 | dev_err(dev, "MODULbus registers not found\n"); | ||
| 1714 | ret = -ENODEV; | ||
| 1715 | goto out_free_ndev; | ||
| 1716 | } | ||
| 1717 | |||
| 1718 | mod->dpm = ioremap(res->start, resource_size(res)); | ||
| 1719 | if (!mod->dpm) { | ||
| 1720 | dev_err(dev, "MODULbus registers not ioremap\n"); | ||
| 1721 | ret = -ENOMEM; | ||
| 1722 | goto out_free_ndev; | ||
| 1723 | } | ||
| 1724 | |||
| 1725 | mod->dpmctrl = mod->dpm + DPM_PAGE_SIZE; | ||
| 1726 | |||
| 1727 | /* get access to the control registers for this module */ | ||
| 1728 | res = platform_get_resource(pdev, IORESOURCE_MEM, 1); | ||
| 1729 | if (!res) { | ||
| 1730 | dev_err(dev, "CONTROL registers not found\n"); | ||
| 1731 | ret = -ENODEV; | ||
| 1732 | goto out_iounmap_dpm; | ||
| 1733 | } | ||
| 1734 | |||
| 1735 | mod->ctrl = ioremap(res->start, resource_size(res)); | ||
| 1736 | if (!mod->ctrl) { | ||
| 1737 | dev_err(dev, "CONTROL registers not ioremap\n"); | ||
| 1738 | ret = -ENOMEM; | ||
| 1739 | goto out_iounmap_dpm; | ||
| 1740 | } | ||
| 1741 | |||
| 1742 | /* disable our IRQ, then hookup the IRQ handler */ | ||
| 1743 | iowrite8(1 << mod->num, &mod->ctrl->int_disable); | ||
| 1744 | ret = request_irq(mod->irq, ican3_irq, IRQF_SHARED, DRV_NAME, mod); | ||
| 1745 | if (ret) { | ||
| 1746 | dev_err(dev, "unable to request IRQ\n"); | ||
| 1747 | goto out_iounmap_ctrl; | ||
| 1748 | } | ||
| 1749 | |||
| 1750 | /* reset and initialize the CAN controller into fast mode */ | ||
| 1751 | napi_enable(&mod->napi); | ||
| 1752 | ret = ican3_startup_module(mod); | ||
| 1753 | if (ret) { | ||
| 1754 | dev_err(dev, "%s: unable to start CANdev\n", __func__); | ||
| 1755 | goto out_free_irq; | ||
| 1756 | } | ||
| 1757 | |||
| 1758 | /* register with the Linux CAN layer */ | ||
| 1759 | ret = register_candev(ndev); | ||
| 1760 | if (ret) { | ||
| 1761 | dev_err(dev, "%s: unable to register CANdev\n", __func__); | ||
| 1762 | goto out_free_irq; | ||
| 1763 | } | ||
| 1764 | |||
| 1765 | dev_info(dev, "module %d: registered CAN device\n", pdata->modno); | ||
| 1766 | return 0; | ||
| 1767 | |||
| 1768 | out_free_irq: | ||
| 1769 | napi_disable(&mod->napi); | ||
| 1770 | iowrite8(1 << mod->num, &mod->ctrl->int_disable); | ||
| 1771 | free_irq(mod->irq, mod); | ||
| 1772 | out_iounmap_ctrl: | ||
| 1773 | iounmap(mod->ctrl); | ||
| 1774 | out_iounmap_dpm: | ||
| 1775 | iounmap(mod->dpm); | ||
| 1776 | out_free_ndev: | ||
| 1777 | free_candev(ndev); | ||
| 1778 | out_return: | ||
| 1779 | return ret; | ||
| 1780 | } | ||
| 1781 | |||
| 1782 | static int __devexit ican3_remove(struct platform_device *pdev) | ||
| 1783 | { | ||
| 1784 | struct net_device *ndev = platform_get_drvdata(pdev); | ||
| 1785 | struct ican3_dev *mod = netdev_priv(ndev); | ||
| 1786 | |||
| 1787 | /* unregister the netdevice, stop interrupts */ | ||
| 1788 | unregister_netdev(ndev); | ||
| 1789 | napi_disable(&mod->napi); | ||
| 1790 | iowrite8(1 << mod->num, &mod->ctrl->int_disable); | ||
| 1791 | free_irq(mod->irq, mod); | ||
| 1792 | |||
| 1793 | /* put the module into reset */ | ||
| 1794 | ican3_shutdown_module(mod); | ||
| 1795 | |||
| 1796 | /* unmap all registers */ | ||
| 1797 | iounmap(mod->ctrl); | ||
| 1798 | iounmap(mod->dpm); | ||
| 1799 | |||
| 1800 | free_candev(ndev); | ||
| 1801 | |||
| 1802 | return 0; | ||
| 1803 | } | ||
| 1804 | |||
| 1805 | static struct platform_driver ican3_driver = { | ||
| 1806 | .driver = { | ||
| 1807 | .name = DRV_NAME, | ||
| 1808 | .owner = THIS_MODULE, | ||
| 1809 | }, | ||
| 1810 | .probe = ican3_probe, | ||
| 1811 | .remove = __devexit_p(ican3_remove), | ||
| 1812 | }; | ||
| 1813 | |||
| 1814 | static int __init ican3_init(void) | ||
| 1815 | { | ||
| 1816 | return platform_driver_register(&ican3_driver); | ||
| 1817 | } | ||
| 1818 | |||
| 1819 | static void __exit ican3_exit(void) | ||
| 1820 | { | ||
| 1821 | platform_driver_unregister(&ican3_driver); | ||
| 1822 | } | ||
| 1823 | |||
| 1824 | MODULE_AUTHOR("Ira W. Snyder <iws@ovro.caltech.edu>"); | ||
| 1825 | MODULE_DESCRIPTION("Janz MODULbus VMOD-ICAN3 Driver"); | ||
| 1826 | MODULE_LICENSE("GPL"); | ||
| 1827 | MODULE_ALIAS("platform:janz-ican3"); | ||
| 1828 | |||
| 1829 | module_init(ican3_init); | ||
| 1830 | module_exit(ican3_exit); | ||
diff --git a/drivers/net/can/mscan/mpc5xxx_can.c b/drivers/net/can/mscan/mpc5xxx_can.c index 225fd147774a..8af8442c694a 100644 --- a/drivers/net/can/mscan/mpc5xxx_can.c +++ b/drivers/net/can/mscan/mpc5xxx_can.c | |||
| @@ -392,15 +392,17 @@ static struct of_device_id __devinitdata mpc5xxx_can_table[] = { | |||
| 392 | }; | 392 | }; |
| 393 | 393 | ||
| 394 | static struct of_platform_driver mpc5xxx_can_driver = { | 394 | static struct of_platform_driver mpc5xxx_can_driver = { |
| 395 | .owner = THIS_MODULE, | 395 | .driver = { |
| 396 | .name = "mpc5xxx_can", | 396 | .name = "mpc5xxx_can", |
| 397 | .owner = THIS_MODULE, | ||
| 398 | .of_match_table = mpc5xxx_can_table, | ||
| 399 | }, | ||
| 397 | .probe = mpc5xxx_can_probe, | 400 | .probe = mpc5xxx_can_probe, |
| 398 | .remove = __devexit_p(mpc5xxx_can_remove), | 401 | .remove = __devexit_p(mpc5xxx_can_remove), |
| 399 | #ifdef CONFIG_PM | 402 | #ifdef CONFIG_PM |
| 400 | .suspend = mpc5xxx_can_suspend, | 403 | .suspend = mpc5xxx_can_suspend, |
| 401 | .resume = mpc5xxx_can_resume, | 404 | .resume = mpc5xxx_can_resume, |
| 402 | #endif | 405 | #endif |
| 403 | .match_table = mpc5xxx_can_table, | ||
| 404 | }; | 406 | }; |
| 405 | 407 | ||
| 406 | static int __init mpc5xxx_can_init(void) | 408 | static int __init mpc5xxx_can_init(void) |
diff --git a/drivers/net/can/sja1000/sja1000_of_platform.c b/drivers/net/can/sja1000/sja1000_of_platform.c index 34e79efbd2fc..ac1a83d7c204 100644 --- a/drivers/net/can/sja1000/sja1000_of_platform.c +++ b/drivers/net/can/sja1000/sja1000_of_platform.c | |||
| @@ -71,7 +71,7 @@ static int __devexit sja1000_ofp_remove(struct of_device *ofdev) | |||
| 71 | { | 71 | { |
| 72 | struct net_device *dev = dev_get_drvdata(&ofdev->dev); | 72 | struct net_device *dev = dev_get_drvdata(&ofdev->dev); |
| 73 | struct sja1000_priv *priv = netdev_priv(dev); | 73 | struct sja1000_priv *priv = netdev_priv(dev); |
| 74 | struct device_node *np = ofdev->node; | 74 | struct device_node *np = ofdev->dev.of_node; |
| 75 | struct resource res; | 75 | struct resource res; |
| 76 | 76 | ||
| 77 | dev_set_drvdata(&ofdev->dev, NULL); | 77 | dev_set_drvdata(&ofdev->dev, NULL); |
| @@ -90,7 +90,7 @@ static int __devexit sja1000_ofp_remove(struct of_device *ofdev) | |||
| 90 | static int __devinit sja1000_ofp_probe(struct of_device *ofdev, | 90 | static int __devinit sja1000_ofp_probe(struct of_device *ofdev, |
| 91 | const struct of_device_id *id) | 91 | const struct of_device_id *id) |
| 92 | { | 92 | { |
| 93 | struct device_node *np = ofdev->node; | 93 | struct device_node *np = ofdev->dev.of_node; |
| 94 | struct net_device *dev; | 94 | struct net_device *dev; |
| 95 | struct sja1000_priv *priv; | 95 | struct sja1000_priv *priv; |
| 96 | struct resource res; | 96 | struct resource res; |
| @@ -215,11 +215,13 @@ static struct of_device_id __devinitdata sja1000_ofp_table[] = { | |||
| 215 | MODULE_DEVICE_TABLE(of, sja1000_ofp_table); | 215 | MODULE_DEVICE_TABLE(of, sja1000_ofp_table); |
| 216 | 216 | ||
| 217 | static struct of_platform_driver sja1000_ofp_driver = { | 217 | static struct of_platform_driver sja1000_ofp_driver = { |
| 218 | .owner = THIS_MODULE, | 218 | .driver = { |
| 219 | .name = DRV_NAME, | 219 | .owner = THIS_MODULE, |
| 220 | .name = DRV_NAME, | ||
| 221 | .of_match_table = sja1000_ofp_table, | ||
| 222 | }, | ||
| 220 | .probe = sja1000_ofp_probe, | 223 | .probe = sja1000_ofp_probe, |
| 221 | .remove = __devexit_p(sja1000_ofp_remove), | 224 | .remove = __devexit_p(sja1000_ofp_remove), |
| 222 | .match_table = sja1000_ofp_table, | ||
| 223 | }; | 225 | }; |
| 224 | 226 | ||
| 225 | static int __init sja1000_ofp_init(void) | 227 | static int __init sja1000_ofp_init(void) |
diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c index 02698a1c80b0..f547894ff48f 100644 --- a/drivers/net/ehea/ehea_main.c +++ b/drivers/net/ehea/ehea_main.c | |||
| @@ -122,8 +122,11 @@ static struct of_device_id ehea_device_table[] = { | |||
| 122 | MODULE_DEVICE_TABLE(of, ehea_device_table); | 122 | MODULE_DEVICE_TABLE(of, ehea_device_table); |
| 123 | 123 | ||
| 124 | static struct of_platform_driver ehea_driver = { | 124 | static struct of_platform_driver ehea_driver = { |
| 125 | .name = "ehea", | 125 | .driver = { |
| 126 | .match_table = ehea_device_table, | 126 | .name = "ehea", |
| 127 | .owner = THIS_MODULE, | ||
| 128 | .of_match_table = ehea_device_table, | ||
| 129 | }, | ||
| 127 | .probe = ehea_probe_adapter, | 130 | .probe = ehea_probe_adapter, |
| 128 | .remove = ehea_remove, | 131 | .remove = ehea_remove, |
| 129 | }; | 132 | }; |
| @@ -3050,7 +3053,7 @@ static DEVICE_ATTR(log_port_id, S_IRUSR | S_IRGRP | S_IROTH, ehea_show_port_id, | |||
| 3050 | static void __devinit logical_port_release(struct device *dev) | 3053 | static void __devinit logical_port_release(struct device *dev) |
| 3051 | { | 3054 | { |
| 3052 | struct ehea_port *port = container_of(dev, struct ehea_port, ofdev.dev); | 3055 | struct ehea_port *port = container_of(dev, struct ehea_port, ofdev.dev); |
| 3053 | of_node_put(port->ofdev.node); | 3056 | of_node_put(port->ofdev.dev.of_node); |
| 3054 | } | 3057 | } |
| 3055 | 3058 | ||
| 3056 | static struct device *ehea_register_port(struct ehea_port *port, | 3059 | static struct device *ehea_register_port(struct ehea_port *port, |
| @@ -3058,7 +3061,7 @@ static struct device *ehea_register_port(struct ehea_port *port, | |||
| 3058 | { | 3061 | { |
| 3059 | int ret; | 3062 | int ret; |
| 3060 | 3063 | ||
| 3061 | port->ofdev.node = of_node_get(dn); | 3064 | port->ofdev.dev.of_node = of_node_get(dn); |
| 3062 | port->ofdev.dev.parent = &port->adapter->ofdev->dev; | 3065 | port->ofdev.dev.parent = &port->adapter->ofdev->dev; |
| 3063 | port->ofdev.dev.bus = &ibmebus_bus_type; | 3066 | port->ofdev.dev.bus = &ibmebus_bus_type; |
| 3064 | 3067 | ||
| @@ -3225,7 +3228,7 @@ static int ehea_setup_ports(struct ehea_adapter *adapter) | |||
| 3225 | const u32 *dn_log_port_id; | 3228 | const u32 *dn_log_port_id; |
| 3226 | int i = 0; | 3229 | int i = 0; |
| 3227 | 3230 | ||
| 3228 | lhea_dn = adapter->ofdev->node; | 3231 | lhea_dn = adapter->ofdev->dev.of_node; |
| 3229 | while ((eth_dn = of_get_next_child(lhea_dn, eth_dn))) { | 3232 | while ((eth_dn = of_get_next_child(lhea_dn, eth_dn))) { |
| 3230 | 3233 | ||
| 3231 | dn_log_port_id = of_get_property(eth_dn, "ibm,hea-port-no", | 3234 | dn_log_port_id = of_get_property(eth_dn, "ibm,hea-port-no", |
| @@ -3264,7 +3267,7 @@ static struct device_node *ehea_get_eth_dn(struct ehea_adapter *adapter, | |||
| 3264 | struct device_node *eth_dn = NULL; | 3267 | struct device_node *eth_dn = NULL; |
| 3265 | const u32 *dn_log_port_id; | 3268 | const u32 *dn_log_port_id; |
| 3266 | 3269 | ||
| 3267 | lhea_dn = adapter->ofdev->node; | 3270 | lhea_dn = adapter->ofdev->dev.of_node; |
| 3268 | while ((eth_dn = of_get_next_child(lhea_dn, eth_dn))) { | 3271 | while ((eth_dn = of_get_next_child(lhea_dn, eth_dn))) { |
| 3269 | 3272 | ||
| 3270 | dn_log_port_id = of_get_property(eth_dn, "ibm,hea-port-no", | 3273 | dn_log_port_id = of_get_property(eth_dn, "ibm,hea-port-no", |
| @@ -3394,7 +3397,7 @@ static int __devinit ehea_probe_adapter(struct of_device *dev, | |||
| 3394 | const u64 *adapter_handle; | 3397 | const u64 *adapter_handle; |
| 3395 | int ret; | 3398 | int ret; |
| 3396 | 3399 | ||
| 3397 | if (!dev || !dev->node) { | 3400 | if (!dev || !dev->dev.of_node) { |
| 3398 | ehea_error("Invalid ibmebus device probed"); | 3401 | ehea_error("Invalid ibmebus device probed"); |
| 3399 | return -EINVAL; | 3402 | return -EINVAL; |
| 3400 | } | 3403 | } |
| @@ -3410,14 +3413,14 @@ static int __devinit ehea_probe_adapter(struct of_device *dev, | |||
| 3410 | 3413 | ||
| 3411 | adapter->ofdev = dev; | 3414 | adapter->ofdev = dev; |
| 3412 | 3415 | ||
| 3413 | adapter_handle = of_get_property(dev->node, "ibm,hea-handle", | 3416 | adapter_handle = of_get_property(dev->dev.of_node, "ibm,hea-handle", |
| 3414 | NULL); | 3417 | NULL); |
| 3415 | if (adapter_handle) | 3418 | if (adapter_handle) |
| 3416 | adapter->handle = *adapter_handle; | 3419 | adapter->handle = *adapter_handle; |
| 3417 | 3420 | ||
| 3418 | if (!adapter->handle) { | 3421 | if (!adapter->handle) { |
| 3419 | dev_err(&dev->dev, "failed getting handle for adapter" | 3422 | dev_err(&dev->dev, "failed getting handle for adapter" |
| 3420 | " '%s'\n", dev->node->full_name); | 3423 | " '%s'\n", dev->dev.of_node->full_name); |
| 3421 | ret = -ENODEV; | 3424 | ret = -ENODEV; |
| 3422 | goto out_free_ad; | 3425 | goto out_free_ad; |
| 3423 | } | 3426 | } |
diff --git a/drivers/net/fec_mpc52xx.c b/drivers/net/fec_mpc52xx.c index 221f440c10f4..25e6cc6840b1 100644 --- a/drivers/net/fec_mpc52xx.c +++ b/drivers/net/fec_mpc52xx.c | |||
| @@ -871,7 +871,7 @@ mpc52xx_fec_probe(struct of_device *op, const struct of_device_id *match) | |||
| 871 | priv->ndev = ndev; | 871 | priv->ndev = ndev; |
| 872 | 872 | ||
| 873 | /* Reserve FEC control zone */ | 873 | /* Reserve FEC control zone */ |
| 874 | rv = of_address_to_resource(op->node, 0, &mem); | 874 | rv = of_address_to_resource(op->dev.of_node, 0, &mem); |
| 875 | if (rv) { | 875 | if (rv) { |
| 876 | printk(KERN_ERR DRIVER_NAME ": " | 876 | printk(KERN_ERR DRIVER_NAME ": " |
| 877 | "Error while parsing device node resource\n" ); | 877 | "Error while parsing device node resource\n" ); |
| @@ -919,7 +919,7 @@ mpc52xx_fec_probe(struct of_device *op, const struct of_device_id *match) | |||
| 919 | 919 | ||
| 920 | /* Get the IRQ we need one by one */ | 920 | /* Get the IRQ we need one by one */ |
| 921 | /* Control */ | 921 | /* Control */ |
| 922 | ndev->irq = irq_of_parse_and_map(op->node, 0); | 922 | ndev->irq = irq_of_parse_and_map(op->dev.of_node, 0); |
| 923 | 923 | ||
| 924 | /* RX */ | 924 | /* RX */ |
| 925 | priv->r_irq = bcom_get_task_irq(priv->rx_dmatsk); | 925 | priv->r_irq = bcom_get_task_irq(priv->rx_dmatsk); |
| @@ -942,20 +942,20 @@ mpc52xx_fec_probe(struct of_device *op, const struct of_device_id *match) | |||
| 942 | /* Start with safe defaults for link connection */ | 942 | /* Start with safe defaults for link connection */ |
| 943 | priv->speed = 100; | 943 | priv->speed = 100; |
| 944 | priv->duplex = DUPLEX_HALF; | 944 | priv->duplex = DUPLEX_HALF; |
| 945 | priv->mdio_speed = ((mpc5xxx_get_bus_frequency(op->node) >> 20) / 5) << 1; | 945 | priv->mdio_speed = ((mpc5xxx_get_bus_frequency(op->dev.of_node) >> 20) / 5) << 1; |
| 946 | 946 | ||
| 947 | /* The current speed preconfigures the speed of the MII link */ | 947 | /* The current speed preconfigures the speed of the MII link */ |
| 948 | prop = of_get_property(op->node, "current-speed", &prop_size); | 948 | prop = of_get_property(op->dev.of_node, "current-speed", &prop_size); |
| 949 | if (prop && (prop_size >= sizeof(u32) * 2)) { | 949 | if (prop && (prop_size >= sizeof(u32) * 2)) { |
| 950 | priv->speed = prop[0]; | 950 | priv->speed = prop[0]; |
| 951 | priv->duplex = prop[1] ? DUPLEX_FULL : DUPLEX_HALF; | 951 | priv->duplex = prop[1] ? DUPLEX_FULL : DUPLEX_HALF; |
| 952 | } | 952 | } |
| 953 | 953 | ||
| 954 | /* If there is a phy handle, then get the PHY node */ | 954 | /* If there is a phy handle, then get the PHY node */ |
| 955 | priv->phy_node = of_parse_phandle(op->node, "phy-handle", 0); | 955 | priv->phy_node = of_parse_phandle(op->dev.of_node, "phy-handle", 0); |
| 956 | 956 | ||
| 957 | /* the 7-wire property means don't use MII mode */ | 957 | /* the 7-wire property means don't use MII mode */ |
| 958 | if (of_find_property(op->node, "fsl,7-wire-mode", NULL)) { | 958 | if (of_find_property(op->dev.of_node, "fsl,7-wire-mode", NULL)) { |
| 959 | priv->seven_wire_mode = 1; | 959 | priv->seven_wire_mode = 1; |
| 960 | dev_info(&ndev->dev, "using 7-wire PHY mode\n"); | 960 | dev_info(&ndev->dev, "using 7-wire PHY mode\n"); |
| 961 | } | 961 | } |
| @@ -1063,9 +1063,11 @@ static struct of_device_id mpc52xx_fec_match[] = { | |||
| 1063 | MODULE_DEVICE_TABLE(of, mpc52xx_fec_match); | 1063 | MODULE_DEVICE_TABLE(of, mpc52xx_fec_match); |
| 1064 | 1064 | ||
| 1065 | static struct of_platform_driver mpc52xx_fec_driver = { | 1065 | static struct of_platform_driver mpc52xx_fec_driver = { |
| 1066 | .owner = THIS_MODULE, | 1066 | .driver = { |
| 1067 | .name = DRIVER_NAME, | 1067 | .name = DRIVER_NAME, |
| 1068 | .match_table = mpc52xx_fec_match, | 1068 | .owner = THIS_MODULE, |
| 1069 | .of_match_table = mpc52xx_fec_match, | ||
| 1070 | }, | ||
| 1069 | .probe = mpc52xx_fec_probe, | 1071 | .probe = mpc52xx_fec_probe, |
| 1070 | .remove = mpc52xx_fec_remove, | 1072 | .remove = mpc52xx_fec_remove, |
| 1071 | #ifdef CONFIG_PM | 1073 | #ifdef CONFIG_PM |
diff --git a/drivers/net/fec_mpc52xx_phy.c b/drivers/net/fec_mpc52xx_phy.c index 7658a082e390..006f64d9f96a 100644 --- a/drivers/net/fec_mpc52xx_phy.c +++ b/drivers/net/fec_mpc52xx_phy.c | |||
| @@ -66,7 +66,7 @@ static int mpc52xx_fec_mdio_probe(struct of_device *of, | |||
| 66 | const struct of_device_id *match) | 66 | const struct of_device_id *match) |
| 67 | { | 67 | { |
| 68 | struct device *dev = &of->dev; | 68 | struct device *dev = &of->dev; |
| 69 | struct device_node *np = of->node; | 69 | struct device_node *np = of->dev.of_node; |
| 70 | struct mii_bus *bus; | 70 | struct mii_bus *bus; |
| 71 | struct mpc52xx_fec_mdio_priv *priv; | 71 | struct mpc52xx_fec_mdio_priv *priv; |
| 72 | struct resource res = {}; | 72 | struct resource res = {}; |
| @@ -107,7 +107,7 @@ static int mpc52xx_fec_mdio_probe(struct of_device *of, | |||
| 107 | 107 | ||
| 108 | /* set MII speed */ | 108 | /* set MII speed */ |
| 109 | out_be32(&priv->regs->mii_speed, | 109 | out_be32(&priv->regs->mii_speed, |
| 110 | ((mpc5xxx_get_bus_frequency(of->node) >> 20) / 5) << 1); | 110 | ((mpc5xxx_get_bus_frequency(of->dev.of_node) >> 20) / 5) << 1); |
| 111 | 111 | ||
| 112 | err = of_mdiobus_register(bus, np); | 112 | err = of_mdiobus_register(bus, np); |
| 113 | if (err) | 113 | if (err) |
| @@ -159,10 +159,13 @@ static struct of_device_id mpc52xx_fec_mdio_match[] = { | |||
| 159 | MODULE_DEVICE_TABLE(of, mpc52xx_fec_mdio_match); | 159 | MODULE_DEVICE_TABLE(of, mpc52xx_fec_mdio_match); |
| 160 | 160 | ||
| 161 | struct of_platform_driver mpc52xx_fec_mdio_driver = { | 161 | struct of_platform_driver mpc52xx_fec_mdio_driver = { |
| 162 | .name = "mpc5200b-fec-phy", | 162 | .driver = { |
| 163 | .name = "mpc5200b-fec-phy", | ||
| 164 | .owner = THIS_MODULE, | ||
| 165 | .of_match_table = mpc52xx_fec_mdio_match, | ||
| 166 | }, | ||
| 163 | .probe = mpc52xx_fec_mdio_probe, | 167 | .probe = mpc52xx_fec_mdio_probe, |
| 164 | .remove = mpc52xx_fec_mdio_remove, | 168 | .remove = mpc52xx_fec_mdio_remove, |
| 165 | .match_table = mpc52xx_fec_mdio_match, | ||
| 166 | }; | 169 | }; |
| 167 | 170 | ||
| 168 | /* let fec driver call it, since this has to be registered before it */ | 171 | /* let fec driver call it, since this has to be registered before it */ |
diff --git a/drivers/net/fs_enet/fs_enet-main.c b/drivers/net/fs_enet/fs_enet-main.c index 0fb0fefcb787..309a0eaddd81 100644 --- a/drivers/net/fs_enet/fs_enet-main.c +++ b/drivers/net/fs_enet/fs_enet-main.c | |||
| @@ -1013,7 +1013,7 @@ static int __devinit fs_enet_probe(struct of_device *ofdev, | |||
| 1013 | return -ENOMEM; | 1013 | return -ENOMEM; |
| 1014 | 1014 | ||
| 1015 | if (!IS_FEC(match)) { | 1015 | if (!IS_FEC(match)) { |
| 1016 | data = of_get_property(ofdev->node, "fsl,cpm-command", &len); | 1016 | data = of_get_property(ofdev->dev.of_node, "fsl,cpm-command", &len); |
| 1017 | if (!data || len != 4) | 1017 | if (!data || len != 4) |
| 1018 | goto out_free_fpi; | 1018 | goto out_free_fpi; |
| 1019 | 1019 | ||
| @@ -1025,8 +1025,8 @@ static int __devinit fs_enet_probe(struct of_device *ofdev, | |||
| 1025 | fpi->rx_copybreak = 240; | 1025 | fpi->rx_copybreak = 240; |
| 1026 | fpi->use_napi = 1; | 1026 | fpi->use_napi = 1; |
| 1027 | fpi->napi_weight = 17; | 1027 | fpi->napi_weight = 17; |
| 1028 | fpi->phy_node = of_parse_phandle(ofdev->node, "phy-handle", 0); | 1028 | fpi->phy_node = of_parse_phandle(ofdev->dev.of_node, "phy-handle", 0); |
| 1029 | if ((!fpi->phy_node) && (!of_get_property(ofdev->node, "fixed-link", | 1029 | if ((!fpi->phy_node) && (!of_get_property(ofdev->dev.of_node, "fixed-link", |
| 1030 | NULL))) | 1030 | NULL))) |
| 1031 | goto out_free_fpi; | 1031 | goto out_free_fpi; |
| 1032 | 1032 | ||
| @@ -1059,7 +1059,7 @@ static int __devinit fs_enet_probe(struct of_device *ofdev, | |||
| 1059 | spin_lock_init(&fep->lock); | 1059 | spin_lock_init(&fep->lock); |
| 1060 | spin_lock_init(&fep->tx_lock); | 1060 | spin_lock_init(&fep->tx_lock); |
| 1061 | 1061 | ||
| 1062 | mac_addr = of_get_mac_address(ofdev->node); | 1062 | mac_addr = of_get_mac_address(ofdev->dev.of_node); |
| 1063 | if (mac_addr) | 1063 | if (mac_addr) |
| 1064 | memcpy(ndev->dev_addr, mac_addr, 6); | 1064 | memcpy(ndev->dev_addr, mac_addr, 6); |
| 1065 | 1065 | ||
| @@ -1156,8 +1156,11 @@ static struct of_device_id fs_enet_match[] = { | |||
| 1156 | MODULE_DEVICE_TABLE(of, fs_enet_match); | 1156 | MODULE_DEVICE_TABLE(of, fs_enet_match); |
| 1157 | 1157 | ||
| 1158 | static struct of_platform_driver fs_enet_driver = { | 1158 | static struct of_platform_driver fs_enet_driver = { |
| 1159 | .name = "fs_enet", | 1159 | .driver = { |
| 1160 | .match_table = fs_enet_match, | 1160 | .owner = THIS_MODULE, |
| 1161 | .name = "fs_enet", | ||
| 1162 | .of_match_table = fs_enet_match, | ||
| 1163 | }, | ||
| 1161 | .probe = fs_enet_probe, | 1164 | .probe = fs_enet_probe, |
| 1162 | .remove = fs_enet_remove, | 1165 | .remove = fs_enet_remove, |
| 1163 | }; | 1166 | }; |
diff --git a/drivers/net/fs_enet/mac-fcc.c b/drivers/net/fs_enet/mac-fcc.c index 0ae65a2f1ab9..48e91b6242ce 100644 --- a/drivers/net/fs_enet/mac-fcc.c +++ b/drivers/net/fs_enet/mac-fcc.c | |||
| @@ -88,19 +88,19 @@ static int do_pd_setup(struct fs_enet_private *fep) | |||
| 88 | struct fs_platform_info *fpi = fep->fpi; | 88 | struct fs_platform_info *fpi = fep->fpi; |
| 89 | int ret = -EINVAL; | 89 | int ret = -EINVAL; |
| 90 | 90 | ||
| 91 | fep->interrupt = of_irq_to_resource(ofdev->node, 0, NULL); | 91 | fep->interrupt = of_irq_to_resource(ofdev->dev.of_node, 0, NULL); |
| 92 | if (fep->interrupt == NO_IRQ) | 92 | if (fep->interrupt == NO_IRQ) |
| 93 | goto out; | 93 | goto out; |
| 94 | 94 | ||
| 95 | fep->fcc.fccp = of_iomap(ofdev->node, 0); | 95 | fep->fcc.fccp = of_iomap(ofdev->dev.of_node, 0); |
| 96 | if (!fep->fcc.fccp) | 96 | if (!fep->fcc.fccp) |
| 97 | goto out; | 97 | goto out; |
| 98 | 98 | ||
| 99 | fep->fcc.ep = of_iomap(ofdev->node, 1); | 99 | fep->fcc.ep = of_iomap(ofdev->dev.of_node, 1); |
| 100 | if (!fep->fcc.ep) | 100 | if (!fep->fcc.ep) |
| 101 | goto out_fccp; | 101 | goto out_fccp; |
| 102 | 102 | ||
| 103 | fep->fcc.fcccp = of_iomap(ofdev->node, 2); | 103 | fep->fcc.fcccp = of_iomap(ofdev->dev.of_node, 2); |
| 104 | if (!fep->fcc.fcccp) | 104 | if (!fep->fcc.fcccp) |
| 105 | goto out_ep; | 105 | goto out_ep; |
| 106 | 106 | ||
diff --git a/drivers/net/fs_enet/mac-fec.c b/drivers/net/fs_enet/mac-fec.c index 7eff92ef01da..7ca1642276d0 100644 --- a/drivers/net/fs_enet/mac-fec.c +++ b/drivers/net/fs_enet/mac-fec.c | |||
| @@ -98,11 +98,11 @@ static int do_pd_setup(struct fs_enet_private *fep) | |||
| 98 | { | 98 | { |
| 99 | struct of_device *ofdev = to_of_device(fep->dev); | 99 | struct of_device *ofdev = to_of_device(fep->dev); |
| 100 | 100 | ||
| 101 | fep->interrupt = of_irq_to_resource(ofdev->node, 0, NULL); | 101 | fep->interrupt = of_irq_to_resource(ofdev->dev.of_node, 0, NULL); |
| 102 | if (fep->interrupt == NO_IRQ) | 102 | if (fep->interrupt == NO_IRQ) |
| 103 | return -EINVAL; | 103 | return -EINVAL; |
| 104 | 104 | ||
| 105 | fep->fec.fecp = of_iomap(ofdev->node, 0); | 105 | fep->fec.fecp = of_iomap(ofdev->dev.of_node, 0); |
| 106 | if (!fep->fcc.fccp) | 106 | if (!fep->fcc.fccp) |
| 107 | return -EINVAL; | 107 | return -EINVAL; |
| 108 | 108 | ||
diff --git a/drivers/net/fs_enet/mac-scc.c b/drivers/net/fs_enet/mac-scc.c index 7f0591e43cd9..a3c44544846d 100644 --- a/drivers/net/fs_enet/mac-scc.c +++ b/drivers/net/fs_enet/mac-scc.c | |||
| @@ -98,15 +98,15 @@ static int do_pd_setup(struct fs_enet_private *fep) | |||
| 98 | { | 98 | { |
| 99 | struct of_device *ofdev = to_of_device(fep->dev); | 99 | struct of_device *ofdev = to_of_device(fep->dev); |
| 100 | 100 | ||
| 101 | fep->interrupt = of_irq_to_resource(ofdev->node, 0, NULL); | 101 | fep->interrupt = of_irq_to_resource(ofdev->dev.of_node, 0, NULL); |
| 102 | if (fep->interrupt == NO_IRQ) | 102 | if (fep->interrupt == NO_IRQ) |
| 103 | return -EINVAL; | 103 | return -EINVAL; |
| 104 | 104 | ||
| 105 | fep->scc.sccp = of_iomap(ofdev->node, 0); | 105 | fep->scc.sccp = of_iomap(ofdev->dev.of_node, 0); |
| 106 | if (!fep->scc.sccp) | 106 | if (!fep->scc.sccp) |
| 107 | return -EINVAL; | 107 | return -EINVAL; |
| 108 | 108 | ||
| 109 | fep->scc.ep = of_iomap(ofdev->node, 1); | 109 | fep->scc.ep = of_iomap(ofdev->dev.of_node, 1); |
| 110 | if (!fep->scc.ep) { | 110 | if (!fep->scc.ep) { |
| 111 | iounmap(fep->scc.sccp); | 111 | iounmap(fep->scc.sccp); |
| 112 | return -EINVAL; | 112 | return -EINVAL; |
diff --git a/drivers/net/fs_enet/mii-bitbang.c b/drivers/net/fs_enet/mii-bitbang.c index 24ff9f43a62b..0f90685d3d19 100644 --- a/drivers/net/fs_enet/mii-bitbang.c +++ b/drivers/net/fs_enet/mii-bitbang.c | |||
| @@ -224,8 +224,11 @@ static struct of_device_id fs_enet_mdio_bb_match[] = { | |||
| 224 | MODULE_DEVICE_TABLE(of, fs_enet_mdio_bb_match); | 224 | MODULE_DEVICE_TABLE(of, fs_enet_mdio_bb_match); |
| 225 | 225 | ||
| 226 | static struct of_platform_driver fs_enet_bb_mdio_driver = { | 226 | static struct of_platform_driver fs_enet_bb_mdio_driver = { |
| 227 | .name = "fsl-bb-mdio", | 227 | .driver = { |
| 228 | .match_table = fs_enet_mdio_bb_match, | 228 | .name = "fsl-bb-mdio", |
| 229 | .owner = THIS_MODULE, | ||
| 230 | .of_match_table = fs_enet_mdio_bb_match, | ||
| 231 | }, | ||
| 229 | .probe = fs_enet_mdio_probe, | 232 | .probe = fs_enet_mdio_probe, |
| 230 | .remove = fs_enet_mdio_remove, | 233 | .remove = fs_enet_mdio_remove, |
| 231 | }; | 234 | }; |
diff --git a/drivers/net/fs_enet/mii-fec.c b/drivers/net/fs_enet/mii-fec.c index 5944b65082cb..bddffd169b93 100644 --- a/drivers/net/fs_enet/mii-fec.c +++ b/drivers/net/fs_enet/mii-fec.c | |||
| @@ -124,7 +124,7 @@ static int __devinit fs_enet_mdio_probe(struct of_device *ofdev, | |||
| 124 | new_bus->write = &fs_enet_fec_mii_write; | 124 | new_bus->write = &fs_enet_fec_mii_write; |
| 125 | new_bus->reset = &fs_enet_fec_mii_reset; | 125 | new_bus->reset = &fs_enet_fec_mii_reset; |
| 126 | 126 | ||
| 127 | ret = of_address_to_resource(ofdev->node, 0, &res); | 127 | ret = of_address_to_resource(ofdev->dev.of_node, 0, &res); |
| 128 | if (ret) | 128 | if (ret) |
| 129 | goto out_res; | 129 | goto out_res; |
| 130 | 130 | ||
| @@ -135,7 +135,7 @@ static int __devinit fs_enet_mdio_probe(struct of_device *ofdev, | |||
| 135 | goto out_fec; | 135 | goto out_fec; |
| 136 | 136 | ||
| 137 | if (get_bus_freq) { | 137 | if (get_bus_freq) { |
| 138 | clock = get_bus_freq(ofdev->node); | 138 | clock = get_bus_freq(ofdev->dev.of_node); |
| 139 | if (!clock) { | 139 | if (!clock) { |
| 140 | /* Use maximum divider if clock is unknown */ | 140 | /* Use maximum divider if clock is unknown */ |
| 141 | dev_warn(&ofdev->dev, "could not determine IPS clock\n"); | 141 | dev_warn(&ofdev->dev, "could not determine IPS clock\n"); |
| @@ -172,7 +172,7 @@ static int __devinit fs_enet_mdio_probe(struct of_device *ofdev, | |||
| 172 | new_bus->parent = &ofdev->dev; | 172 | new_bus->parent = &ofdev->dev; |
| 173 | dev_set_drvdata(&ofdev->dev, new_bus); | 173 | dev_set_drvdata(&ofdev->dev, new_bus); |
| 174 | 174 | ||
| 175 | ret = of_mdiobus_register(new_bus, ofdev->node); | 175 | ret = of_mdiobus_register(new_bus, ofdev->dev.of_node); |
| 176 | if (ret) | 176 | if (ret) |
| 177 | goto out_free_irqs; | 177 | goto out_free_irqs; |
| 178 | 178 | ||
| @@ -222,8 +222,11 @@ static struct of_device_id fs_enet_mdio_fec_match[] = { | |||
| 222 | MODULE_DEVICE_TABLE(of, fs_enet_mdio_fec_match); | 222 | MODULE_DEVICE_TABLE(of, fs_enet_mdio_fec_match); |
| 223 | 223 | ||
| 224 | static struct of_platform_driver fs_enet_fec_mdio_driver = { | 224 | static struct of_platform_driver fs_enet_fec_mdio_driver = { |
| 225 | .name = "fsl-fec-mdio", | 225 | .driver = { |
| 226 | .match_table = fs_enet_mdio_fec_match, | 226 | .name = "fsl-fec-mdio", |
| 227 | .owner = THIS_MODULE, | ||
| 228 | .of_match_table = fs_enet_mdio_fec_match, | ||
| 229 | }, | ||
| 227 | .probe = fs_enet_mdio_probe, | 230 | .probe = fs_enet_mdio_probe, |
| 228 | .remove = fs_enet_mdio_remove, | 231 | .remove = fs_enet_mdio_remove, |
| 229 | }; | 232 | }; |
diff --git a/drivers/net/fsl_pq_mdio.c b/drivers/net/fsl_pq_mdio.c index ff028f59b930..b4c41d72c423 100644 --- a/drivers/net/fsl_pq_mdio.c +++ b/drivers/net/fsl_pq_mdio.c | |||
| @@ -267,7 +267,7 @@ static int get_ucc_id_for_range(u64 start, u64 end, u32 *ucc_id) | |||
| 267 | static int fsl_pq_mdio_probe(struct of_device *ofdev, | 267 | static int fsl_pq_mdio_probe(struct of_device *ofdev, |
| 268 | const struct of_device_id *match) | 268 | const struct of_device_id *match) |
| 269 | { | 269 | { |
| 270 | struct device_node *np = ofdev->node; | 270 | struct device_node *np = ofdev->dev.of_node; |
| 271 | struct device_node *tbi; | 271 | struct device_node *tbi; |
| 272 | struct fsl_pq_mdio_priv *priv; | 272 | struct fsl_pq_mdio_priv *priv; |
| 273 | struct fsl_pq_mdio __iomem *regs = NULL; | 273 | struct fsl_pq_mdio __iomem *regs = NULL; |
| @@ -471,10 +471,13 @@ static struct of_device_id fsl_pq_mdio_match[] = { | |||
| 471 | MODULE_DEVICE_TABLE(of, fsl_pq_mdio_match); | 471 | MODULE_DEVICE_TABLE(of, fsl_pq_mdio_match); |
| 472 | 472 | ||
| 473 | static struct of_platform_driver fsl_pq_mdio_driver = { | 473 | static struct of_platform_driver fsl_pq_mdio_driver = { |
| 474 | .name = "fsl-pq_mdio", | 474 | .driver = { |
| 475 | .name = "fsl-pq_mdio", | ||
| 476 | .owner = THIS_MODULE, | ||
| 477 | .of_match_table = fsl_pq_mdio_match, | ||
| 478 | }, | ||
| 475 | .probe = fsl_pq_mdio_probe, | 479 | .probe = fsl_pq_mdio_probe, |
| 476 | .remove = fsl_pq_mdio_remove, | 480 | .remove = fsl_pq_mdio_remove, |
| 477 | .match_table = fsl_pq_mdio_match, | ||
| 478 | }; | 481 | }; |
| 479 | 482 | ||
| 480 | int __init fsl_pq_mdio_init(void) | 483 | int __init fsl_pq_mdio_init(void) |
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c index c6791cd4ee05..1830f3199cb5 100644 --- a/drivers/net/gianfar.c +++ b/drivers/net/gianfar.c | |||
| @@ -608,7 +608,7 @@ static int gfar_of_init(struct of_device *ofdev, struct net_device **pdev) | |||
| 608 | int err = 0, i; | 608 | int err = 0, i; |
| 609 | struct net_device *dev = NULL; | 609 | struct net_device *dev = NULL; |
| 610 | struct gfar_private *priv = NULL; | 610 | struct gfar_private *priv = NULL; |
| 611 | struct device_node *np = ofdev->node; | 611 | struct device_node *np = ofdev->dev.of_node; |
| 612 | struct device_node *child = NULL; | 612 | struct device_node *child = NULL; |
| 613 | const u32 *stash; | 613 | const u32 *stash; |
| 614 | const u32 *stash_len; | 614 | const u32 *stash_len; |
| @@ -646,7 +646,7 @@ static int gfar_of_init(struct of_device *ofdev, struct net_device **pdev) | |||
| 646 | return -ENOMEM; | 646 | return -ENOMEM; |
| 647 | 647 | ||
| 648 | priv = netdev_priv(dev); | 648 | priv = netdev_priv(dev); |
| 649 | priv->node = ofdev->node; | 649 | priv->node = ofdev->dev.of_node; |
| 650 | priv->ndev = dev; | 650 | priv->ndev = dev; |
| 651 | 651 | ||
| 652 | dev->num_tx_queues = num_tx_qs; | 652 | dev->num_tx_queues = num_tx_qs; |
| @@ -939,7 +939,7 @@ static int gfar_probe(struct of_device *ofdev, | |||
| 939 | priv = netdev_priv(dev); | 939 | priv = netdev_priv(dev); |
| 940 | priv->ndev = dev; | 940 | priv->ndev = dev; |
| 941 | priv->ofdev = ofdev; | 941 | priv->ofdev = ofdev; |
| 942 | priv->node = ofdev->node; | 942 | priv->node = ofdev->dev.of_node; |
| 943 | SET_NETDEV_DEV(dev, &ofdev->dev); | 943 | SET_NETDEV_DEV(dev, &ofdev->dev); |
| 944 | 944 | ||
| 945 | spin_lock_init(&priv->bflock); | 945 | spin_lock_init(&priv->bflock); |
| @@ -3167,12 +3167,14 @@ MODULE_DEVICE_TABLE(of, gfar_match); | |||
| 3167 | 3167 | ||
| 3168 | /* Structure for a device driver */ | 3168 | /* Structure for a device driver */ |
| 3169 | static struct of_platform_driver gfar_driver = { | 3169 | static struct of_platform_driver gfar_driver = { |
| 3170 | .name = "fsl-gianfar", | 3170 | .driver = { |
| 3171 | .match_table = gfar_match, | 3171 | .name = "fsl-gianfar", |
| 3172 | 3172 | .owner = THIS_MODULE, | |
| 3173 | .pm = GFAR_PM_OPS, | ||
| 3174 | .of_match_table = gfar_match, | ||
| 3175 | }, | ||
| 3173 | .probe = gfar_probe, | 3176 | .probe = gfar_probe, |
| 3174 | .remove = gfar_remove, | 3177 | .remove = gfar_remove, |
| 3175 | .driver.pm = GFAR_PM_OPS, | ||
| 3176 | }; | 3178 | }; |
| 3177 | 3179 | ||
| 3178 | static int __init gfar_init(void) | 3180 | static int __init gfar_init(void) |
diff --git a/drivers/net/greth.c b/drivers/net/greth.c index fd491e409488..f37a4c143ddd 100644 --- a/drivers/net/greth.c +++ b/drivers/net/greth.c | |||
| @@ -1499,7 +1499,8 @@ static int __devinit greth_of_probe(struct of_device *ofdev, const struct of_dev | |||
| 1499 | if (i == 6) { | 1499 | if (i == 6) { |
| 1500 | const unsigned char *addr; | 1500 | const unsigned char *addr; |
| 1501 | int len; | 1501 | int len; |
| 1502 | addr = of_get_property(ofdev->node, "local-mac-address", &len); | 1502 | addr = of_get_property(ofdev->dev.of_node, "local-mac-address", |
| 1503 | &len); | ||
| 1503 | if (addr != NULL && len == 6) { | 1504 | if (addr != NULL && len == 6) { |
| 1504 | for (i = 0; i < 6; i++) | 1505 | for (i = 0; i < 6; i++) |
| 1505 | macaddr[i] = (unsigned int) addr[i]; | 1506 | macaddr[i] = (unsigned int) addr[i]; |
diff --git a/drivers/net/ibm_newemac/core.c b/drivers/net/ibm_newemac/core.c index 2484e9e6c1ed..b150c102ca5a 100644 --- a/drivers/net/ibm_newemac/core.c +++ b/drivers/net/ibm_newemac/core.c | |||
| @@ -136,7 +136,8 @@ static inline void emac_report_timeout_error(struct emac_instance *dev, | |||
| 136 | EMAC_FTR_440EP_PHY_CLK_FIX)) | 136 | EMAC_FTR_440EP_PHY_CLK_FIX)) |
| 137 | DBG(dev, "%s" NL, error); | 137 | DBG(dev, "%s" NL, error); |
| 138 | else if (net_ratelimit()) | 138 | else if (net_ratelimit()) |
| 139 | printk(KERN_ERR "%s: %s\n", dev->ofdev->node->full_name, error); | 139 | printk(KERN_ERR "%s: %s\n", dev->ofdev->dev.of_node->full_name, |
| 140 | error); | ||
| 140 | } | 141 | } |
| 141 | 142 | ||
| 142 | /* EMAC PHY clock workaround: | 143 | /* EMAC PHY clock workaround: |
| @@ -2185,7 +2186,7 @@ static void emac_ethtool_get_drvinfo(struct net_device *ndev, | |||
| 2185 | strcpy(info->version, DRV_VERSION); | 2186 | strcpy(info->version, DRV_VERSION); |
| 2186 | info->fw_version[0] = '\0'; | 2187 | info->fw_version[0] = '\0'; |
| 2187 | sprintf(info->bus_info, "PPC 4xx EMAC-%d %s", | 2188 | sprintf(info->bus_info, "PPC 4xx EMAC-%d %s", |
| 2188 | dev->cell_index, dev->ofdev->node->full_name); | 2189 | dev->cell_index, dev->ofdev->dev.of_node->full_name); |
| 2189 | info->regdump_len = emac_ethtool_get_regs_len(ndev); | 2190 | info->regdump_len = emac_ethtool_get_regs_len(ndev); |
| 2190 | } | 2191 | } |
| 2191 | 2192 | ||
| @@ -2379,7 +2380,7 @@ static int __devinit emac_read_uint_prop(struct device_node *np, const char *nam | |||
| 2379 | 2380 | ||
| 2380 | static int __devinit emac_init_phy(struct emac_instance *dev) | 2381 | static int __devinit emac_init_phy(struct emac_instance *dev) |
| 2381 | { | 2382 | { |
| 2382 | struct device_node *np = dev->ofdev->node; | 2383 | struct device_node *np = dev->ofdev->dev.of_node; |
| 2383 | struct net_device *ndev = dev->ndev; | 2384 | struct net_device *ndev = dev->ndev; |
| 2384 | u32 phy_map, adv; | 2385 | u32 phy_map, adv; |
| 2385 | int i; | 2386 | int i; |
| @@ -2514,7 +2515,7 @@ static int __devinit emac_init_phy(struct emac_instance *dev) | |||
| 2514 | 2515 | ||
| 2515 | static int __devinit emac_init_config(struct emac_instance *dev) | 2516 | static int __devinit emac_init_config(struct emac_instance *dev) |
| 2516 | { | 2517 | { |
| 2517 | struct device_node *np = dev->ofdev->node; | 2518 | struct device_node *np = dev->ofdev->dev.of_node; |
| 2518 | const void *p; | 2519 | const void *p; |
| 2519 | unsigned int plen; | 2520 | unsigned int plen; |
| 2520 | const char *pm, *phy_modes[] = { | 2521 | const char *pm, *phy_modes[] = { |
| @@ -2723,7 +2724,7 @@ static int __devinit emac_probe(struct of_device *ofdev, | |||
| 2723 | { | 2724 | { |
| 2724 | struct net_device *ndev; | 2725 | struct net_device *ndev; |
| 2725 | struct emac_instance *dev; | 2726 | struct emac_instance *dev; |
| 2726 | struct device_node *np = ofdev->node; | 2727 | struct device_node *np = ofdev->dev.of_node; |
| 2727 | struct device_node **blist = NULL; | 2728 | struct device_node **blist = NULL; |
| 2728 | int err, i; | 2729 | int err, i; |
| 2729 | 2730 | ||
| @@ -2810,7 +2811,7 @@ static int __devinit emac_probe(struct of_device *ofdev, | |||
| 2810 | err = mal_register_commac(dev->mal, &dev->commac); | 2811 | err = mal_register_commac(dev->mal, &dev->commac); |
| 2811 | if (err) { | 2812 | if (err) { |
| 2812 | printk(KERN_ERR "%s: failed to register with mal %s!\n", | 2813 | printk(KERN_ERR "%s: failed to register with mal %s!\n", |
| 2813 | np->full_name, dev->mal_dev->node->full_name); | 2814 | np->full_name, dev->mal_dev->dev.of_node->full_name); |
| 2814 | goto err_rel_deps; | 2815 | goto err_rel_deps; |
| 2815 | } | 2816 | } |
| 2816 | dev->rx_skb_size = emac_rx_skb_size(ndev->mtu); | 2817 | dev->rx_skb_size = emac_rx_skb_size(ndev->mtu); |
| @@ -2995,9 +2996,11 @@ static struct of_device_id emac_match[] = | |||
| 2995 | MODULE_DEVICE_TABLE(of, emac_match); | 2996 | MODULE_DEVICE_TABLE(of, emac_match); |
| 2996 | 2997 | ||
| 2997 | static struct of_platform_driver emac_driver = { | 2998 | static struct of_platform_driver emac_driver = { |
| 2998 | .name = "emac", | 2999 | .driver = { |
| 2999 | .match_table = emac_match, | 3000 | .name = "emac", |
| 3000 | 3001 | .owner = THIS_MODULE, | |
| 3002 | .of_match_table = emac_match, | ||
| 3003 | }, | ||
| 3001 | .probe = emac_probe, | 3004 | .probe = emac_probe, |
| 3002 | .remove = emac_remove, | 3005 | .remove = emac_remove, |
| 3003 | }; | 3006 | }; |
diff --git a/drivers/net/ibm_newemac/debug.c b/drivers/net/ibm_newemac/debug.c index 775c850a425a..3995fafc1e08 100644 --- a/drivers/net/ibm_newemac/debug.c +++ b/drivers/net/ibm_newemac/debug.c | |||
| @@ -33,7 +33,7 @@ static void emac_desc_dump(struct emac_instance *p) | |||
| 33 | int i; | 33 | int i; |
| 34 | printk("** EMAC %s TX BDs **\n" | 34 | printk("** EMAC %s TX BDs **\n" |
| 35 | " tx_cnt = %d tx_slot = %d ack_slot = %d\n", | 35 | " tx_cnt = %d tx_slot = %d ack_slot = %d\n", |
| 36 | p->ofdev->node->full_name, | 36 | p->ofdev->dev.of_node->full_name, |
| 37 | p->tx_cnt, p->tx_slot, p->ack_slot); | 37 | p->tx_cnt, p->tx_slot, p->ack_slot); |
| 38 | for (i = 0; i < NUM_TX_BUFF / 2; ++i) | 38 | for (i = 0; i < NUM_TX_BUFF / 2; ++i) |
| 39 | printk | 39 | printk |
| @@ -49,7 +49,7 @@ static void emac_desc_dump(struct emac_instance *p) | |||
| 49 | printk("** EMAC %s RX BDs **\n" | 49 | printk("** EMAC %s RX BDs **\n" |
| 50 | " rx_slot = %d flags = 0x%lx rx_skb_size = %d rx_sync_size = %d\n" | 50 | " rx_slot = %d flags = 0x%lx rx_skb_size = %d rx_sync_size = %d\n" |
| 51 | " rx_sg_skb = 0x%p\n", | 51 | " rx_sg_skb = 0x%p\n", |
| 52 | p->ofdev->node->full_name, | 52 | p->ofdev->dev.of_node->full_name, |
| 53 | p->rx_slot, p->commac.flags, p->rx_skb_size, | 53 | p->rx_slot, p->commac.flags, p->rx_skb_size, |
| 54 | p->rx_sync_size, p->rx_sg_skb); | 54 | p->rx_sync_size, p->rx_sg_skb); |
| 55 | for (i = 0; i < NUM_RX_BUFF / 2; ++i) | 55 | for (i = 0; i < NUM_RX_BUFF / 2; ++i) |
| @@ -77,7 +77,8 @@ static void emac_mac_dump(struct emac_instance *dev) | |||
| 77 | "MR0 = 0x%08x MR1 = 0x%08x TMR0 = 0x%08x TMR1 = 0x%08x\n" | 77 | "MR0 = 0x%08x MR1 = 0x%08x TMR0 = 0x%08x TMR1 = 0x%08x\n" |
| 78 | "RMR = 0x%08x ISR = 0x%08x ISER = 0x%08x\n" | 78 | "RMR = 0x%08x ISR = 0x%08x ISER = 0x%08x\n" |
| 79 | "IAR = %04x%08x VTPID = 0x%04x VTCI = 0x%04x\n", | 79 | "IAR = %04x%08x VTPID = 0x%04x VTCI = 0x%04x\n", |
| 80 | dev->ofdev->node->full_name, in_be32(&p->mr0), in_be32(&p->mr1), | 80 | dev->ofdev->dev.of_node->full_name, |
| 81 | in_be32(&p->mr0), in_be32(&p->mr1), | ||
| 81 | in_be32(&p->tmr0), in_be32(&p->tmr1), | 82 | in_be32(&p->tmr0), in_be32(&p->tmr1), |
| 82 | in_be32(&p->rmr), in_be32(&p->isr), in_be32(&p->iser), | 83 | in_be32(&p->rmr), in_be32(&p->isr), in_be32(&p->iser), |
| 83 | in_be32(&p->iahr), in_be32(&p->ialr), in_be32(&p->vtpid), | 84 | in_be32(&p->iahr), in_be32(&p->ialr), in_be32(&p->vtpid), |
| @@ -128,7 +129,7 @@ static void emac_mal_dump(struct mal_instance *mal) | |||
| 128 | "CFG = 0x%08x ESR = 0x%08x IER = 0x%08x\n" | 129 | "CFG = 0x%08x ESR = 0x%08x IER = 0x%08x\n" |
| 129 | "TX|CASR = 0x%08x CARR = 0x%08x EOBISR = 0x%08x DEIR = 0x%08x\n" | 130 | "TX|CASR = 0x%08x CARR = 0x%08x EOBISR = 0x%08x DEIR = 0x%08x\n" |
| 130 | "RX|CASR = 0x%08x CARR = 0x%08x EOBISR = 0x%08x DEIR = 0x%08x\n", | 131 | "RX|CASR = 0x%08x CARR = 0x%08x EOBISR = 0x%08x DEIR = 0x%08x\n", |
| 131 | mal->ofdev->node->full_name, | 132 | mal->ofdev->dev.of_node->full_name, |
| 132 | get_mal_dcrn(mal, MAL_CFG), get_mal_dcrn(mal, MAL_ESR), | 133 | get_mal_dcrn(mal, MAL_CFG), get_mal_dcrn(mal, MAL_ESR), |
| 133 | get_mal_dcrn(mal, MAL_IER), | 134 | get_mal_dcrn(mal, MAL_IER), |
| 134 | get_mal_dcrn(mal, MAL_TXCASR), get_mal_dcrn(mal, MAL_TXCARR), | 135 | get_mal_dcrn(mal, MAL_TXCASR), get_mal_dcrn(mal, MAL_TXCARR), |
diff --git a/drivers/net/ibm_newemac/debug.h b/drivers/net/ibm_newemac/debug.h index b631842ec8d0..e596c77ccdf7 100644 --- a/drivers/net/ibm_newemac/debug.h +++ b/drivers/net/ibm_newemac/debug.h | |||
| @@ -53,8 +53,8 @@ extern void emac_dbg_dump_all(void); | |||
| 53 | 53 | ||
| 54 | #endif | 54 | #endif |
| 55 | 55 | ||
| 56 | #define EMAC_DBG(dev, name, fmt, arg...) \ | 56 | #define EMAC_DBG(d, name, fmt, arg...) \ |
| 57 | printk(KERN_DEBUG #name "%s: " fmt, dev->ofdev->node->full_name, ## arg) | 57 | printk(KERN_DEBUG #name "%s: " fmt, d->ofdev->dev.of_node->full_name, ## arg) |
| 58 | 58 | ||
| 59 | #if DBG_LEVEL > 0 | 59 | #if DBG_LEVEL > 0 |
| 60 | # define DBG(d,f,x...) EMAC_DBG(d, emac, f, ##x) | 60 | # define DBG(d,f,x...) EMAC_DBG(d, emac, f, ##x) |
diff --git a/drivers/net/ibm_newemac/mal.c b/drivers/net/ibm_newemac/mal.c index 5b3d94419fe6..fcff9e0bd382 100644 --- a/drivers/net/ibm_newemac/mal.c +++ b/drivers/net/ibm_newemac/mal.c | |||
| @@ -538,11 +538,11 @@ static int __devinit mal_probe(struct of_device *ofdev, | |||
| 538 | } | 538 | } |
| 539 | mal->index = index; | 539 | mal->index = index; |
| 540 | mal->ofdev = ofdev; | 540 | mal->ofdev = ofdev; |
| 541 | mal->version = of_device_is_compatible(ofdev->node, "ibm,mcmal2") ? 2 : 1; | 541 | mal->version = of_device_is_compatible(ofdev->dev.of_node, "ibm,mcmal2") ? 2 : 1; |
| 542 | 542 | ||
| 543 | MAL_DBG(mal, "probe" NL); | 543 | MAL_DBG(mal, "probe" NL); |
| 544 | 544 | ||
| 545 | prop = of_get_property(ofdev->node, "num-tx-chans", NULL); | 545 | prop = of_get_property(ofdev->dev.of_node, "num-tx-chans", NULL); |
| 546 | if (prop == NULL) { | 546 | if (prop == NULL) { |
| 547 | printk(KERN_ERR | 547 | printk(KERN_ERR |
| 548 | "mal%d: can't find MAL num-tx-chans property!\n", | 548 | "mal%d: can't find MAL num-tx-chans property!\n", |
| @@ -552,7 +552,7 @@ static int __devinit mal_probe(struct of_device *ofdev, | |||
| 552 | } | 552 | } |
| 553 | mal->num_tx_chans = prop[0]; | 553 | mal->num_tx_chans = prop[0]; |
| 554 | 554 | ||
| 555 | prop = of_get_property(ofdev->node, "num-rx-chans", NULL); | 555 | prop = of_get_property(ofdev->dev.of_node, "num-rx-chans", NULL); |
| 556 | if (prop == NULL) { | 556 | if (prop == NULL) { |
| 557 | printk(KERN_ERR | 557 | printk(KERN_ERR |
| 558 | "mal%d: can't find MAL num-rx-chans property!\n", | 558 | "mal%d: can't find MAL num-rx-chans property!\n", |
| @@ -562,14 +562,14 @@ static int __devinit mal_probe(struct of_device *ofdev, | |||
| 562 | } | 562 | } |
| 563 | mal->num_rx_chans = prop[0]; | 563 | mal->num_rx_chans = prop[0]; |
| 564 | 564 | ||
| 565 | dcr_base = dcr_resource_start(ofdev->node, 0); | 565 | dcr_base = dcr_resource_start(ofdev->dev.of_node, 0); |
| 566 | if (dcr_base == 0) { | 566 | if (dcr_base == 0) { |
| 567 | printk(KERN_ERR | 567 | printk(KERN_ERR |
| 568 | "mal%d: can't find DCR resource!\n", index); | 568 | "mal%d: can't find DCR resource!\n", index); |
| 569 | err = -ENODEV; | 569 | err = -ENODEV; |
| 570 | goto fail; | 570 | goto fail; |
| 571 | } | 571 | } |
| 572 | mal->dcr_host = dcr_map(ofdev->node, dcr_base, 0x100); | 572 | mal->dcr_host = dcr_map(ofdev->dev.of_node, dcr_base, 0x100); |
| 573 | if (!DCR_MAP_OK(mal->dcr_host)) { | 573 | if (!DCR_MAP_OK(mal->dcr_host)) { |
| 574 | printk(KERN_ERR | 574 | printk(KERN_ERR |
| 575 | "mal%d: failed to map DCRs !\n", index); | 575 | "mal%d: failed to map DCRs !\n", index); |
| @@ -577,28 +577,28 @@ static int __devinit mal_probe(struct of_device *ofdev, | |||
| 577 | goto fail; | 577 | goto fail; |
| 578 | } | 578 | } |
| 579 | 579 | ||
| 580 | if (of_device_is_compatible(ofdev->node, "ibm,mcmal-405ez")) { | 580 | if (of_device_is_compatible(ofdev->dev.of_node, "ibm,mcmal-405ez")) { |
| 581 | #if defined(CONFIG_IBM_NEW_EMAC_MAL_CLR_ICINTSTAT) && \ | 581 | #if defined(CONFIG_IBM_NEW_EMAC_MAL_CLR_ICINTSTAT) && \ |
| 582 | defined(CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR) | 582 | defined(CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR) |
| 583 | mal->features |= (MAL_FTR_CLEAR_ICINTSTAT | | 583 | mal->features |= (MAL_FTR_CLEAR_ICINTSTAT | |
| 584 | MAL_FTR_COMMON_ERR_INT); | 584 | MAL_FTR_COMMON_ERR_INT); |
| 585 | #else | 585 | #else |
| 586 | printk(KERN_ERR "%s: Support for 405EZ not enabled!\n", | 586 | printk(KERN_ERR "%s: Support for 405EZ not enabled!\n", |
| 587 | ofdev->node->full_name); | 587 | ofdev->dev.of_node->full_name); |
| 588 | err = -ENODEV; | 588 | err = -ENODEV; |
| 589 | goto fail; | 589 | goto fail; |
| 590 | #endif | 590 | #endif |
| 591 | } | 591 | } |
| 592 | 592 | ||
| 593 | mal->txeob_irq = irq_of_parse_and_map(ofdev->node, 0); | 593 | mal->txeob_irq = irq_of_parse_and_map(ofdev->dev.of_node, 0); |
| 594 | mal->rxeob_irq = irq_of_parse_and_map(ofdev->node, 1); | 594 | mal->rxeob_irq = irq_of_parse_and_map(ofdev->dev.of_node, 1); |
| 595 | mal->serr_irq = irq_of_parse_and_map(ofdev->node, 2); | 595 | mal->serr_irq = irq_of_parse_and_map(ofdev->dev.of_node, 2); |
| 596 | 596 | ||
| 597 | if (mal_has_feature(mal, MAL_FTR_COMMON_ERR_INT)) { | 597 | if (mal_has_feature(mal, MAL_FTR_COMMON_ERR_INT)) { |
| 598 | mal->txde_irq = mal->rxde_irq = mal->serr_irq; | 598 | mal->txde_irq = mal->rxde_irq = mal->serr_irq; |
| 599 | } else { | 599 | } else { |
| 600 | mal->txde_irq = irq_of_parse_and_map(ofdev->node, 3); | 600 | mal->txde_irq = irq_of_parse_and_map(ofdev->dev.of_node, 3); |
| 601 | mal->rxde_irq = irq_of_parse_and_map(ofdev->node, 4); | 601 | mal->rxde_irq = irq_of_parse_and_map(ofdev->dev.of_node, 4); |
| 602 | } | 602 | } |
| 603 | 603 | ||
| 604 | if (mal->txeob_irq == NO_IRQ || mal->rxeob_irq == NO_IRQ || | 604 | if (mal->txeob_irq == NO_IRQ || mal->rxeob_irq == NO_IRQ || |
| @@ -629,7 +629,7 @@ static int __devinit mal_probe(struct of_device *ofdev, | |||
| 629 | /* Current Axon is not happy with priority being non-0, it can | 629 | /* Current Axon is not happy with priority being non-0, it can |
| 630 | * deadlock, fix it up here | 630 | * deadlock, fix it up here |
| 631 | */ | 631 | */ |
| 632 | if (of_device_is_compatible(ofdev->node, "ibm,mcmal-axon")) | 632 | if (of_device_is_compatible(ofdev->dev.of_node, "ibm,mcmal-axon")) |
| 633 | cfg &= ~(MAL2_CFG_RPP_10 | MAL2_CFG_WPP_10); | 633 | cfg &= ~(MAL2_CFG_RPP_10 | MAL2_CFG_WPP_10); |
| 634 | 634 | ||
| 635 | /* Apply configuration */ | 635 | /* Apply configuration */ |
| @@ -701,7 +701,7 @@ static int __devinit mal_probe(struct of_device *ofdev, | |||
| 701 | 701 | ||
| 702 | printk(KERN_INFO | 702 | printk(KERN_INFO |
| 703 | "MAL v%d %s, %d TX channels, %d RX channels\n", | 703 | "MAL v%d %s, %d TX channels, %d RX channels\n", |
| 704 | mal->version, ofdev->node->full_name, | 704 | mal->version, ofdev->dev.of_node->full_name, |
| 705 | mal->num_tx_chans, mal->num_rx_chans); | 705 | mal->num_tx_chans, mal->num_rx_chans); |
| 706 | 706 | ||
| 707 | /* Advertise this instance to the rest of the world */ | 707 | /* Advertise this instance to the rest of the world */ |
| @@ -790,9 +790,11 @@ static struct of_device_id mal_platform_match[] = | |||
| 790 | }; | 790 | }; |
| 791 | 791 | ||
| 792 | static struct of_platform_driver mal_of_driver = { | 792 | static struct of_platform_driver mal_of_driver = { |
| 793 | .name = "mcmal", | 793 | .driver = { |
| 794 | .match_table = mal_platform_match, | 794 | .name = "mcmal", |
| 795 | 795 | .owner = THIS_MODULE, | |
| 796 | .of_match_table = mal_platform_match, | ||
| 797 | }, | ||
| 796 | .probe = mal_probe, | 798 | .probe = mal_probe, |
| 797 | .remove = mal_remove, | 799 | .remove = mal_remove, |
| 798 | }; | 800 | }; |
diff --git a/drivers/net/ibm_newemac/rgmii.c b/drivers/net/ibm_newemac/rgmii.c index 5b90d34c8455..108919bcdf13 100644 --- a/drivers/net/ibm_newemac/rgmii.c +++ b/drivers/net/ibm_newemac/rgmii.c | |||
| @@ -103,7 +103,7 @@ int __devinit rgmii_attach(struct of_device *ofdev, int input, int mode) | |||
| 103 | /* Check if we need to attach to a RGMII */ | 103 | /* Check if we need to attach to a RGMII */ |
| 104 | if (input < 0 || !rgmii_valid_mode(mode)) { | 104 | if (input < 0 || !rgmii_valid_mode(mode)) { |
| 105 | printk(KERN_ERR "%s: unsupported settings !\n", | 105 | printk(KERN_ERR "%s: unsupported settings !\n", |
| 106 | ofdev->node->full_name); | 106 | ofdev->dev.of_node->full_name); |
| 107 | return -ENODEV; | 107 | return -ENODEV; |
| 108 | } | 108 | } |
| 109 | 109 | ||
| @@ -113,7 +113,7 @@ int __devinit rgmii_attach(struct of_device *ofdev, int input, int mode) | |||
| 113 | out_be32(&p->fer, in_be32(&p->fer) | rgmii_mode_mask(mode, input)); | 113 | out_be32(&p->fer, in_be32(&p->fer) | rgmii_mode_mask(mode, input)); |
| 114 | 114 | ||
| 115 | printk(KERN_NOTICE "%s: input %d in %s mode\n", | 115 | printk(KERN_NOTICE "%s: input %d in %s mode\n", |
| 116 | ofdev->node->full_name, input, rgmii_mode_name(mode)); | 116 | ofdev->dev.of_node->full_name, input, rgmii_mode_name(mode)); |
| 117 | 117 | ||
| 118 | ++dev->users; | 118 | ++dev->users; |
| 119 | 119 | ||
| @@ -231,7 +231,7 @@ void *rgmii_dump_regs(struct of_device *ofdev, void *buf) | |||
| 231 | static int __devinit rgmii_probe(struct of_device *ofdev, | 231 | static int __devinit rgmii_probe(struct of_device *ofdev, |
| 232 | const struct of_device_id *match) | 232 | const struct of_device_id *match) |
| 233 | { | 233 | { |
| 234 | struct device_node *np = ofdev->node; | 234 | struct device_node *np = ofdev->dev.of_node; |
| 235 | struct rgmii_instance *dev; | 235 | struct rgmii_instance *dev; |
| 236 | struct resource regs; | 236 | struct resource regs; |
| 237 | int rc; | 237 | int rc; |
| @@ -264,11 +264,11 @@ static int __devinit rgmii_probe(struct of_device *ofdev, | |||
| 264 | } | 264 | } |
| 265 | 265 | ||
| 266 | /* Check for RGMII flags */ | 266 | /* Check for RGMII flags */ |
| 267 | if (of_get_property(ofdev->node, "has-mdio", NULL)) | 267 | if (of_get_property(ofdev->dev.of_node, "has-mdio", NULL)) |
| 268 | dev->flags |= EMAC_RGMII_FLAG_HAS_MDIO; | 268 | dev->flags |= EMAC_RGMII_FLAG_HAS_MDIO; |
| 269 | 269 | ||
| 270 | /* CAB lacks the right properties, fix this up */ | 270 | /* CAB lacks the right properties, fix this up */ |
| 271 | if (of_device_is_compatible(ofdev->node, "ibm,rgmii-axon")) | 271 | if (of_device_is_compatible(ofdev->dev.of_node, "ibm,rgmii-axon")) |
| 272 | dev->flags |= EMAC_RGMII_FLAG_HAS_MDIO; | 272 | dev->flags |= EMAC_RGMII_FLAG_HAS_MDIO; |
| 273 | 273 | ||
| 274 | DBG2(dev, " Boot FER = 0x%08x, SSR = 0x%08x\n", | 274 | DBG2(dev, " Boot FER = 0x%08x, SSR = 0x%08x\n", |
| @@ -279,7 +279,7 @@ static int __devinit rgmii_probe(struct of_device *ofdev, | |||
| 279 | 279 | ||
| 280 | printk(KERN_INFO | 280 | printk(KERN_INFO |
| 281 | "RGMII %s initialized with%s MDIO support\n", | 281 | "RGMII %s initialized with%s MDIO support\n", |
| 282 | ofdev->node->full_name, | 282 | ofdev->dev.of_node->full_name, |
| 283 | (dev->flags & EMAC_RGMII_FLAG_HAS_MDIO) ? "" : "out"); | 283 | (dev->flags & EMAC_RGMII_FLAG_HAS_MDIO) ? "" : "out"); |
| 284 | 284 | ||
| 285 | wmb(); | 285 | wmb(); |
| @@ -319,9 +319,11 @@ static struct of_device_id rgmii_match[] = | |||
| 319 | }; | 319 | }; |
| 320 | 320 | ||
| 321 | static struct of_platform_driver rgmii_driver = { | 321 | static struct of_platform_driver rgmii_driver = { |
| 322 | .name = "emac-rgmii", | 322 | .driver = { |
| 323 | .match_table = rgmii_match, | 323 | .name = "emac-rgmii", |
| 324 | 324 | .owner = THIS_MODULE, | |
| 325 | .of_match_table = rgmii_match, | ||
| 326 | }, | ||
| 325 | .probe = rgmii_probe, | 327 | .probe = rgmii_probe, |
| 326 | .remove = rgmii_remove, | 328 | .remove = rgmii_remove, |
| 327 | }; | 329 | }; |
diff --git a/drivers/net/ibm_newemac/tah.c b/drivers/net/ibm_newemac/tah.c index 30173a9fb557..044637144c43 100644 --- a/drivers/net/ibm_newemac/tah.c +++ b/drivers/net/ibm_newemac/tah.c | |||
| @@ -57,7 +57,8 @@ void tah_reset(struct of_device *ofdev) | |||
| 57 | --n; | 57 | --n; |
| 58 | 58 | ||
| 59 | if (unlikely(!n)) | 59 | if (unlikely(!n)) |
| 60 | printk(KERN_ERR "%s: reset timeout\n", ofdev->node->full_name); | 60 | printk(KERN_ERR "%s: reset timeout\n", |
| 61 | ofdev->dev.of_node->full_name); | ||
| 61 | 62 | ||
| 62 | /* 10KB TAH TX FIFO accomodates the max MTU of 9000 */ | 63 | /* 10KB TAH TX FIFO accomodates the max MTU of 9000 */ |
| 63 | out_be32(&p->mr, | 64 | out_be32(&p->mr, |
| @@ -89,7 +90,7 @@ void *tah_dump_regs(struct of_device *ofdev, void *buf) | |||
| 89 | static int __devinit tah_probe(struct of_device *ofdev, | 90 | static int __devinit tah_probe(struct of_device *ofdev, |
| 90 | const struct of_device_id *match) | 91 | const struct of_device_id *match) |
| 91 | { | 92 | { |
| 92 | struct device_node *np = ofdev->node; | 93 | struct device_node *np = ofdev->dev.of_node; |
| 93 | struct tah_instance *dev; | 94 | struct tah_instance *dev; |
| 94 | struct resource regs; | 95 | struct resource regs; |
| 95 | int rc; | 96 | int rc; |
| @@ -127,7 +128,7 @@ static int __devinit tah_probe(struct of_device *ofdev, | |||
| 127 | tah_reset(ofdev); | 128 | tah_reset(ofdev); |
| 128 | 129 | ||
| 129 | printk(KERN_INFO | 130 | printk(KERN_INFO |
| 130 | "TAH %s initialized\n", ofdev->node->full_name); | 131 | "TAH %s initialized\n", ofdev->dev.of_node->full_name); |
| 131 | wmb(); | 132 | wmb(); |
| 132 | 133 | ||
| 133 | return 0; | 134 | return 0; |
| @@ -165,9 +166,11 @@ static struct of_device_id tah_match[] = | |||
| 165 | }; | 166 | }; |
| 166 | 167 | ||
| 167 | static struct of_platform_driver tah_driver = { | 168 | static struct of_platform_driver tah_driver = { |
| 168 | .name = "emac-tah", | 169 | .driver = { |
| 169 | .match_table = tah_match, | 170 | .name = "emac-tah", |
| 170 | 171 | .owner = THIS_MODULE, | |
| 172 | .of_match_table = tah_match, | ||
| 173 | }, | ||
| 171 | .probe = tah_probe, | 174 | .probe = tah_probe, |
| 172 | .remove = tah_remove, | 175 | .remove = tah_remove, |
| 173 | }; | 176 | }; |
diff --git a/drivers/net/ibm_newemac/zmii.c b/drivers/net/ibm_newemac/zmii.c index 1f038f808ab3..046dcd069c45 100644 --- a/drivers/net/ibm_newemac/zmii.c +++ b/drivers/net/ibm_newemac/zmii.c | |||
| @@ -121,13 +121,14 @@ int __devinit zmii_attach(struct of_device *ofdev, int input, int *mode) | |||
| 121 | dev->mode = *mode; | 121 | dev->mode = *mode; |
| 122 | 122 | ||
| 123 | printk(KERN_NOTICE "%s: bridge in %s mode\n", | 123 | printk(KERN_NOTICE "%s: bridge in %s mode\n", |
| 124 | ofdev->node->full_name, zmii_mode_name(dev->mode)); | 124 | ofdev->dev.of_node->full_name, |
| 125 | zmii_mode_name(dev->mode)); | ||
| 125 | } else { | 126 | } else { |
| 126 | /* All inputs must use the same mode */ | 127 | /* All inputs must use the same mode */ |
| 127 | if (*mode != PHY_MODE_NA && *mode != dev->mode) { | 128 | if (*mode != PHY_MODE_NA && *mode != dev->mode) { |
| 128 | printk(KERN_ERR | 129 | printk(KERN_ERR |
| 129 | "%s: invalid mode %d specified for input %d\n", | 130 | "%s: invalid mode %d specified for input %d\n", |
| 130 | ofdev->node->full_name, *mode, input); | 131 | ofdev->dev.of_node->full_name, *mode, input); |
| 131 | mutex_unlock(&dev->lock); | 132 | mutex_unlock(&dev->lock); |
| 132 | return -EINVAL; | 133 | return -EINVAL; |
| 133 | } | 134 | } |
| @@ -233,7 +234,7 @@ void *zmii_dump_regs(struct of_device *ofdev, void *buf) | |||
| 233 | static int __devinit zmii_probe(struct of_device *ofdev, | 234 | static int __devinit zmii_probe(struct of_device *ofdev, |
| 234 | const struct of_device_id *match) | 235 | const struct of_device_id *match) |
| 235 | { | 236 | { |
| 236 | struct device_node *np = ofdev->node; | 237 | struct device_node *np = ofdev->dev.of_node; |
| 237 | struct zmii_instance *dev; | 238 | struct zmii_instance *dev; |
| 238 | struct resource regs; | 239 | struct resource regs; |
| 239 | int rc; | 240 | int rc; |
| @@ -273,7 +274,7 @@ static int __devinit zmii_probe(struct of_device *ofdev, | |||
| 273 | out_be32(&dev->base->fer, 0); | 274 | out_be32(&dev->base->fer, 0); |
| 274 | 275 | ||
| 275 | printk(KERN_INFO | 276 | printk(KERN_INFO |
| 276 | "ZMII %s initialized\n", ofdev->node->full_name); | 277 | "ZMII %s initialized\n", ofdev->dev.of_node->full_name); |
| 277 | wmb(); | 278 | wmb(); |
| 278 | dev_set_drvdata(&ofdev->dev, dev); | 279 | dev_set_drvdata(&ofdev->dev, dev); |
| 279 | 280 | ||
| @@ -312,9 +313,11 @@ static struct of_device_id zmii_match[] = | |||
| 312 | }; | 313 | }; |
| 313 | 314 | ||
| 314 | static struct of_platform_driver zmii_driver = { | 315 | static struct of_platform_driver zmii_driver = { |
| 315 | .name = "emac-zmii", | 316 | .driver = { |
| 316 | .match_table = zmii_match, | 317 | .name = "emac-zmii", |
| 317 | 318 | .owner = THIS_MODULE, | |
| 319 | .of_match_table = zmii_match, | ||
| 320 | }, | ||
| 318 | .probe = zmii_probe, | 321 | .probe = zmii_probe, |
| 319 | .remove = zmii_remove, | 322 | .remove = zmii_remove, |
| 320 | }; | 323 | }; |
diff --git a/drivers/net/ll_temac_main.c b/drivers/net/ll_temac_main.c index fbd07de2e088..52dcc8495647 100644 --- a/drivers/net/ll_temac_main.c +++ b/drivers/net/ll_temac_main.c | |||
| @@ -942,7 +942,7 @@ temac_of_probe(struct of_device *op, const struct of_device_id *match) | |||
| 942 | mutex_init(&lp->indirect_mutex); | 942 | mutex_init(&lp->indirect_mutex); |
| 943 | 943 | ||
| 944 | /* map device registers */ | 944 | /* map device registers */ |
| 945 | lp->regs = of_iomap(op->node, 0); | 945 | lp->regs = of_iomap(op->dev.of_node, 0); |
| 946 | if (!lp->regs) { | 946 | if (!lp->regs) { |
| 947 | dev_err(&op->dev, "could not map temac regs.\n"); | 947 | dev_err(&op->dev, "could not map temac regs.\n"); |
| 948 | goto nodev; | 948 | goto nodev; |
| @@ -961,7 +961,7 @@ temac_of_probe(struct of_device *op, const struct of_device_id *match) | |||
| 961 | lp->temac_features |= TEMAC_FEATURE_RX_CSUM; | 961 | lp->temac_features |= TEMAC_FEATURE_RX_CSUM; |
| 962 | 962 | ||
| 963 | /* Find the DMA node, map the DMA registers, and decode the DMA IRQs */ | 963 | /* Find the DMA node, map the DMA registers, and decode the DMA IRQs */ |
| 964 | np = of_parse_phandle(op->node, "llink-connected", 0); | 964 | np = of_parse_phandle(op->dev.of_node, "llink-connected", 0); |
| 965 | if (!np) { | 965 | if (!np) { |
| 966 | dev_err(&op->dev, "could not find DMA node\n"); | 966 | dev_err(&op->dev, "could not find DMA node\n"); |
| 967 | goto nodev; | 967 | goto nodev; |
| @@ -993,7 +993,7 @@ temac_of_probe(struct of_device *op, const struct of_device_id *match) | |||
| 993 | of_node_put(np); /* Finished with the DMA node; drop the reference */ | 993 | of_node_put(np); /* Finished with the DMA node; drop the reference */ |
| 994 | 994 | ||
| 995 | /* Retrieve the MAC address */ | 995 | /* Retrieve the MAC address */ |
| 996 | addr = of_get_property(op->node, "local-mac-address", &size); | 996 | addr = of_get_property(op->dev.of_node, "local-mac-address", &size); |
| 997 | if ((!addr) || (size != 6)) { | 997 | if ((!addr) || (size != 6)) { |
| 998 | dev_err(&op->dev, "could not find MAC address\n"); | 998 | dev_err(&op->dev, "could not find MAC address\n"); |
| 999 | rc = -ENODEV; | 999 | rc = -ENODEV; |
| @@ -1001,11 +1001,11 @@ temac_of_probe(struct of_device *op, const struct of_device_id *match) | |||
| 1001 | } | 1001 | } |
| 1002 | temac_set_mac_address(ndev, (void *)addr); | 1002 | temac_set_mac_address(ndev, (void *)addr); |
| 1003 | 1003 | ||
| 1004 | rc = temac_mdio_setup(lp, op->node); | 1004 | rc = temac_mdio_setup(lp, op->dev.of_node); |
| 1005 | if (rc) | 1005 | if (rc) |
| 1006 | dev_warn(&op->dev, "error registering MDIO bus\n"); | 1006 | dev_warn(&op->dev, "error registering MDIO bus\n"); |
| 1007 | 1007 | ||
| 1008 | lp->phy_node = of_parse_phandle(op->node, "phy-handle", 0); | 1008 | lp->phy_node = of_parse_phandle(op->dev.of_node, "phy-handle", 0); |
| 1009 | if (lp->phy_node) | 1009 | if (lp->phy_node) |
| 1010 | dev_dbg(lp->dev, "using PHY node %s (%p)\n", np->full_name, np); | 1010 | dev_dbg(lp->dev, "using PHY node %s (%p)\n", np->full_name, np); |
| 1011 | 1011 | ||
| @@ -1058,12 +1058,12 @@ static struct of_device_id temac_of_match[] __devinitdata = { | |||
| 1058 | MODULE_DEVICE_TABLE(of, temac_of_match); | 1058 | MODULE_DEVICE_TABLE(of, temac_of_match); |
| 1059 | 1059 | ||
| 1060 | static struct of_platform_driver temac_of_driver = { | 1060 | static struct of_platform_driver temac_of_driver = { |
| 1061 | .match_table = temac_of_match, | ||
| 1062 | .probe = temac_of_probe, | 1061 | .probe = temac_of_probe, |
| 1063 | .remove = __devexit_p(temac_of_remove), | 1062 | .remove = __devexit_p(temac_of_remove), |
| 1064 | .driver = { | 1063 | .driver = { |
| 1065 | .owner = THIS_MODULE, | 1064 | .owner = THIS_MODULE, |
| 1066 | .name = "xilinx_temac", | 1065 | .name = "xilinx_temac", |
| 1066 | .of_match_table = temac_of_match, | ||
| 1067 | }, | 1067 | }, |
| 1068 | }; | 1068 | }; |
| 1069 | 1069 | ||
diff --git a/drivers/net/mlx4/icm.c b/drivers/net/mlx4/icm.c index 57288ca1395f..b07e4dee80aa 100644 --- a/drivers/net/mlx4/icm.c +++ b/drivers/net/mlx4/icm.c | |||
| @@ -163,28 +163,30 @@ struct mlx4_icm *mlx4_alloc_icm(struct mlx4_dev *dev, int npages, | |||
| 163 | ret = mlx4_alloc_icm_pages(&chunk->mem[chunk->npages], | 163 | ret = mlx4_alloc_icm_pages(&chunk->mem[chunk->npages], |
| 164 | cur_order, gfp_mask); | 164 | cur_order, gfp_mask); |
| 165 | 165 | ||
| 166 | if (!ret) { | 166 | if (ret) { |
| 167 | ++chunk->npages; | 167 | if (--cur_order < 0) |
| 168 | 168 | goto fail; | |
| 169 | if (coherent) | 169 | else |
| 170 | ++chunk->nsg; | 170 | continue; |
| 171 | else if (chunk->npages == MLX4_ICM_CHUNK_LEN) { | 171 | } |
| 172 | chunk->nsg = pci_map_sg(dev->pdev, chunk->mem, | ||
| 173 | chunk->npages, | ||
| 174 | PCI_DMA_BIDIRECTIONAL); | ||
| 175 | 172 | ||
| 176 | if (chunk->nsg <= 0) | 173 | ++chunk->npages; |
| 177 | goto fail; | ||
| 178 | 174 | ||
| 179 | chunk = NULL; | 175 | if (coherent) |
| 180 | } | 176 | ++chunk->nsg; |
| 177 | else if (chunk->npages == MLX4_ICM_CHUNK_LEN) { | ||
| 178 | chunk->nsg = pci_map_sg(dev->pdev, chunk->mem, | ||
| 179 | chunk->npages, | ||
| 180 | PCI_DMA_BIDIRECTIONAL); | ||
| 181 | 181 | ||
| 182 | npages -= 1 << cur_order; | 182 | if (chunk->nsg <= 0) |
| 183 | } else { | ||
| 184 | --cur_order; | ||
| 185 | if (cur_order < 0) | ||
| 186 | goto fail; | 183 | goto fail; |
| 187 | } | 184 | } |
| 185 | |||
| 186 | if (chunk->npages == MLX4_ICM_CHUNK_LEN) | ||
| 187 | chunk = NULL; | ||
| 188 | |||
| 189 | npages -= 1 << cur_order; | ||
| 188 | } | 190 | } |
| 189 | 191 | ||
| 190 | if (!coherent && chunk) { | 192 | if (!coherent && chunk) { |
diff --git a/drivers/net/mlx4/mlx4.h b/drivers/net/mlx4/mlx4.h index bc72d6e4919b..13343e884999 100644 --- a/drivers/net/mlx4/mlx4.h +++ b/drivers/net/mlx4/mlx4.h | |||
| @@ -40,6 +40,7 @@ | |||
| 40 | #include <linux/mutex.h> | 40 | #include <linux/mutex.h> |
| 41 | #include <linux/radix-tree.h> | 41 | #include <linux/radix-tree.h> |
| 42 | #include <linux/timer.h> | 42 | #include <linux/timer.h> |
| 43 | #include <linux/semaphore.h> | ||
| 43 | #include <linux/workqueue.h> | 44 | #include <linux/workqueue.h> |
| 44 | 45 | ||
| 45 | #include <linux/mlx4/device.h> | 46 | #include <linux/mlx4/device.h> |
diff --git a/drivers/net/myri_sbus.c b/drivers/net/myri_sbus.c index 3898108f98ce..1a57c3da1f49 100644 --- a/drivers/net/myri_sbus.c +++ b/drivers/net/myri_sbus.c | |||
| @@ -928,7 +928,7 @@ static const struct net_device_ops myri_ops = { | |||
| 928 | 928 | ||
| 929 | static int __devinit myri_sbus_probe(struct of_device *op, const struct of_device_id *match) | 929 | static int __devinit myri_sbus_probe(struct of_device *op, const struct of_device_id *match) |
| 930 | { | 930 | { |
| 931 | struct device_node *dp = op->node; | 931 | struct device_node *dp = op->dev.of_node; |
| 932 | static unsigned version_printed; | 932 | static unsigned version_printed; |
| 933 | struct net_device *dev; | 933 | struct net_device *dev; |
| 934 | struct myri_eth *mp; | 934 | struct myri_eth *mp; |
| @@ -1161,8 +1161,11 @@ static const struct of_device_id myri_sbus_match[] = { | |||
| 1161 | MODULE_DEVICE_TABLE(of, myri_sbus_match); | 1161 | MODULE_DEVICE_TABLE(of, myri_sbus_match); |
| 1162 | 1162 | ||
| 1163 | static struct of_platform_driver myri_sbus_driver = { | 1163 | static struct of_platform_driver myri_sbus_driver = { |
| 1164 | .name = "myri", | 1164 | .driver = { |
| 1165 | .match_table = myri_sbus_match, | 1165 | .name = "myri", |
| 1166 | .owner = THIS_MODULE, | ||
| 1167 | .of_match_table = myri_sbus_match, | ||
| 1168 | }, | ||
| 1166 | .probe = myri_sbus_probe, | 1169 | .probe = myri_sbus_probe, |
| 1167 | .remove = __devexit_p(myri_sbus_remove), | 1170 | .remove = __devexit_p(myri_sbus_remove), |
| 1168 | }; | 1171 | }; |
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c index c61a61f177b7..6ce6ce1df6d2 100644 --- a/drivers/net/netxen/netxen_nic_main.c +++ b/drivers/net/netxen/netxen_nic_main.c | |||
| @@ -2560,7 +2560,8 @@ netxen_sysfs_validate_crb(struct netxen_adapter *adapter, | |||
| 2560 | } | 2560 | } |
| 2561 | 2561 | ||
| 2562 | static ssize_t | 2562 | static ssize_t |
| 2563 | netxen_sysfs_read_crb(struct kobject *kobj, struct bin_attribute *attr, | 2563 | netxen_sysfs_read_crb(struct file *filp, struct kobject *kobj, |
| 2564 | struct bin_attribute *attr, | ||
| 2564 | char *buf, loff_t offset, size_t size) | 2565 | char *buf, loff_t offset, size_t size) |
| 2565 | { | 2566 | { |
| 2566 | struct device *dev = container_of(kobj, struct device, kobj); | 2567 | struct device *dev = container_of(kobj, struct device, kobj); |
| @@ -2587,7 +2588,8 @@ netxen_sysfs_read_crb(struct kobject *kobj, struct bin_attribute *attr, | |||
| 2587 | } | 2588 | } |
| 2588 | 2589 | ||
| 2589 | static ssize_t | 2590 | static ssize_t |
| 2590 | netxen_sysfs_write_crb(struct kobject *kobj, struct bin_attribute *attr, | 2591 | netxen_sysfs_write_crb(struct file *filp, struct kobject *kobj, |
| 2592 | struct bin_attribute *attr, | ||
| 2591 | char *buf, loff_t offset, size_t size) | 2593 | char *buf, loff_t offset, size_t size) |
| 2592 | { | 2594 | { |
| 2593 | struct device *dev = container_of(kobj, struct device, kobj); | 2595 | struct device *dev = container_of(kobj, struct device, kobj); |
| @@ -2627,7 +2629,8 @@ netxen_sysfs_validate_mem(struct netxen_adapter *adapter, | |||
| 2627 | } | 2629 | } |
| 2628 | 2630 | ||
| 2629 | static ssize_t | 2631 | static ssize_t |
| 2630 | netxen_sysfs_read_mem(struct kobject *kobj, struct bin_attribute *attr, | 2632 | netxen_sysfs_read_mem(struct file *filp, struct kobject *kobj, |
| 2633 | struct bin_attribute *attr, | ||
| 2631 | char *buf, loff_t offset, size_t size) | 2634 | char *buf, loff_t offset, size_t size) |
| 2632 | { | 2635 | { |
| 2633 | struct device *dev = container_of(kobj, struct device, kobj); | 2636 | struct device *dev = container_of(kobj, struct device, kobj); |
| @@ -2647,7 +2650,7 @@ netxen_sysfs_read_mem(struct kobject *kobj, struct bin_attribute *attr, | |||
| 2647 | return size; | 2650 | return size; |
| 2648 | } | 2651 | } |
| 2649 | 2652 | ||
| 2650 | static ssize_t netxen_sysfs_write_mem(struct kobject *kobj, | 2653 | static ssize_t netxen_sysfs_write_mem(struct file *filp, struct kobject *kobj, |
| 2651 | struct bin_attribute *attr, char *buf, | 2654 | struct bin_attribute *attr, char *buf, |
| 2652 | loff_t offset, size_t size) | 2655 | loff_t offset, size_t size) |
| 2653 | { | 2656 | { |
diff --git a/drivers/net/niu.c b/drivers/net/niu.c index 30abb4e436f1..63e8e3893bd6 100644 --- a/drivers/net/niu.c +++ b/drivers/net/niu.c | |||
| @@ -9115,7 +9115,7 @@ static int __devinit niu_n2_irq_init(struct niu *np, u8 *ldg_num_map) | |||
| 9115 | const u32 *int_prop; | 9115 | const u32 *int_prop; |
| 9116 | int i; | 9116 | int i; |
| 9117 | 9117 | ||
| 9118 | int_prop = of_get_property(op->node, "interrupts", NULL); | 9118 | int_prop = of_get_property(op->dev.of_node, "interrupts", NULL); |
| 9119 | if (!int_prop) | 9119 | if (!int_prop) |
| 9120 | return -ENODEV; | 9120 | return -ENODEV; |
| 9121 | 9121 | ||
| @@ -9266,7 +9266,7 @@ static int __devinit niu_get_of_props(struct niu *np) | |||
| 9266 | int prop_len; | 9266 | int prop_len; |
| 9267 | 9267 | ||
| 9268 | if (np->parent->plat_type == PLAT_TYPE_NIU) | 9268 | if (np->parent->plat_type == PLAT_TYPE_NIU) |
| 9269 | dp = np->op->node; | 9269 | dp = np->op->dev.of_node; |
| 9270 | else | 9270 | else |
| 9271 | dp = pci_device_to_OF_node(np->pdev); | 9271 | dp = pci_device_to_OF_node(np->pdev); |
| 9272 | 9272 | ||
| @@ -10083,10 +10083,10 @@ static int __devinit niu_of_probe(struct of_device *op, | |||
| 10083 | 10083 | ||
| 10084 | niu_driver_version(); | 10084 | niu_driver_version(); |
| 10085 | 10085 | ||
| 10086 | reg = of_get_property(op->node, "reg", NULL); | 10086 | reg = of_get_property(op->dev.of_node, "reg", NULL); |
| 10087 | if (!reg) { | 10087 | if (!reg) { |
| 10088 | dev_err(&op->dev, "%s: No 'reg' property, aborting\n", | 10088 | dev_err(&op->dev, "%s: No 'reg' property, aborting\n", |
| 10089 | op->node->full_name); | 10089 | op->dev.of_node->full_name); |
| 10090 | return -ENODEV; | 10090 | return -ENODEV; |
| 10091 | } | 10091 | } |
| 10092 | 10092 | ||
| @@ -10099,7 +10099,7 @@ static int __devinit niu_of_probe(struct of_device *op, | |||
| 10099 | np = netdev_priv(dev); | 10099 | np = netdev_priv(dev); |
| 10100 | 10100 | ||
| 10101 | memset(&parent_id, 0, sizeof(parent_id)); | 10101 | memset(&parent_id, 0, sizeof(parent_id)); |
| 10102 | parent_id.of = of_get_parent(op->node); | 10102 | parent_id.of = of_get_parent(op->dev.of_node); |
| 10103 | 10103 | ||
| 10104 | np->parent = niu_get_parent(np, &parent_id, | 10104 | np->parent = niu_get_parent(np, &parent_id, |
| 10105 | PLAT_TYPE_NIU); | 10105 | PLAT_TYPE_NIU); |
| @@ -10234,8 +10234,11 @@ static const struct of_device_id niu_match[] = { | |||
| 10234 | MODULE_DEVICE_TABLE(of, niu_match); | 10234 | MODULE_DEVICE_TABLE(of, niu_match); |
| 10235 | 10235 | ||
| 10236 | static struct of_platform_driver niu_of_driver = { | 10236 | static struct of_platform_driver niu_of_driver = { |
| 10237 | .name = "niu", | 10237 | .driver = { |
| 10238 | .match_table = niu_match, | 10238 | .name = "niu", |
| 10239 | .owner = THIS_MODULE, | ||
| 10240 | .of_match_table = niu_match, | ||
| 10241 | }, | ||
| 10239 | .probe = niu_of_probe, | 10242 | .probe = niu_of_probe, |
| 10240 | .remove = __devexit_p(niu_of_remove), | 10243 | .remove = __devexit_p(niu_of_remove), |
| 10241 | }; | 10244 | }; |
diff --git a/drivers/net/phy/mdio-gpio.c b/drivers/net/phy/mdio-gpio.c index 35897134a5dd..fc5fef2a8175 100644 --- a/drivers/net/phy/mdio-gpio.c +++ b/drivers/net/phy/mdio-gpio.c | |||
| @@ -199,12 +199,12 @@ static int __devinit mdio_ofgpio_probe(struct of_device *ofdev, | |||
| 199 | if (!pdata) | 199 | if (!pdata) |
| 200 | return -ENOMEM; | 200 | return -ENOMEM; |
| 201 | 201 | ||
| 202 | ret = of_get_gpio(ofdev->node, 0); | 202 | ret = of_get_gpio(ofdev->dev.of_node, 0); |
| 203 | if (ret < 0) | 203 | if (ret < 0) |
| 204 | goto out_free; | 204 | goto out_free; |
| 205 | pdata->mdc = ret; | 205 | pdata->mdc = ret; |
| 206 | 206 | ||
| 207 | ret = of_get_gpio(ofdev->node, 1); | 207 | ret = of_get_gpio(ofdev->dev.of_node, 1); |
| 208 | if (ret < 0) | 208 | if (ret < 0) |
| 209 | goto out_free; | 209 | goto out_free; |
| 210 | pdata->mdio = ret; | 210 | pdata->mdio = ret; |
| @@ -213,7 +213,7 @@ static int __devinit mdio_ofgpio_probe(struct of_device *ofdev, | |||
| 213 | if (!new_bus) | 213 | if (!new_bus) |
| 214 | goto out_free; | 214 | goto out_free; |
| 215 | 215 | ||
| 216 | ret = of_mdiobus_register(new_bus, ofdev->node); | 216 | ret = of_mdiobus_register(new_bus, ofdev->dev.of_node); |
| 217 | if (ret) | 217 | if (ret) |
| 218 | mdio_gpio_bus_deinit(&ofdev->dev); | 218 | mdio_gpio_bus_deinit(&ofdev->dev); |
| 219 | 219 | ||
| @@ -241,8 +241,11 @@ static struct of_device_id mdio_ofgpio_match[] = { | |||
| 241 | MODULE_DEVICE_TABLE(of, mdio_ofgpio_match); | 241 | MODULE_DEVICE_TABLE(of, mdio_ofgpio_match); |
| 242 | 242 | ||
| 243 | static struct of_platform_driver mdio_ofgpio_driver = { | 243 | static struct of_platform_driver mdio_ofgpio_driver = { |
| 244 | .name = "mdio-gpio", | 244 | .driver = { |
| 245 | .match_table = mdio_ofgpio_match, | 245 | .name = "mdio-gpio", |
| 246 | .owner = THIS_MODULE, | ||
| 247 | .of_match_table = mdio_ofgpio_match, | ||
| 248 | }, | ||
| 246 | .probe = mdio_ofgpio_probe, | 249 | .probe = mdio_ofgpio_probe, |
| 247 | .remove = __devexit_p(mdio_ofgpio_remove), | 250 | .remove = __devexit_p(mdio_ofgpio_remove), |
| 248 | }; | 251 | }; |
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c index 5441688daba7..c5f8eb102bf7 100644 --- a/drivers/net/ppp_generic.c +++ b/drivers/net/ppp_generic.c | |||
| @@ -2926,5 +2926,5 @@ EXPORT_SYMBOL(ppp_output_wakeup); | |||
| 2926 | EXPORT_SYMBOL(ppp_register_compressor); | 2926 | EXPORT_SYMBOL(ppp_register_compressor); |
| 2927 | EXPORT_SYMBOL(ppp_unregister_compressor); | 2927 | EXPORT_SYMBOL(ppp_unregister_compressor); |
| 2928 | MODULE_LICENSE("GPL"); | 2928 | MODULE_LICENSE("GPL"); |
| 2929 | MODULE_ALIAS_CHARDEV_MAJOR(PPP_MAJOR); | 2929 | MODULE_ALIAS_CHARDEV(PPP_MAJOR, 0); |
| 2930 | MODULE_ALIAS("/dev/ppp"); | 2930 | MODULE_ALIAS("devname:ppp"); |
diff --git a/drivers/net/qlcnic/qlcnic_main.c b/drivers/net/qlcnic/qlcnic_main.c index 1003eb76fda3..23ea9caa5261 100644 --- a/drivers/net/qlcnic/qlcnic_main.c +++ b/drivers/net/qlcnic/qlcnic_main.c | |||
| @@ -2464,7 +2464,8 @@ qlcnic_sysfs_validate_crb(struct qlcnic_adapter *adapter, | |||
| 2464 | } | 2464 | } |
| 2465 | 2465 | ||
| 2466 | static ssize_t | 2466 | static ssize_t |
| 2467 | qlcnic_sysfs_read_crb(struct kobject *kobj, struct bin_attribute *attr, | 2467 | qlcnic_sysfs_read_crb(struct file *filp, struct kobject *kobj, |
| 2468 | struct bin_attribute *attr, | ||
| 2468 | char *buf, loff_t offset, size_t size) | 2469 | char *buf, loff_t offset, size_t size) |
| 2469 | { | 2470 | { |
| 2470 | struct device *dev = container_of(kobj, struct device, kobj); | 2471 | struct device *dev = container_of(kobj, struct device, kobj); |
| @@ -2488,7 +2489,8 @@ qlcnic_sysfs_read_crb(struct kobject *kobj, struct bin_attribute *attr, | |||
| 2488 | } | 2489 | } |
| 2489 | 2490 | ||
| 2490 | static ssize_t | 2491 | static ssize_t |
| 2491 | qlcnic_sysfs_write_crb(struct kobject *kobj, struct bin_attribute *attr, | 2492 | qlcnic_sysfs_write_crb(struct file *filp, struct kobject *kobj, |
| 2493 | struct bin_attribute *attr, | ||
| 2492 | char *buf, loff_t offset, size_t size) | 2494 | char *buf, loff_t offset, size_t size) |
| 2493 | { | 2495 | { |
| 2494 | struct device *dev = container_of(kobj, struct device, kobj); | 2496 | struct device *dev = container_of(kobj, struct device, kobj); |
| @@ -2525,7 +2527,8 @@ qlcnic_sysfs_validate_mem(struct qlcnic_adapter *adapter, | |||
| 2525 | } | 2527 | } |
| 2526 | 2528 | ||
| 2527 | static ssize_t | 2529 | static ssize_t |
| 2528 | qlcnic_sysfs_read_mem(struct kobject *kobj, struct bin_attribute *attr, | 2530 | qlcnic_sysfs_read_mem(struct file *filp, struct kobject *kobj, |
| 2531 | struct bin_attribute *attr, | ||
| 2529 | char *buf, loff_t offset, size_t size) | 2532 | char *buf, loff_t offset, size_t size) |
| 2530 | { | 2533 | { |
| 2531 | struct device *dev = container_of(kobj, struct device, kobj); | 2534 | struct device *dev = container_of(kobj, struct device, kobj); |
| @@ -2546,7 +2549,8 @@ qlcnic_sysfs_read_mem(struct kobject *kobj, struct bin_attribute *attr, | |||
| 2546 | } | 2549 | } |
| 2547 | 2550 | ||
| 2548 | static ssize_t | 2551 | static ssize_t |
| 2549 | qlcnic_sysfs_write_mem(struct kobject *kobj, struct bin_attribute *attr, | 2552 | qlcnic_sysfs_write_mem(struct file *filp, struct kobject *kobj, |
| 2553 | struct bin_attribute *attr, | ||
| 2550 | char *buf, loff_t offset, size_t size) | 2554 | char *buf, loff_t offset, size_t size) |
| 2551 | { | 2555 | { |
| 2552 | struct device *dev = container_of(kobj, struct device, kobj); | 2556 | struct device *dev = container_of(kobj, struct device, kobj); |
diff --git a/drivers/net/sunbmac.c b/drivers/net/sunbmac.c index 4591fe9bf0b9..367e96f317d4 100644 --- a/drivers/net/sunbmac.c +++ b/drivers/net/sunbmac.c | |||
| @@ -1131,8 +1131,8 @@ static int __devinit bigmac_ether_init(struct of_device *op, | |||
| 1131 | goto fail_and_cleanup; | 1131 | goto fail_and_cleanup; |
| 1132 | 1132 | ||
| 1133 | /* Get supported SBUS burst sizes. */ | 1133 | /* Get supported SBUS burst sizes. */ |
| 1134 | bsizes = of_getintprop_default(qec_op->node, "burst-sizes", 0xff); | 1134 | bsizes = of_getintprop_default(qec_op->dev.of_node, "burst-sizes", 0xff); |
| 1135 | bsizes_more = of_getintprop_default(qec_op->node, "burst-sizes", 0xff); | 1135 | bsizes_more = of_getintprop_default(qec_op->dev.of_node, "burst-sizes", 0xff); |
| 1136 | 1136 | ||
| 1137 | bsizes &= 0xff; | 1137 | bsizes &= 0xff; |
| 1138 | if (bsizes_more != 0xff) | 1138 | if (bsizes_more != 0xff) |
| @@ -1184,7 +1184,7 @@ static int __devinit bigmac_ether_init(struct of_device *op, | |||
| 1184 | } | 1184 | } |
| 1185 | 1185 | ||
| 1186 | /* Get the board revision of this BigMAC. */ | 1186 | /* Get the board revision of this BigMAC. */ |
| 1187 | bp->board_rev = of_getintprop_default(bp->bigmac_op->node, | 1187 | bp->board_rev = of_getintprop_default(bp->bigmac_op->dev.of_node, |
| 1188 | "board-version", 1); | 1188 | "board-version", 1); |
| 1189 | 1189 | ||
| 1190 | /* Init auto-negotiation timer state. */ | 1190 | /* Init auto-negotiation timer state. */ |
| @@ -1290,8 +1290,11 @@ static const struct of_device_id bigmac_sbus_match[] = { | |||
| 1290 | MODULE_DEVICE_TABLE(of, bigmac_sbus_match); | 1290 | MODULE_DEVICE_TABLE(of, bigmac_sbus_match); |
| 1291 | 1291 | ||
| 1292 | static struct of_platform_driver bigmac_sbus_driver = { | 1292 | static struct of_platform_driver bigmac_sbus_driver = { |
| 1293 | .name = "sunbmac", | 1293 | .driver = { |
| 1294 | .match_table = bigmac_sbus_match, | 1294 | .name = "sunbmac", |
| 1295 | .owner = THIS_MODULE, | ||
| 1296 | .of_match_table = bigmac_sbus_match, | ||
| 1297 | }, | ||
| 1295 | .probe = bigmac_sbus_probe, | 1298 | .probe = bigmac_sbus_probe, |
| 1296 | .remove = __devexit_p(bigmac_sbus_remove), | 1299 | .remove = __devexit_p(bigmac_sbus_remove), |
| 1297 | }; | 1300 | }; |
diff --git a/drivers/net/sunhme.c b/drivers/net/sunhme.c index 915c5909c7a8..3d9650b8d38f 100644 --- a/drivers/net/sunhme.c +++ b/drivers/net/sunhme.c | |||
| @@ -2481,7 +2481,7 @@ static void hme_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info | |||
| 2481 | else { | 2481 | else { |
| 2482 | const struct linux_prom_registers *regs; | 2482 | const struct linux_prom_registers *regs; |
| 2483 | struct of_device *op = hp->happy_dev; | 2483 | struct of_device *op = hp->happy_dev; |
| 2484 | regs = of_get_property(op->node, "regs", NULL); | 2484 | regs = of_get_property(op->dev.of_node, "regs", NULL); |
| 2485 | if (regs) | 2485 | if (regs) |
| 2486 | sprintf(info->bus_info, "SBUS:%d", | 2486 | sprintf(info->bus_info, "SBUS:%d", |
| 2487 | regs->which_io); | 2487 | regs->which_io); |
| @@ -2641,14 +2641,14 @@ static const struct net_device_ops hme_netdev_ops = { | |||
| 2641 | #ifdef CONFIG_SBUS | 2641 | #ifdef CONFIG_SBUS |
| 2642 | static int __devinit happy_meal_sbus_probe_one(struct of_device *op, int is_qfe) | 2642 | static int __devinit happy_meal_sbus_probe_one(struct of_device *op, int is_qfe) |
| 2643 | { | 2643 | { |
| 2644 | struct device_node *dp = op->node, *sbus_dp; | 2644 | struct device_node *dp = op->dev.of_node, *sbus_dp; |
| 2645 | struct quattro *qp = NULL; | 2645 | struct quattro *qp = NULL; |
| 2646 | struct happy_meal *hp; | 2646 | struct happy_meal *hp; |
| 2647 | struct net_device *dev; | 2647 | struct net_device *dev; |
| 2648 | int i, qfe_slot = -1; | 2648 | int i, qfe_slot = -1; |
| 2649 | int err = -ENODEV; | 2649 | int err = -ENODEV; |
| 2650 | 2650 | ||
| 2651 | sbus_dp = to_of_device(op->dev.parent)->node; | 2651 | sbus_dp = to_of_device(op->dev.parent)->dev.of_node; |
| 2652 | 2652 | ||
| 2653 | /* We can match PCI devices too, do not accept those here. */ | 2653 | /* We can match PCI devices too, do not accept those here. */ |
| 2654 | if (strcmp(sbus_dp->name, "sbus")) | 2654 | if (strcmp(sbus_dp->name, "sbus")) |
| @@ -3237,7 +3237,7 @@ static void happy_meal_pci_exit(void) | |||
| 3237 | #ifdef CONFIG_SBUS | 3237 | #ifdef CONFIG_SBUS |
| 3238 | static int __devinit hme_sbus_probe(struct of_device *op, const struct of_device_id *match) | 3238 | static int __devinit hme_sbus_probe(struct of_device *op, const struct of_device_id *match) |
| 3239 | { | 3239 | { |
| 3240 | struct device_node *dp = op->node; | 3240 | struct device_node *dp = op->dev.of_node; |
| 3241 | const char *model = of_get_property(dp, "model", NULL); | 3241 | const char *model = of_get_property(dp, "model", NULL); |
| 3242 | int is_qfe = (match->data != NULL); | 3242 | int is_qfe = (match->data != NULL); |
| 3243 | 3243 | ||
| @@ -3291,8 +3291,11 @@ static const struct of_device_id hme_sbus_match[] = { | |||
| 3291 | MODULE_DEVICE_TABLE(of, hme_sbus_match); | 3291 | MODULE_DEVICE_TABLE(of, hme_sbus_match); |
| 3292 | 3292 | ||
| 3293 | static struct of_platform_driver hme_sbus_driver = { | 3293 | static struct of_platform_driver hme_sbus_driver = { |
| 3294 | .name = "hme", | 3294 | .driver = { |
| 3295 | .match_table = hme_sbus_match, | 3295 | .name = "hme", |
| 3296 | .owner = THIS_MODULE, | ||
| 3297 | .of_match_table = hme_sbus_match, | ||
| 3298 | }, | ||
| 3296 | .probe = hme_sbus_probe, | 3299 | .probe = hme_sbus_probe, |
| 3297 | .remove = __devexit_p(hme_sbus_remove), | 3300 | .remove = __devexit_p(hme_sbus_remove), |
| 3298 | }; | 3301 | }; |
diff --git a/drivers/net/sunlance.c b/drivers/net/sunlance.c index 386af7bbe678..7d9c33dd9d1a 100644 --- a/drivers/net/sunlance.c +++ b/drivers/net/sunlance.c | |||
| @@ -1323,7 +1323,7 @@ static int __devinit sparc_lance_probe_one(struct of_device *op, | |||
| 1323 | struct of_device *ledma, | 1323 | struct of_device *ledma, |
| 1324 | struct of_device *lebuffer) | 1324 | struct of_device *lebuffer) |
| 1325 | { | 1325 | { |
| 1326 | struct device_node *dp = op->node; | 1326 | struct device_node *dp = op->dev.of_node; |
| 1327 | static unsigned version_printed; | 1327 | static unsigned version_printed; |
| 1328 | struct lance_private *lp; | 1328 | struct lance_private *lp; |
| 1329 | struct net_device *dev; | 1329 | struct net_device *dev; |
| @@ -1410,7 +1410,7 @@ static int __devinit sparc_lance_probe_one(struct of_device *op, | |||
| 1410 | 1410 | ||
| 1411 | lp->burst_sizes = 0; | 1411 | lp->burst_sizes = 0; |
| 1412 | if (lp->ledma) { | 1412 | if (lp->ledma) { |
| 1413 | struct device_node *ledma_dp = ledma->node; | 1413 | struct device_node *ledma_dp = ledma->dev.of_node; |
| 1414 | struct device_node *sbus_dp; | 1414 | struct device_node *sbus_dp; |
| 1415 | unsigned int sbmask; | 1415 | unsigned int sbmask; |
| 1416 | const char *prop; | 1416 | const char *prop; |
| @@ -1506,7 +1506,7 @@ fail: | |||
| 1506 | static int __devinit sunlance_sbus_probe(struct of_device *op, const struct of_device_id *match) | 1506 | static int __devinit sunlance_sbus_probe(struct of_device *op, const struct of_device_id *match) |
| 1507 | { | 1507 | { |
| 1508 | struct of_device *parent = to_of_device(op->dev.parent); | 1508 | struct of_device *parent = to_of_device(op->dev.parent); |
| 1509 | struct device_node *parent_dp = parent->node; | 1509 | struct device_node *parent_dp = parent->dev.of_node; |
| 1510 | int err; | 1510 | int err; |
| 1511 | 1511 | ||
| 1512 | if (!strcmp(parent_dp->name, "ledma")) { | 1512 | if (!strcmp(parent_dp->name, "ledma")) { |
| @@ -1545,8 +1545,11 @@ static const struct of_device_id sunlance_sbus_match[] = { | |||
| 1545 | MODULE_DEVICE_TABLE(of, sunlance_sbus_match); | 1545 | MODULE_DEVICE_TABLE(of, sunlance_sbus_match); |
| 1546 | 1546 | ||
| 1547 | static struct of_platform_driver sunlance_sbus_driver = { | 1547 | static struct of_platform_driver sunlance_sbus_driver = { |
| 1548 | .name = "sunlance", | 1548 | .driver = { |
| 1549 | .match_table = sunlance_sbus_match, | 1549 | .name = "sunlance", |
| 1550 | .owner = THIS_MODULE, | ||
| 1551 | .of_match_table = sunlance_sbus_match, | ||
| 1552 | }, | ||
| 1550 | .probe = sunlance_sbus_probe, | 1553 | .probe = sunlance_sbus_probe, |
| 1551 | .remove = __devexit_p(sunlance_sbus_remove), | 1554 | .remove = __devexit_p(sunlance_sbus_remove), |
| 1552 | }; | 1555 | }; |
diff --git a/drivers/net/sunqe.c b/drivers/net/sunqe.c index a7542d25c845..72b579c8d812 100644 --- a/drivers/net/sunqe.c +++ b/drivers/net/sunqe.c | |||
| @@ -695,7 +695,7 @@ static void qe_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) | |||
| 695 | strcpy(info->version, "3.0"); | 695 | strcpy(info->version, "3.0"); |
| 696 | 696 | ||
| 697 | op = qep->op; | 697 | op = qep->op; |
| 698 | regs = of_get_property(op->node, "reg", NULL); | 698 | regs = of_get_property(op->dev.of_node, "reg", NULL); |
| 699 | if (regs) | 699 | if (regs) |
| 700 | sprintf(info->bus_info, "SBUS:%d", regs->which_io); | 700 | sprintf(info->bus_info, "SBUS:%d", regs->which_io); |
| 701 | 701 | ||
| @@ -799,7 +799,7 @@ static struct sunqec * __devinit get_qec(struct of_device *child) | |||
| 799 | if (qec_global_reset(qecp->gregs)) | 799 | if (qec_global_reset(qecp->gregs)) |
| 800 | goto fail; | 800 | goto fail; |
| 801 | 801 | ||
| 802 | qecp->qec_bursts = qec_get_burst(op->node); | 802 | qecp->qec_bursts = qec_get_burst(op->dev.of_node); |
| 803 | 803 | ||
| 804 | qec_init_once(qecp, op); | 804 | qec_init_once(qecp, op); |
| 805 | 805 | ||
| @@ -857,7 +857,7 @@ static int __devinit qec_ether_init(struct of_device *op) | |||
| 857 | 857 | ||
| 858 | res = -ENODEV; | 858 | res = -ENODEV; |
| 859 | 859 | ||
| 860 | i = of_getintprop_default(op->node, "channel#", -1); | 860 | i = of_getintprop_default(op->dev.of_node, "channel#", -1); |
| 861 | if (i == -1) | 861 | if (i == -1) |
| 862 | goto fail; | 862 | goto fail; |
| 863 | qe->channel = i; | 863 | qe->channel = i; |
| @@ -977,8 +977,11 @@ static const struct of_device_id qec_sbus_match[] = { | |||
| 977 | MODULE_DEVICE_TABLE(of, qec_sbus_match); | 977 | MODULE_DEVICE_TABLE(of, qec_sbus_match); |
| 978 | 978 | ||
| 979 | static struct of_platform_driver qec_sbus_driver = { | 979 | static struct of_platform_driver qec_sbus_driver = { |
| 980 | .name = "qec", | 980 | .driver = { |
| 981 | .match_table = qec_sbus_match, | 981 | .name = "qec", |
| 982 | .owner = THIS_MODULE, | ||
| 983 | .of_match_table = qec_sbus_match, | ||
| 984 | }, | ||
| 982 | .probe = qec_sbus_probe, | 985 | .probe = qec_sbus_probe, |
| 983 | .remove = __devexit_p(qec_sbus_remove), | 986 | .remove = __devexit_p(qec_sbus_remove), |
| 984 | }; | 987 | }; |
diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 8793c2bf7f15..6ad6fe706312 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c | |||
| @@ -1651,3 +1651,4 @@ MODULE_DESCRIPTION(DRV_DESCRIPTION); | |||
| 1651 | MODULE_AUTHOR(DRV_COPYRIGHT); | 1651 | MODULE_AUTHOR(DRV_COPYRIGHT); |
| 1652 | MODULE_LICENSE("GPL"); | 1652 | MODULE_LICENSE("GPL"); |
| 1653 | MODULE_ALIAS_MISCDEV(TUN_MINOR); | 1653 | MODULE_ALIAS_MISCDEV(TUN_MINOR); |
| 1654 | MODULE_ALIAS("devname:net/tun"); | ||
diff --git a/drivers/net/ucc_geth.c b/drivers/net/ucc_geth.c index 932602db54b3..4a34833b85dd 100644 --- a/drivers/net/ucc_geth.c +++ b/drivers/net/ucc_geth.c | |||
| @@ -3719,7 +3719,7 @@ static const struct net_device_ops ucc_geth_netdev_ops = { | |||
| 3719 | static int ucc_geth_probe(struct of_device* ofdev, const struct of_device_id *match) | 3719 | static int ucc_geth_probe(struct of_device* ofdev, const struct of_device_id *match) |
| 3720 | { | 3720 | { |
| 3721 | struct device *device = &ofdev->dev; | 3721 | struct device *device = &ofdev->dev; |
| 3722 | struct device_node *np = ofdev->node; | 3722 | struct device_node *np = ofdev->dev.of_node; |
| 3723 | struct net_device *dev = NULL; | 3723 | struct net_device *dev = NULL; |
| 3724 | struct ucc_geth_private *ugeth = NULL; | 3724 | struct ucc_geth_private *ugeth = NULL; |
| 3725 | struct ucc_geth_info *ug_info; | 3725 | struct ucc_geth_info *ug_info; |
| @@ -3963,8 +3963,11 @@ static struct of_device_id ucc_geth_match[] = { | |||
| 3963 | MODULE_DEVICE_TABLE(of, ucc_geth_match); | 3963 | MODULE_DEVICE_TABLE(of, ucc_geth_match); |
| 3964 | 3964 | ||
| 3965 | static struct of_platform_driver ucc_geth_driver = { | 3965 | static struct of_platform_driver ucc_geth_driver = { |
| 3966 | .name = DRV_NAME, | 3966 | .driver = { |
| 3967 | .match_table = ucc_geth_match, | 3967 | .name = DRV_NAME, |
| 3968 | .owner = THIS_MODULE, | ||
| 3969 | .of_match_table = ucc_geth_match, | ||
| 3970 | }, | ||
| 3968 | .probe = ucc_geth_probe, | 3971 | .probe = ucc_geth_probe, |
| 3969 | .remove = ucc_geth_remove, | 3972 | .remove = ucc_geth_remove, |
| 3970 | .suspend = ucc_geth_suspend, | 3973 | .suspend = ucc_geth_suspend, |
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index b0a85d038796..78eb3190b9b1 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c | |||
| @@ -122,7 +122,7 @@ static void skb_xmit_done(struct virtqueue *svq) | |||
| 122 | struct virtnet_info *vi = svq->vdev->priv; | 122 | struct virtnet_info *vi = svq->vdev->priv; |
| 123 | 123 | ||
| 124 | /* Suppress further interrupts. */ | 124 | /* Suppress further interrupts. */ |
| 125 | svq->vq_ops->disable_cb(svq); | 125 | virtqueue_disable_cb(svq); |
| 126 | 126 | ||
| 127 | /* We were probably waiting for more output buffers. */ | 127 | /* We were probably waiting for more output buffers. */ |
| 128 | netif_wake_queue(vi->dev); | 128 | netif_wake_queue(vi->dev); |
| @@ -210,7 +210,7 @@ static int receive_mergeable(struct virtnet_info *vi, struct sk_buff *skb) | |||
| 210 | return -EINVAL; | 210 | return -EINVAL; |
| 211 | } | 211 | } |
| 212 | 212 | ||
| 213 | page = vi->rvq->vq_ops->get_buf(vi->rvq, &len); | 213 | page = virtqueue_get_buf(vi->rvq, &len); |
| 214 | if (!page) { | 214 | if (!page) { |
| 215 | pr_debug("%s: rx error: %d buffers missing\n", | 215 | pr_debug("%s: rx error: %d buffers missing\n", |
| 216 | skb->dev->name, hdr->mhdr.num_buffers); | 216 | skb->dev->name, hdr->mhdr.num_buffers); |
| @@ -340,7 +340,7 @@ static int add_recvbuf_small(struct virtnet_info *vi, gfp_t gfp) | |||
| 340 | 340 | ||
| 341 | skb_to_sgvec(skb, vi->rx_sg + 1, 0, skb->len); | 341 | skb_to_sgvec(skb, vi->rx_sg + 1, 0, skb->len); |
| 342 | 342 | ||
| 343 | err = vi->rvq->vq_ops->add_buf(vi->rvq, vi->rx_sg, 0, 2, skb); | 343 | err = virtqueue_add_buf(vi->rvq, vi->rx_sg, 0, 2, skb); |
| 344 | if (err < 0) | 344 | if (err < 0) |
| 345 | dev_kfree_skb(skb); | 345 | dev_kfree_skb(skb); |
| 346 | 346 | ||
| @@ -385,7 +385,7 @@ static int add_recvbuf_big(struct virtnet_info *vi, gfp_t gfp) | |||
| 385 | 385 | ||
| 386 | /* chain first in list head */ | 386 | /* chain first in list head */ |
| 387 | first->private = (unsigned long)list; | 387 | first->private = (unsigned long)list; |
| 388 | err = vi->rvq->vq_ops->add_buf(vi->rvq, vi->rx_sg, 0, MAX_SKB_FRAGS + 2, | 388 | err = virtqueue_add_buf(vi->rvq, vi->rx_sg, 0, MAX_SKB_FRAGS + 2, |
| 389 | first); | 389 | first); |
| 390 | if (err < 0) | 390 | if (err < 0) |
| 391 | give_pages(vi, first); | 391 | give_pages(vi, first); |
| @@ -404,7 +404,7 @@ static int add_recvbuf_mergeable(struct virtnet_info *vi, gfp_t gfp) | |||
| 404 | 404 | ||
| 405 | sg_init_one(vi->rx_sg, page_address(page), PAGE_SIZE); | 405 | sg_init_one(vi->rx_sg, page_address(page), PAGE_SIZE); |
| 406 | 406 | ||
| 407 | err = vi->rvq->vq_ops->add_buf(vi->rvq, vi->rx_sg, 0, 1, page); | 407 | err = virtqueue_add_buf(vi->rvq, vi->rx_sg, 0, 1, page); |
| 408 | if (err < 0) | 408 | if (err < 0) |
| 409 | give_pages(vi, page); | 409 | give_pages(vi, page); |
| 410 | 410 | ||
| @@ -433,7 +433,7 @@ static bool try_fill_recv(struct virtnet_info *vi, gfp_t gfp) | |||
| 433 | } while (err > 0); | 433 | } while (err > 0); |
| 434 | if (unlikely(vi->num > vi->max)) | 434 | if (unlikely(vi->num > vi->max)) |
| 435 | vi->max = vi->num; | 435 | vi->max = vi->num; |
| 436 | vi->rvq->vq_ops->kick(vi->rvq); | 436 | virtqueue_kick(vi->rvq); |
| 437 | return !oom; | 437 | return !oom; |
| 438 | } | 438 | } |
| 439 | 439 | ||
| @@ -442,7 +442,7 @@ static void skb_recv_done(struct virtqueue *rvq) | |||
| 442 | struct virtnet_info *vi = rvq->vdev->priv; | 442 | struct virtnet_info *vi = rvq->vdev->priv; |
| 443 | /* Schedule NAPI, Suppress further interrupts if successful. */ | 443 | /* Schedule NAPI, Suppress further interrupts if successful. */ |
| 444 | if (napi_schedule_prep(&vi->napi)) { | 444 | if (napi_schedule_prep(&vi->napi)) { |
| 445 | rvq->vq_ops->disable_cb(rvq); | 445 | virtqueue_disable_cb(rvq); |
| 446 | __napi_schedule(&vi->napi); | 446 | __napi_schedule(&vi->napi); |
| 447 | } | 447 | } |
| 448 | } | 448 | } |
| @@ -471,7 +471,7 @@ static int virtnet_poll(struct napi_struct *napi, int budget) | |||
| 471 | 471 | ||
| 472 | again: | 472 | again: |
| 473 | while (received < budget && | 473 | while (received < budget && |
| 474 | (buf = vi->rvq->vq_ops->get_buf(vi->rvq, &len)) != NULL) { | 474 | (buf = virtqueue_get_buf(vi->rvq, &len)) != NULL) { |
| 475 | receive_buf(vi->dev, buf, len); | 475 | receive_buf(vi->dev, buf, len); |
| 476 | --vi->num; | 476 | --vi->num; |
| 477 | received++; | 477 | received++; |
| @@ -485,9 +485,9 @@ again: | |||
| 485 | /* Out of packets? */ | 485 | /* Out of packets? */ |
| 486 | if (received < budget) { | 486 | if (received < budget) { |
| 487 | napi_complete(napi); | 487 | napi_complete(napi); |
| 488 | if (unlikely(!vi->rvq->vq_ops->enable_cb(vi->rvq)) && | 488 | if (unlikely(!virtqueue_enable_cb(vi->rvq)) && |
| 489 | napi_schedule_prep(napi)) { | 489 | napi_schedule_prep(napi)) { |
| 490 | vi->rvq->vq_ops->disable_cb(vi->rvq); | 490 | virtqueue_disable_cb(vi->rvq); |
| 491 | __napi_schedule(napi); | 491 | __napi_schedule(napi); |
| 492 | goto again; | 492 | goto again; |
| 493 | } | 493 | } |
| @@ -501,7 +501,7 @@ static unsigned int free_old_xmit_skbs(struct virtnet_info *vi) | |||
| 501 | struct sk_buff *skb; | 501 | struct sk_buff *skb; |
| 502 | unsigned int len, tot_sgs = 0; | 502 | unsigned int len, tot_sgs = 0; |
| 503 | 503 | ||
| 504 | while ((skb = vi->svq->vq_ops->get_buf(vi->svq, &len)) != NULL) { | 504 | while ((skb = virtqueue_get_buf(vi->svq, &len)) != NULL) { |
| 505 | pr_debug("Sent skb %p\n", skb); | 505 | pr_debug("Sent skb %p\n", skb); |
| 506 | vi->dev->stats.tx_bytes += skb->len; | 506 | vi->dev->stats.tx_bytes += skb->len; |
| 507 | vi->dev->stats.tx_packets++; | 507 | vi->dev->stats.tx_packets++; |
| @@ -554,7 +554,7 @@ static int xmit_skb(struct virtnet_info *vi, struct sk_buff *skb) | |||
| 554 | sg_set_buf(vi->tx_sg, &hdr->hdr, sizeof hdr->hdr); | 554 | sg_set_buf(vi->tx_sg, &hdr->hdr, sizeof hdr->hdr); |
| 555 | 555 | ||
| 556 | hdr->num_sg = skb_to_sgvec(skb, vi->tx_sg + 1, 0, skb->len) + 1; | 556 | hdr->num_sg = skb_to_sgvec(skb, vi->tx_sg + 1, 0, skb->len) + 1; |
| 557 | return vi->svq->vq_ops->add_buf(vi->svq, vi->tx_sg, hdr->num_sg, | 557 | return virtqueue_add_buf(vi->svq, vi->tx_sg, hdr->num_sg, |
| 558 | 0, skb); | 558 | 0, skb); |
| 559 | } | 559 | } |
| 560 | 560 | ||
| @@ -574,14 +574,14 @@ again: | |||
| 574 | if (unlikely(capacity < 0)) { | 574 | if (unlikely(capacity < 0)) { |
| 575 | netif_stop_queue(dev); | 575 | netif_stop_queue(dev); |
| 576 | dev_warn(&dev->dev, "Unexpected full queue\n"); | 576 | dev_warn(&dev->dev, "Unexpected full queue\n"); |
| 577 | if (unlikely(!vi->svq->vq_ops->enable_cb(vi->svq))) { | 577 | if (unlikely(!virtqueue_enable_cb(vi->svq))) { |
| 578 | vi->svq->vq_ops->disable_cb(vi->svq); | 578 | virtqueue_disable_cb(vi->svq); |
| 579 | netif_start_queue(dev); | 579 | netif_start_queue(dev); |
| 580 | goto again; | 580 | goto again; |
| 581 | } | 581 | } |
| 582 | return NETDEV_TX_BUSY; | 582 | return NETDEV_TX_BUSY; |
| 583 | } | 583 | } |
| 584 | vi->svq->vq_ops->kick(vi->svq); | 584 | virtqueue_kick(vi->svq); |
| 585 | 585 | ||
| 586 | /* Don't wait up for transmitted skbs to be freed. */ | 586 | /* Don't wait up for transmitted skbs to be freed. */ |
| 587 | skb_orphan(skb); | 587 | skb_orphan(skb); |
| @@ -591,12 +591,12 @@ again: | |||
| 591 | * before it gets out of hand. Naturally, this wastes entries. */ | 591 | * before it gets out of hand. Naturally, this wastes entries. */ |
| 592 | if (capacity < 2+MAX_SKB_FRAGS) { | 592 | if (capacity < 2+MAX_SKB_FRAGS) { |
| 593 | netif_stop_queue(dev); | 593 | netif_stop_queue(dev); |
| 594 | if (unlikely(!vi->svq->vq_ops->enable_cb(vi->svq))) { | 594 | if (unlikely(!virtqueue_enable_cb(vi->svq))) { |
| 595 | /* More just got used, free them then recheck. */ | 595 | /* More just got used, free them then recheck. */ |
| 596 | capacity += free_old_xmit_skbs(vi); | 596 | capacity += free_old_xmit_skbs(vi); |
| 597 | if (capacity >= 2+MAX_SKB_FRAGS) { | 597 | if (capacity >= 2+MAX_SKB_FRAGS) { |
| 598 | netif_start_queue(dev); | 598 | netif_start_queue(dev); |
| 599 | vi->svq->vq_ops->disable_cb(vi->svq); | 599 | virtqueue_disable_cb(vi->svq); |
| 600 | } | 600 | } |
| 601 | } | 601 | } |
| 602 | } | 602 | } |
| @@ -641,7 +641,7 @@ static int virtnet_open(struct net_device *dev) | |||
| 641 | * now. virtnet_poll wants re-enable the queue, so we disable here. | 641 | * now. virtnet_poll wants re-enable the queue, so we disable here. |
| 642 | * We synchronize against interrupts via NAPI_STATE_SCHED */ | 642 | * We synchronize against interrupts via NAPI_STATE_SCHED */ |
| 643 | if (napi_schedule_prep(&vi->napi)) { | 643 | if (napi_schedule_prep(&vi->napi)) { |
| 644 | vi->rvq->vq_ops->disable_cb(vi->rvq); | 644 | virtqueue_disable_cb(vi->rvq); |
| 645 | __napi_schedule(&vi->napi); | 645 | __napi_schedule(&vi->napi); |
| 646 | } | 646 | } |
| 647 | return 0; | 647 | return 0; |
| @@ -678,15 +678,15 @@ static bool virtnet_send_command(struct virtnet_info *vi, u8 class, u8 cmd, | |||
| 678 | sg_set_buf(&sg[i + 1], sg_virt(s), s->length); | 678 | sg_set_buf(&sg[i + 1], sg_virt(s), s->length); |
| 679 | sg_set_buf(&sg[out + in - 1], &status, sizeof(status)); | 679 | sg_set_buf(&sg[out + in - 1], &status, sizeof(status)); |
| 680 | 680 | ||
| 681 | BUG_ON(vi->cvq->vq_ops->add_buf(vi->cvq, sg, out, in, vi) < 0); | 681 | BUG_ON(virtqueue_add_buf(vi->cvq, sg, out, in, vi) < 0); |
| 682 | 682 | ||
| 683 | vi->cvq->vq_ops->kick(vi->cvq); | 683 | virtqueue_kick(vi->cvq); |
| 684 | 684 | ||
| 685 | /* | 685 | /* |
| 686 | * Spin for a response, the kick causes an ioport write, trapping | 686 | * Spin for a response, the kick causes an ioport write, trapping |
| 687 | * into the hypervisor, so the request should be handled immediately. | 687 | * into the hypervisor, so the request should be handled immediately. |
| 688 | */ | 688 | */ |
| 689 | while (!vi->cvq->vq_ops->get_buf(vi->cvq, &tmp)) | 689 | while (!virtqueue_get_buf(vi->cvq, &tmp)) |
| 690 | cpu_relax(); | 690 | cpu_relax(); |
| 691 | 691 | ||
| 692 | return status == VIRTIO_NET_OK; | 692 | return status == VIRTIO_NET_OK; |
| @@ -1003,13 +1003,13 @@ static void free_unused_bufs(struct virtnet_info *vi) | |||
| 1003 | { | 1003 | { |
| 1004 | void *buf; | 1004 | void *buf; |
| 1005 | while (1) { | 1005 | while (1) { |
| 1006 | buf = vi->svq->vq_ops->detach_unused_buf(vi->svq); | 1006 | buf = virtqueue_detach_unused_buf(vi->svq); |
| 1007 | if (!buf) | 1007 | if (!buf) |
| 1008 | break; | 1008 | break; |
| 1009 | dev_kfree_skb(buf); | 1009 | dev_kfree_skb(buf); |
| 1010 | } | 1010 | } |
| 1011 | while (1) { | 1011 | while (1) { |
| 1012 | buf = vi->rvq->vq_ops->detach_unused_buf(vi->rvq); | 1012 | buf = virtqueue_detach_unused_buf(vi->rvq); |
| 1013 | if (!buf) | 1013 | if (!buf) |
| 1014 | break; | 1014 | break; |
| 1015 | if (vi->mergeable_rx_bufs || vi->big_packets) | 1015 | if (vi->mergeable_rx_bufs || vi->big_packets) |
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c index a441aad922c2..3b7ab20a5c54 100644 --- a/drivers/net/wireless/airo.c +++ b/drivers/net/wireless/airo.c | |||
| @@ -5162,13 +5162,6 @@ static void proc_SSID_on_close(struct inode *inode, struct file *file) | |||
| 5162 | enable_MAC(ai, 1); | 5162 | enable_MAC(ai, 1); |
| 5163 | } | 5163 | } |
| 5164 | 5164 | ||
| 5165 | static inline u8 hexVal(char c) { | ||
| 5166 | if (c>='0' && c<='9') return c -= '0'; | ||
| 5167 | if (c>='a' && c<='f') return c -= 'a'-10; | ||
| 5168 | if (c>='A' && c<='F') return c -= 'A'-10; | ||
| 5169 | return 0; | ||
| 5170 | } | ||
| 5171 | |||
| 5172 | static void proc_APList_on_close( struct inode *inode, struct file *file ) { | 5165 | static void proc_APList_on_close( struct inode *inode, struct file *file ) { |
| 5173 | struct proc_data *data = (struct proc_data *)file->private_data; | 5166 | struct proc_data *data = (struct proc_data *)file->private_data; |
| 5174 | struct proc_dir_entry *dp = PDE(inode); | 5167 | struct proc_dir_entry *dp = PDE(inode); |
| @@ -5188,11 +5181,11 @@ static void proc_APList_on_close( struct inode *inode, struct file *file ) { | |||
| 5188 | switch(j%3) { | 5181 | switch(j%3) { |
| 5189 | case 0: | 5182 | case 0: |
| 5190 | APList_rid.ap[i][j/3]= | 5183 | APList_rid.ap[i][j/3]= |
| 5191 | hexVal(data->wbuffer[j+i*6*3])<<4; | 5184 | hex_to_bin(data->wbuffer[j+i*6*3])<<4; |
| 5192 | break; | 5185 | break; |
| 5193 | case 1: | 5186 | case 1: |
| 5194 | APList_rid.ap[i][j/3]|= | 5187 | APList_rid.ap[i][j/3]|= |
| 5195 | hexVal(data->wbuffer[j+i*6*3]); | 5188 | hex_to_bin(data->wbuffer[j+i*6*3]); |
| 5196 | break; | 5189 | break; |
| 5197 | } | 5190 | } |
| 5198 | } | 5191 | } |
| @@ -5340,10 +5333,10 @@ static void proc_wepkey_on_close( struct inode *inode, struct file *file ) { | |||
| 5340 | for( i = 0; i < 16*3 && data->wbuffer[i+j]; i++ ) { | 5333 | for( i = 0; i < 16*3 && data->wbuffer[i+j]; i++ ) { |
| 5341 | switch(i%3) { | 5334 | switch(i%3) { |
| 5342 | case 0: | 5335 | case 0: |
| 5343 | key[i/3] = hexVal(data->wbuffer[i+j])<<4; | 5336 | key[i/3] = hex_to_bin(data->wbuffer[i+j])<<4; |
| 5344 | break; | 5337 | break; |
| 5345 | case 1: | 5338 | case 1: |
| 5346 | key[i/3] |= hexVal(data->wbuffer[i+j]); | 5339 | key[i/3] |= hex_to_bin(data->wbuffer[i+j]); |
| 5347 | break; | 5340 | break; |
| 5348 | } | 5341 | } |
| 5349 | } | 5342 | } |
diff --git a/drivers/net/xilinx_emaclite.c b/drivers/net/xilinx_emaclite.c index a7db68d37ee9..d04c5b262050 100644 --- a/drivers/net/xilinx_emaclite.c +++ b/drivers/net/xilinx_emaclite.c | |||
| @@ -1088,7 +1088,7 @@ static void xemaclite_remove_ndev(struct net_device *ndev) | |||
| 1088 | */ | 1088 | */ |
| 1089 | static bool get_bool(struct of_device *ofdev, const char *s) | 1089 | static bool get_bool(struct of_device *ofdev, const char *s) |
| 1090 | { | 1090 | { |
| 1091 | u32 *p = (u32 *)of_get_property(ofdev->node, s, NULL); | 1091 | u32 *p = (u32 *)of_get_property(ofdev->dev.of_node, s, NULL); |
| 1092 | 1092 | ||
| 1093 | if (p) { | 1093 | if (p) { |
| 1094 | return (bool)*p; | 1094 | return (bool)*p; |
| @@ -1130,14 +1130,14 @@ static int __devinit xemaclite_of_probe(struct of_device *ofdev, | |||
| 1130 | dev_info(dev, "Device Tree Probing\n"); | 1130 | dev_info(dev, "Device Tree Probing\n"); |
| 1131 | 1131 | ||
| 1132 | /* Get iospace for the device */ | 1132 | /* Get iospace for the device */ |
| 1133 | rc = of_address_to_resource(ofdev->node, 0, &r_mem); | 1133 | rc = of_address_to_resource(ofdev->dev.of_node, 0, &r_mem); |
| 1134 | if (rc) { | 1134 | if (rc) { |
| 1135 | dev_err(dev, "invalid address\n"); | 1135 | dev_err(dev, "invalid address\n"); |
| 1136 | return rc; | 1136 | return rc; |
| 1137 | } | 1137 | } |
| 1138 | 1138 | ||
| 1139 | /* Get IRQ for the device */ | 1139 | /* Get IRQ for the device */ |
| 1140 | rc = of_irq_to_resource(ofdev->node, 0, &r_irq); | 1140 | rc = of_irq_to_resource(ofdev->dev.of_node, 0, &r_irq); |
| 1141 | if (rc == NO_IRQ) { | 1141 | if (rc == NO_IRQ) { |
| 1142 | dev_err(dev, "no IRQ found\n"); | 1142 | dev_err(dev, "no IRQ found\n"); |
| 1143 | return rc; | 1143 | return rc; |
| @@ -1182,7 +1182,7 @@ static int __devinit xemaclite_of_probe(struct of_device *ofdev, | |||
| 1182 | lp->next_rx_buf_to_use = 0x0; | 1182 | lp->next_rx_buf_to_use = 0x0; |
| 1183 | lp->tx_ping_pong = get_bool(ofdev, "xlnx,tx-ping-pong"); | 1183 | lp->tx_ping_pong = get_bool(ofdev, "xlnx,tx-ping-pong"); |
| 1184 | lp->rx_ping_pong = get_bool(ofdev, "xlnx,rx-ping-pong"); | 1184 | lp->rx_ping_pong = get_bool(ofdev, "xlnx,rx-ping-pong"); |
| 1185 | mac_address = of_get_mac_address(ofdev->node); | 1185 | mac_address = of_get_mac_address(ofdev->dev.of_node); |
| 1186 | 1186 | ||
| 1187 | if (mac_address) | 1187 | if (mac_address) |
| 1188 | /* Set the MAC address. */ | 1188 | /* Set the MAC address. */ |
| @@ -1197,7 +1197,7 @@ static int __devinit xemaclite_of_probe(struct of_device *ofdev, | |||
| 1197 | /* Set the MAC address in the EmacLite device */ | 1197 | /* Set the MAC address in the EmacLite device */ |
| 1198 | xemaclite_update_address(lp, ndev->dev_addr); | 1198 | xemaclite_update_address(lp, ndev->dev_addr); |
| 1199 | 1199 | ||
| 1200 | lp->phy_node = of_parse_phandle(ofdev->node, "phy-handle", 0); | 1200 | lp->phy_node = of_parse_phandle(ofdev->dev.of_node, "phy-handle", 0); |
| 1201 | rc = xemaclite_mdio_setup(lp, &ofdev->dev); | 1201 | rc = xemaclite_mdio_setup(lp, &ofdev->dev); |
| 1202 | if (rc) | 1202 | if (rc) |
| 1203 | dev_warn(&ofdev->dev, "error registering MDIO bus\n"); | 1203 | dev_warn(&ofdev->dev, "error registering MDIO bus\n"); |
| @@ -1291,8 +1291,11 @@ static struct of_device_id xemaclite_of_match[] __devinitdata = { | |||
| 1291 | MODULE_DEVICE_TABLE(of, xemaclite_of_match); | 1291 | MODULE_DEVICE_TABLE(of, xemaclite_of_match); |
| 1292 | 1292 | ||
| 1293 | static struct of_platform_driver xemaclite_of_driver = { | 1293 | static struct of_platform_driver xemaclite_of_driver = { |
| 1294 | .name = DRIVER_NAME, | 1294 | .driver = { |
| 1295 | .match_table = xemaclite_of_match, | 1295 | .name = DRIVER_NAME, |
| 1296 | .owner = THIS_MODULE, | ||
| 1297 | .of_match_table = xemaclite_of_match, | ||
| 1298 | }, | ||
| 1296 | .probe = xemaclite_of_probe, | 1299 | .probe = xemaclite_of_probe, |
| 1297 | .remove = __devexit_p(xemaclite_of_remove), | 1300 | .remove = __devexit_p(xemaclite_of_remove), |
| 1298 | }; | 1301 | }; |
