Merge tag 'staging-6.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging

Pull staging driver updates from Greg KH:
"Here is the big set of staging driver cleanups and updates for
6.15-rc1.

As expected, with the introduction of the gpib drivers, loads of
cleanups and fixes showed up, with the huge majority of changes being
for that chunk of drivers. This is good and shows that the community
can fix up things in public when asked to. Also included in here are:

- small sm750fb cleanups

- tiny rtl8723bs cleanups

- more vchiq_arm cleanups and changes, hopefully this will get out of
staging soon

All of these have been in linux-next for almost 2 weeks now with no
reported issues"

* tag 'staging-6.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (76 commits)
staging: rtl8723bs: fixed a unnecessary parentheses coding style issue
staging: vchiq_arm: Improve initial VCHIQ connect
staging: vchiq_arm: Create keep-alive thread during probe
staging: vchiq_arm: Stop kthreads if vchiq cdev register fails
staging: vchiq_arm: Fix possible NPR of keep-alive thread
staging: vchiq_arm: Register debugfs after cdev
staging: vchiq_arm: Don't use %pK through printk
staging: rtl8723bs: select CONFIG_CRYPTO_LIB_AES
staging: rtl8723bs: Remove some unused functions, macros, and structs
staging: gpib: change return type of t1_delay function to report errors
staging: gpib: remove commented-out lines
staging: gpib: fix kernel-doc section for usb_gpib_line_status() function
staging: gpib: fix kernel-doc section for function usb_gpib_interface_clear()
staging: gpib: fix kernel-doc section for write_loop() function
staging: gpib: Removing typedef for gpib_board
staging: gpib: struct typing for gpib_gboard_t
staging: gpib: tnt4882: struct gpib_board
staging: gpib: tms9914: struct gpib_board
staging: gpib: pc2: struct gpib_board
staging: gpib: ni_usb_gpib: struct gpib_board
...

+3235 -4434
+1
drivers/pnp/isapnp/core.c
··· 843 843 EXPORT_SYMBOL(isapnp_present); 844 844 EXPORT_SYMBOL(isapnp_cfg_begin); 845 845 EXPORT_SYMBOL(isapnp_cfg_end); 846 + EXPORT_SYMBOL(isapnp_read_byte); 846 847 EXPORT_SYMBOL(isapnp_write_byte); 847 848 848 849 static int isapnp_get_resources(struct pnp_dev *dev)
-5
drivers/staging/gpib/Kconfig
··· 50 50 tristate "CEC PCI board" 51 51 depends on PCI 52 52 depends on HAS_IOPORT 53 - depends on !X86_PAE 54 53 select GPIB_COMMON 55 54 select GPIB_NEC7210 56 55 help ··· 63 64 tristate "NI PCI/ISA compatible boards" 64 65 depends on ISA_BUS || PCI || PCMCIA 65 66 depends on HAS_IOPORT 66 - depends on !X86_PAE 67 67 depends on PCMCIA || !PCMCIA 68 68 depends on HAS_IOPORT_MAP 69 69 select GPIB_COMMON ··· 88 90 tristate "Measurement Computing compatible boards" 89 91 depends on HAS_IOPORT 90 92 depends on ISA_BUS || PCI || PCMCIA 91 - depends on !X86_PAE 92 93 depends on PCMCIA || !PCMCIA 93 94 select GPIB_COMMON 94 95 select GPIB_NEC7210 ··· 166 169 tristate "HP82341x" 167 170 select GPIB_COMMON 168 171 select GPIB_TMS9914 169 - depends on BROKEN 170 172 depends on ISA_BUS || EISA 171 173 help 172 174 GPIB driver for HP82341 A/B/C/D boards ··· 178 182 depends on PCI || ISA_BUS || PCMCIA 179 183 depends on PCMCIA || !PCMCIA 180 184 depends on HAS_IOPORT 181 - depends on !X86_PAE 182 185 select GPIB_COMMON 183 186 select GPIB_NEC7210 184 187 help
+104 -156
drivers/staging/gpib/agilent_82350b/agilent_82350b.c
··· 4 4 * copyright : (C) 2002, 2004 by Frank Mori Hess * 5 5 ***************************************************************************/ 6 6 7 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 8 + #define dev_fmt pr_fmt 9 + #define DRV_NAME KBUILD_MODNAME 10 + 7 11 #include "agilent_82350b.h" 8 12 #include <linux/delay.h> 9 13 #include <linux/ioport.h> ··· 24 20 MODULE_LICENSE("GPL"); 25 21 MODULE_DESCRIPTION("GPIB driver for Agilent 82350b"); 26 22 27 - int agilent_82350b_accel_read(gpib_board_t *board, uint8_t *buffer, size_t length, int *end, 28 - size_t *bytes_read) 23 + static int read_transfer_counter(struct agilent_82350b_priv *a_priv); 24 + static unsigned short read_and_clear_event_status(struct gpib_board *board); 25 + static void set_transfer_counter(struct agilent_82350b_priv *a_priv, int count); 26 + static int agilent_82350b_write(struct gpib_board *board, uint8_t *buffer, 27 + size_t length, int send_eoi, size_t *bytes_written); 28 + 29 + static int agilent_82350b_accel_read(struct gpib_board *board, uint8_t *buffer, 30 + size_t length, int *end, size_t *bytes_read) 29 31 30 32 { 31 33 struct agilent_82350b_priv *a_priv = board->private_data; ··· 58 48 59 49 retval = tms9914_read(board, tms_priv, buffer, 1, end, &num_bytes); 60 50 *bytes_read += num_bytes; 61 - if (retval < 0) 62 - dev_err(board->gpib_dev, "%s: tms9914_read failed retval=%i\n", 63 - driver_name, retval); 64 51 if (retval < 0 || *end) 65 52 return retval; 66 53 ++buffer; ··· 73 66 int j; 74 67 int count; 75 68 76 - if (num_fifo_bytes - i < agilent_82350b_fifo_size) 77 - block_size = num_fifo_bytes - i; 78 - else 79 - block_size = agilent_82350b_fifo_size; 69 + block_size = min(num_fifo_bytes - i, agilent_82350b_fifo_size); 80 70 set_transfer_counter(a_priv, block_size); 81 71 writeb(ENABLE_TI_TO_SRAM | DIRECTION_GPIB_TO_HOST, 82 72 a_priv->gpib_base + SRAM_ACCESS_CONTROL_REG); ··· 90 86 test_bit(DEV_CLEAR_BN, &tms_priv->state) || 91 87 test_bit(TIMO_NUM, &board->status)); 92 88 if (retval) { 93 - dev_dbg(board->gpib_dev, "%s: read wait interrupted\n", driver_name); 94 89 retval = -ERESTARTSYS; 95 90 break; 96 91 } ··· 103 100 *end = 1; 104 101 } 105 102 if (test_bit(TIMO_NUM, &board->status)) { 106 - dev_err(board->gpib_dev, "%s: read timed out\n", driver_name); 107 103 retval = -ETIMEDOUT; 108 104 break; 109 105 } 110 106 if (test_bit(DEV_CLEAR_BN, &tms_priv->state)) { 111 - dev_err(board->gpib_dev, "%s: device clear interrupted read\n", 112 - driver_name); 113 107 retval = -EINTR; 114 108 break; 115 109 } ··· 130 130 return 0; 131 131 } 132 132 133 - static int translate_wait_return_value(gpib_board_t *board, int retval) 133 + static int translate_wait_return_value(struct gpib_board *board, int retval) 134 134 135 135 { 136 136 struct agilent_82350b_priv *a_priv = board->private_data; 137 137 struct tms9914_priv *tms_priv = &a_priv->tms9914_priv; 138 138 139 - if (retval) { 140 - dev_err(board->gpib_dev, "%s: write wait interrupted\n", driver_name); 139 + if (retval) 141 140 return -ERESTARTSYS; 142 - } 143 - if (test_bit(TIMO_NUM, &board->status)) { 144 - dev_err(board->gpib_dev, "%s: write timed out\n", driver_name); 141 + if (test_bit(TIMO_NUM, &board->status)) 145 142 return -ETIMEDOUT; 146 - } 147 - if (test_bit(DEV_CLEAR_BN, &tms_priv->state)) { 148 - dev_err(board->gpib_dev, "%s: device clear interrupted write\n", driver_name); 143 + if (test_bit(DEV_CLEAR_BN, &tms_priv->state)) 149 144 return -EINTR; 150 - } 151 145 return 0; 152 146 } 153 147 154 - int agilent_82350b_accel_write(gpib_board_t *board, uint8_t *buffer, size_t length, int send_eoi, 155 - size_t *bytes_written) 156 - 148 + static int agilent_82350b_accel_write(struct gpib_board *board, uint8_t *buffer, 149 + size_t length, int send_eoi, 150 + size_t *bytes_written) 157 151 { 158 152 struct agilent_82350b_priv *a_priv = board->private_data; 159 153 struct tms9914_priv *tms_priv = &a_priv->tms9914_priv; ··· 168 174 169 175 event_status = read_and_clear_event_status(board); 170 176 171 - //pr_info("ag_ac_wr: event status 0x%x tms state 0x%lx\n", event_status, tms_priv->state); 172 - 173 177 #ifdef EXPERIMENTAL 174 - pr_info("ag_ac_wr: wait for previous BO to complete if any\n"); 178 + // wait for previous BO to complete if any 175 179 retval = wait_event_interruptible(board->wait, 176 180 test_bit(DEV_CLEAR_BN, &tms_priv->state) || 177 181 test_bit(WRITE_READY_BN, &tms_priv->state) || ··· 180 188 return retval; 181 189 #endif 182 190 183 - //pr_info("ag_ac_wr: sending first byte\n"); 184 191 retval = agilent_82350b_write(board, buffer, 1, 0, &num_bytes); 185 192 *bytes_written += num_bytes; 186 193 if (retval < 0) 187 194 return retval; 188 195 189 - //pr_info("ag_ac_wr: %ld bytes eoi %d tms state 0x%lx\n",length, send_eoi, tms_priv->state); 190 - 191 196 write_byte(tms_priv, tms_priv->imr0_bits & ~HR_BOIE, IMR0); 192 197 for (i = 1; i < fifotransferlength;) { 193 198 clear_bit(WRITE_READY_BN, &tms_priv->state); 194 199 195 - if (fifotransferlength - i < agilent_82350b_fifo_size) 196 - block_size = fifotransferlength - i; 197 - else 198 - block_size = agilent_82350b_fifo_size; 200 + block_size = min(fifotransferlength - i, agilent_82350b_fifo_size); 199 201 set_transfer_counter(a_priv, block_size); 200 202 for (j = 0; j < block_size; ++j, ++i) { 201 203 // load data into board's sram ··· 197 211 } 198 212 writeb(ENABLE_TI_TO_SRAM, a_priv->gpib_base + SRAM_ACCESS_CONTROL_REG); 199 213 200 - //pr_info("ag_ac_wr: send block: %d bytes tms 0x%lx\n", block_size, 201 - // tms_priv->state); 202 - 203 - if (agilent_82350b_fifo_is_halted(a_priv)) { 214 + if (agilent_82350b_fifo_is_halted(a_priv)) 204 215 writeb(RESTART_STREAM_BIT, a_priv->gpib_base + STREAM_STATUS_REG); 205 - // pr_info("ag_ac_wr: needed restart\n"); 206 - } 207 216 208 217 retval = wait_event_interruptible(board->wait, 209 218 ((event_status = ··· 208 227 test_bit(TIMO_NUM, &board->status)); 209 228 writeb(0, a_priv->gpib_base + SRAM_ACCESS_CONTROL_REG); 210 229 num_bytes = block_size - read_transfer_counter(a_priv); 211 - //pr_info("ag_ac_wr: sent %ld bytes tms 0x%lx\n", num_bytes, tms_priv->state); 212 230 213 231 *bytes_written += num_bytes; 214 232 retval = translate_wait_return_value(board, retval); ··· 219 239 return retval; 220 240 221 241 if (send_eoi) { 222 - //pr_info("ag_ac_wr: sending last byte with eoi byte no: %d\n", 223 - // fifotransferlength+1); 224 - 225 242 retval = agilent_82350b_write(board, buffer + fifotransferlength, 1, send_eoi, 226 243 &num_bytes); 227 244 *bytes_written += num_bytes; ··· 228 251 return 0; 229 252 } 230 253 231 - unsigned short read_and_clear_event_status(gpib_board_t *board) 232 - 254 + static unsigned short read_and_clear_event_status(struct gpib_board *board) 233 255 { 234 256 struct agilent_82350b_priv *a_priv = board->private_data; 235 257 unsigned long flags; ··· 241 265 return status; 242 266 } 243 267 244 - irqreturn_t agilent_82350b_interrupt(int irq, void *arg) 268 + static irqreturn_t agilent_82350b_interrupt(int irq, void *arg) 245 269 246 270 { 247 271 int tms9914_status1 = 0, tms9914_status2 = 0; 248 272 int event_status; 249 - gpib_board_t *board = arg; 273 + struct gpib_board *board = arg; 250 274 struct agilent_82350b_priv *a_priv = board->private_data; 251 275 unsigned long flags; 252 276 irqreturn_t retval = IRQ_NONE; ··· 262 286 tms9914_interrupt_have_status(board, &a_priv->tms9914_priv, tms9914_status1, 263 287 tms9914_status2); 264 288 } 265 - //pr_info("event_status=0x%x s1 %x s2 %x\n", event_status,tms9914_status1,tms9914_status2); 266 289 //write-clear status bits 267 290 if (event_status & (BUFFER_END_STATUS_BIT | TERM_COUNT_STATUS_BIT)) { 268 291 writeb(event_status & (BUFFER_END_STATUS_BIT | TERM_COUNT_STATUS_BIT), ··· 273 298 return retval; 274 299 } 275 300 276 - void agilent_82350b_detach(gpib_board_t *board); 301 + static void agilent_82350b_detach(struct gpib_board *board); 277 302 278 - const char *driver_name = "agilent_82350b"; 279 - 280 - int read_transfer_counter(struct agilent_82350b_priv *a_priv) 281 - 303 + static int read_transfer_counter(struct agilent_82350b_priv *a_priv) 282 304 { 283 305 int lo, mid, value; 284 306 ··· 286 314 return value; 287 315 } 288 316 289 - void set_transfer_counter(struct agilent_82350b_priv *a_priv, int count) 290 - 317 + static void set_transfer_counter(struct agilent_82350b_priv *a_priv, int count) 291 318 { 292 319 int complement = -count; 293 320 ··· 297 326 } 298 327 299 328 // wrappers for interface functions 300 - int agilent_82350b_read(gpib_board_t *board, uint8_t *buffer, size_t length, int *end, 301 - size_t *bytes_read) 302 - 329 + static int agilent_82350b_read(struct gpib_board *board, uint8_t *buffer, 330 + size_t length, int *end, size_t *bytes_read) 303 331 { 304 332 struct agilent_82350b_priv *priv = board->private_data; 305 333 306 334 return tms9914_read(board, &priv->tms9914_priv, buffer, length, end, bytes_read); 307 335 } 308 336 309 - int agilent_82350b_write(gpib_board_t *board, uint8_t *buffer, size_t length, int send_eoi, 310 - size_t *bytes_written) 337 + static int agilent_82350b_write(struct gpib_board *board, uint8_t *buffer, 338 + size_t length, int send_eoi, size_t *bytes_written) 311 339 312 340 { 313 341 struct agilent_82350b_priv *priv = board->private_data; ··· 314 344 return tms9914_write(board, &priv->tms9914_priv, buffer, length, send_eoi, bytes_written); 315 345 } 316 346 317 - int agilent_82350b_command(gpib_board_t *board, uint8_t *buffer, size_t length, 318 - size_t *bytes_written) 347 + static int agilent_82350b_command(struct gpib_board *board, uint8_t *buffer, 348 + size_t length, size_t *bytes_written) 319 349 320 350 { 321 351 struct agilent_82350b_priv *priv = board->private_data; ··· 323 353 return tms9914_command(board, &priv->tms9914_priv, buffer, length, bytes_written); 324 354 } 325 355 326 - int agilent_82350b_take_control(gpib_board_t *board, int synchronous) 356 + static int agilent_82350b_take_control(struct gpib_board *board, int synchronous) 327 357 328 358 { 329 359 struct agilent_82350b_priv *priv = board->private_data; ··· 331 361 return tms9914_take_control_workaround(board, &priv->tms9914_priv, synchronous); 332 362 } 333 363 334 - int agilent_82350b_go_to_standby(gpib_board_t *board) 364 + static int agilent_82350b_go_to_standby(struct gpib_board *board) 335 365 336 366 { 337 367 struct agilent_82350b_priv *priv = board->private_data; ··· 339 369 return tms9914_go_to_standby(board, &priv->tms9914_priv); 340 370 } 341 371 342 - void agilent_82350b_request_system_control(gpib_board_t *board, int request_control) 372 + static void agilent_82350b_request_system_control(struct gpib_board *board, 373 + int request_control) 343 374 344 375 { 345 376 struct agilent_82350b_priv *a_priv = board->private_data; ··· 358 387 tms9914_request_system_control(board, &a_priv->tms9914_priv, request_control); 359 388 } 360 389 361 - void agilent_82350b_interface_clear(gpib_board_t *board, int assert) 390 + static void agilent_82350b_interface_clear(struct gpib_board *board, int assert) 362 391 363 392 { 364 393 struct agilent_82350b_priv *priv = board->private_data; ··· 366 395 tms9914_interface_clear(board, &priv->tms9914_priv, assert); 367 396 } 368 397 369 - void agilent_82350b_remote_enable(gpib_board_t *board, int enable) 370 - 398 + static void agilent_82350b_remote_enable(struct gpib_board *board, int enable) 371 399 { 372 400 struct agilent_82350b_priv *priv = board->private_data; 373 401 374 402 tms9914_remote_enable(board, &priv->tms9914_priv, enable); 375 403 } 376 404 377 - int agilent_82350b_enable_eos(gpib_board_t *board, uint8_t eos_byte, int compare_8_bits) 378 - 405 + static int agilent_82350b_enable_eos(struct gpib_board *board, uint8_t eos_byte, 406 + int compare_8_bits) 379 407 { 380 408 struct agilent_82350b_priv *priv = board->private_data; 381 409 382 410 return tms9914_enable_eos(board, &priv->tms9914_priv, eos_byte, compare_8_bits); 383 411 } 384 412 385 - void agilent_82350b_disable_eos(gpib_board_t *board) 386 - 413 + static void agilent_82350b_disable_eos(struct gpib_board *board) 387 414 { 388 415 struct agilent_82350b_priv *priv = board->private_data; 389 416 390 417 tms9914_disable_eos(board, &priv->tms9914_priv); 391 418 } 392 419 393 - unsigned int agilent_82350b_update_status(gpib_board_t *board, unsigned int clear_mask) 394 - 420 + static unsigned int agilent_82350b_update_status(struct gpib_board *board, 421 + unsigned int clear_mask) 395 422 { 396 423 struct agilent_82350b_priv *priv = board->private_data; 397 424 398 425 return tms9914_update_status(board, &priv->tms9914_priv, clear_mask); 399 426 } 400 427 401 - int agilent_82350b_primary_address(gpib_board_t *board, unsigned int address) 402 - 428 + static int agilent_82350b_primary_address(struct gpib_board *board, 429 + unsigned int address) 403 430 { 404 431 struct agilent_82350b_priv *priv = board->private_data; 405 432 406 433 return tms9914_primary_address(board, &priv->tms9914_priv, address); 407 434 } 408 435 409 - int agilent_82350b_secondary_address(gpib_board_t *board, unsigned int address, int enable) 410 - 436 + static int agilent_82350b_secondary_address(struct gpib_board *board, 437 + unsigned int address, int enable) 411 438 { 412 439 struct agilent_82350b_priv *priv = board->private_data; 413 440 414 441 return tms9914_secondary_address(board, &priv->tms9914_priv, address, enable); 415 442 } 416 443 417 - int agilent_82350b_parallel_poll(gpib_board_t *board, uint8_t *result) 418 - 444 + static int agilent_82350b_parallel_poll(struct gpib_board *board, uint8_t *result) 419 445 { 420 446 struct agilent_82350b_priv *priv = board->private_data; 421 447 422 448 return tms9914_parallel_poll(board, &priv->tms9914_priv, result); 423 449 } 424 450 425 - void agilent_82350b_parallel_poll_configure(gpib_board_t *board, uint8_t config) 426 - 451 + static void agilent_82350b_parallel_poll_configure(struct gpib_board *board, 452 + uint8_t config) 427 453 { 428 454 struct agilent_82350b_priv *priv = board->private_data; 429 455 430 456 tms9914_parallel_poll_configure(board, &priv->tms9914_priv, config); 431 457 } 432 458 433 - void agilent_82350b_parallel_poll_response(gpib_board_t *board, int ist) 434 - 459 + static void agilent_82350b_parallel_poll_response(struct gpib_board *board, int ist) 435 460 { 436 461 struct agilent_82350b_priv *priv = board->private_data; 437 462 438 463 tms9914_parallel_poll_response(board, &priv->tms9914_priv, ist); 439 464 } 440 465 441 - void agilent_82350b_serial_poll_response(gpib_board_t *board, uint8_t status) 442 - 466 + static void agilent_82350b_serial_poll_response(struct gpib_board *board, uint8_t status) 443 467 { 444 468 struct agilent_82350b_priv *priv = board->private_data; 445 469 446 470 tms9914_serial_poll_response(board, &priv->tms9914_priv, status); 447 471 } 448 472 449 - uint8_t agilent_82350b_serial_poll_status(gpib_board_t *board) 450 - 473 + static uint8_t agilent_82350b_serial_poll_status(struct gpib_board *board) 451 474 { 452 475 struct agilent_82350b_priv *priv = board->private_data; 453 476 454 477 return tms9914_serial_poll_status(board, &priv->tms9914_priv); 455 478 } 456 479 457 - int agilent_82350b_line_status(const gpib_board_t *board) 458 - 480 + static int agilent_82350b_line_status(const struct gpib_board *board) 459 481 { 460 482 struct agilent_82350b_priv *priv = board->private_data; 461 483 462 484 return tms9914_line_status(board, &priv->tms9914_priv); 463 485 } 464 486 465 - unsigned int agilent_82350b_t1_delay(gpib_board_t *board, unsigned int nanosec) 466 - 487 + static int agilent_82350b_t1_delay(struct gpib_board *board, unsigned int nanosec) 467 488 { 468 489 struct agilent_82350b_priv *a_priv = board->private_data; 469 490 static const int nanosec_per_clock = 30; ··· 470 507 return value * nanosec_per_clock; 471 508 } 472 509 473 - void agilent_82350b_return_to_local(gpib_board_t *board) 474 - 510 + static void agilent_82350b_return_to_local(struct gpib_board *board) 475 511 { 476 512 struct agilent_82350b_priv *priv = board->private_data; 477 513 478 514 tms9914_return_to_local(board, &priv->tms9914_priv); 479 515 } 480 516 481 - int agilent_82350b_allocate_private(gpib_board_t *board) 482 - 517 + static int agilent_82350b_allocate_private(struct gpib_board *board) 483 518 { 484 519 board->private_data = kzalloc(sizeof(struct agilent_82350b_priv), GFP_KERNEL); 485 520 if (!board->private_data) ··· 485 524 return 0; 486 525 } 487 526 488 - void agilent_82350b_free_private(gpib_board_t *board) 489 - 527 + static void agilent_82350b_free_private(struct gpib_board *board) 490 528 { 491 529 kfree(board->private_data); 492 530 board->private_data = NULL; 493 531 } 494 532 495 - static int init_82350a_hardware(gpib_board_t *board, const gpib_board_config_t *config) 496 - 533 + static int init_82350a_hardware(struct gpib_board *board, 534 + const gpib_board_config_t *config) 497 535 { 498 536 struct agilent_82350b_priv *a_priv = board->private_data; 499 537 static const unsigned int firmware_length = 5302; ··· 517 557 return 0; 518 558 // need to programme borg 519 559 if (!config->init_data || config->init_data_length != firmware_length) { 520 - dev_err(board->gpib_dev, "%s: the 82350A board requires firmware after powering on.\n", 521 - driver_name); 560 + dev_err(board->gpib_dev, "the 82350A board requires firmware after powering on.\n"); 522 561 return -EIO; 523 562 } 524 - dev_info(board->gpib_dev, "%s: Loading firmware...\n", driver_name); 563 + dev_dbg(board->gpib_dev, "Loading firmware...\n"); 525 564 526 565 // tickle the borg 527 566 writel(plx_cntrl_static_bits | PLX9050_USER3_DATA_BIT, ··· 539 580 usleep_range(10, 20); 540 581 } 541 582 if (j == timeout) { 542 - dev_err(board->gpib_dev, "%s: timed out loading firmware.\n", driver_name); 583 + dev_err(board->gpib_dev, "timed out loading firmware.\n"); 543 584 return -ETIMEDOUT; 544 585 } 545 586 writeb(firmware_data[i], a_priv->gpib_base + CONFIG_DATA_REG); ··· 550 591 usleep_range(10, 20); 551 592 } 552 593 if (j == timeout) { 553 - dev_err(board->gpib_dev, "%s: timed out waiting for firmware load to complete.\n", 554 - driver_name); 594 + dev_err(board->gpib_dev, "timed out waiting for firmware load to complete.\n"); 555 595 return -ETIMEDOUT; 556 596 } 557 - dev_info(board->gpib_dev, "%s: ...done.\n", driver_name); 597 + dev_dbg(board->gpib_dev, " ...done.\n"); 558 598 return 0; 559 599 } 560 600 561 - static int test_sram(gpib_board_t *board) 601 + static int test_sram(struct gpib_board *board) 562 602 563 603 { 564 604 struct agilent_82350b_priv *a_priv = board->private_data; ··· 575 617 unsigned int read_value = readb(a_priv->sram_base + i); 576 618 577 619 if ((i & byte_mask) != read_value) { 578 - dev_err(board->gpib_dev, "%s: SRAM test failed at %d wanted %d got %d\n", 579 - driver_name, i, (i & byte_mask), read_value); 620 + dev_err(board->gpib_dev, "SRAM test failed at %d wanted %d got %d\n", 621 + i, (i & byte_mask), read_value); 580 622 return -EIO; 581 623 } 582 624 if (need_resched()) 583 625 schedule(); 584 626 } 585 - dev_info(board->gpib_dev, "%s: SRAM test passed 0x%x bytes checked\n", 586 - driver_name, sram_length); 627 + dev_dbg(board->gpib_dev, "SRAM test passed 0x%x bytes checked\n", sram_length); 587 628 return 0; 588 629 } 589 630 590 - static int agilent_82350b_generic_attach(gpib_board_t *board, const gpib_board_config_t *config, 631 + static int agilent_82350b_generic_attach(struct gpib_board *board, 632 + const gpib_board_config_t *config, 591 633 int use_fifos) 592 634 593 635 { ··· 611 653 PCI_DEVICE_ID_82350B, NULL); 612 654 if (a_priv->pci_device) { 613 655 a_priv->model = MODEL_82350B; 614 - dev_info(board->gpib_dev, "%s: Agilent 82350B board found\n", driver_name); 656 + dev_dbg(board->gpib_dev, "Agilent 82350B board found\n"); 615 657 616 658 } else { 617 659 a_priv->pci_device = gpib_pci_get_device(config, PCI_VENDOR_ID_AGILENT, 618 660 PCI_DEVICE_ID_82351A, NULL); 619 661 if (a_priv->pci_device) { 620 662 a_priv->model = MODEL_82351A; 621 - dev_info(board->gpib_dev, "%s: Agilent 82351B board found\n", driver_name); 663 + dev_dbg(board->gpib_dev, "Agilent 82351B board found\n"); 622 664 623 665 } else { 624 666 a_priv->pci_device = gpib_pci_get_subsys(config, PCI_VENDOR_ID_PLX, ··· 628 670 a_priv->pci_device); 629 671 if (a_priv->pci_device) { 630 672 a_priv->model = MODEL_82350A; 631 - dev_info(board->gpib_dev, "%s: HP/Agilent 82350A board found\n", 632 - driver_name); 673 + dev_dbg(board->gpib_dev, "HP/Agilent 82350A board found\n"); 633 674 } else { 634 - dev_err(board->gpib_dev, "%s: no 82350/82351 board found\n", 635 - driver_name); 675 + dev_err(board->gpib_dev, "no 82350/82351 board found\n"); 636 676 return -ENODEV; 637 677 } 638 678 } 639 679 } 640 680 if (pci_enable_device(a_priv->pci_device)) { 641 - dev_err(board->gpib_dev, "%s: error enabling pci device\n", driver_name); 681 + dev_err(board->gpib_dev, "error enabling pci device\n"); 642 682 return -EIO; 643 683 } 644 - if (pci_request_regions(a_priv->pci_device, driver_name)) 645 - return -EIO; 684 + if (pci_request_regions(a_priv->pci_device, DRV_NAME)) 685 + return -ENOMEM; 646 686 switch (a_priv->model) { 647 687 case MODEL_82350A: 648 688 a_priv->plx_base = ioremap(pci_resource_start(a_priv->pci_device, PLX_MEM_REGION), 649 689 pci_resource_len(a_priv->pci_device, PLX_MEM_REGION)); 650 - dev_dbg(board->gpib_dev, "%s: plx base address remapped to 0x%p\n", 651 - driver_name, a_priv->plx_base); 690 + dev_dbg(board->gpib_dev, "plx base address remapped to 0x%p\n", a_priv->plx_base); 652 691 a_priv->gpib_base = ioremap(pci_resource_start(a_priv->pci_device, 653 692 GPIB_82350A_REGION), 654 693 pci_resource_len(a_priv->pci_device, 655 694 GPIB_82350A_REGION)); 656 - dev_dbg(board->gpib_dev, "%s: gpib base address remapped to 0x%p\n", 657 - driver_name, a_priv->gpib_base); 695 + dev_dbg(board->gpib_dev, "chip base address remapped to 0x%p\n", a_priv->gpib_base); 658 696 tms_priv->mmiobase = a_priv->gpib_base + TMS9914_BASE_REG; 659 697 a_priv->sram_base = ioremap(pci_resource_start(a_priv->pci_device, 660 698 SRAM_82350A_REGION), 661 699 pci_resource_len(a_priv->pci_device, 662 700 SRAM_82350A_REGION)); 663 - dev_dbg(board->gpib_dev, "%s: sram base address remapped to 0x%p\n", 664 - driver_name, a_priv->sram_base); 701 + dev_dbg(board->gpib_dev, "sram base address remapped to 0x%p\n", a_priv->sram_base); 665 702 a_priv->borg_base = ioremap(pci_resource_start(a_priv->pci_device, 666 703 BORG_82350A_REGION), 667 704 pci_resource_len(a_priv->pci_device, 668 705 BORG_82350A_REGION)); 669 - dev_dbg(board->gpib_dev, "%s: borg base address remapped to 0x%p\n", 670 - driver_name, a_priv->borg_base); 706 + dev_dbg(board->gpib_dev, "borg base address remapped to 0x%p\n", a_priv->borg_base); 671 707 672 708 retval = init_82350a_hardware(board, config); 673 709 if (retval < 0) ··· 671 719 case MODEL_82351A: 672 720 a_priv->gpib_base = ioremap(pci_resource_start(a_priv->pci_device, GPIB_REGION), 673 721 pci_resource_len(a_priv->pci_device, GPIB_REGION)); 674 - dev_dbg(board->gpib_dev, "%s: gpib base address remapped to 0x%p\n", 675 - driver_name, a_priv->gpib_base); 722 + dev_dbg(board->gpib_dev, "chip base address remapped to 0x%p\n", a_priv->gpib_base); 676 723 tms_priv->mmiobase = a_priv->gpib_base + TMS9914_BASE_REG; 677 724 a_priv->sram_base = ioremap(pci_resource_start(a_priv->pci_device, SRAM_REGION), 678 725 pci_resource_len(a_priv->pci_device, SRAM_REGION)); 679 - dev_dbg(board->gpib_dev, "%s: sram base address remapped to 0x%p\n", 680 - driver_name, a_priv->sram_base); 726 + dev_dbg(board->gpib_dev, "sram base address remapped to 0x%p\n", a_priv->sram_base); 681 727 a_priv->misc_base = ioremap(pci_resource_start(a_priv->pci_device, MISC_REGION), 682 728 pci_resource_len(a_priv->pci_device, MISC_REGION)); 683 - dev_dbg(board->gpib_dev, "%s: misc base address remapped to 0x%p\n", 684 - driver_name, a_priv->misc_base); 729 + dev_dbg(board->gpib_dev, "misc base address remapped to 0x%p\n", a_priv->misc_base); 685 730 break; 686 731 default: 687 - pr_err("%s: invalid board\n", driver_name); 688 - return -1; 732 + dev_err(board->gpib_dev, "invalid board\n"); 733 + return -ENODEV; 689 734 } 690 735 691 736 retval = test_sram(board); ··· 690 741 return retval; 691 742 692 743 if (request_irq(a_priv->pci_device->irq, agilent_82350b_interrupt, 693 - IRQF_SHARED, driver_name, board)) { 694 - pr_err("%s: can't request IRQ %d\n", driver_name, a_priv->pci_device->irq); 744 + IRQF_SHARED, DRV_NAME, board)) { 745 + dev_err(board->gpib_dev, "failed to obtain irq %d\n", a_priv->pci_device->irq); 695 746 return -EIO; 696 747 } 697 748 a_priv->irq = a_priv->pci_device->irq; 698 - dev_dbg(board->gpib_dev, "%s: IRQ %d\n", driver_name, a_priv->irq); 749 + dev_dbg(board->gpib_dev, " IRQ %d\n", a_priv->irq); 699 750 700 751 writeb(0, a_priv->gpib_base + SRAM_ACCESS_CONTROL_REG); 701 752 a_priv->card_mode_bits = ENABLE_PCI_IRQ_BIT; ··· 729 780 return 0; 730 781 } 731 782 732 - int agilent_82350b_unaccel_attach(gpib_board_t *board, const gpib_board_config_t *config) 733 - 783 + static int agilent_82350b_unaccel_attach(struct gpib_board *board, 784 + const gpib_board_config_t *config) 734 785 { 735 786 return agilent_82350b_generic_attach(board, config, 0); 736 787 } 737 788 738 - int agilent_82350b_accel_attach(gpib_board_t *board, const gpib_board_config_t *config) 739 - 789 + static int agilent_82350b_accel_attach(struct gpib_board *board, 790 + const gpib_board_config_t *config) 740 791 { 741 792 return agilent_82350b_generic_attach(board, config, 1); 742 793 } 743 794 744 - void agilent_82350b_detach(gpib_board_t *board) 745 - 795 + static void agilent_82350b_detach(struct gpib_board *board) 746 796 { 747 797 struct agilent_82350b_priv *a_priv = board->private_data; 748 798 struct tms9914_priv *tms_priv; ··· 796 848 .primary_address = agilent_82350b_primary_address, 797 849 .secondary_address = agilent_82350b_secondary_address, 798 850 .serial_poll_response = agilent_82350b_serial_poll_response, 851 + .serial_poll_status = agilent_82350b_serial_poll_status, 799 852 .t1_delay = agilent_82350b_t1_delay, 800 853 .return_to_local = agilent_82350b_return_to_local, 801 854 }; ··· 824 875 .primary_address = agilent_82350b_primary_address, 825 876 .secondary_address = agilent_82350b_secondary_address, 826 877 .serial_poll_response = agilent_82350b_serial_poll_response, 878 + .serial_poll_status = agilent_82350b_serial_poll_status, 827 879 .t1_delay = agilent_82350b_t1_delay, 828 880 .return_to_local = agilent_82350b_return_to_local, 829 881 }; ··· 845 895 MODULE_DEVICE_TABLE(pci, agilent_82350b_pci_table); 846 896 847 897 static struct pci_driver agilent_82350b_pci_driver = { 848 - .name = "agilent_82350b", 898 + .name = DRV_NAME, 849 899 .id_table = agilent_82350b_pci_table, 850 900 .probe = &agilent_82350b_pci_probe 851 901 }; 852 902 853 903 static int __init agilent_82350b_init_module(void) 854 - 855 904 { 856 905 int result; 857 906 858 907 result = pci_register_driver(&agilent_82350b_pci_driver); 859 908 if (result) { 860 - pr_err("agilent_82350b: pci_register_driver failed: error = %d\n", result); 909 + pr_err("pci_register_driver failed: error = %d\n", result); 861 910 return result; 862 911 } 863 912 864 913 result = gpib_register_driver(&agilent_82350b_unaccel_interface, THIS_MODULE); 865 914 if (result) { 866 - pr_err("agilent_82350b: gpib_register_driver failed: error = %d\n", result); 915 + pr_err("gpib_register_driver failed: error = %d\n", result); 867 916 goto err_unaccel; 868 917 } 869 918 870 919 result = gpib_register_driver(&agilent_82350b_interface, THIS_MODULE); 871 920 if (result) { 872 - pr_err("agilent_82350b: gpib_register_driver failed: error = %d\n", result); 921 + pr_err("gpib_register_driver failed: error = %d\n", result); 873 922 goto err_interface; 874 923 } 875 924 ··· 883 934 } 884 935 885 936 static void __exit agilent_82350b_exit_module(void) 886 - 887 937 { 888 938 gpib_unregister_driver(&agilent_82350b_interface); 889 939 gpib_unregister_driver(&agilent_82350b_unaccel_interface);
-50
drivers/staging/gpib/agilent_82350b/agilent_82350b.h
··· 57 57 bool using_fifos; 58 58 }; 59 59 60 - // driver name 61 - extern const char *driver_name; 62 - 63 - // init functions 64 - 65 - int agilent_82350b_unaccel_attach(gpib_board_t *board, const gpib_board_config_t *config); 66 - int agilent_82350b_accel_attach(gpib_board_t *board, const gpib_board_config_t *config); 67 - 68 - // interface functions 69 - int agilent_82350b_accel_read(gpib_board_t *board, uint8_t *buffer, size_t length, int *end, 70 - size_t *bytes_read); 71 - int agilent_82350b_accel_write(gpib_board_t *board, uint8_t *buffer, size_t length, int send_eoi, 72 - size_t *bytes_written); 73 - int agilent_82350b_read(gpib_board_t *board, uint8_t *buffer, size_t length, int *end, 74 - size_t *bytes_read); 75 - int agilent_82350b_write(gpib_board_t *board, uint8_t *buffer, size_t length, int send_eoi, 76 - size_t *bytes_written); 77 - int agilent_82350b_command(gpib_board_t *board, uint8_t *buffer, size_t length, 78 - size_t *bytes_written); 79 - int agilent_82350b_take_control(gpib_board_t *board, int synchronous); 80 - int agilent_82350b_go_to_standby(gpib_board_t *board); 81 - void agilent_82350b_request_system_control(gpib_board_t *board, int request_control); 82 - void agilent_82350b_interface_clear(gpib_board_t *board, int assert); 83 - void agilent_82350b_remote_enable(gpib_board_t *board, int enable); 84 - int agilent_82350b_enable_eos(gpib_board_t *board, uint8_t eos_byte, int 85 - compare_8_bits); 86 - void agilent_82350b_disable_eos(gpib_board_t *board); 87 - unsigned int agilent_82350b_update_status(gpib_board_t *board, unsigned int clear_mask); 88 - int agilent_82350b_primary_address(gpib_board_t *board, unsigned int address); 89 - int agilent_82350b_secondary_address(gpib_board_t *board, unsigned int address, int 90 - enable); 91 - int agilent_82350b_parallel_poll(gpib_board_t *board, uint8_t *result); 92 - void agilent_82350b_parallel_poll_configure(gpib_board_t *board, uint8_t config); 93 - void agilent_82350b_parallel_poll_response(gpib_board_t *board, int ist); 94 - void agilent_82350b_serial_poll_response(gpib_board_t *board, uint8_t status); 95 - void agilent_82350b_return_to_local(gpib_board_t *board); 96 - uint8_t agilent_82350b_serial_poll_status(gpib_board_t *board); 97 - int agilent_82350b_line_status(const gpib_board_t *board); 98 - unsigned int agilent_82350b_t1_delay(gpib_board_t *board, unsigned int nanosec); 99 - 100 - // interrupt service routines 101 - irqreturn_t agilent_82350b_interrupt(int irq, void *arg); 102 - 103 - // utility functions 104 - int agilent_82350b_allocate_private(gpib_board_t *board); 105 - void agilent_82350b_free_private(gpib_board_t *board); 106 - unsigned short read_and_clear_event_status(gpib_board_t *board); 107 - int read_transfer_counter(struct agilent_82350b_priv *a_priv); 108 - void set_transfer_counter(struct agilent_82350b_priv *a_priv, int count); 109 - 110 60 //registers 111 61 enum agilent_82350b_gpib_registers 112 62
+253 -274
drivers/staging/gpib/agilent_82357a/agilent_82357a.c
··· 7 7 8 8 #define _GNU_SOURCE 9 9 10 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 11 + #define dev_fmt pr_fmt 12 + #define DRV_NAME KBUILD_MODNAME 13 + 10 14 #include <linux/kernel.h> 11 15 #include <linux/module.h> 12 16 #include <linux/slab.h> ··· 25 21 static struct usb_interface *agilent_82357a_driver_interfaces[MAX_NUM_82357A_INTERFACES]; 26 22 static DEFINE_MUTEX(agilent_82357a_hotplug_lock); // protect board insertion and removal 27 23 28 - static unsigned int agilent_82357a_update_status(gpib_board_t *board, unsigned int clear_mask); 24 + static unsigned int agilent_82357a_update_status(struct gpib_board *board, 25 + unsigned int clear_mask); 29 26 30 - static int agilent_82357a_take_control_internal(gpib_board_t *board, int synchronous); 27 + static int agilent_82357a_take_control_internal(struct gpib_board *board, int synchronous); 31 28 32 29 static void agilent_82357a_bulk_complete(struct urb *urb) 33 30 { ··· 84 79 85 80 retval = usb_submit_urb(a_priv->bulk_urb, GFP_KERNEL); 86 81 if (retval) { 87 - dev_err(&usb_dev->dev, "%s: failed to submit bulk out urb, retval=%i\n", 88 - __func__, retval); 82 + dev_err(&usb_dev->dev, "failed to submit bulk out urb, retval=%i\n", retval); 89 83 mutex_unlock(&a_priv->bulk_alloc_lock); 90 84 goto cleanup; 91 85 } 92 86 mutex_unlock(&a_priv->bulk_alloc_lock); 93 87 if (down_interruptible(&context->complete)) { 94 - dev_err(&usb_dev->dev, "%s: interrupted\n", __func__); 95 88 retval = -ERESTARTSYS; 96 89 goto cleanup; 97 90 } ··· 152 149 153 150 retval = usb_submit_urb(a_priv->bulk_urb, GFP_KERNEL); 154 151 if (retval) { 155 - dev_err(&usb_dev->dev, "%s: failed to submit bulk out urb, retval=%i\n", 156 - __func__, retval); 152 + dev_err(&usb_dev->dev, "failed to submit bulk in urb, retval=%i\n", retval); 157 153 mutex_unlock(&a_priv->bulk_alloc_lock); 158 154 goto cleanup; 159 155 } 160 156 mutex_unlock(&a_priv->bulk_alloc_lock); 161 157 if (down_interruptible(&context->complete)) { 162 - dev_err(&usb_dev->dev, "%s: interrupted\n", __func__); 163 158 retval = -ERESTARTSYS; 164 159 goto cleanup; 165 160 } ··· 206 205 207 206 static void agilent_82357a_dump_raw_block(const u8 *raw_data, int length) 208 207 { 209 - pr_info("hex block dump\n"); 210 208 print_hex_dump(KERN_INFO, "", DUMP_PREFIX_NONE, 8, 1, raw_data, length, true); 211 209 } 212 210 ··· 225 225 static const int max_writes = 31; 226 226 227 227 if (num_writes > max_writes) { 228 - dev_err(&usb_dev->dev, "%s: bug! num_writes=%i too large\n", __func__, num_writes); 228 + dev_err(&usb_dev->dev, "bug! num_writes=%i too large\n", num_writes); 229 229 return -EIO; 230 230 } 231 231 out_data_length = num_writes * bytes_per_write + header_length; ··· 239 239 out_data[i++] = writes[j].address; 240 240 out_data[i++] = writes[j].value; 241 241 } 242 - if (i > out_data_length) 243 - dev_err(&usb_dev->dev, "%s: bug! buffer overrun\n", __func__); 242 + 244 243 retval = mutex_lock_interruptible(&a_priv->bulk_transfer_lock); 245 244 if (retval) { 246 245 kfree(out_data); ··· 248 249 retval = agilent_82357a_send_bulk_msg(a_priv, out_data, i, &bytes_written, 1000); 249 250 kfree(out_data); 250 251 if (retval) { 251 - dev_err(&usb_dev->dev, "%s: agilent_82357a_send_bulk_msg returned %i, bytes_written=%i, i=%i\n", 252 - __func__, retval, bytes_written, i); 252 + dev_err(&usb_dev->dev, "send_bulk_msg returned %i, bytes_written=%i, i=%i\n", 253 + retval, bytes_written, i); 253 254 mutex_unlock(&a_priv->bulk_transfer_lock); 254 255 return retval; 255 256 } ··· 264 265 mutex_unlock(&a_priv->bulk_transfer_lock); 265 266 266 267 if (retval) { 267 - dev_err(&usb_dev->dev, "%s: agilent_82357a_receive_bulk_msg returned %i, bytes_read=%i\n", 268 - __func__, retval, bytes_read); 268 + dev_err(&usb_dev->dev, "receive_bulk_msg returned %i, bytes_read=%i\n", 269 + retval, bytes_read); 269 270 agilent_82357a_dump_raw_block(in_data, bytes_read); 270 271 kfree(in_data); 271 272 return -EIO; 272 273 } 273 274 if (in_data[0] != (0xff & ~DATA_PIPE_CMD_WR_REGS)) { 274 - dev_err(&usb_dev->dev, "%s: error, bulk command=0x%x != ~DATA_PIPE_CMD_WR_REGS\n", 275 - __func__, in_data[0]); 275 + dev_err(&usb_dev->dev, "bulk command=0x%x != ~DATA_PIPE_CMD_WR_REGS\n", in_data[0]); 276 276 return -EIO; 277 277 } 278 278 if (in_data[1]) { 279 - dev_err(&usb_dev->dev, "%s: nonzero error code 0x%x in DATA_PIPE_CMD_WR_REGS response\n", 280 - __func__, in_data[1]); 279 + dev_err(&usb_dev->dev, "nonzero error code 0x%x in DATA_PIPE_CMD_WR_REGS response\n", 280 + in_data[1]); 281 281 return -EIO; 282 282 } 283 283 kfree(in_data); ··· 297 299 static const int header_length = 2; 298 300 static const int max_reads = 62; 299 301 300 - if (num_reads > max_reads) 301 - dev_err(&usb_dev->dev, "%s: bug! num_reads=%i too large\n", __func__, num_reads); 302 - 302 + if (num_reads > max_reads) { 303 + dev_err(&usb_dev->dev, "bug! num_reads=%i too large\n", num_reads); 304 + return -EIO; 305 + } 303 306 out_data_length = num_reads + header_length; 304 307 out_data = kmalloc(out_data_length, GFP_KERNEL); 305 308 if (!out_data) ··· 310 311 out_data[i++] = num_reads; 311 312 for (j = 0; j < num_reads; j++) 312 313 out_data[i++] = reads[j].address; 313 - if (i > out_data_length) 314 - dev_err(&usb_dev->dev, "%s: bug! buffer overrun\n", __func__); 314 + 315 315 if (blocking) { 316 316 retval = mutex_lock_interruptible(&a_priv->bulk_transfer_lock); 317 317 if (retval) { ··· 327 329 retval = agilent_82357a_send_bulk_msg(a_priv, out_data, i, &bytes_written, 1000); 328 330 kfree(out_data); 329 331 if (retval) { 330 - dev_err(&usb_dev->dev, "%s: agilent_82357a_send_bulk_msg returned %i, bytes_written=%i, i=%i\n", 331 - __func__, retval, bytes_written, i); 332 + dev_err(&usb_dev->dev, "send_bulk_msg returned %i, bytes_written=%i, i=%i\n", 333 + retval, bytes_written, i); 332 334 mutex_unlock(&a_priv->bulk_transfer_lock); 333 335 return retval; 334 336 } ··· 343 345 mutex_unlock(&a_priv->bulk_transfer_lock); 344 346 345 347 if (retval) { 346 - dev_err(&usb_dev->dev, "%s: agilent_82357a_receive_bulk_msg returned %i, bytes_read=%i\n", 347 - __func__, retval, bytes_read); 348 + dev_err(&usb_dev->dev, "receive_bulk_msg returned %i, bytes_read=%i\n", 349 + retval, bytes_read); 348 350 agilent_82357a_dump_raw_block(in_data, bytes_read); 349 351 kfree(in_data); 350 352 return -EIO; 351 353 } 352 354 i = 0; 353 355 if (in_data[i++] != (0xff & ~DATA_PIPE_CMD_RD_REGS)) { 354 - dev_err(&usb_dev->dev, "%s: error, bulk command=0x%x != ~DATA_PIPE_CMD_RD_REGS\n", 355 - __func__, in_data[0]); 356 + dev_err(&usb_dev->dev, "bulk command=0x%x != ~DATA_PIPE_CMD_RD_REGS\n", in_data[0]); 356 357 return -EIO; 357 358 } 358 359 if (in_data[i++]) { 359 - dev_err(&usb_dev->dev, "%s: nonzero error code 0x%x in DATA_PIPE_CMD_RD_REGS response\n", 360 - __func__, in_data[1]); 360 + dev_err(&usb_dev->dev, "nonzero error code 0x%x in DATA_PIPE_CMD_RD_REGS response\n", 361 + in_data[1]); 361 362 return -EIO; 362 363 } 363 364 for (j = 0; j < num_reads; j++) ··· 387 390 wIndex, status_data, 388 391 status_data_len, 100); 389 392 if (receive_control_retval < 0) { 390 - dev_err(&usb_dev->dev, "%s: agilent_82357a_receive_control_msg() returned %i\n", 391 - __func__, receive_control_retval); 393 + dev_err(&usb_dev->dev, "82357a_receive_control_msg() returned %i\n", 394 + receive_control_retval); 392 395 retval = -EIO; 393 396 goto cleanup; 394 397 } 395 398 if (status_data[0] != (~XFER_ABORT & 0xff)) { 396 - dev_err(&usb_dev->dev, "%s: error, major code=0x%x != ~XFER_ABORT\n", 397 - __func__, status_data[0]); 399 + dev_err(&usb_dev->dev, "major code=0x%x != ~XFER_ABORT\n", status_data[0]); 398 400 retval = -EIO; 399 401 goto cleanup; 400 402 } ··· 409 413 fallthrough; 410 414 case UGP_ERR_FLUSHING_ALREADY: 411 415 default: 412 - dev_err(&usb_dev->dev, "%s: abort returned error code=0x%x\n", 413 - __func__, status_data[1]); 416 + dev_err(&usb_dev->dev, "abort returned error code=0x%x\n", status_data[1]); 414 417 retval = -EIO; 415 418 break; 416 419 } ··· 420 425 } 421 426 422 427 // interface functions 423 - int agilent_82357a_command(gpib_board_t *board, uint8_t *buffer, size_t length, 428 + int agilent_82357a_command(struct gpib_board *board, uint8_t *buffer, size_t length, 424 429 size_t *bytes_written); 425 430 426 - static int agilent_82357a_read(gpib_board_t *board, uint8_t *buffer, size_t length, int *end, 431 + static int agilent_82357a_read(struct gpib_board *board, uint8_t *buffer, size_t length, int *end, 427 432 size_t *nbytes) 428 433 { 429 434 int retval; 430 435 struct agilent_82357a_priv *a_priv = board->private_data; 431 - struct usb_device *usb_dev = interface_to_usbdev(a_priv->bus_interface); 436 + struct usb_device *usb_dev; 432 437 u8 *out_data, *in_data; 433 438 int out_data_length, in_data_length; 434 439 int bytes_written, bytes_read; ··· 439 444 440 445 *nbytes = 0; 441 446 *end = 0; 447 + 448 + if (!a_priv->bus_interface) 449 + return -ENODEV; 450 + usb_dev = interface_to_usbdev(a_priv->bus_interface); 442 451 out_data_length = 0x9; 443 452 out_data = kmalloc(out_data_length, GFP_KERNEL); 444 453 if (!out_data) ··· 468 469 retval = agilent_82357a_send_bulk_msg(a_priv, out_data, i, &bytes_written, msec_timeout); 469 470 kfree(out_data); 470 471 if (retval || bytes_written != i) { 471 - dev_err(&usb_dev->dev, "%s: agilent_82357a_send_bulk_msg returned %i, bytes_written=%i, i=%i\n", 472 - __func__, retval, bytes_written, i); 472 + dev_err(&usb_dev->dev, "send_bulk_msg returned %i, bytes_written=%i, i=%i\n", 473 + retval, bytes_written, i); 473 474 mutex_unlock(&a_priv->bulk_transfer_lock); 474 475 if (retval < 0) 475 476 return retval; ··· 500 501 &extra_bytes_read, 100); 501 502 bytes_read += extra_bytes_read; 502 503 if (extra_bytes_retval) { 503 - dev_err(&usb_dev->dev, "%s: extra_bytes_retval=%i, bytes_read=%i\n", 504 - __func__, extra_bytes_retval, bytes_read); 504 + dev_err(&usb_dev->dev, "extra_bytes_retval=%i, bytes_read=%i\n", 505 + extra_bytes_retval, bytes_read); 505 506 agilent_82357a_abort(a_priv, 0); 506 507 } 507 508 } else if (retval) { 508 - dev_err(&usb_dev->dev, "%s: agilent_82357a_receive_bulk_msg returned %i, bytes_read=%i\n", 509 - __func__, retval, bytes_read); 509 + dev_err(&usb_dev->dev, "receive_bulk_msg returned %i, bytes_read=%i\n", 510 + retval, bytes_read); 510 511 agilent_82357a_abort(a_priv, 0); 511 512 } 512 513 mutex_unlock(&a_priv->bulk_transfer_lock); 513 514 if (bytes_read > length + 1) { 514 515 bytes_read = length + 1; 515 - pr_warn("%s: bytes_read > length? truncating", __func__); 516 + dev_warn(&usb_dev->dev, "bytes_read > length? truncating"); 516 517 } 517 518 518 519 if (bytes_read >= 1) { ··· 534 535 return retval; 535 536 } 536 537 537 - static ssize_t agilent_82357a_generic_write(gpib_board_t *board, uint8_t *buffer, size_t length, 538 - int send_commands, int send_eoi, size_t *bytes_written) 538 + static ssize_t agilent_82357a_generic_write(struct gpib_board *board, 539 + uint8_t *buffer, size_t length, 540 + int send_commands, int send_eoi, 541 + size_t *bytes_written) 539 542 { 540 543 int retval; 541 544 struct agilent_82357a_priv *a_priv = board->private_data; 542 - struct usb_device *usb_dev = interface_to_usbdev(a_priv->bus_interface); 545 + struct usb_device *usb_dev; 543 546 u8 *out_data = NULL; 544 547 u8 *status_data = NULL; 545 548 int out_data_length; ··· 552 551 struct agilent_82357a_register_pairlet read_reg; 553 552 554 553 *bytes_written = 0; 554 + if (!a_priv->bus_interface) 555 + return -ENODEV; 556 + 557 + usb_dev = interface_to_usbdev(a_priv->bus_interface); 555 558 out_data_length = length + 0x8; 556 559 out_data = kmalloc(out_data_length, GFP_KERNEL); 557 560 if (!out_data) ··· 589 584 kfree(out_data); 590 585 if (retval || raw_bytes_written != i) { 591 586 agilent_82357a_abort(a_priv, 0); 592 - dev_err(&usb_dev->dev, "%s: agilent_82357a_send_bulk_msg returned %i, raw_bytes_written=%i, i=%i\n", 593 - __func__, retval, raw_bytes_written, i); 587 + dev_err(&usb_dev->dev, "send_bulk_msg returned %i, raw_bytes_written=%i, i=%i\n", 588 + retval, raw_bytes_written, i); 594 589 mutex_unlock(&a_priv->bulk_transfer_lock); 595 590 if (retval < 0) 596 591 return retval; ··· 602 597 &a_priv->interrupt_flags) || 603 598 test_bit(TIMO_NUM, &board->status)); 604 599 if (retval) { 605 - dev_err(&usb_dev->dev, "%s: wait write complete interrupted\n", __func__); 600 + dev_dbg(&usb_dev->dev, "wait write complete interrupted\n"); 606 601 agilent_82357a_abort(a_priv, 0); 607 602 mutex_unlock(&a_priv->bulk_transfer_lock); 608 603 return -ERESTARTSYS; ··· 619 614 read_reg.address = BSR; 620 615 retval = agilent_82357a_read_registers(a_priv, &read_reg, 1, 1); 621 616 if (retval) { 622 - dev_err(&usb_dev->dev, "%s: agilent_82357a_read_registers() returned error\n", 623 - __func__); 617 + dev_err(&usb_dev->dev, "read_registers() returned error\n"); 624 618 return -ETIMEDOUT; 625 619 } 626 620 ··· 636 632 read_reg.address = ADSR; 637 633 retval = agilent_82357a_read_registers(a_priv, &read_reg, 1, 1); 638 634 if (retval) { 639 - dev_err(&usb_dev->dev, "%s: agilent_82357a_read_registers() returned error\n", 640 - __func__); 635 + dev_err(&usb_dev->dev, "read_registers() returned error\n"); 641 636 return -ETIMEDOUT; 642 637 } 643 638 adsr = read_reg.value; ··· 662 659 100); 663 660 mutex_unlock(&a_priv->bulk_transfer_lock); 664 661 if (retval < 0) { 665 - dev_err(&usb_dev->dev, "%s: agilent_82357a_receive_control_msg() returned %i\n", 666 - __func__, retval); 662 + dev_err(&usb_dev->dev, "receive_control_msg() returned %i\n", retval); 667 663 kfree(status_data); 668 664 return -EIO; 669 665 } ··· 675 673 return 0; 676 674 } 677 675 678 - static int agilent_82357a_write(gpib_board_t *board, uint8_t *buffer, size_t length, 679 - int send_eoi, size_t *bytes_written) 676 + static int agilent_82357a_write(struct gpib_board *board, uint8_t *buffer, 677 + size_t length, int send_eoi, size_t *bytes_written) 680 678 { 681 679 return agilent_82357a_generic_write(board, buffer, length, 0, send_eoi, bytes_written); 682 680 } 683 681 684 - int agilent_82357a_command(gpib_board_t *board, uint8_t *buffer, size_t length, 682 + int agilent_82357a_command(struct gpib_board *board, uint8_t *buffer, size_t length, 685 683 size_t *bytes_written) 686 684 { 687 685 return agilent_82357a_generic_write(board, buffer, length, 1, 0, bytes_written); 688 686 } 689 687 690 - int agilent_82357a_take_control_internal(gpib_board_t *board, int synchronous) 688 + int agilent_82357a_take_control_internal(struct gpib_board *board, int synchronous) 691 689 { 692 690 struct agilent_82357a_priv *a_priv = board->private_data; 693 691 struct usb_device *usb_dev = interface_to_usbdev(a_priv->bus_interface); ··· 701 699 write.value = AUX_TCA; 702 700 retval = agilent_82357a_write_registers(a_priv, &write, 1); 703 701 if (retval) 704 - dev_err(&usb_dev->dev, "%s: agilent_82357a_write_registers() returned error\n", 705 - __func__); 702 + dev_err(&usb_dev->dev, "write_registers() returned error\n"); 706 703 707 704 return retval; 708 705 } 709 706 710 - static int agilent_82357a_take_control(gpib_board_t *board, int synchronous) 707 + static int agilent_82357a_take_control(struct gpib_board *board, int synchronous) 711 708 { 709 + struct agilent_82357a_priv *a_priv = board->private_data; 712 710 const int timeout = 10; 713 711 int i; 712 + 713 + if (!a_priv->bus_interface) 714 + return -ENODEV; 714 715 715 716 /* It looks like the 9914 does not handle tcs properly. 716 717 * See comment above tms9914_take_control_workaround() in ··· 735 730 return 0; 736 731 } 737 732 738 - static int agilent_82357a_go_to_standby(gpib_board_t *board) 733 + static int agilent_82357a_go_to_standby(struct gpib_board *board) 739 734 { 740 735 struct agilent_82357a_priv *a_priv = board->private_data; 741 - struct usb_device *usb_dev = interface_to_usbdev(a_priv->bus_interface); 736 + struct usb_device *usb_dev; 742 737 struct agilent_82357a_register_pairlet write; 743 738 int retval; 744 739 740 + if (!a_priv->bus_interface) 741 + return -ENODEV; 742 + 743 + usb_dev = interface_to_usbdev(a_priv->bus_interface); 745 744 write.address = AUXCR; 746 745 write.value = AUX_GTS; 747 746 retval = agilent_82357a_write_registers(a_priv, &write, 1); 748 747 if (retval) 749 - dev_err(&usb_dev->dev, "%s: agilent_82357a_write_registers() returned error\n", 750 - __func__); 748 + dev_err(&usb_dev->dev, "write_registers() returned error\n"); 751 749 return 0; 752 750 } 753 751 754 752 //FIXME should change prototype to return int 755 - static void agilent_82357a_request_system_control(gpib_board_t *board, int request_control) 753 + static void agilent_82357a_request_system_control(struct gpib_board *board, 754 + int request_control) 756 755 { 757 756 struct agilent_82357a_priv *a_priv = board->private_data; 758 - struct usb_device *usb_dev = interface_to_usbdev(a_priv->bus_interface); 757 + struct usb_device *usb_dev; 759 758 struct agilent_82357a_register_pairlet writes[2]; 760 759 int retval; 761 760 int i = 0; 762 761 762 + if (!a_priv->bus_interface) 763 + return; // -ENODEV; 764 + 765 + usb_dev = interface_to_usbdev(a_priv->bus_interface); 763 766 /* 82357B needs bit to be set in 9914 AUXCR register */ 764 767 writes[i].address = AUXCR; 765 768 if (request_control) { ··· 784 771 ++i; 785 772 retval = agilent_82357a_write_registers(a_priv, writes, i); 786 773 if (retval) 787 - dev_err(&usb_dev->dev, "%s: agilent_82357a_write_registers() returned error\n", 788 - __func__); 774 + dev_err(&usb_dev->dev, "write_registers() returned error\n"); 789 775 return;// retval; 790 776 } 791 777 792 - static void agilent_82357a_interface_clear(gpib_board_t *board, int assert) 778 + static void agilent_82357a_interface_clear(struct gpib_board *board, int assert) 793 779 { 794 780 struct agilent_82357a_priv *a_priv = board->private_data; 795 - struct usb_device *usb_dev = interface_to_usbdev(a_priv->bus_interface); 781 + struct usb_device *usb_dev; 796 782 struct agilent_82357a_register_pairlet write; 797 783 int retval; 798 784 785 + if (!a_priv->bus_interface) 786 + return; // -ENODEV; 787 + 788 + usb_dev = interface_to_usbdev(a_priv->bus_interface); 799 789 write.address = AUXCR; 800 790 write.value = AUX_SIC; 801 791 if (assert) { ··· 807 791 } 808 792 retval = agilent_82357a_write_registers(a_priv, &write, 1); 809 793 if (retval) 810 - dev_err(&usb_dev->dev, "%s: agilent_82357a_write_registers() returned error\n", 811 - __func__); 794 + dev_err(&usb_dev->dev, "write_registers() returned error\n"); 812 795 } 813 796 814 - static void agilent_82357a_remote_enable(gpib_board_t *board, int enable) 797 + static void agilent_82357a_remote_enable(struct gpib_board *board, int enable) 815 798 { 816 799 struct agilent_82357a_priv *a_priv = board->private_data; 817 - struct usb_device *usb_dev = interface_to_usbdev(a_priv->bus_interface); 800 + struct usb_device *usb_dev; 818 801 struct agilent_82357a_register_pairlet write; 819 802 int retval; 820 803 804 + if (!a_priv->bus_interface) 805 + return; //-ENODEV; 806 + 807 + usb_dev = interface_to_usbdev(a_priv->bus_interface); 821 808 write.address = AUXCR; 822 809 write.value = AUX_SRE; 823 810 if (enable) 824 811 write.value |= AUX_CS; 825 812 retval = agilent_82357a_write_registers(a_priv, &write, 1); 826 813 if (retval) 827 - dev_err(&usb_dev->dev, "%s: agilent_82357a_write_registers() returned error\n", 828 - __func__); 814 + dev_err(&usb_dev->dev, "write_registers() returned error\n"); 829 815 a_priv->ren_state = enable; 830 816 return;// 0; 831 817 } 832 818 833 - static int agilent_82357a_enable_eos(gpib_board_t *board, uint8_t eos_byte, int compare_8_bits) 819 + static int agilent_82357a_enable_eos(struct gpib_board *board, uint8_t eos_byte, 820 + int compare_8_bits) 834 821 { 835 822 struct agilent_82357a_priv *a_priv = board->private_data; 836 823 837 - if (compare_8_bits == 0) { 838 - pr_warn("%s: hardware only supports 8-bit EOS compare", __func__); 824 + if (!a_priv->bus_interface) 825 + return -ENODEV; 826 + if (compare_8_bits == 0) 839 827 return -EOPNOTSUPP; 840 - } 828 + 841 829 a_priv->eos_char = eos_byte; 842 830 a_priv->eos_mode = REOS | BIN; 843 831 return 0; 844 832 } 845 833 846 - static void agilent_82357a_disable_eos(gpib_board_t *board) 834 + static void agilent_82357a_disable_eos(struct gpib_board *board) 847 835 { 848 836 struct agilent_82357a_priv *a_priv = board->private_data; 849 837 850 838 a_priv->eos_mode &= ~REOS; 851 839 } 852 840 853 - static unsigned int agilent_82357a_update_status(gpib_board_t *board, unsigned int clear_mask) 841 + static unsigned int agilent_82357a_update_status(struct gpib_board *board, 842 + unsigned int clear_mask) 854 843 { 855 844 struct agilent_82357a_priv *a_priv = board->private_data; 856 - struct usb_device *usb_dev = interface_to_usbdev(a_priv->bus_interface); 845 + struct usb_device *usb_dev; 857 846 struct agilent_82357a_register_pairlet address_status, bus_status; 858 847 int retval; 859 848 849 + if (!a_priv->bus_interface) 850 + return -ENODEV; 851 + usb_dev = interface_to_usbdev(a_priv->bus_interface); 860 852 board->status &= ~clear_mask; 861 853 if (a_priv->is_cic) 862 854 set_bit(CIC_NUM, &board->status); ··· 874 850 retval = agilent_82357a_read_registers(a_priv, &address_status, 1, 0); 875 851 if (retval) { 876 852 if (retval != -EAGAIN) 877 - dev_err(&usb_dev->dev, "%s: agilent_82357a_read_registers() returned error\n", 878 - __func__); 853 + dev_err(&usb_dev->dev, "read_registers() returned error\n"); 879 854 return board->status; 880 855 } 881 856 // check for remote/local ··· 906 883 retval = agilent_82357a_read_registers(a_priv, &bus_status, 1, 0); 907 884 if (retval) { 908 885 if (retval != -EAGAIN) 909 - dev_err(&usb_dev->dev, "%s: agilent_82357a_read_registers() returned error\n", 910 - __func__); 886 + dev_err(&usb_dev->dev, "read_registers() returned error\n"); 911 887 return board->status; 912 888 } 913 889 if (bus_status.value & BSR_SRQ_BIT) ··· 917 895 return board->status; 918 896 } 919 897 920 - static int agilent_82357a_primary_address(gpib_board_t *board, unsigned int address) 898 + static int agilent_82357a_primary_address(struct gpib_board *board, unsigned int address) 921 899 { 922 900 struct agilent_82357a_priv *a_priv = board->private_data; 923 901 struct usb_device *usb_dev = interface_to_usbdev(a_priv->bus_interface); 924 902 struct agilent_82357a_register_pairlet write; 925 903 int retval; 926 904 905 + if (!a_priv->bus_interface) 906 + return -ENODEV; 907 + usb_dev = interface_to_usbdev(a_priv->bus_interface); 927 908 // put primary address in address0 928 909 write.address = ADR; 929 910 write.value = address & ADDRESS_MASK; 930 911 retval = agilent_82357a_write_registers(a_priv, &write, 1); 931 912 if (retval) { 932 - dev_err(&usb_dev->dev, "%s: agilent_82357a_write_registers() returned error\n", 933 - __func__); 913 + dev_err(&usb_dev->dev, "write_registers() returned error\n"); 934 914 return retval; 935 915 } 936 916 return retval; 937 917 } 938 918 939 - static int agilent_82357a_secondary_address(gpib_board_t *board, unsigned int address, int enable) 919 + static int agilent_82357a_secondary_address(struct gpib_board *board, 920 + unsigned int address, int enable) 940 921 { 941 922 if (enable) 942 - pr_warn("%s: warning: assigning a secondary address not supported\n", __func__); 943 - return -EOPNOTSUPP; 923 + return -EOPNOTSUPP; 924 + return 0; 944 925 } 945 926 946 - static int agilent_82357a_parallel_poll(gpib_board_t *board, uint8_t *result) 927 + static int agilent_82357a_parallel_poll(struct gpib_board *board, uint8_t *result) 947 928 { 948 929 struct agilent_82357a_priv *a_priv = board->private_data; 949 - struct usb_device *usb_dev = interface_to_usbdev(a_priv->bus_interface); 930 + struct usb_device *usb_dev; 950 931 struct agilent_82357a_register_pairlet writes[2]; 951 932 struct agilent_82357a_register_pairlet read; 952 933 int retval; 953 934 935 + if (!a_priv->bus_interface) 936 + return -ENODEV; 937 + usb_dev = interface_to_usbdev(a_priv->bus_interface); 954 938 // execute parallel poll 955 939 writes[0].address = AUXCR; 956 940 writes[0].value = AUX_CS | AUX_RPP; ··· 964 936 writes[1].value = a_priv->hw_control_bits & ~NOT_PARALLEL_POLL; 965 937 retval = agilent_82357a_write_registers(a_priv, writes, 2); 966 938 if (retval) { 967 - dev_err(&usb_dev->dev, "%s: agilent_82357a_write_registers() returned error\n", 968 - __func__); 939 + dev_err(&usb_dev->dev, "write_registers() returned error\n"); 969 940 return retval; 970 941 } 971 942 udelay(2); //silly, since usb write will take way longer 972 943 read.address = CPTR; 973 944 retval = agilent_82357a_read_registers(a_priv, &read, 1, 1); 974 945 if (retval) { 975 - dev_err(&usb_dev->dev, "%s: agilent_82357a_read_registers() returned error\n", 976 - __func__); 946 + dev_err(&usb_dev->dev, "read_registers() returned error\n"); 977 947 return retval; 978 948 } 979 949 *result = read.value; ··· 982 956 writes[1].value = AUX_RPP; 983 957 retval = agilent_82357a_write_registers(a_priv, writes, 2); 984 958 if (retval) { 985 - dev_err(&usb_dev->dev, "%s: agilent_82357a_write_registers() returned error\n", 986 - __func__); 959 + dev_err(&usb_dev->dev, "write_registers() returned error\n"); 987 960 return retval; 988 961 } 989 962 return 0; 990 963 } 991 964 992 - static void agilent_82357a_parallel_poll_configure(gpib_board_t *board, uint8_t config) 965 + static void agilent_82357a_parallel_poll_configure(struct gpib_board *board, uint8_t config) 993 966 { 994 967 //board can only be system controller 995 968 return;// 0; 996 969 } 997 970 998 - static void agilent_82357a_parallel_poll_response(gpib_board_t *board, int ist) 971 + static void agilent_82357a_parallel_poll_response(struct gpib_board *board, int ist) 999 972 { 1000 973 //board can only be system controller 1001 974 return;// 0; 1002 975 } 1003 976 1004 - static void agilent_82357a_serial_poll_response(gpib_board_t *board, uint8_t status) 977 + static void agilent_82357a_serial_poll_response(struct gpib_board *board, uint8_t status) 1005 978 { 1006 979 //board can only be system controller 1007 980 return;// 0; 1008 981 } 1009 982 1010 - static uint8_t agilent_82357a_serial_poll_status(gpib_board_t *board) 983 + static uint8_t agilent_82357a_serial_poll_status(struct gpib_board *board) 1011 984 { 1012 985 //board can only be system controller 1013 986 return 0; 1014 987 } 1015 988 1016 - static void agilent_82357a_return_to_local(gpib_board_t *board) 989 + static void agilent_82357a_return_to_local(struct gpib_board *board) 1017 990 { 1018 991 //board can only be system controller 1019 992 return;// 0; 1020 993 } 1021 994 1022 - static int agilent_82357a_line_status(const gpib_board_t *board) 995 + static int agilent_82357a_line_status(const struct gpib_board *board) 1023 996 { 1024 997 struct agilent_82357a_priv *a_priv = board->private_data; 1025 - struct usb_device *usb_dev = interface_to_usbdev(a_priv->bus_interface); 998 + struct usb_device *usb_dev; 1026 999 struct agilent_82357a_register_pairlet bus_status; 1027 1000 int retval; 1028 - int status = ValidALL; 1001 + int status = VALID_ALL; 1029 1002 1003 + if (!a_priv->bus_interface) 1004 + return -ENODEV; 1005 + usb_dev = interface_to_usbdev(a_priv->bus_interface); 1030 1006 bus_status.address = BSR; 1031 1007 retval = agilent_82357a_read_registers(a_priv, &bus_status, 1, 0); 1032 1008 if (retval) { 1033 1009 if (retval != -EAGAIN) 1034 - dev_err(&usb_dev->dev, "%s: agilent_82357a_read_registers() returned error\n", 1035 - __func__); 1010 + dev_err(&usb_dev->dev, "read_registers() returned error\n"); 1036 1011 return retval; 1037 1012 } 1038 1013 if (bus_status.value & BSR_REN_BIT) 1039 - status |= BusREN; 1014 + status |= BUS_REN; 1040 1015 if (bus_status.value & BSR_IFC_BIT) 1041 - status |= BusIFC; 1016 + status |= BUS_IFC; 1042 1017 if (bus_status.value & BSR_SRQ_BIT) 1043 - status |= BusSRQ; 1018 + status |= BUS_SRQ; 1044 1019 if (bus_status.value & BSR_EOI_BIT) 1045 - status |= BusEOI; 1020 + status |= BUS_EOI; 1046 1021 if (bus_status.value & BSR_NRFD_BIT) 1047 - status |= BusNRFD; 1022 + status |= BUS_NRFD; 1048 1023 if (bus_status.value & BSR_NDAC_BIT) 1049 - status |= BusNDAC; 1024 + status |= BUS_NDAC; 1050 1025 if (bus_status.value & BSR_DAV_BIT) 1051 - status |= BusDAV; 1026 + status |= BUS_DAV; 1052 1027 if (bus_status.value & BSR_ATN_BIT) 1053 - status |= BusATN; 1028 + status |= BUS_ATN; 1054 1029 return status; 1055 1030 } 1056 1031 ··· 1071 1044 return bits; 1072 1045 } 1073 1046 1074 - static unsigned int agilent_82357a_t1_delay(gpib_board_t *board, unsigned int nanosec) 1047 + static int agilent_82357a_t1_delay(struct gpib_board *board, unsigned int nanosec) 1075 1048 { 1076 1049 struct agilent_82357a_priv *a_priv = board->private_data; 1077 - struct usb_device *usb_dev = interface_to_usbdev(a_priv->bus_interface); 1050 + struct usb_device *usb_dev; 1078 1051 struct agilent_82357a_register_pairlet write; 1079 1052 int retval; 1080 1053 1054 + if (!a_priv->bus_interface) 1055 + return -ENODEV; 1056 + usb_dev = interface_to_usbdev(a_priv->bus_interface); 1081 1057 write.address = FAST_TALKER_T1; 1082 1058 write.value = nanosec_to_fast_talker_bits(&nanosec); 1083 1059 retval = agilent_82357a_write_registers(a_priv, &write, 1); 1084 1060 if (retval) 1085 - dev_err(&usb_dev->dev, "%s: agilent_82357a_write_registers() returned error\n", 1086 - __func__); 1061 + dev_err(&usb_dev->dev, "write_registers() returned error\n"); 1087 1062 return nanosec; 1088 1063 } 1089 1064 1090 1065 static void agilent_82357a_interrupt_complete(struct urb *urb) 1091 1066 { 1092 - gpib_board_t *board = urb->context; 1067 + struct gpib_board *board = urb->context; 1093 1068 struct agilent_82357a_priv *a_priv = board->private_data; 1094 1069 struct usb_device *usb_dev = interface_to_usbdev(a_priv->bus_interface); 1095 1070 int retval; ··· 1110 1081 default: /* other error, resubmit */ 1111 1082 retval = usb_submit_urb(a_priv->interrupt_urb, GFP_ATOMIC); 1112 1083 if (retval) 1113 - dev_err(&usb_dev->dev, "%s: failed to resubmit interrupt urb\n", __func__); 1084 + dev_err(&usb_dev->dev, "failed to resubmit interrupt urb\n"); 1114 1085 return; 1115 1086 } 1116 1087 ··· 1126 1097 1127 1098 retval = usb_submit_urb(a_priv->interrupt_urb, GFP_ATOMIC); 1128 1099 if (retval) 1129 - dev_err(&usb_dev->dev, "%s: failed to resubmit interrupt urb\n", __func__); 1100 + dev_err(&usb_dev->dev, "failed to resubmit interrupt urb\n"); 1130 1101 } 1131 1102 1132 - static int agilent_82357a_setup_urbs(gpib_board_t *board) 1103 + static int agilent_82357a_setup_urbs(struct gpib_board *board) 1133 1104 { 1134 1105 struct agilent_82357a_priv *a_priv = board->private_data; 1135 1106 struct usb_device *usb_dev; ··· 1162 1133 if (retval) { 1163 1134 usb_free_urb(a_priv->interrupt_urb); 1164 1135 a_priv->interrupt_urb = NULL; 1165 - dev_err(&usb_dev->dev, "%s: failed to submit first interrupt urb, retval=%i\n", 1166 - __func__, retval); 1136 + dev_err(&usb_dev->dev, "failed to submit first interrupt urb, retval=%i\n", retval); 1167 1137 goto setup_exit; 1168 1138 } 1169 1139 mutex_unlock(&a_priv->interrupt_alloc_lock); ··· 1193 1165 } 1194 1166 } 1195 1167 1196 - static int agilent_82357a_allocate_private(gpib_board_t *board) 1168 + static int agilent_82357a_allocate_private(struct gpib_board *board) 1197 1169 { 1198 1170 struct agilent_82357a_priv *a_priv; 1199 1171 ··· 1208 1180 return 0; 1209 1181 } 1210 1182 1211 - static void agilent_82357a_free_private(gpib_board_t *board) 1183 + static void agilent_82357a_free_private(struct gpib_board *board) 1212 1184 { 1213 1185 kfree(board->private_data); 1214 1186 board->private_data = NULL; 1215 - 1216 1187 } 1217 1188 1218 - static int agilent_82357a_init(gpib_board_t *board) 1189 + #define INIT_NUM_REG_WRITES 18 1190 + static int agilent_82357a_init(struct gpib_board *board) 1219 1191 { 1220 1192 struct agilent_82357a_priv *a_priv = board->private_data; 1221 1193 struct usb_device *usb_dev = interface_to_usbdev(a_priv->bus_interface); 1222 1194 struct agilent_82357a_register_pairlet hw_control; 1223 - struct agilent_82357a_register_pairlet writes[0x20]; 1195 + struct agilent_82357a_register_pairlet writes[INIT_NUM_REG_WRITES]; 1224 1196 int retval; 1225 - int i; 1226 1197 unsigned int nanosec; 1227 1198 1228 - i = 0; 1229 - writes[i].address = LED_CONTROL; 1230 - writes[i].value = FAIL_LED_ON; 1231 - ++i; 1232 - writes[i].address = RESET_TO_POWERUP; 1233 - writes[i].value = RESET_SPACEBALL; 1234 - ++i; 1235 - retval = agilent_82357a_write_registers(a_priv, writes, i); 1199 + writes[0].address = LED_CONTROL; 1200 + writes[0].value = FAIL_LED_ON; 1201 + writes[1].address = RESET_TO_POWERUP; 1202 + writes[1].value = RESET_SPACEBALL; 1203 + retval = agilent_82357a_write_registers(a_priv, writes, 2); 1236 1204 if (retval) { 1237 - dev_err(&usb_dev->dev, "%s: agilent_82357a_write_registers() returned error\n", 1238 - __func__); 1205 + dev_err(&usb_dev->dev, "write_registers() returned error\n"); 1239 1206 return -EIO; 1240 1207 } 1241 1208 set_current_state(TASK_INTERRUPTIBLE); 1242 1209 if (schedule_timeout(usec_to_jiffies(2000))) 1243 1210 return -ERESTARTSYS; 1244 - i = 0; 1245 - writes[i].address = AUXCR; 1246 - writes[i].value = AUX_NBAF; 1247 - ++i; 1248 - writes[i].address = AUXCR; 1249 - writes[i].value = AUX_HLDE; 1250 - ++i; 1251 - writes[i].address = AUXCR; 1252 - writes[i].value = AUX_TON; 1253 - ++i; 1254 - writes[i].address = AUXCR; 1255 - writes[i].value = AUX_LON; 1256 - ++i; 1257 - writes[i].address = AUXCR; 1258 - writes[i].value = AUX_RSV2; 1259 - ++i; 1260 - writes[i].address = AUXCR; 1261 - writes[i].value = AUX_INVAL; 1262 - ++i; 1263 - writes[i].address = AUXCR; 1264 - writes[i].value = AUX_RPP; 1265 - ++i; 1266 - writes[i].address = AUXCR; 1267 - writes[i].value = AUX_STDL; 1268 - ++i; 1269 - writes[i].address = AUXCR; 1270 - writes[i].value = AUX_VSTDL; 1271 - ++i; 1272 - writes[i].address = FAST_TALKER_T1; 1211 + writes[0].address = AUXCR; 1212 + writes[0].value = AUX_NBAF; 1213 + writes[1].address = AUXCR; 1214 + writes[1].value = AUX_HLDE; 1215 + writes[2].address = AUXCR; 1216 + writes[2].value = AUX_TON; 1217 + writes[3].address = AUXCR; 1218 + writes[3].value = AUX_LON; 1219 + writes[4].address = AUXCR; 1220 + writes[4].value = AUX_RSV2; 1221 + writes[5].address = AUXCR; 1222 + writes[5].value = AUX_INVAL; 1223 + writes[6].address = AUXCR; 1224 + writes[6].value = AUX_RPP; 1225 + writes[7].address = AUXCR; 1226 + writes[7].value = AUX_STDL; 1227 + writes[8].address = AUXCR; 1228 + writes[8].value = AUX_VSTDL; 1229 + writes[9].address = FAST_TALKER_T1; 1273 1230 nanosec = board->t1_nano_sec; 1274 - writes[i].value = nanosec_to_fast_talker_bits(&nanosec); 1231 + writes[9].value = nanosec_to_fast_talker_bits(&nanosec); 1275 1232 board->t1_nano_sec = nanosec; 1276 - ++i; 1277 - writes[i].address = ADR; 1278 - writes[i].value = board->pad & ADDRESS_MASK; 1279 - ++i; 1280 - writes[i].address = PPR; 1281 - writes[i].value = 0; 1282 - ++i; 1283 - writes[i].address = SPMR; 1284 - writes[i].value = 0; 1285 - ++i; 1286 - writes[i].address = PROTOCOL_CONTROL; 1287 - writes[i].value = WRITE_COMPLETE_INTERRUPT_EN; 1288 - ++i; 1289 - writes[i].address = IMR0; 1290 - writes[i].value = HR_BOIE | HR_BIIE; 1291 - ++i; 1292 - writes[i].address = IMR1; 1293 - writes[i].value = HR_SRQIE; 1294 - ++i; 1233 + writes[10].address = ADR; 1234 + writes[10].value = board->pad & ADDRESS_MASK; 1235 + writes[11].address = PPR; 1236 + writes[11].value = 0; 1237 + writes[12].address = SPMR; 1238 + writes[12].value = 0; 1239 + writes[13].address = PROTOCOL_CONTROL; 1240 + writes[13].value = WRITE_COMPLETE_INTERRUPT_EN; 1241 + writes[14].address = IMR0; 1242 + writes[14].value = HR_BOIE | HR_BIIE; 1243 + writes[15].address = IMR1; 1244 + writes[15].value = HR_SRQIE; 1295 1245 // turn off reset state 1296 - writes[i].address = AUXCR; 1297 - writes[i].value = AUX_CHIP_RESET; 1298 - ++i; 1299 - writes[i].address = LED_CONTROL; 1300 - writes[i].value = FIRMWARE_LED_CONTROL; 1301 - ++i; 1302 - if (i > ARRAY_SIZE(writes)) { 1303 - dev_err(&usb_dev->dev, "%s: bug! writes[] overflow\n", __func__); 1304 - return -EFAULT; 1305 - } 1306 - retval = agilent_82357a_write_registers(a_priv, writes, i); 1246 + writes[16].address = AUXCR; 1247 + writes[16].value = AUX_CHIP_RESET; 1248 + writes[17].address = LED_CONTROL; 1249 + writes[17].value = FIRMWARE_LED_CONTROL; 1250 + retval = agilent_82357a_write_registers(a_priv, writes, INIT_NUM_REG_WRITES); 1307 1251 if (retval) { 1308 - dev_err(&usb_dev->dev, "%s: agilent_82357a_write_registers() returned error\n", 1309 - __func__); 1252 + dev_err(&usb_dev->dev, "write_registers() returned error\n"); 1310 1253 return -EIO; 1311 1254 } 1312 1255 hw_control.address = HW_CONTROL; 1313 1256 retval = agilent_82357a_read_registers(a_priv, &hw_control, 1, 1); 1314 1257 if (retval) { 1315 - dev_err(&usb_dev->dev, "%s: agilent_82357a_read_registers() returned error\n", 1316 - __func__); 1258 + dev_err(&usb_dev->dev, "read_registers() returned error\n"); 1317 1259 return -EIO; 1318 1260 } 1319 1261 a_priv->hw_control_bits = (hw_control.value & ~0x7) | NOT_TI_RESET | NOT_PARALLEL_POLL; ··· 1305 1307 return 1; 1306 1308 } 1307 1309 1308 - static int agilent_82357a_attach(gpib_board_t *board, const gpib_board_config_t *config) 1310 + static int agilent_82357a_attach(struct gpib_board *board, const gpib_board_config_t *config) 1309 1311 { 1310 1312 int retval; 1311 1313 int i; ··· 1334 1336 } 1335 1337 if (i == MAX_NUM_82357A_INTERFACES) { 1336 1338 dev_err(board->gpib_dev, 1337 - "No Agilent 82357 gpib adapters found, have you loaded its firmware?\n"); 1339 + "No supported adapters found, have you loaded its firmware?\n"); 1338 1340 retval = -ENODEV; 1339 1341 goto attach_fail; 1340 1342 } ··· 1370 1372 goto attach_fail; 1371 1373 } 1372 1374 1373 - dev_info(&usb_dev->dev, 1374 - "bus %d dev num %d attached to gpib minor %d, agilent usb interface %i\n", 1375 + dev_info(&usb_dev->dev, "bus %d dev num %d attached to gpib%d, interface %i\n", 1375 1376 usb_dev->bus->busnum, usb_dev->devnum, board->minor, i); 1376 1377 mutex_unlock(&agilent_82357a_hotplug_lock); 1377 1378 return retval; ··· 1381 1384 return retval; 1382 1385 } 1383 1386 1384 - static int agilent_82357a_go_idle(gpib_board_t *board) 1387 + static int agilent_82357a_go_idle(struct gpib_board *board) 1385 1388 { 1386 1389 struct agilent_82357a_priv *a_priv = board->private_data; 1387 1390 struct usb_device *usb_dev = interface_to_usbdev(a_priv->bus_interface); 1388 1391 struct agilent_82357a_register_pairlet writes[0x20]; 1389 1392 int retval; 1390 - int i; 1391 1393 1392 - i = 0; 1393 1394 // turn on tms9914 reset state 1394 - writes[i].address = AUXCR; 1395 - writes[i].value = AUX_CS | AUX_CHIP_RESET; 1396 - ++i; 1395 + writes[0].address = AUXCR; 1396 + writes[0].value = AUX_CS | AUX_CHIP_RESET; 1397 1397 a_priv->hw_control_bits &= ~NOT_TI_RESET; 1398 - writes[i].address = HW_CONTROL; 1399 - writes[i].value = a_priv->hw_control_bits; 1400 - ++i; 1401 - writes[i].address = PROTOCOL_CONTROL; 1402 - writes[i].value = 0; 1403 - ++i; 1404 - writes[i].address = IMR0; 1405 - writes[i].value = 0; 1406 - ++i; 1407 - writes[i].address = IMR1; 1408 - writes[i].value = 0; 1409 - ++i; 1410 - writes[i].address = LED_CONTROL; 1411 - writes[i].value = 0; 1412 - ++i; 1413 - if (i > ARRAY_SIZE(writes)) { 1414 - dev_err(&usb_dev->dev, "%s: bug! writes[] overflow\n", __func__); 1415 - return -EFAULT; 1416 - } 1417 - retval = agilent_82357a_write_registers(a_priv, writes, i); 1398 + writes[1].address = HW_CONTROL; 1399 + writes[1].value = a_priv->hw_control_bits; 1400 + writes[2].address = PROTOCOL_CONTROL; 1401 + writes[2].value = 0; 1402 + writes[3].address = IMR0; 1403 + writes[3].value = 0; 1404 + writes[4].address = IMR1; 1405 + writes[4].value = 0; 1406 + writes[5].address = LED_CONTROL; 1407 + writes[5].value = 0; 1408 + retval = agilent_82357a_write_registers(a_priv, writes, 6); 1418 1409 if (retval) { 1419 - dev_err(&usb_dev->dev, "%s: agilent_82357a_write_registers() returned error\n", 1420 - __func__); 1410 + dev_err(&usb_dev->dev, "write_registers() returned error\n"); 1421 1411 return -EIO; 1422 1412 } 1423 1413 return 0; 1424 1414 } 1425 1415 1426 - static void agilent_82357a_detach(gpib_board_t *board) 1416 + static void agilent_82357a_detach(struct gpib_board *board) 1427 1417 { 1428 1418 struct agilent_82357a_priv *a_priv; 1429 1419 ··· 1429 1445 agilent_82357a_release_urbs(a_priv); 1430 1446 agilent_82357a_free_private(board); 1431 1447 } 1432 - dev_info(board->gpib_dev, "%s: detached\n", __func__); 1433 1448 mutex_unlock(&agilent_82357a_hotplug_lock); 1434 1449 } 1435 1450 ··· 1493 1510 if (i == MAX_NUM_82357A_INTERFACES) { 1494 1511 usb_put_dev(usb_dev); 1495 1512 mutex_unlock(&agilent_82357a_hotplug_lock); 1496 - dev_err(&usb_dev->dev, "%s: out of space in agilent_82357a_driver_interfaces[]\n", 1497 - __func__); 1513 + dev_err(&usb_dev->dev, "out of space in agilent_82357a_driver_interfaces[]\n"); 1498 1514 return -1; 1499 1515 } 1500 1516 path = kmalloc(path_length, GFP_KERNEL); ··· 1518 1536 1519 1537 for (i = 0; i < MAX_NUM_82357A_INTERFACES; ++i) { 1520 1538 if (agilent_82357a_driver_interfaces[i] == interface) { 1521 - gpib_board_t *board = usb_get_intfdata(interface); 1539 + struct gpib_board *board = usb_get_intfdata(interface); 1522 1540 1523 1541 if (board) { 1524 1542 struct agilent_82357a_priv *a_priv = board->private_data; ··· 1534 1552 mutex_unlock(&a_priv->control_alloc_lock); 1535 1553 } 1536 1554 } 1537 - dev_dbg(&usb_dev->dev, "nulled agilent_82357a_driver_interfaces[%i]\n", i); 1538 1555 agilent_82357a_driver_interfaces[i] = NULL; 1539 1556 break; 1540 1557 } 1541 1558 } 1542 1559 if (i == MAX_NUM_82357A_INTERFACES) 1543 - dev_err(&usb_dev->dev, "unable to find interface in agilent_82357a_driver_interfaces[]? bug?\n"); 1560 + dev_err(&usb_dev->dev, "unable to find interface - bug?\n"); 1544 1561 usb_put_dev(usb_dev); 1545 1562 1546 1563 mutex_unlock(&agilent_82357a_hotplug_lock); ··· 1554 1573 1555 1574 for (i = 0; i < MAX_NUM_82357A_INTERFACES; ++i) { 1556 1575 if (agilent_82357a_driver_interfaces[i] == interface) { 1557 - gpib_board_t *board = usb_get_intfdata(interface); 1576 + struct gpib_board *board = usb_get_intfdata(interface); 1558 1577 1559 1578 if (board) { 1560 1579 struct agilent_82357a_priv *a_priv = board->private_data; ··· 1564 1583 agilent_82357a_abort(a_priv, 0); 1565 1584 retval = agilent_82357a_go_idle(board); 1566 1585 if (retval) { 1567 - dev_err(&usb_dev->dev, "%s: failed to go idle, retval=%i\n", 1568 - __func__, retval); 1586 + dev_err(&usb_dev->dev, "failed to go idle, retval=%i\n", 1587 + retval); 1569 1588 mutex_unlock(&agilent_82357a_hotplug_lock); 1570 1589 return retval; 1571 1590 } 1572 1591 mutex_lock(&a_priv->interrupt_alloc_lock); 1573 1592 agilent_82357a_cleanup_urbs(a_priv); 1574 1593 mutex_unlock(&a_priv->interrupt_alloc_lock); 1575 - dev_info(&usb_dev->dev, 1576 - "bus %d dev num %d gpib minor %d, agilent usb interface %i suspended\n", 1577 - usb_dev->bus->busnum, usb_dev->devnum, 1578 - board->minor, i); 1594 + dev_dbg(&usb_dev->dev, 1595 + "bus %d dev num %d gpib %d, interface %i suspended\n", 1596 + usb_dev->bus->busnum, usb_dev->devnum, 1597 + board->minor, i); 1579 1598 } 1580 1599 } 1581 1600 break; ··· 1590 1609 static int agilent_82357a_driver_resume(struct usb_interface *interface) 1591 1610 { 1592 1611 struct usb_device *usb_dev = interface_to_usbdev(interface); 1593 - gpib_board_t *board; 1612 + struct gpib_board *board; 1594 1613 int i, retval; 1595 1614 1596 1615 mutex_lock(&agilent_82357a_hotplug_lock); ··· 1612 1631 mutex_lock(&a_priv->interrupt_alloc_lock); 1613 1632 retval = usb_submit_urb(a_priv->interrupt_urb, GFP_KERNEL); 1614 1633 if (retval) { 1615 - dev_err(&usb_dev->dev, "%s: failed to resubmit interrupt urb, retval=%i\n", 1616 - __func__, retval); 1634 + dev_err(&usb_dev->dev, "failed to resubmit interrupt urb in resume, retval=%i\n", 1635 + retval); 1617 1636 mutex_unlock(&a_priv->interrupt_alloc_lock); 1618 1637 mutex_unlock(&agilent_82357a_hotplug_lock); 1619 1638 return retval; ··· 1636 1655 // assert/unassert REN 1637 1656 agilent_82357a_remote_enable(board, a_priv->ren_state); 1638 1657 1639 - dev_info(&usb_dev->dev, 1640 - "bus %d dev num %d gpib minor %d, agilent usb interface %i resumed\n", 1641 - usb_dev->bus->busnum, usb_dev->devnum, board->minor, i); 1658 + dev_dbg(&usb_dev->dev, 1659 + "bus %d dev num %d gpib%d, interface %i resumed\n", 1660 + usb_dev->bus->busnum, usb_dev->devnum, board->minor, i); 1642 1661 } 1643 1662 1644 1663 resume_exit: ··· 1648 1667 } 1649 1668 1650 1669 static struct usb_driver agilent_82357a_bus_driver = { 1651 - .name = "agilent_82357a_gpib", 1670 + .name = DRV_NAME, 1652 1671 .probe = agilent_82357a_driver_probe, 1653 1672 .disconnect = agilent_82357a_driver_disconnect, 1654 1673 .suspend = agilent_82357a_driver_suspend, ··· 1661 1680 int i; 1662 1681 int ret; 1663 1682 1664 - pr_info("agilent_82357a_gpib driver loading"); 1665 1683 for (i = 0; i < MAX_NUM_82357A_INTERFACES; ++i) 1666 1684 agilent_82357a_driver_interfaces[i] = NULL; 1667 1685 1668 1686 ret = usb_register(&agilent_82357a_bus_driver); 1669 1687 if (ret) { 1670 - pr_err("agilent_82357a: usb_register failed: error = %d\n", ret); 1688 + pr_err("usb_register failed: error = %d\n", ret); 1671 1689 return ret; 1672 1690 } 1673 1691 1674 1692 ret = gpib_register_driver(&agilent_82357a_gpib_interface, THIS_MODULE); 1675 1693 if (ret) { 1676 - pr_err("agilent_82357a: gpib_register_driver failed: error = %d\n", ret); 1694 + pr_err("gpib_register_driver failed: error = %d\n", ret); 1677 1695 usb_deregister(&agilent_82357a_bus_driver); 1678 1696 return ret; 1679 1697 } ··· 1682 1702 1683 1703 static void __exit agilent_82357a_exit_module(void) 1684 1704 { 1685 - pr_info("agilent_82357a_gpib driver unloading"); 1686 1705 gpib_unregister_driver(&agilent_82357a_gpib_interface); 1687 1706 usb_deregister(&agilent_82357a_bus_driver); 1688 1707 }
-1
drivers/staging/gpib/cb7210/Makefile
··· 1 - ccflags-$(CONFIG_GPIB_PCMCIA) := -DGPIB_PCMCIA 2 1 obj-$(CONFIG_GPIB_CB7210) += cb7210.o 3 2 4 3
+131 -156
drivers/staging/gpib/cb7210/cb7210.c
··· 5 5 * copyright : (C) 2001, 2002 by Frank Mori Hess 6 6 ***************************************************************************/ 7 7 8 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 9 + #define dev_fmt pr_fmt 10 + #define DRV_NAME KBUILD_MODNAME 11 + 8 12 #include "cb7210.h" 9 13 #include <linux/ioport.h> 10 14 #include <linux/sched.h> ··· 27 23 MODULE_LICENSE("GPL"); 28 24 MODULE_DESCRIPTION("GPIB driver Measurement Computing boards using cb7210.2 and cbi488.2"); 29 25 30 - static inline int have_fifo_word(const struct cb7210_priv *cb_priv) 26 + static int cb7210_read(struct gpib_board *board, uint8_t *buffer, size_t length, 27 + int *end, size_t *bytes_read); 28 + 29 + static inline int have_fifo_word(const struct cb7210_priv *cb_priv) 31 30 { 32 31 if (((cb7210_read_byte(cb_priv, HS_STATUS)) & 33 32 (HS_RX_MSB_NOT_EMPTY | HS_RX_LSB_NOT_EMPTY)) == ··· 40 33 return 0; 41 34 } 42 35 43 - static inline void input_fifo_enable(gpib_board_t *board, int enable) 36 + static inline void input_fifo_enable(struct gpib_board *board, int enable) 44 37 { 45 38 struct cb7210_priv *cb_priv = board->private_data; 46 39 struct nec7210_priv *nec_priv = &cb_priv->nec7210_priv; ··· 76 69 spin_unlock_irqrestore(&board->spinlock, flags); 77 70 } 78 71 79 - static int fifo_read(gpib_board_t *board, struct cb7210_priv *cb_priv, uint8_t *buffer, 72 + static int fifo_read(struct gpib_board *board, struct cb7210_priv *cb_priv, uint8_t *buffer, 80 73 size_t length, int *end, size_t *bytes_read) 81 74 { 82 75 ssize_t retval = 0; ··· 87 80 88 81 *bytes_read = 0; 89 82 if (cb_priv->fifo_iobase == 0) { 90 - pr_err("cb7210: fifo iobase is zero!\n"); 83 + dev_err(board->gpib_dev, "fifo iobase is zero!\n"); 91 84 return -EIO; 92 85 } 93 86 *end = 0; 94 87 if (length <= cb7210_fifo_size) { 95 - pr_err("cb7210: bug! %s with length < fifo size\n", __func__); 88 + dev_err(board->gpib_dev, " bug! fifo read length < fifo size\n"); 96 89 return -EINVAL; 97 90 } 98 91 ··· 107 100 test_bit(RECEIVED_END_BN, &nec_priv->state) || 108 101 test_bit(DEV_CLEAR_BN, &nec_priv->state) || 109 102 test_bit(TIMO_NUM, &board->status))) { 110 - pr_warn("cb7210: fifo half full wait interrupted\n"); 111 103 retval = -ERESTARTSYS; 112 104 nec7210_set_reg_bits(nec_priv, IMR2, HR_DMAI, 0); 113 105 break; ··· 156 150 test_bit(RECEIVED_END_BN, &nec_priv->state) || 157 151 test_bit(DEV_CLEAR_BN, &nec_priv->state) || 158 152 test_bit(TIMO_NUM, &board->status))) { 159 - pr_warn("cb7210: fifo half full wait interrupted\n"); 160 153 retval = -ERESTARTSYS; 161 154 } 162 155 if (test_bit(TIMO_NUM, &board->status)) ··· 170 165 return retval; 171 166 } 172 167 173 - int cb7210_accel_read(gpib_board_t *board, uint8_t *buffer, 174 - size_t length, int *end, size_t *bytes_read) 168 + static int cb7210_accel_read(struct gpib_board *board, uint8_t *buffer, 169 + size_t length, int *end, size_t *bytes_read) 175 170 { 176 171 ssize_t retval; 177 172 struct cb7210_priv *cb_priv = board->private_data; ··· 190 185 test_bit(READ_READY_BN, &nec_priv->state) || 191 186 test_bit(DEV_CLEAR_BN, &nec_priv->state) || 192 187 test_bit(TIMO_NUM, &board->status))) { 193 - pr_warn("cb7210: read ready wait interrupted\n"); 194 188 return -ERESTARTSYS; 195 189 } 196 190 if (test_bit(TIMO_NUM, &board->status)) ··· 229 225 return 0; 230 226 } 231 227 232 - static inline void output_fifo_enable(gpib_board_t *board, int enable) 228 + static inline void output_fifo_enable(struct gpib_board *board, int enable) 233 229 { 234 230 struct cb7210_priv *cb_priv = board->private_data; 235 231 struct nec7210_priv *nec_priv = &cb_priv->nec7210_priv; ··· 264 260 spin_unlock_irqrestore(&board->spinlock, flags); 265 261 } 266 262 267 - static int fifo_write(gpib_board_t *board, uint8_t *buffer, size_t length, size_t *bytes_written) 263 + static int fifo_write(struct gpib_board *board, uint8_t *buffer, size_t length, 264 + size_t *bytes_written) 268 265 { 269 266 size_t count = 0; 270 267 ssize_t retval = 0; ··· 276 271 277 272 *bytes_written = 0; 278 273 if (cb_priv->fifo_iobase == 0) { 279 - pr_err("cb7210: fifo iobase is zero!\n"); 274 + dev_err(board->gpib_dev, "fifo iobase is zero!\n"); 280 275 return -EINVAL; 281 276 } 282 277 if (length == 0) ··· 295 290 test_bit(DEV_CLEAR_BN, &nec_priv->state) || 296 291 test_bit(BUS_ERROR_BN, &nec_priv->state) || 297 292 test_bit(TIMO_NUM, &board->status))) { 298 - pr_warn("cb7210: fifo wait interrupted\n"); 299 293 retval = -ERESTARTSYS; 300 294 break; 301 295 } ··· 310 306 if (num_bytes + count > length) 311 307 num_bytes = length - count; 312 308 if (num_bytes % cb7210_fifo_width) { 313 - pr_err("cb7210: bug! %s with odd number of bytes\n", __func__); 309 + dev_err(board->gpib_dev, " bug! fifo write with odd number of bytes\n"); 314 310 retval = -EINVAL; 315 311 break; 316 312 } ··· 335 331 test_bit(DEV_CLEAR_BN, &nec_priv->state) || 336 332 test_bit(BUS_ERROR_BN, &nec_priv->state) || 337 333 test_bit(TIMO_NUM, &board->status))) { 338 - pr_err("cb7210: wait for last byte interrupted\n"); 339 334 retval = -ERESTARTSYS; 340 335 } 341 336 if (test_bit(TIMO_NUM, &board->status)) ··· 350 347 return retval; 351 348 } 352 349 353 - int cb7210_accel_write(gpib_board_t *board, uint8_t *buffer, size_t length, int send_eoi, 354 - size_t *bytes_written) 350 + static int cb7210_accel_write(struct gpib_board *board, uint8_t *buffer, 351 + size_t length, int send_eoi, size_t *bytes_written) 355 352 { 356 353 struct cb7210_priv *cb_priv = board->private_data; 357 354 struct nec7210_priv *nec_priv = &cb_priv->nec7210_priv; ··· 378 375 return retval; 379 376 } 380 377 381 - int cb7210_line_status(const gpib_board_t *board) 378 + static int cb7210_line_status(const struct gpib_board *board) 382 379 { 383 - int status = ValidALL; 380 + int status = VALID_ALL; 384 381 int bsr_bits; 385 382 struct cb7210_priv *cb_priv; 386 - struct nec7210_priv *nec_priv; 387 383 388 384 cb_priv = board->private_data; 389 - nec_priv = &cb_priv->nec7210_priv; 390 385 391 386 bsr_bits = cb7210_paged_read_byte(cb_priv, BUS_STATUS, BUS_STATUS_PAGE); 392 387 393 388 if ((bsr_bits & BSR_REN_BIT) == 0) 394 - status |= BusREN; 389 + status |= BUS_REN; 395 390 if ((bsr_bits & BSR_IFC_BIT) == 0) 396 - status |= BusIFC; 391 + status |= BUS_IFC; 397 392 if ((bsr_bits & BSR_SRQ_BIT) == 0) 398 - status |= BusSRQ; 393 + status |= BUS_SRQ; 399 394 if ((bsr_bits & BSR_EOI_BIT) == 0) 400 - status |= BusEOI; 395 + status |= BUS_EOI; 401 396 if ((bsr_bits & BSR_NRFD_BIT) == 0) 402 - status |= BusNRFD; 397 + status |= BUS_NRFD; 403 398 if ((bsr_bits & BSR_NDAC_BIT) == 0) 404 - status |= BusNDAC; 399 + status |= BUS_NDAC; 405 400 if ((bsr_bits & BSR_DAV_BIT) == 0) 406 - status |= BusDAV; 401 + status |= BUS_DAV; 407 402 if ((bsr_bits & BSR_ATN_BIT) == 0) 408 - status |= BusATN; 403 + status |= BUS_ATN; 409 404 410 405 return status; 411 406 } 412 407 413 - unsigned int cb7210_t1_delay(gpib_board_t *board, unsigned int nano_sec) 408 + static int cb7210_t1_delay(struct gpib_board *board, unsigned int nano_sec) 414 409 { 415 410 struct cb7210_priv *cb_priv = board->private_data; 416 411 struct nec7210_priv *nec_priv = &cb_priv->nec7210_priv; ··· 425 424 return retval; 426 425 } 427 426 428 - irqreturn_t cb7210_locked_internal_interrupt(gpib_board_t *board); 427 + static irqreturn_t cb7210_locked_internal_interrupt(struct gpib_board *board); 429 428 430 429 /* 431 430 * GPIB interrupt service routines 432 431 */ 433 432 434 - irqreturn_t cb_pci_interrupt(int irq, void *arg) 433 + static irqreturn_t cb_pci_interrupt(int irq, void *arg) 435 434 { 436 435 int bits; 437 - gpib_board_t *board = arg; 436 + struct gpib_board *board = arg; 438 437 struct cb7210_priv *priv = board->private_data; 439 438 440 439 // first task check if this is really our interrupt in a shared irq environment ··· 463 462 return cb7210_locked_internal_interrupt(arg); 464 463 } 465 464 466 - irqreturn_t cb7210_internal_interrupt(gpib_board_t *board) 465 + static irqreturn_t cb7210_internal_interrupt(struct gpib_board *board) 467 466 { 468 467 int hs_status, status1, status2; 469 468 struct cb7210_priv *priv = board->private_data; ··· 480 479 status2 = read_byte(nec_priv, ISR2); 481 480 nec7210_interrupt_have_status(board, nec_priv, status1, status2); 482 481 483 - dev_dbg(board->gpib_dev, "cb7210: status 0x%x, mode 0x%x\n", hs_status, priv->hs_mode_bits); 482 + dev_dbg(board->gpib_dev, "status 0x%x, mode 0x%x\n", hs_status, priv->hs_mode_bits); 484 483 485 484 clear_bits = 0; 486 485 ··· 517 516 return IRQ_HANDLED; 518 517 } 519 518 520 - irqreturn_t cb7210_locked_internal_interrupt(gpib_board_t *board) 519 + static irqreturn_t cb7210_locked_internal_interrupt(struct gpib_board *board) 521 520 { 522 521 unsigned long flags; 523 522 irqreturn_t retval; ··· 528 527 return retval; 529 528 } 530 529 531 - irqreturn_t cb7210_interrupt(int irq, void *arg) 530 + static irqreturn_t cb7210_interrupt(int irq, void *arg) 532 531 { 533 532 return cb7210_internal_interrupt(arg); 534 533 } 535 534 536 - static int cb_pci_attach(gpib_board_t *board, const gpib_board_config_t *config); 537 - static int cb_isa_attach(gpib_board_t *board, const gpib_board_config_t *config); 535 + static int cb_pci_attach(struct gpib_board *board, const gpib_board_config_t *config); 536 + static int cb_isa_attach(struct gpib_board *board, const gpib_board_config_t *config); 538 537 539 - static void cb_pci_detach(gpib_board_t *board); 540 - static void cb_isa_detach(gpib_board_t *board); 538 + static void cb_pci_detach(struct gpib_board *board); 539 + static void cb_isa_detach(struct gpib_board *board); 541 540 542 541 // wrappers for interface functions 543 - int cb7210_read(gpib_board_t *board, uint8_t *buffer, size_t length, int *end, size_t *bytes_read) 542 + static int cb7210_read(struct gpib_board *board, uint8_t *buffer, size_t length, 543 + int *end, size_t *bytes_read) 544 544 { 545 545 struct cb7210_priv *priv = board->private_data; 546 546 547 547 return nec7210_read(board, &priv->nec7210_priv, buffer, length, end, bytes_read); 548 548 } 549 549 550 - int cb7210_write(gpib_board_t *board, uint8_t *buffer, size_t length, 551 - int send_eoi, size_t *bytes_written) 550 + static int cb7210_write(struct gpib_board *board, uint8_t *buffer, size_t length, 551 + int send_eoi, size_t *bytes_written) 552 552 { 553 553 struct cb7210_priv *priv = board->private_data; 554 554 555 555 return nec7210_write(board, &priv->nec7210_priv, buffer, length, send_eoi, bytes_written); 556 556 } 557 557 558 - int cb7210_command(gpib_board_t *board, uint8_t *buffer, size_t length, size_t *bytes_written) 558 + static int cb7210_command(struct gpib_board *board, uint8_t *buffer, size_t length, 559 + size_t *bytes_written) 559 560 { 560 561 struct cb7210_priv *priv = board->private_data; 561 562 562 563 return nec7210_command(board, &priv->nec7210_priv, buffer, length, bytes_written); 563 564 } 564 565 565 - int cb7210_take_control(gpib_board_t *board, int synchronous) 566 + static int cb7210_take_control(struct gpib_board *board, int synchronous) 566 567 { 567 568 struct cb7210_priv *priv = board->private_data; 568 569 569 570 return nec7210_take_control(board, &priv->nec7210_priv, synchronous); 570 571 } 571 572 572 - int cb7210_go_to_standby(gpib_board_t *board) 573 + static int cb7210_go_to_standby(struct gpib_board *board) 573 574 { 574 575 struct cb7210_priv *priv = board->private_data; 575 576 576 577 return nec7210_go_to_standby(board, &priv->nec7210_priv); 577 578 } 578 579 579 - void cb7210_request_system_control(gpib_board_t *board, int request_control) 580 + static void cb7210_request_system_control(struct gpib_board *board, int request_control) 580 581 { 581 582 struct cb7210_priv *priv = board->private_data; 582 583 struct nec7210_priv *nec_priv = &priv->nec7210_priv; ··· 592 589 nec7210_request_system_control(board, nec_priv, request_control); 593 590 } 594 591 595 - void cb7210_interface_clear(gpib_board_t *board, int assert) 592 + static void cb7210_interface_clear(struct gpib_board *board, int assert) 596 593 { 597 594 struct cb7210_priv *priv = board->private_data; 598 595 599 596 nec7210_interface_clear(board, &priv->nec7210_priv, assert); 600 597 } 601 598 602 - void cb7210_remote_enable(gpib_board_t *board, int enable) 599 + static void cb7210_remote_enable(struct gpib_board *board, int enable) 603 600 { 604 601 struct cb7210_priv *priv = board->private_data; 605 602 606 603 nec7210_remote_enable(board, &priv->nec7210_priv, enable); 607 604 } 608 605 609 - int cb7210_enable_eos(gpib_board_t *board, uint8_t eos_byte, int compare_8_bits) 606 + static int cb7210_enable_eos(struct gpib_board *board, uint8_t eos_byte, int compare_8_bits) 610 607 { 611 608 struct cb7210_priv *priv = board->private_data; 612 609 613 610 return nec7210_enable_eos(board, &priv->nec7210_priv, eos_byte, compare_8_bits); 614 611 } 615 612 616 - void cb7210_disable_eos(gpib_board_t *board) 613 + static void cb7210_disable_eos(struct gpib_board *board) 617 614 { 618 615 struct cb7210_priv *priv = board->private_data; 619 616 620 617 nec7210_disable_eos(board, &priv->nec7210_priv); 621 618 } 622 619 623 - unsigned int cb7210_update_status(gpib_board_t *board, unsigned int clear_mask) 620 + static unsigned int cb7210_update_status(struct gpib_board *board, unsigned int clear_mask) 624 621 { 625 622 struct cb7210_priv *priv = board->private_data; 626 623 627 624 return nec7210_update_status(board, &priv->nec7210_priv, clear_mask); 628 625 } 629 626 630 - int cb7210_primary_address(gpib_board_t *board, unsigned int address) 627 + static int cb7210_primary_address(struct gpib_board *board, unsigned int address) 631 628 { 632 629 struct cb7210_priv *priv = board->private_data; 633 630 634 631 return nec7210_primary_address(board, &priv->nec7210_priv, address); 635 632 } 636 633 637 - int cb7210_secondary_address(gpib_board_t *board, unsigned int address, int enable) 634 + static int cb7210_secondary_address(struct gpib_board *board, unsigned int address, int enable) 638 635 { 639 636 struct cb7210_priv *priv = board->private_data; 640 637 641 638 return nec7210_secondary_address(board, &priv->nec7210_priv, address, enable); 642 639 } 643 640 644 - int cb7210_parallel_poll(gpib_board_t *board, uint8_t *result) 641 + static int cb7210_parallel_poll(struct gpib_board *board, uint8_t *result) 645 642 { 646 643 struct cb7210_priv *priv = board->private_data; 647 644 648 645 return nec7210_parallel_poll(board, &priv->nec7210_priv, result); 649 646 } 650 647 651 - void cb7210_parallel_poll_configure(gpib_board_t *board, uint8_t configuration) 648 + static void cb7210_parallel_poll_configure(struct gpib_board *board, uint8_t configuration) 652 649 { 653 650 struct cb7210_priv *priv = board->private_data; 654 651 655 652 nec7210_parallel_poll_configure(board, &priv->nec7210_priv, configuration); 656 653 } 657 654 658 - void cb7210_parallel_poll_response(gpib_board_t *board, int ist) 655 + static void cb7210_parallel_poll_response(struct gpib_board *board, int ist) 659 656 { 660 657 struct cb7210_priv *priv = board->private_data; 661 658 662 659 nec7210_parallel_poll_response(board, &priv->nec7210_priv, ist); 663 660 } 664 661 665 - void cb7210_serial_poll_response(gpib_board_t *board, uint8_t status) 662 + static void cb7210_serial_poll_response(struct gpib_board *board, uint8_t status) 666 663 { 667 664 struct cb7210_priv *priv = board->private_data; 668 665 669 666 nec7210_serial_poll_response(board, &priv->nec7210_priv, status); 670 667 } 671 668 672 - uint8_t cb7210_serial_poll_status(gpib_board_t *board) 669 + static uint8_t cb7210_serial_poll_status(struct gpib_board *board) 673 670 { 674 671 struct cb7210_priv *priv = board->private_data; 675 672 676 673 return nec7210_serial_poll_status(board, &priv->nec7210_priv); 677 674 } 678 675 679 - void cb7210_return_to_local(gpib_board_t *board) 676 + static void cb7210_return_to_local(struct gpib_board *board) 680 677 { 681 678 struct cb7210_priv *priv = board->private_data; 682 679 struct nec7210_priv *nec_priv = &priv->nec7210_priv; ··· 852 849 .return_to_local = cb7210_return_to_local, 853 850 }; 854 851 855 - static int cb7210_allocate_private(gpib_board_t *board) 852 + static int cb7210_allocate_private(struct gpib_board *board) 856 853 { 857 854 struct cb7210_priv *priv; 858 855 859 856 board->private_data = kmalloc(sizeof(struct cb7210_priv), GFP_KERNEL); 860 857 if (!board->private_data) 861 - return -1; 858 + return -ENOMEM; 862 859 priv = board->private_data; 863 860 memset(priv, 0, sizeof(struct cb7210_priv)); 864 861 init_nec7210_private(&priv->nec7210_priv); 865 862 return 0; 866 863 } 867 864 868 - void cb7210_generic_detach(gpib_board_t *board) 865 + static void cb7210_generic_detach(struct gpib_board *board) 869 866 { 870 867 kfree(board->private_data); 871 868 board->private_data = NULL; 872 869 } 873 870 874 871 // generic part of attach functions shared by all cb7210 boards 875 - int cb7210_generic_attach(gpib_board_t *board) 872 + static int cb7210_generic_attach(struct gpib_board *board) 876 873 { 877 874 struct cb7210_priv *cb_priv; 878 875 struct nec7210_priv *nec_priv; ··· 890 887 return 0; 891 888 } 892 889 893 - int cb7210_init(struct cb7210_priv *cb_priv, gpib_board_t *board) 890 + static int cb7210_init(struct cb7210_priv *cb_priv, struct gpib_board *board) 894 891 { 895 892 struct nec7210_priv *nec_priv = &cb_priv->nec7210_priv; 896 893 ··· 920 917 921 918 /* poll so we can detect assertion of ATN */ 922 919 if (gpib_request_pseudo_irq(board, cb_pci_interrupt)) { 923 - pr_err("pc2_gpib: failed to allocate pseudo_irq\n"); 920 + pr_err("failed to allocate pseudo_irq\n"); 924 921 return -1; 925 922 } 926 923 return 0; 927 924 } 928 925 929 - int cb_pci_attach(gpib_board_t *board, const gpib_board_config_t *config) 926 + static int cb_pci_attach(struct gpib_board *board, const gpib_board_config_t *config) 930 927 { 931 928 struct cb7210_priv *cb_priv; 932 929 struct nec7210_priv *nec_priv; ··· 960 957 } 961 958 } 962 959 if (!cb_priv->pci_device) { 963 - pr_warn("cb7210: no supported boards found.\n"); 964 - return -1; 960 + dev_err(board->gpib_dev, "no supported boards found.\n"); 961 + return -ENODEV; 965 962 } 966 963 967 964 if (pci_enable_device(cb_priv->pci_device)) { 968 - pr_err("cb7210: error enabling pci device\n"); 969 - return -1; 965 + dev_err(board->gpib_dev, "error enabling pci device\n"); 966 + return -EIO; 970 967 } 971 968 972 - if (pci_request_regions(cb_priv->pci_device, "cb7210")) 973 - return -1; 969 + if (pci_request_regions(cb_priv->pci_device, DRV_NAME)) 970 + return -EBUSY; 974 971 switch (cb_priv->pci_chip) { 975 972 case PCI_CHIP_AMCC_S5933: 976 973 cb_priv->amcc_iobase = pci_resource_start(cb_priv->pci_device, 0); ··· 982 979 cb_priv->fifo_iobase = nec_priv->iobase; 983 980 break; 984 981 default: 985 - pr_err("cb7210: bug! unhandled pci_chip=%i\n", cb_priv->pci_chip); 982 + dev_err(board->gpib_dev, "bug! unhandled pci_chip=%i\n", cb_priv->pci_chip); 986 983 return -EIO; 987 984 } 988 985 isr_flags |= IRQF_SHARED; 989 - if (request_irq(cb_priv->pci_device->irq, cb_pci_interrupt, isr_flags, "cb7210", board)) { 990 - pr_err("cb7210: can't request IRQ %d\n", cb_priv->pci_device->irq); 991 - return -1; 986 + if (request_irq(cb_priv->pci_device->irq, cb_pci_interrupt, isr_flags, DRV_NAME, board)) { 987 + dev_err(board->gpib_dev, "can't request IRQ %d\n", 988 + cb_priv->pci_device->irq); 989 + return -EBUSY; 992 990 } 993 991 cb_priv->irq = cb_priv->pci_device->irq; 994 992 ··· 1008 1004 return cb7210_init(cb_priv, board); 1009 1005 } 1010 1006 1011 - void cb_pci_detach(gpib_board_t *board) 1007 + static void cb_pci_detach(struct gpib_board *board) 1012 1008 { 1013 1009 struct cb7210_priv *cb_priv = board->private_data; 1014 1010 struct nec7210_priv *nec_priv; ··· 1031 1027 cb7210_generic_detach(board); 1032 1028 } 1033 1029 1034 - int cb_isa_attach(gpib_board_t *board, const gpib_board_config_t *config) 1030 + static int cb_isa_attach(struct gpib_board *board, const gpib_board_config_t *config) 1035 1031 { 1036 1032 int isr_flags = 0; 1037 1033 struct cb7210_priv *cb_priv; ··· 1044 1040 return retval; 1045 1041 cb_priv = board->private_data; 1046 1042 nec_priv = &cb_priv->nec7210_priv; 1047 - if (!request_region(config->ibbase, cb7210_iosize, "cb7210")) { 1048 - pr_err("gpib: ioports starting at 0x%x are already in use\n", config->ibbase); 1049 - return -EIO; 1043 + if (!request_region(config->ibbase, cb7210_iosize, DRV_NAME)) { 1044 + dev_err(board->gpib_dev, "ioports starting at 0x%x are already in use\n", 1045 + config->ibbase); 1046 + return -EBUSY; 1050 1047 } 1051 1048 nec_priv->iobase = config->ibbase; 1052 1049 cb_priv->fifo_iobase = nec7210_iobase(cb_priv); 1053 1050 1054 1051 bits = irq_bits(config->ibirq); 1055 1052 if (bits == 0) 1056 - pr_err("board incapable of using irq %i, try 2-5, 7, 10, or 11\n", config->ibirq); 1053 + dev_err(board->gpib_dev, "board incapable of using irq %i, try 2-5, 7, 10, or 11\n", 1054 + config->ibirq); 1057 1055 1058 1056 // install interrupt handler 1059 - if (request_irq(config->ibirq, cb7210_interrupt, isr_flags, "cb7210", board)) { 1060 - pr_err("gpib: can't request IRQ %d\n", config->ibirq); 1057 + if (request_irq(config->ibirq, cb7210_interrupt, isr_flags, DRV_NAME, board)) { 1058 + dev_err(board->gpib_dev, "failed to obtain IRQ %d\n", config->ibirq); 1061 1059 return -EBUSY; 1062 1060 } 1063 1061 cb_priv->irq = config->ibirq; ··· 1067 1061 return cb7210_init(cb_priv, board); 1068 1062 } 1069 1063 1070 - void cb_isa_detach(gpib_board_t *board) 1064 + static void cb_isa_detach(struct gpib_board *board) 1071 1065 { 1072 1066 struct cb7210_priv *cb_priv = board->private_data; 1073 1067 struct nec7210_priv *nec_priv; ··· 1099 1093 MODULE_DEVICE_TABLE(pci, cb7210_pci_table); 1100 1094 1101 1095 static struct pci_driver cb7210_pci_driver = { 1102 - .name = "cb7210", 1096 + .name = DRV_NAME, 1103 1097 .id_table = cb7210_pci_table, 1104 1098 .probe = &cb7210_pci_probe 1105 1099 }; ··· 1112 1106 * pcmcia skeleton example (presumably David Hinds) 1113 1107 ***************************************************************************/ 1114 1108 1115 - #ifdef GPIB_PCMCIA 1109 + #ifdef CONFIG_GPIB_PCMCIA 1116 1110 1117 1111 #include <linux/kernel.h> 1118 1112 #include <linux/ptrace.h> ··· 1121 1115 1122 1116 #include <pcmcia/cistpl.h> 1123 1117 #include <pcmcia/ds.h> 1124 - 1125 - /* 1126 - * All the PCMCIA modules use PCMCIA_DEBUG to control debugging. If 1127 - * you do not define PCMCIA_DEBUG at all, all the debug code will be 1128 - * left out. If you compile with PCMCIA_DEBUG=0, the debug code will 1129 - * be present but disabled -- but it can then be enabled for specific 1130 - * modules at load time with a 'pc_debug=#' option to insmod. 1131 - */ 1132 - 1133 - #define PCMCIA_DEBUG 1 1134 - 1135 - #ifdef PCMCIA_DEBUG 1136 - static int pc_debug = PCMCIA_DEBUG; 1137 - #define DEBUG(n, args...) do {if (pc_debug > (n)) pr_debug(args); } while (0) 1138 - #else 1139 - #define DEBUG(args...) 1140 - #endif 1141 1118 1142 1119 /* 1143 1120 * The event() function is this driver's Card Services event handler. ··· 1133 1144 1134 1145 static int cb_gpib_config(struct pcmcia_device *link); 1135 1146 static void cb_gpib_release(struct pcmcia_device *link); 1136 - static int cb_pcmcia_attach(gpib_board_t *board, const gpib_board_config_t *config); 1137 - static void cb_pcmcia_detach(gpib_board_t *board); 1147 + static int cb_pcmcia_attach(struct gpib_board *board, const gpib_board_config_t *config); 1148 + static void cb_pcmcia_detach(struct gpib_board *board); 1138 1149 1139 1150 /* 1140 1151 * A linked list of "instances" of the gpib device. Each actual ··· 1167 1178 1168 1179 struct local_info { 1169 1180 struct pcmcia_device *p_dev; 1170 - gpib_board_t *dev; 1181 + struct gpib_board *dev; 1171 1182 }; 1172 1183 1173 1184 /* ··· 1185 1196 struct local_info *info; 1186 1197 1187 1198 // int ret, i; 1188 - 1189 - DEBUG(0, "%s(0x%p)\n", __func__, link); 1190 1199 1191 1200 /* Allocate space for private device-specific data */ 1192 1201 info = kzalloc(sizeof(*info), GFP_KERNEL); ··· 1223 1236 static void cb_gpib_remove(struct pcmcia_device *link) 1224 1237 { 1225 1238 struct local_info *info = link->priv; 1226 - //struct gpib_board_t *dev = info->dev; 1227 - 1228 - DEBUG(0, "%s(0x%p)\n", __func__, link); 1239 + //struct struct gpib_board *dev = info->dev; 1229 1240 1230 1241 if (info->dev) 1231 1242 cb_pcmcia_detach(info->dev); ··· 1252 1267 1253 1268 handle = link; 1254 1269 dev = link->priv; 1255 - DEBUG(0, "%s(0x%p)\n", __func__, link); 1256 1270 1257 1271 retval = pcmcia_loop_config(link, &cb_gpib_config_iteration, NULL); 1258 1272 if (retval) { ··· 1259 1275 cb_gpib_release(link); 1260 1276 return -ENODEV; 1261 1277 } 1262 - 1263 - DEBUG(0, "gpib_cs: manufacturer: 0x%x card: 0x%x\n", link->manf_id, link->card_id); 1264 1278 1265 1279 /* 1266 1280 * This actually configures the PCMCIA socket -- setting up ··· 1271 1289 return -ENODEV; 1272 1290 } 1273 1291 1274 - pr_info("gpib device loaded\n"); 1275 1292 return 0; 1276 1293 } /* gpib_config */ 1277 1294 ··· 1282 1301 1283 1302 static void cb_gpib_release(struct pcmcia_device *link) 1284 1303 { 1285 - DEBUG(0, "%s(0x%p)\n", __func__, link); 1286 1304 pcmcia_disable_device(link); 1287 1305 } 1288 1306 1289 1307 static int cb_gpib_suspend(struct pcmcia_device *link) 1290 1308 { 1291 1309 //struct local_info *info = link->priv; 1292 - //struct gpib_board_t *dev = info->dev; 1293 - DEBUG(0, "%s(0x%p)\n", __func__, link); 1310 + //struct struct gpib_board *dev = info->dev; 1294 1311 1295 1312 if (link->open) 1296 - pr_warn("Device still open ???\n"); 1313 + dev_warn(&link->dev, "Device still open\n"); 1297 1314 //netif_device_detach(dev); 1298 1315 1299 1316 return 0; ··· 1300 1321 static int cb_gpib_resume(struct pcmcia_device *link) 1301 1322 { 1302 1323 //struct local_info *info = link->priv; 1303 - //struct gpib_board_t *dev = info->dev; 1304 - DEBUG(0, "%s(0x%p)\n", __func__, link); 1324 + //struct struct gpib_board *dev = info->dev; 1305 1325 1306 1326 /*if (link->open) { 1307 1327 * ni_gpib_probe(dev); / really? 1308 - * printk("Gpib resumed ???\n"); 1309 1328 * //netif_device_attach(dev); 1310 1329 * 1311 1330 */ ··· 1319 1342 MODULE_DEVICE_TABLE(pcmcia, cb_pcmcia_ids); 1320 1343 1321 1344 static struct pcmcia_driver cb_gpib_cs_driver = { 1345 + .name = "cb_gpib_cs", 1322 1346 .owner = THIS_MODULE, 1323 - .drv = { .name = "cb_gpib_cs", }, 1324 1347 .id_table = cb_pcmcia_ids, 1325 1348 .probe = cb_gpib_probe, 1326 1349 .remove = cb_gpib_remove, ··· 1328 1351 .resume = cb_gpib_resume, 1329 1352 }; 1330 1353 1331 - void cb_pcmcia_cleanup_module(void) 1354 + static void cb_pcmcia_cleanup_module(void) 1332 1355 { 1333 - DEBUG(0, "cb_gpib_cs: unloading\n"); 1334 1356 pcmcia_unregister_driver(&cb_gpib_cs_driver); 1335 1357 } 1336 1358 ··· 1417 1441 .return_to_local = cb7210_return_to_local, 1418 1442 }; 1419 1443 1420 - int cb_pcmcia_attach(gpib_board_t *board, const gpib_board_config_t *config) 1444 + static int cb_pcmcia_attach(struct gpib_board *board, const gpib_board_config_t *config) 1421 1445 { 1422 1446 struct cb7210_priv *cb_priv; 1423 1447 struct nec7210_priv *nec_priv; 1424 1448 int retval; 1425 1449 1426 1450 if (!curr_dev) { 1427 - pr_err("no cb pcmcia cards found\n"); 1428 - return -1; 1451 + dev_err(board->gpib_dev, "no cb pcmcia cards found\n"); 1452 + return -ENODEV; 1429 1453 } 1430 1454 1431 1455 retval = cb7210_generic_attach(board); ··· 1436 1460 nec_priv = &cb_priv->nec7210_priv; 1437 1461 1438 1462 if (!request_region(curr_dev->resource[0]->start, resource_size(curr_dev->resource[0]), 1439 - "cb7210")) { 1440 - pr_err("gpib: ioports starting at 0x%lx are already in use\n", 1441 - (unsigned long)curr_dev->resource[0]->start); 1442 - return -EIO; 1463 + DRV_NAME)) { 1464 + dev_err(board->gpib_dev, "ioports starting at 0x%lx are already in use\n", 1465 + (unsigned long)curr_dev->resource[0]->start); 1466 + return -EBUSY; 1443 1467 } 1444 1468 nec_priv->iobase = curr_dev->resource[0]->start; 1445 1469 cb_priv->fifo_iobase = curr_dev->resource[0]->start; 1446 1470 1447 - if (request_irq(curr_dev->irq, cb7210_interrupt, IRQF_SHARED, 1448 - "cb7210", board)) { 1449 - pr_err("cb7210: failed to request IRQ %d\n", curr_dev->irq); 1450 - return -1; 1471 + if (request_irq(curr_dev->irq, cb7210_interrupt, IRQF_SHARED, DRV_NAME, board)) { 1472 + dev_err(board->gpib_dev, "failed to request IRQ %d\n", curr_dev->irq); 1473 + return -EBUSY; 1451 1474 } 1452 1475 cb_priv->irq = curr_dev->irq; 1453 1476 1454 1477 return cb7210_init(cb_priv, board); 1455 1478 } 1456 1479 1457 - void cb_pcmcia_detach(gpib_board_t *board) 1480 + static void cb_pcmcia_detach(struct gpib_board *board) 1458 1481 { 1459 1482 struct cb7210_priv *cb_priv = board->private_data; 1460 1483 struct nec7210_priv *nec_priv; ··· 1471 1496 cb7210_generic_detach(board); 1472 1497 } 1473 1498 1474 - #endif /* GPIB_PCMCIA */ 1499 + #endif /* CONFIG_GPIB_PCMCIA */ 1475 1500 1476 1501 static int __init cb7210_init_module(void) 1477 1502 { ··· 1479 1504 1480 1505 ret = pci_register_driver(&cb7210_pci_driver); 1481 1506 if (ret) { 1482 - pr_err("cb7210: pci_register_driver failed: error = %d\n", ret); 1507 + pr_err("pci_register_driver failed: error = %d\n", ret); 1483 1508 return ret; 1484 1509 } 1485 1510 1486 1511 ret = gpib_register_driver(&cb_pci_interface, THIS_MODULE); 1487 1512 if (ret) { 1488 - pr_err("cb7210: gpib_register_driver failed: error = %d\n", ret); 1513 + pr_err("gpib_register_driver failed: error = %d\n", ret); 1489 1514 goto err_pci; 1490 1515 } 1491 1516 1492 1517 ret = gpib_register_driver(&cb_isa_interface, THIS_MODULE); 1493 1518 if (ret) { 1494 - pr_err("cb7210: gpib_register_driver failed: error = %d\n", ret); 1519 + pr_err("gpib_register_driver failed: error = %d\n", ret); 1495 1520 goto err_isa; 1496 1521 } 1497 1522 1498 1523 ret = gpib_register_driver(&cb_pci_accel_interface, THIS_MODULE); 1499 1524 if (ret) { 1500 - pr_err("cb7210: gpib_register_driver failed: error = %d\n", ret); 1525 + pr_err("gpib_register_driver failed: error = %d\n", ret); 1501 1526 goto err_pci_accel; 1502 1527 } 1503 1528 1504 1529 ret = gpib_register_driver(&cb_pci_unaccel_interface, THIS_MODULE); 1505 1530 if (ret) { 1506 - pr_err("cb7210: gpib_register_driver failed: error = %d\n", ret); 1531 + pr_err("gpib_register_driver failed: error = %d\n", ret); 1507 1532 goto err_pci_unaccel; 1508 1533 } 1509 1534 1510 1535 ret = gpib_register_driver(&cb_isa_accel_interface, THIS_MODULE); 1511 1536 if (ret) { 1512 - pr_err("cb7210: gpib_register_driver failed: error = %d\n", ret); 1537 + pr_err("gpib_register_driver failed: error = %d\n", ret); 1513 1538 goto err_isa_accel; 1514 1539 } 1515 1540 1516 1541 ret = gpib_register_driver(&cb_isa_unaccel_interface, THIS_MODULE); 1517 1542 if (ret) { 1518 - pr_err("cb7210: gpib_register_driver failed: error = %d\n", ret); 1543 + pr_err("gpib_register_driver failed: error = %d\n", ret); 1519 1544 goto err_isa_unaccel; 1520 1545 } 1521 1546 1522 - #ifdef GPIB_PCMCIA 1547 + #ifdef CONFIG_GPIB_PCMCIA 1523 1548 ret = gpib_register_driver(&cb_pcmcia_interface, THIS_MODULE); 1524 1549 if (ret) { 1525 - pr_err("cb7210: gpib_register_driver failed: error = %d\n", ret); 1550 + pr_err("gpib_register_driver failed: error = %d\n", ret); 1526 1551 goto err_pcmcia; 1527 1552 } 1528 1553 1529 1554 ret = gpib_register_driver(&cb_pcmcia_accel_interface, THIS_MODULE); 1530 1555 if (ret) { 1531 - pr_err("cb7210: gpib_register_driver failed: error = %d\n", ret); 1556 + pr_err("gpib_register_driver failed: error = %d\n", ret); 1532 1557 goto err_pcmcia_accel; 1533 1558 } 1534 1559 1535 1560 ret = gpib_register_driver(&cb_pcmcia_unaccel_interface, THIS_MODULE); 1536 1561 if (ret) { 1537 - pr_err("cb7210: gpib_register_driver failed: error = %d\n", ret); 1562 + pr_err("gpib_register_driver failed: error = %d\n", ret); 1538 1563 goto err_pcmcia_unaccel; 1539 1564 } 1540 1565 1541 1566 ret = pcmcia_register_driver(&cb_gpib_cs_driver); 1542 1567 if (ret) { 1543 - pr_err("cb7210: pcmcia_register_driver failed: error = %d\n", ret); 1568 + pr_err("pcmcia_register_driver failed: error = %d\n", ret); 1544 1569 goto err_pcmcia_driver; 1545 1570 } 1546 1571 #endif 1547 1572 1548 1573 return 0; 1549 1574 1550 - #ifdef GPIB_PCMCIA 1575 + #ifdef CONFIG_GPIB_PCMCIA 1551 1576 err_pcmcia_driver: 1552 1577 gpib_unregister_driver(&cb_pcmcia_unaccel_interface); 1553 1578 err_pcmcia_unaccel: ··· 1581 1606 gpib_unregister_driver(&cb_pci_unaccel_interface); 1582 1607 gpib_unregister_driver(&cb_isa_accel_interface); 1583 1608 gpib_unregister_driver(&cb_isa_unaccel_interface); 1584 - #ifdef GPIB_PCMCIA 1609 + #ifdef CONFIG_GPIB_PCMCIA 1585 1610 gpib_unregister_driver(&cb_pcmcia_interface); 1586 1611 gpib_unregister_driver(&cb_pcmcia_accel_interface); 1587 1612 gpib_unregister_driver(&cb_pcmcia_unaccel_interface);
-45
drivers/staging/gpib/cb7210/cb7210.h
··· 36 36 unsigned in_fifo_half_full : 1; 37 37 }; 38 38 39 - // interrupt service routines 40 - irqreturn_t cb_pci_interrupt(int irq, void *arg); 41 - irqreturn_t cb7210_interrupt(int irq, void *arg); 42 - irqreturn_t cb7210_internal_interrupt(gpib_board_t *board); 43 - 44 - // interface functions 45 - int cb7210_read(gpib_board_t *board, uint8_t *buffer, size_t length, 46 - int *end, size_t *bytes_read); 47 - int cb7210_accel_read(gpib_board_t *board, uint8_t *buffer, size_t length, 48 - int *end, size_t *bytes_read); 49 - int cb7210_write(gpib_board_t *board, uint8_t *buffer, size_t length, 50 - int send_eoi, size_t *bytes_written); 51 - int cb7210_accel_write(gpib_board_t *board, uint8_t *buffer, size_t length, 52 - int send_eoi, size_t *bytes_written); 53 - int cb7210_command(gpib_board_t *board, uint8_t *buffer, size_t length, size_t *bytes_written); 54 - int cb7210_take_control(gpib_board_t *board, int synchronous); 55 - int cb7210_go_to_standby(gpib_board_t *board); 56 - void cb7210_request_system_control(gpib_board_t *board, int request_control); 57 - void cb7210_interface_clear(gpib_board_t *board, int assert); 58 - void cb7210_remote_enable(gpib_board_t *board, int enable); 59 - int cb7210_enable_eos(gpib_board_t *board, uint8_t eos_byte, 60 - int compare_8_bits); 61 - void cb7210_disable_eos(gpib_board_t *board); 62 - unsigned int cb7210_update_status(gpib_board_t *board, unsigned int clear_mask); 63 - int cb7210_primary_address(gpib_board_t *board, unsigned int address); 64 - int cb7210_secondary_address(gpib_board_t *board, unsigned int address, 65 - int enable); 66 - int cb7210_parallel_poll(gpib_board_t *board, uint8_t *result); 67 - void cb7210_serial_poll_response(gpib_board_t *board, uint8_t status); 68 - uint8_t cb7210_serial_poll_status(gpib_board_t *board); 69 - void cb7210_parallel_poll_configure(gpib_board_t *board, uint8_t configuration); 70 - void cb7210_parallel_poll_response(gpib_board_t *board, int ist); 71 - int cb7210_line_status(const gpib_board_t *board); 72 - unsigned int cb7210_t1_delay(gpib_board_t *board, unsigned int nano_sec); 73 - void cb7210_return_to_local(gpib_board_t *board); 74 - 75 - // utility functions 76 - void cb7210_generic_detach(gpib_board_t *board); 77 - int cb7210_generic_attach(gpib_board_t *board); 78 - int cb7210_init(struct cb7210_priv *priv, gpib_board_t *board); 79 - 80 - // pcmcia init/cleanup 81 - int cb_pcmcia_init_module(void); 82 - void cb_pcmcia_cleanup_module(void); 83 - 84 39 // pci-gpib register offset 85 40 static const int cb7210_reg_offset = 1; 86 41
-29
drivers/staging/gpib/cec/cec.h
··· 16 16 unsigned int irq; 17 17 }; 18 18 19 - // interface functions 20 - int cec_read(gpib_board_t *board, uint8_t *buffer, size_t length, int *end, size_t *bytes_read); 21 - int cec_write(gpib_board_t *board, uint8_t *buffer, size_t length, int send_eoi, 22 - size_t *bytes_written); 23 - int cec_command(gpib_board_t *board, uint8_t *buffer, size_t length, size_t *bytes_written); 24 - int cec_take_control(gpib_board_t *board, int synchronous); 25 - int cec_go_to_standby(gpib_board_t *board); 26 - void cec_request_system_control(gpib_board_t *board, int request_control); 27 - void cec_interface_clear(gpib_board_t *board, int assert); 28 - void cec_remote_enable(gpib_board_t *board, int enable); 29 - int cec_enable_eos(gpib_board_t *board, uint8_t eos_byte, int compare_8_bits); 30 - void cec_disable_eos(gpib_board_t *board); 31 - unsigned int cec_update_status(gpib_board_t *board, unsigned int clear_mask); 32 - int cec_primary_address(gpib_board_t *board, unsigned int address); 33 - int cec_secondary_address(gpib_board_t *board, unsigned int address, int enable); 34 - int cec_parallel_poll(gpib_board_t *board, uint8_t *result); 35 - void cec_parallel_poll_configure(gpib_board_t *board, uint8_t configuration); 36 - void cec_parallel_poll_response(gpib_board_t *board, int ist); 37 - void cec_serial_poll_response(gpib_board_t *board, uint8_t status); 38 - void cec_return_to_local(gpib_board_t *board); 39 - 40 - // interrupt service routines 41 - irqreturn_t cec_interrupt(int irq, void *arg); 42 - 43 - // utility functions 44 - void cec_free_private(gpib_board_t *board); 45 - int cec_generic_attach(gpib_board_t *board); 46 - void cec_init(struct cec_priv *priv, const gpib_board_t *board); 47 - 48 19 // offset between consecutive nec7210 registers 49 20 static const int cec_reg_offset = 1;
+50 -46
drivers/staging/gpib/cec/cec_gpib.c
··· 4 4 * copyright : (C) 2002 by Frank Mori Hess 5 5 ***************************************************************************/ 6 6 7 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 8 + #define dev_fmt pr_fmt 9 + #define DRV_NAME KBUILD_MODNAME 10 + 7 11 #include "cec.h" 8 12 #include <linux/pci.h> 9 13 #include <linux/io.h> ··· 23 19 * GPIB interrupt service routines 24 20 */ 25 21 26 - irqreturn_t cec_interrupt(int irq, void *arg) 22 + static irqreturn_t cec_interrupt(int irq, void *arg) 27 23 { 28 - gpib_board_t *board = arg; 24 + struct gpib_board *board = arg; 29 25 struct cec_priv *priv = board->private_data; 30 26 unsigned long flags; 31 27 irqreturn_t retval; ··· 40 36 #define CEC_DEV_ID 0x5cec 41 37 #define CEC_SUBID 0x9050 42 38 43 - static int cec_pci_attach(gpib_board_t *board, const gpib_board_config_t *config); 39 + static int cec_pci_attach(struct gpib_board *board, const gpib_board_config_t *config); 44 40 45 - static void cec_pci_detach(gpib_board_t *board); 41 + static void cec_pci_detach(struct gpib_board *board); 46 42 47 43 // wrappers for interface functions 48 - int cec_read(gpib_board_t *board, uint8_t *buffer, size_t length, int *end, size_t *bytes_read) 44 + static int cec_read(struct gpib_board *board, uint8_t *buffer, size_t length, int *end, 45 + size_t *bytes_read) 49 46 { 50 47 struct cec_priv *priv = board->private_data; 51 48 52 49 return nec7210_read(board, &priv->nec7210_priv, buffer, length, end, bytes_read); 53 50 } 54 51 55 - int cec_write(gpib_board_t *board, uint8_t *buffer, size_t length, int send_eoi, 56 - size_t *bytes_written) 52 + static int cec_write(struct gpib_board *board, uint8_t *buffer, size_t length, int send_eoi, 53 + size_t *bytes_written) 57 54 { 58 55 struct cec_priv *priv = board->private_data; 59 56 60 57 return nec7210_write(board, &priv->nec7210_priv, buffer, length, send_eoi, bytes_written); 61 58 } 62 59 63 - int cec_command(gpib_board_t *board, uint8_t *buffer, size_t length, size_t *bytes_written) 60 + static int cec_command(struct gpib_board *board, uint8_t *buffer, 61 + size_t length, size_t *bytes_written) 64 62 { 65 63 struct cec_priv *priv = board->private_data; 66 64 67 65 return nec7210_command(board, &priv->nec7210_priv, buffer, length, bytes_written); 68 66 } 69 67 70 - int cec_take_control(gpib_board_t *board, int synchronous) 68 + static int cec_take_control(struct gpib_board *board, int synchronous) 71 69 { 72 70 struct cec_priv *priv = board->private_data; 73 71 74 72 return nec7210_take_control(board, &priv->nec7210_priv, synchronous); 75 73 } 76 74 77 - int cec_go_to_standby(gpib_board_t *board) 75 + static int cec_go_to_standby(struct gpib_board *board) 78 76 { 79 77 struct cec_priv *priv = board->private_data; 80 78 81 79 return nec7210_go_to_standby(board, &priv->nec7210_priv); 82 80 } 83 81 84 - void cec_request_system_control(gpib_board_t *board, int request_control) 82 + static void cec_request_system_control(struct gpib_board *board, int request_control) 85 83 { 86 84 struct cec_priv *priv = board->private_data; 87 85 88 86 nec7210_request_system_control(board, &priv->nec7210_priv, request_control); 89 87 } 90 88 91 - void cec_interface_clear(gpib_board_t *board, int assert) 89 + static void cec_interface_clear(struct gpib_board *board, int assert) 92 90 { 93 91 struct cec_priv *priv = board->private_data; 94 92 95 93 nec7210_interface_clear(board, &priv->nec7210_priv, assert); 96 94 } 97 95 98 - void cec_remote_enable(gpib_board_t *board, int enable) 96 + static void cec_remote_enable(struct gpib_board *board, int enable) 99 97 { 100 98 struct cec_priv *priv = board->private_data; 101 99 102 100 nec7210_remote_enable(board, &priv->nec7210_priv, enable); 103 101 } 104 102 105 - int cec_enable_eos(gpib_board_t *board, uint8_t eos_byte, int compare_8_bits) 103 + static int cec_enable_eos(struct gpib_board *board, uint8_t eos_byte, int compare_8_bits) 106 104 { 107 105 struct cec_priv *priv = board->private_data; 108 106 109 107 return nec7210_enable_eos(board, &priv->nec7210_priv, eos_byte, compare_8_bits); 110 108 } 111 109 112 - void cec_disable_eos(gpib_board_t *board) 110 + static void cec_disable_eos(struct gpib_board *board) 113 111 { 114 112 struct cec_priv *priv = board->private_data; 115 113 116 114 nec7210_disable_eos(board, &priv->nec7210_priv); 117 115 } 118 116 119 - unsigned int cec_update_status(gpib_board_t *board, unsigned int clear_mask) 117 + static unsigned int cec_update_status(struct gpib_board *board, unsigned int clear_mask) 120 118 { 121 119 struct cec_priv *priv = board->private_data; 122 120 123 121 return nec7210_update_status(board, &priv->nec7210_priv, clear_mask); 124 122 } 125 123 126 - int cec_primary_address(gpib_board_t *board, unsigned int address) 124 + static int cec_primary_address(struct gpib_board *board, unsigned int address) 127 125 { 128 126 struct cec_priv *priv = board->private_data; 129 127 130 128 return nec7210_primary_address(board, &priv->nec7210_priv, address); 131 129 } 132 130 133 - int cec_secondary_address(gpib_board_t *board, unsigned int address, int enable) 131 + static int cec_secondary_address(struct gpib_board *board, unsigned int address, int enable) 134 132 { 135 133 struct cec_priv *priv = board->private_data; 136 134 137 135 return nec7210_secondary_address(board, &priv->nec7210_priv, address, enable); 138 136 } 139 137 140 - int cec_parallel_poll(gpib_board_t *board, uint8_t *result) 138 + static int cec_parallel_poll(struct gpib_board *board, uint8_t *result) 141 139 { 142 140 struct cec_priv *priv = board->private_data; 143 141 144 142 return nec7210_parallel_poll(board, &priv->nec7210_priv, result); 145 143 } 146 144 147 - void cec_parallel_poll_configure(gpib_board_t *board, uint8_t config) 145 + static void cec_parallel_poll_configure(struct gpib_board *board, uint8_t config) 148 146 { 149 147 struct cec_priv *priv = board->private_data; 150 148 151 149 nec7210_parallel_poll_configure(board, &priv->nec7210_priv, config); 152 150 } 153 151 154 - void cec_parallel_poll_response(gpib_board_t *board, int ist) 152 + static void cec_parallel_poll_response(struct gpib_board *board, int ist) 155 153 { 156 154 struct cec_priv *priv = board->private_data; 157 155 158 156 nec7210_parallel_poll_response(board, &priv->nec7210_priv, ist); 159 157 } 160 158 161 - void cec_serial_poll_response(gpib_board_t *board, uint8_t status) 159 + static void cec_serial_poll_response(struct gpib_board *board, uint8_t status) 162 160 { 163 161 struct cec_priv *priv = board->private_data; 164 162 165 163 nec7210_serial_poll_response(board, &priv->nec7210_priv, status); 166 164 } 167 165 168 - static uint8_t cec_serial_poll_status(gpib_board_t *board) 166 + static uint8_t cec_serial_poll_status(struct gpib_board *board) 169 167 { 170 168 struct cec_priv *priv = board->private_data; 171 169 172 170 return nec7210_serial_poll_status(board, &priv->nec7210_priv); 173 171 } 174 172 175 - static unsigned int cec_t1_delay(gpib_board_t *board, unsigned int nano_sec) 173 + static int cec_t1_delay(struct gpib_board *board, unsigned int nano_sec) 176 174 { 177 175 struct cec_priv *priv = board->private_data; 178 176 179 177 return nec7210_t1_delay(board, &priv->nec7210_priv, nano_sec); 180 178 } 181 179 182 - void cec_return_to_local(gpib_board_t *board) 180 + static void cec_return_to_local(struct gpib_board *board) 183 181 { 184 182 struct cec_priv *priv = board->private_data; 185 183 ··· 216 210 .return_to_local = cec_return_to_local, 217 211 }; 218 212 219 - static int cec_allocate_private(gpib_board_t *board) 213 + static int cec_allocate_private(struct gpib_board *board) 220 214 { 221 215 struct cec_priv *priv; 222 216 ··· 229 223 return 0; 230 224 } 231 225 232 - void cec_free_private(gpib_board_t *board) 226 + static void cec_free_private(struct gpib_board *board) 233 227 { 234 228 kfree(board->private_data); 235 229 board->private_data = NULL; 236 230 } 237 231 238 - int cec_generic_attach(gpib_board_t *board) 232 + static int cec_generic_attach(struct gpib_board *board) 239 233 { 240 234 struct cec_priv *cec_priv; 241 235 struct nec7210_priv *nec_priv; ··· 253 247 return 0; 254 248 } 255 249 256 - void cec_init(struct cec_priv *cec_priv, const gpib_board_t *board) 250 + static void cec_init(struct cec_priv *cec_priv, const struct gpib_board *board) 257 251 { 258 252 struct nec7210_priv *nec_priv = &cec_priv->nec7210_priv; 259 253 ··· 265 259 nec7210_board_online(nec_priv, board); 266 260 } 267 261 268 - int cec_pci_attach(gpib_board_t *board, const gpib_board_config_t *config) 262 + static int cec_pci_attach(struct gpib_board *board, const gpib_board_config_t *config) 269 263 { 270 264 struct cec_priv *cec_priv; 271 265 struct nec7210_priv *nec_priv; ··· 289 283 break; 290 284 } 291 285 if (!cec_priv->pci_device) { 292 - pr_err("gpib: no cec PCI board found\n"); 293 - return -1; 286 + dev_err(board->gpib_dev, "no cec PCI board found\n"); 287 + return -ENODEV; 294 288 } 295 289 296 290 if (pci_enable_device(cec_priv->pci_device)) { 297 - pr_err("error enabling pci device\n"); 298 - return -1; 291 + dev_err(board->gpib_dev, "error enabling pci device\n"); 292 + return -EIO; 299 293 } 300 294 301 295 if (pci_request_regions(cec_priv->pci_device, "cec-gpib")) 302 - return -1; 296 + return -EBUSY; 303 297 304 298 cec_priv->plx_iobase = pci_resource_start(cec_priv->pci_device, 1); 305 - pr_info(" plx9050 base address 0x%lx\n", cec_priv->plx_iobase); 306 - nec_priv->iobase = pci_resource_start(cec_priv->pci_device, 3); 307 - pr_info(" nec7210 base address 0x%x\n", nec_priv->iobase); 299 + nec_priv->iobase = pci_resource_start(cec_priv->pci_device, 3); 308 300 309 301 isr_flags |= IRQF_SHARED; 310 - if (request_irq(cec_priv->pci_device->irq, cec_interrupt, isr_flags, "pci-gpib", board)) { 311 - pr_err("gpib: can't request IRQ %d\n", cec_priv->pci_device->irq); 312 - return -1; 302 + if (request_irq(cec_priv->pci_device->irq, cec_interrupt, isr_flags, DRV_NAME, board)) { 303 + dev_err(board->gpib_dev, "failed to obtain IRQ %d\n", cec_priv->pci_device->irq); 304 + return -EBUSY; 313 305 } 314 306 cec_priv->irq = cec_priv->pci_device->irq; 315 307 if (gpib_request_pseudo_irq(board, cec_interrupt)) { 316 - pr_err("cec: failed to allocate pseudo irq\n"); 308 + dev_err(board->gpib_dev, "failed to allocate pseudo irq\n"); 317 309 return -1; 318 310 } 319 311 cec_init(cec_priv, board); ··· 323 319 return 0; 324 320 } 325 321 326 - void cec_pci_detach(gpib_board_t *board) 322 + static void cec_pci_detach(struct gpib_board *board) 327 323 { 328 324 struct cec_priv *cec_priv = board->private_data; 329 325 struct nec7210_priv *nec_priv; ··· 358 354 MODULE_DEVICE_TABLE(pci, cec_pci_table); 359 355 360 356 static struct pci_driver cec_pci_driver = { 361 - .name = "cec_gpib", 357 + .name = DRV_NAME, 362 358 .id_table = cec_pci_table, 363 359 .probe = &cec_pci_probe 364 360 }; ··· 369 365 370 366 result = pci_register_driver(&cec_pci_driver); 371 367 if (result) { 372 - pr_err("cec_gpib: pci_register_driver failed: error = %d\n", result); 368 + pr_err("pci_register_driver failed: error = %d\n", result); 373 369 return result; 374 370 } 375 371 376 372 result = gpib_register_driver(&cec_pci_interface, THIS_MODULE); 377 373 if (result) { 378 - pr_err("cec_gpib: gpib_register_driver failed: error = %d\n", result); 374 + pr_err("gpib_register_driver failed: error = %d\n", result); 379 375 return result; 380 376 } 381 377
+151 -177
drivers/staging/gpib/common/gpib_os.c
··· 5 5 *************************************************************************** 6 6 */ 7 7 8 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 9 + #define dev_fmt pr_fmt 10 + 8 11 #include "ibsys.h" 9 12 #include <linux/module.h> 10 13 #include <linux/wait.h> ··· 26 23 MODULE_DESCRIPTION("GPIB base support"); 27 24 MODULE_ALIAS_CHARDEV_MAJOR(GPIB_CODE); 28 25 29 - static int board_type_ioctl(gpib_file_private_t *file_priv, gpib_board_t *board, unsigned long arg); 30 - static int read_ioctl(gpib_file_private_t *file_priv, gpib_board_t *board, 26 + static int board_type_ioctl(gpib_file_private_t *file_priv, struct gpib_board *board, unsigned long arg); 27 + static int read_ioctl(gpib_file_private_t *file_priv, struct gpib_board *board, 31 28 unsigned long arg); 32 - static int write_ioctl(gpib_file_private_t *file_priv, gpib_board_t *board, 29 + static int write_ioctl(gpib_file_private_t *file_priv, struct gpib_board *board, 33 30 unsigned long arg); 34 - static int command_ioctl(gpib_file_private_t *file_priv, gpib_board_t *board, 31 + static int command_ioctl(gpib_file_private_t *file_priv, struct gpib_board *board, 35 32 unsigned long arg); 36 - static int open_dev_ioctl(struct file *filep, gpib_board_t *board, unsigned long arg); 37 - static int close_dev_ioctl(struct file *filep, gpib_board_t *board, unsigned long arg); 38 - static int serial_poll_ioctl(gpib_board_t *board, unsigned long arg); 39 - static int wait_ioctl(gpib_file_private_t *file_priv, gpib_board_t *board, unsigned long arg); 40 - static int parallel_poll_ioctl(gpib_board_t *board, unsigned long arg); 41 - static int online_ioctl(gpib_board_t *board, unsigned long arg); 42 - static int remote_enable_ioctl(gpib_board_t *board, unsigned long arg); 43 - static int take_control_ioctl(gpib_board_t *board, unsigned long arg); 44 - static int line_status_ioctl(gpib_board_t *board, unsigned long arg); 45 - static int pad_ioctl(gpib_board_t *board, gpib_file_private_t *file_priv, 33 + static int open_dev_ioctl(struct file *filep, struct gpib_board *board, unsigned long arg); 34 + static int close_dev_ioctl(struct file *filep, struct gpib_board *board, unsigned long arg); 35 + static int serial_poll_ioctl(struct gpib_board *board, unsigned long arg); 36 + static int wait_ioctl(gpib_file_private_t *file_priv, struct gpib_board *board, unsigned long arg); 37 + static int parallel_poll_ioctl(struct gpib_board *board, unsigned long arg); 38 + static int online_ioctl(struct gpib_board *board, unsigned long arg); 39 + static int remote_enable_ioctl(struct gpib_board *board, unsigned long arg); 40 + static int take_control_ioctl(struct gpib_board *board, unsigned long arg); 41 + static int line_status_ioctl(struct gpib_board *board, unsigned long arg); 42 + static int pad_ioctl(struct gpib_board *board, gpib_file_private_t *file_priv, 46 43 unsigned long arg); 47 - static int sad_ioctl(gpib_board_t *board, gpib_file_private_t *file_priv, 44 + static int sad_ioctl(struct gpib_board *board, gpib_file_private_t *file_priv, 48 45 unsigned long arg); 49 - static int eos_ioctl(gpib_board_t *board, unsigned long arg); 50 - static int request_service_ioctl(gpib_board_t *board, unsigned long arg); 51 - static int request_service2_ioctl(gpib_board_t *board, unsigned long arg); 46 + static int eos_ioctl(struct gpib_board *board, unsigned long arg); 47 + static int request_service_ioctl(struct gpib_board *board, unsigned long arg); 48 + static int request_service2_ioctl(struct gpib_board *board, unsigned long arg); 52 49 static int iobase_ioctl(gpib_board_config_t *config, unsigned long arg); 53 50 static int irq_ioctl(gpib_board_config_t *config, unsigned long arg); 54 51 static int dma_ioctl(gpib_board_config_t *config, unsigned long arg); 55 - static int autospoll_ioctl(gpib_board_t *board, gpib_file_private_t *file_priv, 52 + static int autospoll_ioctl(struct gpib_board *board, gpib_file_private_t *file_priv, 56 53 unsigned long arg); 57 - static int mutex_ioctl(gpib_board_t *board, gpib_file_private_t *file_priv, 54 + static int mutex_ioctl(struct gpib_board *board, gpib_file_private_t *file_priv, 58 55 unsigned long arg); 59 - static int timeout_ioctl(gpib_board_t *board, unsigned long arg); 60 - static int status_bytes_ioctl(gpib_board_t *board, unsigned long arg); 61 - static int board_info_ioctl(const gpib_board_t *board, unsigned long arg); 62 - static int ppc_ioctl(gpib_board_t *board, unsigned long arg); 63 - static int set_local_ppoll_mode_ioctl(gpib_board_t *board, unsigned long arg); 64 - static int get_local_ppoll_mode_ioctl(gpib_board_t *board, unsigned long arg); 65 - static int query_board_rsv_ioctl(gpib_board_t *board, unsigned long arg); 66 - static int interface_clear_ioctl(gpib_board_t *board, unsigned long arg); 56 + static int timeout_ioctl(struct gpib_board *board, unsigned long arg); 57 + static int status_bytes_ioctl(struct gpib_board *board, unsigned long arg); 58 + static int board_info_ioctl(const struct gpib_board *board, unsigned long arg); 59 + static int ppc_ioctl(struct gpib_board *board, unsigned long arg); 60 + static int set_local_ppoll_mode_ioctl(struct gpib_board *board, unsigned long arg); 61 + static int get_local_ppoll_mode_ioctl(struct gpib_board *board, unsigned long arg); 62 + static int query_board_rsv_ioctl(struct gpib_board *board, unsigned long arg); 63 + static int interface_clear_ioctl(struct gpib_board *board, unsigned long arg); 67 64 static int select_pci_ioctl(gpib_board_config_t *config, unsigned long arg); 68 65 static int select_device_path_ioctl(gpib_board_config_t *config, unsigned long arg); 69 - static int event_ioctl(gpib_board_t *board, unsigned long arg); 70 - static int request_system_control_ioctl(gpib_board_t *board, unsigned long arg); 71 - static int t1_delay_ioctl(gpib_board_t *board, unsigned long arg); 66 + static int event_ioctl(struct gpib_board *board, unsigned long arg); 67 + static int request_system_control_ioctl(struct gpib_board *board, unsigned long arg); 68 + static int t1_delay_ioctl(struct gpib_board *board, unsigned long arg); 72 69 73 - static int cleanup_open_devices(gpib_file_private_t *file_priv, gpib_board_t *board); 70 + static int cleanup_open_devices(gpib_file_private_t *file_priv, struct gpib_board *board); 74 71 75 - static int pop_gpib_event_nolock(gpib_board_t *board, gpib_event_queue_t *queue, short *event_type); 72 + static int pop_gpib_event_nolock(struct gpib_board *board, gpib_event_queue_t *queue, short *event_type); 76 73 77 74 /* 78 75 * Timer functions ··· 82 79 83 80 static void watchdog_timeout(struct timer_list *t) 84 81 { 85 - gpib_board_t *board = from_timer(board, t, timer); 82 + struct gpib_board *board = from_timer(board, t, timer); 86 83 87 84 set_bit(TIMO_NUM, &board->status); 88 85 wake_up_interruptible(&board->wait); 89 86 } 90 87 91 88 /* install timer interrupt handler */ 92 - void os_start_timer(gpib_board_t *board, unsigned int usec_timeout) 89 + void os_start_timer(struct gpib_board *board, unsigned int usec_timeout) 93 90 /* Starts the timeout task */ 94 91 { 95 92 if (timer_pending(&board->timer)) { 96 - pr_err("gpib: bug! timer already running?\n"); 93 + dev_err(board->gpib_dev, "bug! timer already running?\n"); 97 94 return; 98 95 } 99 96 clear_bit(TIMO_NUM, &board->status); ··· 105 102 } 106 103 } 107 104 108 - void os_remove_timer(gpib_board_t *board) 105 + void os_remove_timer(struct gpib_board *board) 109 106 /* Removes the timeout task */ 110 107 { 111 108 if (timer_pending(&board->timer)) 112 109 del_timer_sync(&board->timer); 113 110 } 114 111 115 - int io_timed_out(gpib_board_t *board) 112 + int io_timed_out(struct gpib_board *board) 116 113 { 117 114 if (test_bit(TIMO_NUM, &board->status)) 118 115 return 1; ··· 140 137 mod_timer(&pseudo_irq->timer, jiffies + pseudo_irq_period()); 141 138 } 142 139 143 - int gpib_request_pseudo_irq(gpib_board_t *board, irqreturn_t (*handler)(int, void *)) 140 + int gpib_request_pseudo_irq(struct gpib_board *board, irqreturn_t (*handler)(int, void *)) 144 141 { 145 142 if (timer_pending(&board->pseudo_irq.timer) || board->pseudo_irq.handler) { 146 - pr_err("gpib: only one pseudo interrupt per board allowed\n"); 143 + dev_err(board->gpib_dev, "only one pseudo interrupt per board allowed\n"); 147 144 return -1; 148 145 } 149 146 ··· 159 156 } 160 157 EXPORT_SYMBOL(gpib_request_pseudo_irq); 161 158 162 - void gpib_free_pseudo_irq(gpib_board_t *board) 159 + void gpib_free_pseudo_irq(struct gpib_board *board) 163 160 { 164 161 atomic_set(&board->pseudo_irq.active, 0); 165 162 ··· 178 175 } 179 176 180 177 // push status byte onto back of status byte fifo 181 - int push_status_byte(gpib_board_t *board, gpib_status_queue_t *device, u8 poll_byte) 178 + int push_status_byte(struct gpib_board *board, gpib_status_queue_t *device, u8 poll_byte) 182 179 { 183 180 struct list_head *head = &device->status_bytes; 184 181 status_byte_t *status; ··· 212 209 } 213 210 214 211 // pop status byte from front of status byte fifo 215 - int pop_status_byte(gpib_board_t *board, gpib_status_queue_t *device, u8 *poll_byte) 212 + int pop_status_byte(struct gpib_board *board, gpib_status_queue_t *device, u8 *poll_byte) 216 213 { 217 214 struct list_head *head = &device->status_bytes; 218 215 struct list_head *front = head->next; ··· 243 240 return 0; 244 241 } 245 242 246 - gpib_status_queue_t *get_gpib_status_queue(gpib_board_t *board, unsigned int pad, int sad) 243 + gpib_status_queue_t *get_gpib_status_queue(struct gpib_board *board, unsigned int pad, int sad) 247 244 { 248 245 gpib_status_queue_t *device; 249 246 struct list_head *list_ptr; ··· 258 255 return NULL; 259 256 } 260 257 261 - int get_serial_poll_byte(gpib_board_t *board, unsigned int pad, int sad, unsigned int usec_timeout, 258 + int get_serial_poll_byte(struct gpib_board *board, unsigned int pad, int sad, unsigned int usec_timeout, 262 259 uint8_t *poll_byte) 263 260 { 264 261 gpib_status_queue_t *device; 265 - 266 - dev_dbg(board->gpib_dev, "%s:()\n", __func__); 267 262 268 263 device = get_gpib_status_queue(board, pad, sad); 269 264 if (num_status_bytes(device)) ··· 270 269 return dvrsp(board, pad, sad, usec_timeout, poll_byte); 271 270 } 272 271 273 - int autopoll_all_devices(gpib_board_t *board) 272 + int autopoll_all_devices(struct gpib_board *board) 274 273 { 275 274 int retval; 276 275 277 - dev_dbg(board->gpib_dev, "entering %s()\n", __func__); 278 276 if (mutex_lock_interruptible(&board->user_mutex)) 279 277 return -ERESTARTSYS; 280 278 if (mutex_lock_interruptible(&board->big_gpib_mutex)) { ··· 290 290 return retval; 291 291 } 292 292 293 - dev_dbg(board->gpib_dev, "%s complete\n", __func__); 293 + dev_dbg(board->gpib_dev, "complete\n"); 294 294 /* need to wake wait queue in case someone is 295 295 * waiting on RQS 296 296 */ ··· 301 301 return retval; 302 302 } 303 303 304 - static int setup_serial_poll(gpib_board_t *board, unsigned int usec_timeout) 304 + static int setup_serial_poll(struct gpib_board *board, unsigned int usec_timeout) 305 305 { 306 306 u8 cmd_string[8]; 307 307 int i; 308 308 size_t bytes_written; 309 309 int ret; 310 - 311 - dev_dbg(board->gpib_dev, "entering %s()\n", __func__); 312 310 313 311 os_start_timer(board, usec_timeout); 314 312 ret = ibcac(board, 1, 1); ··· 324 326 325 327 ret = board->interface->command(board, cmd_string, i, &bytes_written); 326 328 if (ret < 0 || bytes_written < i) { 327 - pr_err("gpib: failed to setup serial poll\n"); 329 + dev_dbg(board->gpib_dev, "failed to setup serial poll\n"); 328 330 os_remove_timer(board); 329 331 return -EIO; 330 332 } ··· 333 335 return 0; 334 336 } 335 337 336 - static int read_serial_poll_byte(gpib_board_t *board, unsigned int pad, 338 + static int read_serial_poll_byte(struct gpib_board *board, unsigned int pad, 337 339 int sad, unsigned int usec_timeout, uint8_t *result) 338 340 { 339 341 u8 cmd_string[8]; ··· 342 344 int i; 343 345 size_t nbytes; 344 346 345 - dev_dbg(board->gpib_dev, "entering %s(), pad=%i sad=%i\n", __func__, pad, sad); 347 + dev_dbg(board->gpib_dev, "entering pad=%i sad=%i\n", pad, sad); 346 348 347 349 os_start_timer(board, usec_timeout); 348 350 ret = ibcac(board, 1, 1); ··· 359 361 360 362 ret = board->interface->command(board, cmd_string, i, &nbytes); 361 363 if (ret < 0 || nbytes < i) { 362 - pr_err("gpib: failed to setup serial poll\n"); 364 + dev_err(board->gpib_dev, "failed to setup serial poll\n"); 363 365 os_remove_timer(board); 364 366 return -EIO; 365 367 } ··· 369 371 // read poll result 370 372 ret = board->interface->read(board, result, 1, &end_flag, &nbytes); 371 373 if (ret < 0 || nbytes < 1) { 372 - pr_err("gpib: serial poll failed\n"); 374 + dev_err(board->gpib_dev, "serial poll failed\n"); 373 375 os_remove_timer(board); 374 376 return -EIO; 375 377 } ··· 378 380 return 0; 379 381 } 380 382 381 - static int cleanup_serial_poll(gpib_board_t *board, unsigned int usec_timeout) 383 + static int cleanup_serial_poll(struct gpib_board *board, unsigned int usec_timeout) 382 384 { 383 385 u8 cmd_string[8]; 384 386 int ret; 385 387 size_t bytes_written; 386 - 387 - dev_dbg(board->gpib_dev, "entering %s()\n", __func__); 388 388 389 389 os_start_timer(board, usec_timeout); 390 390 ret = ibcac(board, 1, 1); ··· 395 399 cmd_string[1] = UNT; 396 400 ret = board->interface->command(board, cmd_string, 2, &bytes_written); 397 401 if (ret < 0 || bytes_written < 2) { 398 - pr_err("gpib: failed to disable serial poll\n"); 402 + dev_err(board->gpib_dev, "failed to disable serial poll\n"); 399 403 os_remove_timer(board); 400 404 return -EIO; 401 405 } ··· 404 408 return 0; 405 409 } 406 410 407 - static int serial_poll_single(gpib_board_t *board, unsigned int pad, int sad, 411 + static int serial_poll_single(struct gpib_board *board, unsigned int pad, int sad, 408 412 unsigned int usec_timeout, uint8_t *result) 409 413 { 410 414 int retval, cleanup_retval; ··· 422 426 return 0; 423 427 } 424 428 425 - int serial_poll_all(gpib_board_t *board, unsigned int usec_timeout) 429 + int serial_poll_all(struct gpib_board *board, unsigned int usec_timeout) 426 430 { 427 431 int retval = 0; 428 432 struct list_head *cur; ··· 430 434 gpib_status_queue_t *device; 431 435 u8 result; 432 436 unsigned int num_bytes = 0; 433 - 434 - dev_dbg(board->gpib_dev, "entering %s()\n", __func__); 435 437 436 438 head = &board->device_list; 437 439 if (head->next == head) ··· 469 475 * SPD and UNT are sent at the completion of the poll. 470 476 */ 471 477 472 - int dvrsp(gpib_board_t *board, unsigned int pad, int sad, 478 + int dvrsp(struct gpib_board *board, unsigned int pad, int sad, 473 479 unsigned int usec_timeout, uint8_t *result) 474 480 { 475 481 int status = ibstatus(board); 476 482 int retval; 477 483 478 484 if ((status & CIC) == 0) { 479 - pr_err("gpib: not CIC during serial poll\n"); 485 + dev_err(board->gpib_dev, "not CIC during serial poll\n"); 480 486 return -1; 481 487 } 482 488 483 489 if (pad > MAX_GPIB_PRIMARY_ADDRESS || sad > MAX_GPIB_SECONDARY_ADDRESS || sad < -1) { 484 - pr_err("gpib: bad address for serial poll"); 490 + dev_err(board->gpib_dev, "bad address for serial poll"); 485 491 return -1; 486 492 } 487 493 ··· 521 527 int ibopen(struct inode *inode, struct file *filep) 522 528 { 523 529 unsigned int minor = iminor(inode); 524 - gpib_board_t *board; 530 + struct gpib_board *board; 525 531 gpib_file_private_t *priv; 526 532 527 533 if (minor >= GPIB_MAX_NUM_BOARDS) { ··· 538 544 priv = filep->private_data; 539 545 init_gpib_file_private((gpib_file_private_t *)filep->private_data); 540 546 541 - dev_dbg(board->gpib_dev, "pid %i, gpib: opening minor %d\n", current->pid, minor); 542 - 543 547 if (board->use_count == 0) { 544 548 int retval; 545 549 546 550 retval = request_module("gpib%i", minor); 547 - if (retval) { 548 - dev_dbg(board->gpib_dev, "pid %i, gpib: request module returned %i\n", 549 - current->pid, retval); 550 - } 551 + if (retval) 552 + dev_dbg(board->gpib_dev, "request module returned %i\n", retval); 551 553 } 552 554 if (board->interface) { 553 555 if (!try_module_get(board->provider_module)) { 554 - pr_err("gpib: try_module_get() failed\n"); 556 + dev_err(board->gpib_dev, "try_module_get() failed\n"); 555 557 return -EIO; 556 558 } 557 559 board->use_count++; ··· 559 569 int ibclose(struct inode *inode, struct file *filep) 560 570 { 561 571 unsigned int minor = iminor(inode); 562 - gpib_board_t *board; 572 + struct gpib_board *board; 563 573 gpib_file_private_t *priv = filep->private_data; 564 574 gpib_descriptor_t *desc; 565 575 ··· 570 580 571 581 board = &board_array[minor]; 572 582 573 - dev_dbg(board->gpib_dev, "pid %i, closing minor %d\n", current->pid, minor); 574 - 575 583 if (priv) { 576 584 desc = handle_to_descriptor(priv, 0); 577 585 if (desc) { 578 586 if (desc->autopoll_enabled) { 579 - dev_dbg(board->gpib_dev, "pid %i, decrementing autospollers\n", 580 - current->pid); 587 + dev_dbg(board->gpib_dev, "decrementing autospollers\n"); 581 588 if (board->autospollers > 0) 582 589 board->autospollers--; 583 590 else 584 - pr_err("gpib: Attempt to decrement zero autospollers\n"); 591 + dev_err(board->gpib_dev, 592 + "Attempt to decrement zero autospollers\n"); 585 593 } 586 594 } else { 587 - pr_err("gpib: Unexpected null gpib_descriptor\n"); 595 + dev_err(board->gpib_dev, "Unexpected null gpib_descriptor\n"); 588 596 } 589 597 590 598 cleanup_open_devices(priv, board); ··· 605 617 long ibioctl(struct file *filep, unsigned int cmd, unsigned long arg) 606 618 { 607 619 unsigned int minor = iminor(filep->f_path.dentry->d_inode); 608 - gpib_board_t *board; 620 + struct gpib_board *board; 609 621 gpib_file_private_t *file_priv = filep->private_data; 610 622 long retval = -ENOTTY; 611 623 ··· 618 630 if (mutex_lock_interruptible(&board->big_gpib_mutex)) 619 631 return -ERESTARTSYS; 620 632 621 - dev_dbg(board->gpib_dev, "pid %i, ioctl %d, interface=%s, use=%d, onl=%d\n", 622 - current->pid, cmd & 0xff, 633 + dev_dbg(board->gpib_dev, "ioctl %d, interface=%s, use=%d, onl=%d\n", 634 + cmd & 0xff, 623 635 board->interface ? board->interface->name : "", 624 636 board->use_count, 625 637 board->online); ··· 635 647 break; 636 648 } 637 649 if (!board->interface) { 638 - pr_err("gpib: no gpib board configured on /dev/gpib%i\n", minor); 650 + dev_err(board->gpib_dev, "no gpib board configured\n"); 639 651 retval = -ENODEV; 640 652 goto done; 641 653 } 642 654 if (file_priv->got_module == 0) { 643 655 if (!try_module_get(board->provider_module)) { 644 - pr_err("gpib: try_module_get() failed\n"); 656 + dev_err(board->gpib_dev, "try_module_get() failed\n"); 645 657 retval = -EIO; 646 658 goto done; 647 659 } ··· 687 699 } 688 700 689 701 if (!board->online) { 690 - pr_err("gpib: ioctl %i invalid for offline board\n", 691 - cmd & 0xff); 692 702 retval = -EINVAL; 693 703 goto done; 694 704 } ··· 723 737 spin_lock(&board->locking_pid_spinlock); 724 738 if (current->pid != board->locking_pid) { 725 739 spin_unlock(&board->locking_pid_spinlock); 726 - pr_err("gpib: need to hold board lock to perform ioctl %i\n", 727 - cmd & 0xff); 728 740 retval = -EPERM; 729 741 goto done; 730 742 } ··· 806 822 return retval; 807 823 } 808 824 809 - static int board_type_ioctl(gpib_file_private_t *file_priv, gpib_board_t *board, unsigned long arg) 825 + static int board_type_ioctl(gpib_file_private_t *file_priv, struct gpib_board *board, unsigned long arg) 810 826 { 811 827 struct list_head *list_ptr; 812 828 board_type_ioctl_t cmd; ··· 814 830 815 831 if (!capable(CAP_SYS_ADMIN)) 816 832 return -EPERM; 817 - if (board->online) { 818 - pr_err("gpib: can't change board type while board is online.\n"); 833 + if (board->online) 819 834 return -EBUSY; 820 - } 821 835 822 836 retval = copy_from_user(&cmd, (void __user *)arg, sizeof(board_type_ioctl_t)); 823 837 if (retval) ··· 857 875 return -EINVAL; 858 876 } 859 877 860 - static int read_ioctl(gpib_file_private_t *file_priv, gpib_board_t *board, 878 + static int read_ioctl(gpib_file_private_t *file_priv, struct gpib_board *board, 861 879 unsigned long arg) 862 880 { 863 881 read_write_ioctl_t read_cmd; ··· 933 951 } 934 952 935 953 static int command_ioctl(gpib_file_private_t *file_priv, 936 - gpib_board_t *board, unsigned long arg) 954 + struct gpib_board *board, unsigned long arg) 937 955 { 938 956 read_write_ioctl_t cmd; 939 957 u8 __user *userbuf; ··· 1016 1034 return retval; 1017 1035 } 1018 1036 1019 - static int write_ioctl(gpib_file_private_t *file_priv, gpib_board_t *board, 1037 + static int write_ioctl(gpib_file_private_t *file_priv, struct gpib_board *board, 1020 1038 unsigned long arg) 1021 1039 { 1022 1040 read_write_ioctl_t write_cmd; ··· 1087 1105 return retval; 1088 1106 } 1089 1107 1090 - static int status_bytes_ioctl(gpib_board_t *board, unsigned long arg) 1108 + static int status_bytes_ioctl(struct gpib_board *board, unsigned long arg) 1091 1109 { 1092 1110 gpib_status_queue_t *device; 1093 1111 spoll_bytes_ioctl_t cmd; ··· 1110 1128 return 0; 1111 1129 } 1112 1130 1113 - static int increment_open_device_count(gpib_board_t *board, struct list_head *head, 1131 + static int increment_open_device_count(struct gpib_board *board, struct list_head *head, 1114 1132 unsigned int pad, int sad) 1115 1133 { 1116 1134 struct list_head *list_ptr; ··· 1122 1140 for (list_ptr = head->next; list_ptr != head; list_ptr = list_ptr->next) { 1123 1141 device = list_entry(list_ptr, gpib_status_queue_t, list); 1124 1142 if (gpib_address_equal(device->pad, device->sad, pad, sad)) { 1125 - dev_dbg(board->gpib_dev, "pid %i, incrementing open count for pad %i, sad %i\n", 1126 - current->pid, device->pad, device->sad); 1143 + dev_dbg(board->gpib_dev, "incrementing open count for pad %i, sad %i\n", 1144 + device->pad, device->sad); 1127 1145 device->reference_count++; 1128 1146 return 0; 1129 1147 } ··· 1140 1158 1141 1159 list_add(&device->list, head); 1142 1160 1143 - dev_dbg(board->gpib_dev, "pid %i, opened pad %i, sad %i\n", 1144 - current->pid, device->pad, device->sad); 1161 + dev_dbg(board->gpib_dev, "opened pad %i, sad %i\n", device->pad, device->sad); 1145 1162 1146 1163 return 0; 1147 1164 } 1148 1165 1149 - static int subtract_open_device_count(gpib_board_t *board, struct list_head *head, 1166 + static int subtract_open_device_count(struct gpib_board *board, struct list_head *head, 1150 1167 unsigned int pad, int sad, unsigned int count) 1151 1168 { 1152 1169 gpib_status_queue_t *device; ··· 1154 1173 for (list_ptr = head->next; list_ptr != head; list_ptr = list_ptr->next) { 1155 1174 device = list_entry(list_ptr, gpib_status_queue_t, list); 1156 1175 if (gpib_address_equal(device->pad, device->sad, pad, sad)) { 1157 - dev_dbg(board->gpib_dev, "pid %i, decrementing open count for pad %i, sad %i\n", 1158 - current->pid, device->pad, device->sad); 1176 + dev_dbg(board->gpib_dev, "decrementing open count for pad %i, sad %i\n", 1177 + device->pad, device->sad); 1159 1178 if (count > device->reference_count) { 1160 - pr_err("gpib: bug! in %s()\n", __func__); 1179 + dev_err(board->gpib_dev, "bug! in %s()\n", __func__); 1161 1180 return -EINVAL; 1162 1181 } 1163 1182 device->reference_count -= count; 1164 1183 if (device->reference_count == 0) { 1165 - dev_dbg(board->gpib_dev, "pid %i, closing pad %i, sad %i\n", 1166 - current->pid, device->pad, device->sad); 1184 + dev_dbg(board->gpib_dev, "closing pad %i, sad %i\n", 1185 + device->pad, device->sad); 1167 1186 list_del(list_ptr); 1168 1187 kfree(device); 1169 1188 } 1170 1189 return 0; 1171 1190 } 1172 1191 } 1173 - pr_err("gpib: bug! tried to close address that was never opened!\n"); 1192 + dev_err(board->gpib_dev, "bug! tried to close address that was never opened!\n"); 1174 1193 return -EINVAL; 1175 1194 } 1176 1195 1177 - static inline int decrement_open_device_count(gpib_board_t *board, struct list_head *head, 1196 + static inline int decrement_open_device_count(struct gpib_board *board, struct list_head *head, 1178 1197 unsigned int pad, int sad) 1179 1198 { 1180 1199 return subtract_open_device_count(board, head, pad, sad, 1); 1181 1200 } 1182 1201 1183 - static int cleanup_open_devices(gpib_file_private_t *file_priv, gpib_board_t *board) 1202 + static int cleanup_open_devices(gpib_file_private_t *file_priv, struct gpib_board *board) 1184 1203 { 1185 1204 int retval = 0; 1186 1205 int i; ··· 1205 1224 return 0; 1206 1225 } 1207 1226 1208 - static int open_dev_ioctl(struct file *filep, gpib_board_t *board, unsigned long arg) 1227 + static int open_dev_ioctl(struct file *filep, struct gpib_board *board, unsigned long arg) 1209 1228 { 1210 1229 open_dev_ioctl_t open_dev_cmd; 1211 1230 int retval; ··· 1255 1274 return 0; 1256 1275 } 1257 1276 1258 - static int close_dev_ioctl(struct file *filep, gpib_board_t *board, unsigned long arg) 1277 + static int close_dev_ioctl(struct file *filep, struct gpib_board *board, unsigned long arg) 1259 1278 { 1260 1279 close_dev_ioctl_t cmd; 1261 1280 gpib_file_private_t *file_priv = filep->private_data; ··· 1282 1301 return 0; 1283 1302 } 1284 1303 1285 - static int serial_poll_ioctl(gpib_board_t *board, unsigned long arg) 1304 + static int serial_poll_ioctl(struct gpib_board *board, unsigned long arg) 1286 1305 { 1287 1306 serial_poll_ioctl_t serial_cmd; 1288 1307 int retval; 1289 - 1290 - dev_dbg(board->gpib_dev, "pid %i, entering %s()\n", current->pid, __func__); 1291 1308 1292 1309 retval = copy_from_user(&serial_cmd, (void __user *)arg, sizeof(serial_cmd)); 1293 1310 if (retval) ··· 1303 1324 return 0; 1304 1325 } 1305 1326 1306 - static int wait_ioctl(gpib_file_private_t *file_priv, gpib_board_t *board, 1327 + static int wait_ioctl(gpib_file_private_t *file_priv, struct gpib_board *board, 1307 1328 unsigned long arg) 1308 1329 { 1309 1330 wait_ioctl_t wait_cmd; ··· 1330 1351 return 0; 1331 1352 } 1332 1353 1333 - static int parallel_poll_ioctl(gpib_board_t *board, unsigned long arg) 1354 + static int parallel_poll_ioctl(struct gpib_board *board, unsigned long arg) 1334 1355 { 1335 1356 u8 poll_byte; 1336 1357 int retval; ··· 1346 1367 return 0; 1347 1368 } 1348 1369 1349 - static int online_ioctl(gpib_board_t *board, unsigned long arg) 1370 + static int online_ioctl(struct gpib_board *board, unsigned long arg) 1350 1371 { 1351 1372 online_ioctl_t online_cmd; 1352 1373 int retval; ··· 1390 1411 return retval; 1391 1412 } 1392 1413 1393 - static int remote_enable_ioctl(gpib_board_t *board, unsigned long arg) 1414 + static int remote_enable_ioctl(struct gpib_board *board, unsigned long arg) 1394 1415 { 1395 1416 int enable; 1396 1417 int retval; ··· 1402 1423 return ibsre(board, enable); 1403 1424 } 1404 1425 1405 - static int take_control_ioctl(gpib_board_t *board, unsigned long arg) 1426 + static int take_control_ioctl(struct gpib_board *board, unsigned long arg) 1406 1427 { 1407 1428 int synchronous; 1408 1429 int retval; ··· 1414 1435 return ibcac(board, synchronous, 1); 1415 1436 } 1416 1437 1417 - static int line_status_ioctl(gpib_board_t *board, unsigned long arg) 1438 + static int line_status_ioctl(struct gpib_board *board, unsigned long arg) 1418 1439 { 1419 1440 short lines; 1420 1441 int retval; ··· 1430 1451 return 0; 1431 1452 } 1432 1453 1433 - static int pad_ioctl(gpib_board_t *board, gpib_file_private_t *file_priv, 1454 + static int pad_ioctl(struct gpib_board *board, gpib_file_private_t *file_priv, 1434 1455 unsigned long arg) 1435 1456 { 1436 1457 pad_ioctl_t cmd; ··· 1466 1487 return 0; 1467 1488 } 1468 1489 1469 - static int sad_ioctl(gpib_board_t *board, gpib_file_private_t *file_priv, 1490 + static int sad_ioctl(struct gpib_board *board, gpib_file_private_t *file_priv, 1470 1491 unsigned long arg) 1471 1492 { 1472 1493 sad_ioctl_t cmd; ··· 1501 1522 return 0; 1502 1523 } 1503 1524 1504 - static int eos_ioctl(gpib_board_t *board, unsigned long arg) 1525 + static int eos_ioctl(struct gpib_board *board, unsigned long arg) 1505 1526 { 1506 1527 eos_ioctl_t eos_cmd; 1507 1528 int retval; ··· 1513 1534 return ibeos(board, eos_cmd.eos, eos_cmd.eos_flags); 1514 1535 } 1515 1536 1516 - static int request_service_ioctl(gpib_board_t *board, unsigned long arg) 1537 + static int request_service_ioctl(struct gpib_board *board, unsigned long arg) 1517 1538 { 1518 1539 u8 status_byte; 1519 1540 int retval; ··· 1525 1546 return ibrsv2(board, status_byte, status_byte & request_service_bit); 1526 1547 } 1527 1548 1528 - static int request_service2_ioctl(gpib_board_t *board, unsigned long arg) 1549 + static int request_service2_ioctl(struct gpib_board *board, unsigned long arg) 1529 1550 { 1530 1551 request_service2_t request_service2_cmd; 1531 1552 int retval; ··· 1592 1613 return 0; 1593 1614 } 1594 1615 1595 - static int autospoll_ioctl(gpib_board_t *board, gpib_file_private_t *file_priv, 1616 + static int autospoll_ioctl(struct gpib_board *board, gpib_file_private_t *file_priv, 1596 1617 unsigned long arg) 1597 1618 { 1598 1619 autospoll_ioctl_t enable; ··· 1618 1639 board->autospollers--; 1619 1640 retval = 0; 1620 1641 } else { 1621 - pr_err("gpib: tried to set number of autospollers negative\n"); 1642 + dev_err(board->gpib_dev, 1643 + "tried to set number of autospollers negative\n"); 1622 1644 retval = -EINVAL; 1623 1645 } 1624 1646 } else { 1625 - pr_err("gpib: autopoll disable requested before enable\n"); 1647 + dev_err(board->gpib_dev, "autopoll disable requested before enable\n"); 1626 1648 retval = -EINVAL; 1627 1649 } 1628 1650 } 1629 1651 return retval; 1630 1652 } 1631 1653 1632 - static int mutex_ioctl(gpib_board_t *board, gpib_file_private_t *file_priv, 1654 + static int mutex_ioctl(struct gpib_board *board, gpib_file_private_t *file_priv, 1633 1655 unsigned long arg) 1634 1656 { 1635 1657 int retval, lock_mutex; ··· 1641 1661 1642 1662 if (lock_mutex) { 1643 1663 retval = mutex_lock_interruptible(&board->user_mutex); 1644 - if (retval) { 1645 - pr_warn("gpib: ioctl interrupted while waiting on lock\n"); 1664 + if (retval) 1646 1665 return -ERESTARTSYS; 1647 - } 1648 1666 1649 1667 spin_lock(&board->locking_pid_spinlock); 1650 1668 board->locking_pid = current->pid; ··· 1650 1672 1651 1673 atomic_set(&file_priv->holding_mutex, 1); 1652 1674 1653 - dev_dbg(board->gpib_dev, "pid %i, locked board %d mutex\n", 1654 - current->pid, board->minor); 1675 + dev_dbg(board->gpib_dev, "locked board mutex\n"); 1655 1676 } else { 1656 1677 spin_lock(&board->locking_pid_spinlock); 1657 1678 if (current->pid != board->locking_pid) { 1658 - pr_err("gpib: bug! pid %i tried to release mutex held by pid %i\n", 1659 - current->pid, board->locking_pid); 1679 + dev_err(board->gpib_dev, "bug! pid %i tried to release mutex held by pid %i\n", 1680 + current->pid, board->locking_pid); 1660 1681 spin_unlock(&board->locking_pid_spinlock); 1661 1682 return -EPERM; 1662 1683 } ··· 1665 1688 atomic_set(&file_priv->holding_mutex, 0); 1666 1689 1667 1690 mutex_unlock(&board->user_mutex); 1668 - dev_dbg(board->gpib_dev, "pid %i, unlocked board %i mutex\n", 1669 - current->pid, board->minor); 1691 + dev_dbg(board->gpib_dev, "unlocked board mutex\n"); 1670 1692 } 1671 1693 return 0; 1672 1694 } 1673 1695 1674 - static int timeout_ioctl(gpib_board_t *board, unsigned long arg) 1696 + static int timeout_ioctl(struct gpib_board *board, unsigned long arg) 1675 1697 { 1676 1698 unsigned int timeout; 1677 1699 int retval; ··· 1680 1704 return -EFAULT; 1681 1705 1682 1706 board->usec_timeout = timeout; 1683 - dev_dbg(board->gpib_dev, "pid %i, timeout set to %i usec\n", current->pid, timeout); 1707 + dev_dbg(board->gpib_dev, "timeout set to %i usec\n", timeout); 1684 1708 1685 1709 return 0; 1686 1710 } 1687 1711 1688 - static int ppc_ioctl(gpib_board_t *board, unsigned long arg) 1712 + static int ppc_ioctl(struct gpib_board *board, unsigned long arg) 1689 1713 { 1690 1714 ppoll_config_ioctl_t cmd; 1691 1715 int retval; ··· 1711 1735 return 0; 1712 1736 } 1713 1737 1714 - static int set_local_ppoll_mode_ioctl(gpib_board_t *board, unsigned long arg) 1738 + static int set_local_ppoll_mode_ioctl(struct gpib_board *board, unsigned long arg) 1715 1739 { 1716 1740 local_ppoll_mode_ioctl_t cmd; 1717 1741 int retval; ··· 1720 1744 if (retval) 1721 1745 return -EFAULT; 1722 1746 1723 - if (!board->interface->local_parallel_poll_mode) { 1724 - pr_warn("gpib: local/remote parallel poll mode not supported by driver."); 1725 - return -EIO; 1726 - } 1747 + if (!board->interface->local_parallel_poll_mode) 1748 + return -ENOENT; 1727 1749 board->local_ppoll_mode = cmd != 0; 1728 1750 board->interface->local_parallel_poll_mode(board, board->local_ppoll_mode); 1729 1751 1730 1752 return 0; 1731 1753 } 1732 1754 1733 - static int get_local_ppoll_mode_ioctl(gpib_board_t *board, unsigned long arg) 1755 + static int get_local_ppoll_mode_ioctl(struct gpib_board *board, unsigned long arg) 1734 1756 { 1735 1757 local_ppoll_mode_ioctl_t cmd; 1736 1758 int retval; ··· 1741 1767 return 0; 1742 1768 } 1743 1769 1744 - static int query_board_rsv_ioctl(gpib_board_t *board, unsigned long arg) 1770 + static int query_board_rsv_ioctl(struct gpib_board *board, unsigned long arg) 1745 1771 { 1746 1772 int status; 1747 1773 int retval; ··· 1755 1781 return 0; 1756 1782 } 1757 1783 1758 - static int board_info_ioctl(const gpib_board_t *board, unsigned long arg) 1784 + static int board_info_ioctl(const struct gpib_board *board, unsigned long arg) 1759 1785 { 1760 1786 board_info_ioctl_t info; 1761 1787 int retval; ··· 1778 1804 return 0; 1779 1805 } 1780 1806 1781 - static int interface_clear_ioctl(gpib_board_t *board, unsigned long arg) 1807 + static int interface_clear_ioctl(struct gpib_board *board, unsigned long arg) 1782 1808 { 1783 1809 unsigned int usec_duration; 1784 1810 int retval; ··· 1841 1867 return queue->num_events; 1842 1868 } 1843 1869 1844 - static int push_gpib_event_nolock(gpib_board_t *board, short event_type) 1870 + static int push_gpib_event_nolock(struct gpib_board *board, short event_type) 1845 1871 { 1846 1872 gpib_event_queue_t *queue = &board->event_queue; 1847 1873 struct list_head *head = &queue->event_head; ··· 1861 1887 event = kmalloc(sizeof(gpib_event_t), GFP_ATOMIC); 1862 1888 if (!event) { 1863 1889 queue->dropped_event = 1; 1864 - pr_err("gpib: failed to allocate memory for event\n"); 1890 + dev_err(board->gpib_dev, "failed to allocate memory for event\n"); 1865 1891 return -ENOMEM; 1866 1892 } 1867 1893 ··· 1879 1905 } 1880 1906 1881 1907 // push event onto back of event queue 1882 - int push_gpib_event(gpib_board_t *board, short event_type) 1908 + int push_gpib_event(struct gpib_board *board, short event_type) 1883 1909 { 1884 1910 unsigned long flags; 1885 1911 int retval; ··· 1897 1923 } 1898 1924 EXPORT_SYMBOL(push_gpib_event); 1899 1925 1900 - static int pop_gpib_event_nolock(gpib_board_t *board, gpib_event_queue_t *queue, short *event_type) 1926 + static int pop_gpib_event_nolock(struct gpib_board *board, gpib_event_queue_t *queue, short *event_type) 1901 1927 { 1902 1928 struct list_head *head = &queue->event_head; 1903 1929 struct list_head *front = head->next; ··· 1931 1957 } 1932 1958 1933 1959 // pop event from front of event queue 1934 - int pop_gpib_event(gpib_board_t *board, gpib_event_queue_t *queue, short *event_type) 1960 + int pop_gpib_event(struct gpib_board *board, gpib_event_queue_t *queue, short *event_type) 1935 1961 { 1936 1962 unsigned long flags; 1937 1963 int retval; ··· 1942 1968 return retval; 1943 1969 } 1944 1970 1945 - static int event_ioctl(gpib_board_t *board, unsigned long arg) 1971 + static int event_ioctl(struct gpib_board *board, unsigned long arg) 1946 1972 { 1947 1973 event_ioctl_t user_event; 1948 1974 int retval; ··· 1961 1987 return 0; 1962 1988 } 1963 1989 1964 - static int request_system_control_ioctl(gpib_board_t *board, unsigned long arg) 1990 + static int request_system_control_ioctl(struct gpib_board *board, unsigned long arg) 1965 1991 { 1966 1992 rsc_ioctl_t request_control; 1967 1993 int retval; ··· 1975 2001 return 0; 1976 2002 } 1977 2003 1978 - static int t1_delay_ioctl(gpib_board_t *board, unsigned long arg) 2004 + static int t1_delay_ioctl(struct gpib_board *board, unsigned long arg) 1979 2005 { 1980 2006 t1_delay_ioctl_t cmd; 1981 2007 unsigned int delay; 1982 2008 int retval; 1983 2009 1984 - if (!board->interface->t1_delay) { 1985 - pr_warn("gpib: t1 delay not implemented in driver!\n"); 1986 - return -EIO; 1987 - } 2010 + if (!board->interface->t1_delay) 2011 + return -ENOENT; 1988 2012 1989 2013 retval = copy_from_user(&cmd, (void __user *)arg, sizeof(cmd)); 1990 2014 if (retval) ··· 1990 2018 1991 2019 delay = cmd; 1992 2020 1993 - board->t1_nano_sec = board->interface->t1_delay(board, delay); 2021 + retval = board->interface->t1_delay(board, delay); 2022 + if (retval < 0) 2023 + return retval; 1994 2024 2025 + board->t1_nano_sec = retval; 1995 2026 return 0; 1996 2027 } 1997 2028 ··· 2007 2032 .release = &ibclose, 2008 2033 }; 2009 2034 2010 - gpib_board_t board_array[GPIB_MAX_NUM_BOARDS]; 2035 + struct gpib_board board_array[GPIB_MAX_NUM_BOARDS]; 2011 2036 2012 2037 LIST_HEAD(registered_drivers); 2013 2038 ··· 2042 2067 struct list_head *list_ptr; 2043 2068 2044 2069 for (i = 0; i < GPIB_MAX_NUM_BOARDS; i++) { 2045 - gpib_board_t *board = &board_array[i]; 2070 + struct gpib_board *board = &board_array[i]; 2046 2071 2047 2072 if (board->interface == interface) { 2048 2073 if (board->use_count > 0) ··· 2062 2087 kfree(entry); 2063 2088 } 2064 2089 } 2065 - pr_info("gpib: unregistered %s interface\n", interface->name); 2066 2090 } 2067 2091 EXPORT_SYMBOL(gpib_unregister_driver); 2068 2092 ··· 2072 2098 config->pci_slot = -1; 2073 2099 } 2074 2100 2075 - void init_gpib_board(gpib_board_t *board) 2101 + void init_gpib_board(struct gpib_board *board) 2076 2102 { 2077 2103 board->interface = NULL; 2078 2104 board->provider_module = NULL; ··· 2107 2133 board->local_ppoll_mode = 0; 2108 2134 } 2109 2135 2110 - int gpib_allocate_board(gpib_board_t *board) 2136 + int gpib_allocate_board(struct gpib_board *board) 2111 2137 { 2112 2138 if (!board->buffer) { 2113 2139 board->buffer_length = 0x4000; ··· 2120 2146 return 0; 2121 2147 } 2122 2148 2123 - void gpib_deallocate_board(gpib_board_t *board) 2149 + void gpib_deallocate_board(struct gpib_board *board) 2124 2150 { 2125 2151 short dummy; 2126 2152 ··· 2133 2159 pop_gpib_event(board, &board->event_queue, &dummy); 2134 2160 } 2135 2161 2136 - static void init_board_array(gpib_board_t *board_array, unsigned int length) 2162 + static void init_board_array(struct gpib_board *board_array, unsigned int length) 2137 2163 { 2138 2164 int i; 2139 2165 ··· 2158 2184 { 2159 2185 int i; 2160 2186 2161 - pr_info("Linux-GPIB core driver\n"); 2187 + pr_info("GPIB core driver\n"); 2162 2188 init_board_array(board_array, GPIB_MAX_NUM_BOARDS); 2163 2189 if (register_chrdev(GPIB_CODE, "gpib", &ib_fops)) { 2164 2190 pr_err("gpib: can't get major %d\n", GPIB_CODE);
+65 -102
drivers/staging/gpib/common/iblib.c
··· 4 4 * copyright : (C) 2001, 2002 by Frank Mori Hess 5 5 ***************************************************************************/ 6 6 7 + #define dev_fmt(fmt) KBUILD_MODNAME ": " fmt 8 + 7 9 #include "ibsys.h" 8 10 #include <linux/delay.h> 9 11 #include <linux/kthread.h> ··· 21 19 * If fallback_to_async is non-zero, try to take control asynchronously 22 20 * if synchronous attempt fails. 23 21 */ 24 - int ibcac(gpib_board_t *board, int sync, int fallback_to_async) 22 + int ibcac(struct gpib_board *board, int sync, int fallback_to_async) 25 23 { 26 24 int status = ibstatus(board); 27 25 int retval; 28 26 29 - if ((status & CIC) == 0) { 30 - pr_err("gpib: not CIC during %s()\n", __func__); 31 - return -1; 32 - } 27 + if ((status & CIC) == 0) 28 + return -EINVAL; 33 29 34 30 if (status & ATN) 35 31 return 0; ··· 61 61 * set the skip_check_for_command_acceptors flag in their 62 62 * gpib_interface_struct to avoid useless overhead. 63 63 */ 64 - static int check_for_command_acceptors(gpib_board_t *board) 64 + static int check_for_command_acceptors(struct gpib_board *board) 65 65 { 66 66 int lines; 67 67 ··· 76 76 if (lines < 0) 77 77 return lines; 78 78 79 - if (lines & ValidATN) { 80 - if ((lines & BusATN) == 0) { 81 - pr_err("gpib: ATN not asserted in %s()?", __func__); 82 - return 0; 83 - } 84 - } 85 - 86 - if ((lines & ValidNRFD) && (lines & ValidNDAC)) { 87 - if ((lines & BusNRFD) == 0 && (lines & BusNDAC) == 0) 79 + if ((lines & VALID_NRFD) && (lines & VALID_NDAC)) { 80 + if ((lines & BUS_NRFD) == 0 && (lines & BUS_NDAC) == 0) 88 81 return -ENOTCONN; 89 82 } 90 83 ··· 96 103 * must be called to initialize the GPIB and enable 97 104 * the interface to leave the controller idle state. 98 105 */ 99 - int ibcmd(gpib_board_t *board, uint8_t *buf, size_t length, size_t *bytes_written) 106 + int ibcmd(struct gpib_board *board, uint8_t *buf, size_t length, size_t *bytes_written) 100 107 { 101 108 ssize_t ret = 0; 102 109 int status; ··· 105 112 106 113 status = ibstatus(board); 107 114 108 - if ((status & CIC) == 0) { 109 - pr_err("gpib: cannot send command when not controller-in-charge\n"); 110 - return -EIO; 111 - } 115 + if ((status & CIC) == 0) 116 + return -EINVAL; 112 117 113 118 os_start_timer(board, board->usec_timeout); 114 119 ··· 131 140 * active state, i.e., turn ATN off. 132 141 */ 133 142 134 - int ibgts(gpib_board_t *board) 143 + int ibgts(struct gpib_board *board) 135 144 { 136 145 int status = ibstatus(board); 137 146 int retval; 138 147 139 - if ((status & CIC) == 0) { 140 - pr_err("gpib: not CIC during %s()\n", __func__); 141 - return -1; 142 - } 148 + if ((status & CIC) == 0) 149 + return -EINVAL; 143 150 144 151 retval = board->interface->go_to_standby(board); /* go to standby */ 145 - if (retval < 0) 146 - pr_err("gpib: error while going to standby\n"); 147 152 148 153 board->interface->update_status(board, 0); 149 154 150 155 return retval; 151 156 } 152 157 153 - static int autospoll_wait_should_wake_up(gpib_board_t *board) 158 + static int autospoll_wait_should_wake_up(struct gpib_board *board) 154 159 { 155 160 int retval; 156 161 ··· 162 175 163 176 static int autospoll_thread(void *board_void) 164 177 { 165 - gpib_board_t *board = board_void; 178 + struct gpib_board *board = board_void; 166 179 int retval = 0; 167 180 168 181 dev_dbg(board->gpib_dev, "entering autospoll thread\n"); ··· 187 200 retval = autopoll_all_devices(board); 188 201 module_put(board->provider_module); 189 202 } else { 190 - pr_err("gpib%i: %s: try_module_get() failed!\n", board->minor, __func__); 203 + dev_err(board->gpib_dev, "try_module_get() failed!\n"); 191 204 } 192 205 if (retval <= 0) { 193 - pr_err("gpib%i: %s: stuck SRQ\n", board->minor, __func__); 206 + dev_err(board->gpib_dev, "stuck SRQ\n"); 194 207 195 208 atomic_set(&board->stuck_srq, 1); // XXX could be better 196 209 set_bit(SRQI_NUM, &board->status); 197 210 } 198 211 } 199 - pr_info("gpib%i: exiting autospoll thread\n", board->minor); 200 212 return retval; 201 213 } 202 214 203 - int ibonline(gpib_board_t *board) 215 + int ibonline(struct gpib_board *board) 204 216 { 205 217 int retval; 206 218 ··· 216 230 retval = board->interface->attach(board, &board->config); 217 231 if (retval < 0) { 218 232 board->interface->detach(board); 219 - pr_err("gpib: interface attach failed\n"); 220 233 return retval; 221 234 } 222 235 /* nios2nommu on 2.6.11 uclinux kernel has weird problems ··· 226 241 "gpib%d_autospoll_kthread", board->minor); 227 242 retval = IS_ERR(board->autospoll_task); 228 243 if (retval) { 229 - pr_err("gpib: failed to create autospoll thread\n"); 244 + dev_err(board->gpib_dev, "failed to create autospoll thread\n"); 230 245 board->interface->detach(board); 231 246 return retval; 232 247 } 233 248 #endif 234 249 board->online = 1; 235 - dev_dbg(board->gpib_dev, "gpib: board online\n"); 250 + dev_dbg(board->gpib_dev, "board online\n"); 236 251 237 252 return 0; 238 253 } 239 254 240 255 /* XXX need to make sure board is generally not in use (grab board lock?) */ 241 - int iboffline(gpib_board_t *board) 256 + int iboffline(struct gpib_board *board) 242 257 { 243 258 int retval; 244 259 ··· 250 265 if (board->autospoll_task && !IS_ERR(board->autospoll_task)) { 251 266 retval = kthread_stop(board->autospoll_task); 252 267 if (retval) 253 - pr_err("gpib: kthread_stop returned %i\n", retval); 268 + dev_err(board->gpib_dev, "kthread_stop returned %i\n", retval); 254 269 board->autospoll_task = NULL; 255 270 } 256 271 257 272 board->interface->detach(board); 258 273 gpib_deallocate_board(board); 259 274 board->online = 0; 260 - dev_dbg(board->gpib_dev, "gpib: board offline\n"); 275 + dev_dbg(board->gpib_dev, "board offline\n"); 261 276 262 277 return 0; 263 278 } ··· 270 285 * Next LSB (bits 8-15) - STATUS lines mask (lines that are currently set). 271 286 * 272 287 */ 273 - int iblines(const gpib_board_t *board, short *lines) 288 + int iblines(const struct gpib_board *board, short *lines) 274 289 { 275 290 int retval; 276 291 ··· 297 312 * calling ibcmd. 298 313 */ 299 314 300 - int ibrd(gpib_board_t *board, uint8_t *buf, size_t length, int *end_flag, size_t *nbytes) 315 + int ibrd(struct gpib_board *board, uint8_t *buf, size_t length, int *end_flag, size_t *nbytes) 301 316 { 302 317 ssize_t ret = 0; 303 318 int retval; ··· 305 320 306 321 *nbytes = 0; 307 322 *end_flag = 0; 308 - if (length == 0) { 309 - pr_warn("gpib: %s() called with zero length?\n", __func__); 323 + if (length == 0) 310 324 return 0; 311 - } 312 325 313 326 if (board->master) { 314 327 retval = ibgts(board); ··· 321 338 322 339 do { 323 340 ret = board->interface->read(board, buf, length - *nbytes, end_flag, &bytes_read); 324 - if (ret < 0) { 325 - pr_err("gpib read error\n"); 341 + if (ret < 0) 326 342 goto ibrd_out; 327 - } 343 + 328 344 buf += bytes_read; 329 345 *nbytes += bytes_read; 330 346 if (need_resched()) ··· 343 361 * 1. Prior to conducting the poll the interface is placed 344 362 * in the controller active state. 345 363 */ 346 - int ibrpp(gpib_board_t *board, uint8_t *result) 364 + int ibrpp(struct gpib_board *board, uint8_t *result) 347 365 { 348 366 int retval = 0; 349 367 ··· 352 370 if (retval) 353 371 return -1; 354 372 355 - if (board->interface->parallel_poll(board, result)) { 356 - pr_err("gpib: parallel poll failed\n"); 357 - retval = -1; 358 - } 373 + retval = board->interface->parallel_poll(board, result); 374 + 359 375 os_remove_timer(board); 360 376 return retval; 361 377 } 362 378 363 - int ibppc(gpib_board_t *board, uint8_t configuration) 379 + int ibppc(struct gpib_board *board, uint8_t configuration) 364 380 { 365 381 configuration &= 0x1f; 366 382 board->interface->parallel_poll_configure(board, configuration); ··· 367 387 return 0; 368 388 } 369 389 370 - int ibrsv2(gpib_board_t *board, uint8_t status_byte, int new_reason_for_service) 390 + int ibrsv2(struct gpib_board *board, uint8_t status_byte, int new_reason_for_service) 371 391 { 372 392 int board_status = ibstatus(board); 373 393 const unsigned int MSS = status_byte & request_service_bit; 374 394 375 - if ((board_status & CIC)) { 376 - pr_err("gpib: interface requested service while CIC\n"); 395 + if ((board_status & CIC)) 377 396 return -EINVAL; 378 - } 379 397 380 398 if (MSS == 0 && new_reason_for_service) 381 399 return -EINVAL; ··· 400 422 * ibcmd in order to initialize the bus and enable the 401 423 * interface to leave the controller idle state. 402 424 */ 403 - int ibsic(gpib_board_t *board, unsigned int usec_duration) 425 + int ibsic(struct gpib_board *board, unsigned int usec_duration) 404 426 { 405 - if (board->master == 0) { 406 - pr_err("gpib: tried to assert IFC when not system controller\n"); 407 - return -1; 408 - } 427 + if (board->master == 0) 428 + return -EINVAL; 409 429 410 430 if (usec_duration < 100) 411 431 usec_duration = 100; 412 - if (usec_duration > 1000) { 432 + if (usec_duration > 1000) 413 433 usec_duration = 1000; 414 - pr_warn("gpib: warning, shortening long udelay\n"); 415 - } 416 434 417 - dev_dbg(board->gpib_dev, "sending interface clear\n"); 435 + dev_dbg(board->gpib_dev, "sending interface clear, delay = %ius\n", usec_duration); 418 436 board->interface->interface_clear(board, 1); 419 437 udelay(usec_duration); 420 438 board->interface->interface_clear(board, 0); ··· 418 444 return 0; 419 445 } 420 446 421 - void ibrsc(gpib_board_t *board, int request_control) 447 + /* FIXME make int */ 448 + void ibrsc(struct gpib_board *board, int request_control) 422 449 { 423 450 board->master = request_control != 0; 424 - if (!board->interface->request_system_control) { 425 - pr_err("gpib: bug! driver does not implement request_system_control()\n"); 426 - return; 427 - } 428 - board->interface->request_system_control(board, request_control); 451 + if (board->interface->request_system_control) 452 + board->interface->request_system_control(board, request_control); 429 453 } 430 454 431 455 /* 432 456 * IBSRE 433 457 * Send REN true if v is non-zero or false if v is zero. 434 458 */ 435 - int ibsre(gpib_board_t *board, int enable) 459 + int ibsre(struct gpib_board *board, int enable) 436 460 { 437 - if (board->master == 0) { 438 - pr_err("gpib: tried to set REN when not system controller\n"); 439 - return -1; 440 - } 461 + if (board->master == 0) 462 + return -EINVAL; 441 463 442 464 board->interface->remote_enable(board, enable); /* set or clear REN */ 443 465 if (!enable) ··· 447 477 * change the GPIB address of the interface board. The address 448 478 * must be 0 through 30. ibonl resets the address to PAD. 449 479 */ 450 - int ibpad(gpib_board_t *board, unsigned int addr) 480 + int ibpad(struct gpib_board *board, unsigned int addr) 451 481 { 452 - if (addr > MAX_GPIB_PRIMARY_ADDRESS) { 453 - pr_err("gpib: invalid primary address %u\n", addr); 454 - return -1; 455 - } 482 + if (addr > MAX_GPIB_PRIMARY_ADDRESS) 483 + return -EINVAL; 484 + 456 485 board->pad = addr; 457 486 if (board->online) 458 487 board->interface->primary_address(board, board->pad); ··· 465 496 * The address must be 0 through 30, or negative disables. ibonl resets the 466 497 * address to SAD. 467 498 */ 468 - int ibsad(gpib_board_t *board, int addr) 499 + int ibsad(struct gpib_board *board, int addr) 469 500 { 470 - if (addr > MAX_GPIB_SECONDARY_ADDRESS) { 471 - pr_err("gpib: invalid secondary address %i\n", addr); 472 - return -1; 473 - } 501 + if (addr > MAX_GPIB_SECONDARY_ADDRESS) 502 + return -EINVAL; 474 503 board->sad = addr; 475 504 if (board->online) { 476 505 if (board->sad >= 0) ··· 486 519 * Set the end-of-string modes for I/O operations to v. 487 520 * 488 521 */ 489 - int ibeos(gpib_board_t *board, int eos, int eosflags) 522 + int ibeos(struct gpib_board *board, int eos, int eosflags) 490 523 { 491 524 int retval; 492 525 493 - if (eosflags & ~EOS_MASK) { 494 - pr_err("bad EOS modes\n"); 526 + if (eosflags & ~EOS_MASK) 495 527 return -EINVAL; 496 - } 497 528 if (eosflags & REOS) { 498 529 retval = board->interface->enable_eos(board, eos, eosflags & BIN); 499 530 } else { ··· 501 536 return retval; 502 537 } 503 538 504 - int ibstatus(gpib_board_t *board) 539 + int ibstatus(struct gpib_board *board) 505 540 { 506 541 return general_ibstatus(board, NULL, 0, 0, NULL); 507 542 } 508 543 509 - int general_ibstatus(gpib_board_t *board, const gpib_status_queue_t *device, 544 + int general_ibstatus(struct gpib_board *board, const gpib_status_queue_t *device, 510 545 int clear_mask, int set_mask, gpib_descriptor_t *desc) 511 546 { 512 547 int status = 0; ··· 520 555 status &= ~TIMO; 521 556 /* get real SRQI status if we can */ 522 557 if (iblines(board, &line_status) == 0) { 523 - if ((line_status & ValidSRQ)) { 524 - if ((line_status & BusSRQ)) 558 + if ((line_status & VALID_SRQ)) { 559 + if ((line_status & BUS_SRQ)) 525 560 status |= SRQI; 526 561 else 527 562 status &= ~SRQI; ··· 552 587 } 553 588 554 589 struct wait_info { 555 - gpib_board_t *board; 590 + struct gpib_board *board; 556 591 struct timer_list timer; 557 592 int timed_out; 558 593 unsigned long usec_timeout; ··· 576 611 static int wait_satisfied(struct wait_info *winfo, gpib_status_queue_t *status_queue, 577 612 int wait_mask, int *status, gpib_descriptor_t *desc) 578 613 { 579 - gpib_board_t *board = winfo->board; 614 + struct gpib_board *board = winfo->board; 580 615 int temp_status; 581 616 582 617 if (mutex_lock_interruptible(&board->big_gpib_mutex)) ··· 622 657 * If the mask is 0 then 623 658 * no condition is waited for. 624 659 */ 625 - int ibwait(gpib_board_t *board, int wait_mask, int clear_mask, int set_mask, 660 + int ibwait(struct gpib_board *board, int wait_mask, int clear_mask, int set_mask, 626 661 int *status, unsigned long usec_timeout, gpib_descriptor_t *desc) 627 662 { 628 663 int retval = 0; ··· 677 712 * well as the interface board itself must be 678 713 * addressed by calling ibcmd. 679 714 */ 680 - int ibwrt(gpib_board_t *board, uint8_t *buf, size_t cnt, int send_eoi, size_t *bytes_written) 715 + int ibwrt(struct gpib_board *board, uint8_t *buf, size_t cnt, int send_eoi, size_t *bytes_written) 681 716 { 682 717 int ret = 0; 683 718 int retval; 684 719 685 - if (cnt == 0) { 686 - pr_warn("gpib: %s() called with zero length?\n", __func__); 720 + if (cnt == 0) 687 721 return 0; 688 - } 689 722 690 723 if (board->master) { 691 724 retval = ibgts(board);
+7 -7
drivers/staging/gpib/common/ibsys.h
··· 19 19 #define MAX_GPIB_PRIMARY_ADDRESS 30 20 20 #define MAX_GPIB_SECONDARY_ADDRESS 31 21 21 22 - int gpib_allocate_board(gpib_board_t *board); 23 - void gpib_deallocate_board(gpib_board_t *board); 22 + int gpib_allocate_board(struct gpib_board *board); 23 + void gpib_deallocate_board(struct gpib_board *board); 24 24 25 25 unsigned int num_status_bytes(const gpib_status_queue_t *dev); 26 - int push_status_byte(gpib_board_t *board, gpib_status_queue_t *device, uint8_t poll_byte); 27 - int pop_status_byte(gpib_board_t *board, gpib_status_queue_t *device, uint8_t *poll_byte); 28 - gpib_status_queue_t *get_gpib_status_queue(gpib_board_t *board, unsigned int pad, int sad); 29 - int get_serial_poll_byte(gpib_board_t *board, unsigned int pad, int sad, 26 + int push_status_byte(struct gpib_board *board, gpib_status_queue_t *device, uint8_t poll_byte); 27 + int pop_status_byte(struct gpib_board *board, gpib_status_queue_t *device, uint8_t *poll_byte); 28 + gpib_status_queue_t *get_gpib_status_queue(struct gpib_board *board, unsigned int pad, int sad); 29 + int get_serial_poll_byte(struct gpib_board *board, unsigned int pad, int sad, 30 30 unsigned int usec_timeout, uint8_t *poll_byte); 31 - int autopoll_all_devices(gpib_board_t *board); 31 + int autopoll_all_devices(struct gpib_board *board);
+83 -121
drivers/staging/gpib/eastwood/fluke_gpib.c
··· 7 7 * copyright: (C) 2006, 2010, 2015 Fluke Corporation 8 8 ***************************************************************************/ 9 9 10 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 11 + #define dev_fmt pr_fmt 12 + #define DRV_NAME KBUILD_MODNAME 13 + 10 14 #include "fluke_gpib.h" 11 15 12 16 #include "gpibP.h" ··· 24 20 MODULE_LICENSE("GPL"); 25 21 MODULE_DESCRIPTION("GPIB Driver for Fluke cda devices"); 26 22 27 - static int fluke_attach_holdoff_all(gpib_board_t *board, const gpib_board_config_t *config); 28 - static int fluke_attach_holdoff_end(gpib_board_t *board, const gpib_board_config_t *config); 29 - static void fluke_detach(gpib_board_t *board); 30 - static int fluke_config_dma(gpib_board_t *board, int output); 31 - static irqreturn_t fluke_gpib_internal_interrupt(gpib_board_t *board); 23 + static int fluke_attach_holdoff_all(struct gpib_board *board, const gpib_board_config_t *config); 24 + static int fluke_attach_holdoff_end(struct gpib_board *board, const gpib_board_config_t *config); 25 + static void fluke_detach(struct gpib_board *board); 26 + static int fluke_config_dma(struct gpib_board *board, int output); 27 + static irqreturn_t fluke_gpib_internal_interrupt(struct gpib_board *board); 32 28 33 29 static struct platform_device *fluke_gpib_pdev; 34 30 ··· 54 50 } 55 51 56 52 // wrappers for interface functions 57 - static int fluke_read(gpib_board_t *board, uint8_t *buffer, size_t length, int *end, 53 + static int fluke_read(struct gpib_board *board, uint8_t *buffer, size_t length, int *end, 58 54 size_t *bytes_read) 59 55 { 60 56 struct fluke_priv *priv = board->private_data; ··· 62 58 return nec7210_read(board, &priv->nec7210_priv, buffer, length, end, bytes_read); 63 59 } 64 60 65 - static int fluke_write(gpib_board_t *board, uint8_t *buffer, size_t length, 61 + static int fluke_write(struct gpib_board *board, uint8_t *buffer, size_t length, 66 62 int send_eoi, size_t *bytes_written) 67 63 { 68 64 struct fluke_priv *priv = board->private_data; ··· 70 66 return nec7210_write(board, &priv->nec7210_priv, buffer, length, send_eoi, bytes_written); 71 67 } 72 68 73 - static int fluke_command(gpib_board_t *board, uint8_t *buffer, size_t length, size_t *bytes_written) 69 + static int fluke_command(struct gpib_board *board, uint8_t *buffer, 70 + size_t length, size_t *bytes_written) 74 71 { 75 72 struct fluke_priv *priv = board->private_data; 76 73 77 74 return nec7210_command(board, &priv->nec7210_priv, buffer, length, bytes_written); 78 75 } 79 76 80 - static int fluke_take_control(gpib_board_t *board, int synchronous) 77 + static int fluke_take_control(struct gpib_board *board, int synchronous) 81 78 { 82 79 struct fluke_priv *priv = board->private_data; 83 80 84 81 return nec7210_take_control(board, &priv->nec7210_priv, synchronous); 85 82 } 86 83 87 - static int fluke_go_to_standby(gpib_board_t *board) 84 + static int fluke_go_to_standby(struct gpib_board *board) 88 85 { 89 86 struct fluke_priv *priv = board->private_data; 90 87 91 88 return nec7210_go_to_standby(board, &priv->nec7210_priv); 92 89 } 93 90 94 - static void fluke_request_system_control(gpib_board_t *board, int request_control) 91 + static void fluke_request_system_control(struct gpib_board *board, int request_control) 95 92 { 96 93 struct fluke_priv *priv = board->private_data; 97 94 struct nec7210_priv *nec_priv = &priv->nec7210_priv; ··· 100 95 nec7210_request_system_control(board, nec_priv, request_control); 101 96 } 102 97 103 - static void fluke_interface_clear(gpib_board_t *board, int assert) 98 + static void fluke_interface_clear(struct gpib_board *board, int assert) 104 99 { 105 100 struct fluke_priv *priv = board->private_data; 106 101 107 102 nec7210_interface_clear(board, &priv->nec7210_priv, assert); 108 103 } 109 104 110 - static void fluke_remote_enable(gpib_board_t *board, int enable) 105 + static void fluke_remote_enable(struct gpib_board *board, int enable) 111 106 { 112 107 struct fluke_priv *priv = board->private_data; 113 108 114 109 nec7210_remote_enable(board, &priv->nec7210_priv, enable); 115 110 } 116 111 117 - static int fluke_enable_eos(gpib_board_t *board, uint8_t eos_byte, int compare_8_bits) 112 + static int fluke_enable_eos(struct gpib_board *board, uint8_t eos_byte, int compare_8_bits) 118 113 { 119 114 struct fluke_priv *priv = board->private_data; 120 115 121 116 return nec7210_enable_eos(board, &priv->nec7210_priv, eos_byte, compare_8_bits); 122 117 } 123 118 124 - static void fluke_disable_eos(gpib_board_t *board) 119 + static void fluke_disable_eos(struct gpib_board *board) 125 120 { 126 121 struct fluke_priv *priv = board->private_data; 127 122 128 123 nec7210_disable_eos(board, &priv->nec7210_priv); 129 124 } 130 125 131 - static unsigned int fluke_update_status(gpib_board_t *board, unsigned int clear_mask) 126 + static unsigned int fluke_update_status(struct gpib_board *board, unsigned int clear_mask) 132 127 { 133 128 struct fluke_priv *priv = board->private_data; 134 129 135 130 return nec7210_update_status(board, &priv->nec7210_priv, clear_mask); 136 131 } 137 132 138 - static int fluke_primary_address(gpib_board_t *board, unsigned int address) 133 + static int fluke_primary_address(struct gpib_board *board, unsigned int address) 139 134 { 140 135 struct fluke_priv *priv = board->private_data; 141 136 142 137 return nec7210_primary_address(board, &priv->nec7210_priv, address); 143 138 } 144 139 145 - static int fluke_secondary_address(gpib_board_t *board, unsigned int address, int enable) 140 + static int fluke_secondary_address(struct gpib_board *board, unsigned int address, int enable) 146 141 { 147 142 struct fluke_priv *priv = board->private_data; 148 143 149 144 return nec7210_secondary_address(board, &priv->nec7210_priv, address, enable); 150 145 } 151 146 152 - static int fluke_parallel_poll(gpib_board_t *board, uint8_t *result) 147 + static int fluke_parallel_poll(struct gpib_board *board, uint8_t *result) 153 148 { 154 149 struct fluke_priv *priv = board->private_data; 155 150 156 151 return nec7210_parallel_poll(board, &priv->nec7210_priv, result); 157 152 } 158 153 159 - static void fluke_parallel_poll_configure(gpib_board_t *board, uint8_t configuration) 154 + static void fluke_parallel_poll_configure(struct gpib_board *board, uint8_t configuration) 160 155 { 161 156 struct fluke_priv *priv = board->private_data; 162 157 163 158 nec7210_parallel_poll_configure(board, &priv->nec7210_priv, configuration); 164 159 } 165 160 166 - static void fluke_parallel_poll_response(gpib_board_t *board, int ist) 161 + static void fluke_parallel_poll_response(struct gpib_board *board, int ist) 167 162 { 168 163 struct fluke_priv *priv = board->private_data; 169 164 170 165 nec7210_parallel_poll_response(board, &priv->nec7210_priv, ist); 171 166 } 172 167 173 - static void fluke_serial_poll_response(gpib_board_t *board, uint8_t status) 168 + static void fluke_serial_poll_response(struct gpib_board *board, uint8_t status) 174 169 { 175 170 struct fluke_priv *priv = board->private_data; 176 171 177 172 nec7210_serial_poll_response(board, &priv->nec7210_priv, status); 178 173 } 179 174 180 - static uint8_t fluke_serial_poll_status(gpib_board_t *board) 175 + static uint8_t fluke_serial_poll_status(struct gpib_board *board) 181 176 { 182 177 struct fluke_priv *priv = board->private_data; 183 178 184 179 return nec7210_serial_poll_status(board, &priv->nec7210_priv); 185 180 } 186 181 187 - static void fluke_return_to_local(gpib_board_t *board) 182 + static void fluke_return_to_local(struct gpib_board *board) 188 183 { 189 184 struct fluke_priv *priv = board->private_data; 190 185 struct nec7210_priv *nec_priv = &priv->nec7210_priv; ··· 194 189 write_byte(nec_priv, AUX_RTL, AUXMR); 195 190 } 196 191 197 - static int fluke_line_status(const gpib_board_t *board) 192 + static int fluke_line_status(const struct gpib_board *board) 198 193 { 199 - int status = ValidALL; 194 + int status = VALID_ALL; 200 195 int bsr_bits; 201 196 struct fluke_priv *e_priv; 202 - struct nec7210_priv *nec_priv; 203 197 204 198 e_priv = board->private_data; 205 - nec_priv = &e_priv->nec7210_priv; 206 199 207 200 bsr_bits = fluke_paged_read_byte(e_priv, BUS_STATUS, BUS_STATUS_PAGE); 208 201 209 202 if ((bsr_bits & BSR_REN_BIT) == 0) 210 - status |= BusREN; 203 + status |= BUS_REN; 211 204 if ((bsr_bits & BSR_IFC_BIT) == 0) 212 - status |= BusIFC; 205 + status |= BUS_IFC; 213 206 if ((bsr_bits & BSR_SRQ_BIT) == 0) 214 - status |= BusSRQ; 207 + status |= BUS_SRQ; 215 208 if ((bsr_bits & BSR_EOI_BIT) == 0) 216 - status |= BusEOI; 209 + status |= BUS_EOI; 217 210 if ((bsr_bits & BSR_NRFD_BIT) == 0) 218 - status |= BusNRFD; 211 + status |= BUS_NRFD; 219 212 if ((bsr_bits & BSR_NDAC_BIT) == 0) 220 - status |= BusNDAC; 213 + status |= BUS_NDAC; 221 214 if ((bsr_bits & BSR_DAV_BIT) == 0) 222 - status |= BusDAV; 215 + status |= BUS_DAV; 223 216 if ((bsr_bits & BSR_ATN_BIT) == 0) 224 - status |= BusATN; 217 + status |= BUS_ATN; 225 218 226 219 return status; 227 220 } 228 221 229 - static unsigned int fluke_t1_delay(gpib_board_t *board, unsigned int nano_sec) 222 + static int fluke_t1_delay(struct gpib_board *board, unsigned int nano_sec) 230 223 { 231 224 struct fluke_priv *e_priv = board->private_data; 232 225 struct nec7210_priv *nec_priv = &e_priv->nec7210_priv; ··· 241 238 return retval; 242 239 } 243 240 244 - static int lacs_or_read_ready(gpib_board_t *board) 241 + static int lacs_or_read_ready(struct gpib_board *board) 245 242 { 246 243 const struct fluke_priv *e_priv = board->private_data; 247 244 const struct nec7210_priv *nec_priv = &e_priv->nec7210_priv; ··· 257 254 /* Wait until it is possible for a read to do something useful. This 258 255 * is not essential, it only exists to prevent RFD holdoff from being released pointlessly. 259 256 */ 260 - static int wait_for_read(gpib_board_t *board) 257 + static int wait_for_read(struct gpib_board *board) 261 258 { 262 259 struct fluke_priv *e_priv = board->private_data; 263 260 struct nec7210_priv *nec_priv = &e_priv->nec7210_priv; ··· 266 263 if (wait_event_interruptible(board->wait, 267 264 lacs_or_read_ready(board) || 268 265 test_bit(DEV_CLEAR_BN, &nec_priv->state) || 269 - test_bit(TIMO_NUM, &board->status))) { 266 + test_bit(TIMO_NUM, &board->status))) 270 267 retval = -ERESTARTSYS; 271 - } 268 + 272 269 if (test_bit(TIMO_NUM, &board->status)) 273 270 retval = -ETIMEDOUT; 274 271 if (test_and_clear_bit(DEV_CLEAR_BN, &nec_priv->state)) ··· 314 311 * If the chip is SGNS it is probably waiting for a a byte to 315 312 * be written to it. 316 313 */ 317 - static int wait_for_data_out_ready(gpib_board_t *board) 314 + static int wait_for_data_out_ready(struct gpib_board *board) 318 315 { 319 316 struct fluke_priv *e_priv = board->private_data; 320 317 struct nec7210_priv *nec_priv = &e_priv->nec7210_priv; 321 318 int retval = 0; 322 - // printk("%s: enter\n", __FUNCTION__); 323 319 324 320 if (wait_event_interruptible(board->wait, 325 321 (test_bit(TACS_NUM, &board->status) && 326 322 source_handshake_is_sgns(e_priv)) || 327 323 test_bit(DEV_CLEAR_BN, &nec_priv->state) || 328 - test_bit(TIMO_NUM, &board->status))) { 324 + test_bit(TIMO_NUM, &board->status))) 329 325 retval = -ERESTARTSYS; 330 - } 331 326 if (test_bit(TIMO_NUM, &board->status)) 332 327 retval = -ETIMEDOUT; 333 328 if (test_and_clear_bit(DEV_CLEAR_BN, &nec_priv->state)) 334 329 retval = -EINTR; 335 - // printk("%s: exit, retval=%i\n", __FUNCTION__, retval); 336 330 return retval; 337 331 } 338 332 339 - static int wait_for_sids_or_sgns(gpib_board_t *board) 333 + static int wait_for_sids_or_sgns(struct gpib_board *board) 340 334 { 341 335 struct fluke_priv *e_priv = board->private_data; 342 336 struct nec7210_priv *nec_priv = &e_priv->nec7210_priv; 343 337 int retval = 0; 344 - // printk("%s: enter\n", __FUNCTION__); 345 338 346 339 if (wait_event_interruptible(board->wait, 347 340 source_handshake_is_sids_or_sgns(e_priv) || ··· 349 350 retval = -ETIMEDOUT; 350 351 if (test_and_clear_bit(DEV_CLEAR_BN, &nec_priv->state)) 351 352 retval = -EINTR; 352 - // printk("%s: exit, retval=%i\n", __FUNCTION__, retval); 353 353 return retval; 354 354 } 355 355 356 356 static void fluke_dma_callback(void *arg) 357 357 { 358 - gpib_board_t *board = arg; 358 + struct gpib_board *board = arg; 359 359 struct fluke_priv *e_priv = board->private_data; 360 360 struct nec7210_priv *nec_priv = &e_priv->nec7210_priv; 361 361 unsigned long flags; 362 362 363 363 spin_lock_irqsave(&board->spinlock, flags); 364 - // printk("%s: enter\n", __FUNCTION__); 365 364 366 365 nec7210_set_reg_bits(nec_priv, IMR1, HR_DOIE | HR_DIIE, HR_DOIE | HR_DIIE); 367 366 wake_up_interruptible(&board->wait); ··· 367 370 fluke_gpib_internal_interrupt(board); 368 371 clear_bit(DMA_WRITE_IN_PROGRESS_BN, &nec_priv->state); 369 372 clear_bit(DMA_READ_IN_PROGRESS_BN, &nec_priv->state); 370 - // printk("%s: exit\n", __FUNCTION__); 373 + 371 374 spin_unlock_irqrestore(&board->spinlock, flags); 372 375 } 373 376 374 - static int fluke_dma_write(gpib_board_t *board, uint8_t *buffer, size_t length, 377 + static int fluke_dma_write(struct gpib_board *board, uint8_t *buffer, size_t length, 375 378 size_t *bytes_written) 376 379 { 377 380 struct fluke_priv *e_priv = board->private_data; ··· 382 385 struct dma_async_tx_descriptor *tx_desc; 383 386 384 387 *bytes_written = 0; 385 - // printk("%s: enter\n", __FUNCTION__); 388 + 386 389 if (WARN_ON_ONCE(length > e_priv->dma_buffer_size)) 387 390 return -EFAULT; 388 391 dmaengine_terminate_all(e_priv->dma_channel); ··· 400 403 tx_desc = dmaengine_prep_slave_single(e_priv->dma_channel, address, length, DMA_MEM_TO_DEV, 401 404 DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 402 405 if (!tx_desc) { 403 - pr_err("fluke_gpib: failed to allocate dma transmit descriptor\n"); 406 + dev_err(board->gpib_dev, "failed to allocate dma transmit descriptor\n"); 404 407 retval = -ENOMEM; 405 408 goto cleanup; 406 409 } ··· 416 419 clear_bit(WRITE_READY_BN, &nec_priv->state); 417 420 set_bit(DMA_WRITE_IN_PROGRESS_BN, &nec_priv->state); 418 421 419 - // printk("%s: in spin lock\n", __FUNCTION__); 420 422 spin_unlock_irqrestore(&board->spinlock, flags); 421 423 422 - // printk("%s: waiting for write.\n", __FUNCTION__); 423 424 // suspend until message is sent 424 425 if (wait_event_interruptible(board->wait, 425 426 ((readl(e_priv->write_transfer_counter) & ··· 425 430 test_bit(BUS_ERROR_BN, &nec_priv->state) || 426 431 test_bit(DEV_CLEAR_BN, &nec_priv->state) || 427 432 test_bit(TIMO_NUM, &board->status))) { 428 - dev_dbg(board->gpib_dev, "gpib write interrupted!\n"); 429 433 retval = -ERESTARTSYS; 430 434 } 431 435 if (test_bit(TIMO_NUM, &board->status)) ··· 453 459 454 460 cleanup: 455 461 dma_unmap_single(board->dev, address, length, DMA_TO_DEVICE); 456 - // printk("%s: exit, retval=%d\n", __FUNCTION__, retval); 457 462 return retval; 458 463 } 459 464 460 - static int fluke_accel_write(gpib_board_t *board, uint8_t *buffer, size_t length, 465 + static int fluke_accel_write(struct gpib_board *board, uint8_t *buffer, size_t length, 461 466 int send_eoi, size_t *bytes_written) 462 467 { 463 468 struct fluke_priv *e_priv = board->private_data; ··· 467 474 size_t dma_remainder = remainder; 468 475 469 476 if (!e_priv->dma_channel) { 470 - pr_err("fluke_gpib: No dma channel available, cannot do accel write."); 477 + dev_err(board->gpib_dev, "No dma channel available, cannot do accel write."); 471 478 return -ENXIO; 472 479 } 473 480 ··· 479 486 480 487 if (send_eoi) 481 488 --dma_remainder; 482 - // printk("%s: entering while loop\n", __FUNCTION__); 483 489 484 490 while (dma_remainder > 0) { 485 491 size_t num_bytes; ··· 504 512 //handle sending of last byte with eoi 505 513 if (send_eoi) { 506 514 size_t num_bytes; 507 - // printk("%s: handling last byte\n", __FUNCTION__); 515 + 508 516 if (WARN_ON_ONCE(remainder != 1)) 509 517 return -EFAULT; 510 518 ··· 525 533 return retval; 526 534 remainder -= num_bytes; 527 535 } 528 - // printk("%s: bytes send=%i\n", __FUNCTION__, (int)(length - remainder)); 529 536 return 0; 530 537 } 531 538 ··· 535 544 536 545 result = dmaengine_pause(chan); 537 546 if (result < 0) { 538 - pr_err("fluke_gpib: dma pause failed?\n"); 547 + pr_err("dma pause failed?\n"); 539 548 return result; 540 549 } 541 550 dmaengine_tx_status(chan, cookie, &state); ··· 544 553 return state.residue; 545 554 } 546 555 547 - static int fluke_dma_read(gpib_board_t *board, uint8_t *buffer, 556 + static int fluke_dma_read(struct gpib_board *board, uint8_t *buffer, 548 557 size_t length, int *end, size_t *bytes_read) 549 558 { 550 559 struct fluke_priv *e_priv = board->private_data; ··· 557 566 dma_cookie_t dma_cookie; 558 567 int i; 559 568 static const int timeout = 10; 560 - 561 - // printk("%s: enter, bus_address=0x%x, length=%i\n", __FUNCTION__, 562 - // (unsigned)bus_address, 563 - // (int)length); 564 569 565 570 *bytes_read = 0; 566 571 *end = 0; ··· 576 589 bus_address, length, DMA_DEV_TO_MEM, 577 590 DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 578 591 if (!tx_desc) { 579 - pr_err("fluke_gpib: failed to allocate dma transmit descriptor\n"); 592 + dev_err(board->gpib_dev, "failed to allocate dma transmit descriptor\n"); 580 593 dma_unmap_single(NULL, bus_address, length, DMA_FROM_DEVICE); 581 594 return -EIO; 582 595 } ··· 595 608 clear_bit(READ_READY_BN, &nec_priv->state); 596 609 597 610 spin_unlock_irqrestore(&board->spinlock, flags); 598 - // printk("waiting for data transfer.\n"); 599 611 // wait for data to transfer 600 612 if (wait_event_interruptible(board->wait, 601 613 test_bit(DMA_READ_IN_PROGRESS_BN, &nec_priv->state) == 0 || 602 614 test_bit(RECEIVED_END_BN, &nec_priv->state) || 603 615 test_bit(DEV_CLEAR_BN, &nec_priv->state) || 604 616 test_bit(TIMO_NUM, &board->status))) { 605 - pr_warn("fluke: dma read wait interrupted\n"); 606 617 retval = -ERESTARTSYS; 607 618 } 608 619 if (test_bit(TIMO_NUM, &board->status)) ··· 657 672 return retval; 658 673 } 659 674 660 - static int fluke_accel_read(gpib_board_t *board, uint8_t *buffer, size_t length, 675 + static int fluke_accel_read(struct gpib_board *board, uint8_t *buffer, size_t length, 661 676 int *end, size_t *bytes_read) 662 677 { 663 678 struct fluke_priv *e_priv = board->private_data; ··· 667 682 int retval = 0; 668 683 size_t dma_nbytes; 669 684 670 - /* printk("%s: enter, buffer=0x%p, length=%i\n", __FUNCTION__, 671 - * buffer, (int)length); 672 - * printk("\t dma_buffer=0x%p\n", e_priv->dma_buffer); 673 - */ 674 685 *end = 0; 675 686 *bytes_read = 0; 676 687 ··· 680 699 681 700 nec7210_release_rfd_holdoff(board, nec_priv); 682 701 683 - // printk("%s: entering while loop\n", __FUNCTION__); 684 702 while (remain > 0) { 685 703 transfer_size = (e_priv->dma_buffer_size < remain) ? 686 704 e_priv->dma_buffer_size : remain; ··· 689 709 *bytes_read += dma_nbytes; 690 710 if (*end) 691 711 break; 692 - if (retval < 0) { 693 - // printk("%s: early exit, retval=%i\n", __FUNCTION__, (int)retval); 712 + if (retval < 0) 694 713 return retval; 695 - } 696 714 if (need_resched()) 697 715 schedule(); 698 716 } 699 - // printk("%s: exit, retval=%i\n", __FUNCTION__, (int)retval); 717 + 700 718 return retval; 701 719 } 702 720 ··· 787 809 .return_to_local = fluke_return_to_local, 788 810 }; 789 811 790 - irqreturn_t fluke_gpib_internal_interrupt(gpib_board_t *board) 812 + irqreturn_t fluke_gpib_internal_interrupt(struct gpib_board *board) 791 813 { 792 814 int status0, status1, status2; 793 815 struct fluke_priv *priv = board->private_data; ··· 808 830 809 831 if (nec7210_interrupt_have_status(board, nec_priv, status1, status2) == IRQ_HANDLED) 810 832 retval = IRQ_HANDLED; 811 - /* 812 - * if((status1 & nec_priv->reg_bits[IMR1]) || 813 - * (status2 & (nec_priv->reg_bits[IMR2] & IMR2_ENABLE_INTR_MASK))) 814 - * { 815 - * printk("fluke: status1 0x%x, status2 0x%x\n", status1, status2); 816 - * } 817 - */ 818 833 819 834 if (read_byte(nec_priv, ADR0) & DATA_IN_STATUS) { 820 835 if (test_bit(RFD_HOLDOFF_BN, &nec_priv->state)) ··· 824 853 825 854 static irqreturn_t fluke_gpib_interrupt(int irq, void *arg) 826 855 { 827 - gpib_board_t *board = arg; 856 + struct gpib_board *board = arg; 828 857 unsigned long flags; 829 858 irqreturn_t retval; 830 859 ··· 834 863 return retval; 835 864 } 836 865 837 - static int fluke_allocate_private(gpib_board_t *board) 866 + static int fluke_allocate_private(struct gpib_board *board) 838 867 { 839 868 struct fluke_priv *priv; 840 869 ··· 851 880 return 0; 852 881 } 853 882 854 - static void fluke_generic_detach(gpib_board_t *board) 883 + static void fluke_generic_detach(struct gpib_board *board) 855 884 { 856 885 if (board->private_data) { 857 886 struct fluke_priv *e_priv = board->private_data; ··· 863 892 } 864 893 865 894 // generic part of attach functions shared by all cb7210 boards 866 - static int fluke_generic_attach(gpib_board_t *board) 895 + static int fluke_generic_attach(struct gpib_board *board) 867 896 { 868 897 struct fluke_priv *e_priv; 869 898 struct nec7210_priv *nec_priv; ··· 883 912 return 0; 884 913 } 885 914 886 - static int fluke_config_dma(gpib_board_t *board, int output) 915 + static int fluke_config_dma(struct gpib_board *board, int output) 887 916 { 888 917 struct fluke_priv *e_priv = board->private_data; 889 918 struct dma_slave_config config; ··· 908 937 return dmaengine_slave_config(e_priv->dma_channel, &config); 909 938 } 910 939 911 - static int fluke_init(struct fluke_priv *e_priv, gpib_board_t *board, int handshake_mode) 940 + static int fluke_init(struct fluke_priv *e_priv, struct gpib_board *board, int handshake_mode) 912 941 { 913 942 struct nec7210_priv *nec_priv = &e_priv->nec7210_priv; 914 943 ··· 925 954 926 955 /* poll so we can detect ATN changes */ 927 956 if (gpib_request_pseudo_irq(board, fluke_gpib_interrupt)) { 928 - pr_err("fluke_gpib: failed to allocate pseudo_irq\n"); 957 + dev_err(board->gpib_dev, "failed to allocate pseudo_irq\n"); 929 958 return -EINVAL; 930 959 } 931 960 ··· 943 972 return chan->chan_id == 0; 944 973 } 945 974 946 - static int fluke_attach_impl(gpib_board_t *board, const gpib_board_config_t *config, 975 + static int fluke_attach_impl(struct gpib_board *board, const gpib_board_config_t *config, 947 976 unsigned int handshake_mode) 948 977 { 949 978 struct fluke_priv *e_priv; ··· 955 984 dma_cap_mask_t dma_cap; 956 985 957 986 if (!fluke_gpib_pdev) { 958 - pr_err("No gpib platform device was found, attach failed.\n"); 987 + dev_err(board->gpib_dev, "No fluke device was found, attach failed.\n"); 959 988 return -ENODEV; 960 989 } 961 990 ··· 970 999 971 1000 res = platform_get_resource(fluke_gpib_pdev, IORESOURCE_MEM, 0); 972 1001 if (!res) { 973 - dev_err(&fluke_gpib_pdev->dev, "Unable to locate mmio resource for cb7210 gpib\n"); 1002 + dev_err(&fluke_gpib_pdev->dev, "Unable to locate mmio resource\n"); 974 1003 return -ENODEV; 975 1004 } 976 1005 ··· 983 1012 e_priv->gpib_iomem_res = res; 984 1013 985 1014 nec_priv->mmiobase = ioremap(e_priv->gpib_iomem_res->start, 986 - resource_size(e_priv->gpib_iomem_res)); 987 - pr_info("gpib: mmiobase %llx remapped to %p, length=%d\n", 988 - (u64)e_priv->gpib_iomem_res->start, 989 - nec_priv->mmiobase, (int)resource_size(e_priv->gpib_iomem_res)); 1015 + resource_size(e_priv->gpib_iomem_res)); 990 1016 if (!nec_priv->mmiobase) { 991 1017 dev_err(&fluke_gpib_pdev->dev, "Could not map I/O memory\n"); 992 1018 return -ENOMEM; ··· 1018 1050 1019 1051 e_priv->write_transfer_counter = ioremap(e_priv->write_transfer_counter_res->start, 1020 1052 resource_size(e_priv->write_transfer_counter_res)); 1021 - pr_info("gpib: write transfer counter %lx remapped to %p, length=%d\n", 1022 - (unsigned long)e_priv->write_transfer_counter_res->start, 1023 - e_priv->write_transfer_counter, 1024 - (int)resource_size(e_priv->write_transfer_counter_res)); 1025 1053 if (!e_priv->write_transfer_counter) { 1026 1054 dev_err(&fluke_gpib_pdev->dev, "Could not map I/O memory\n"); 1027 1055 return -ENOMEM; 1028 1056 } 1029 1057 1030 1058 irq = platform_get_irq(fluke_gpib_pdev, 0); 1031 - pr_info("gpib: irq %d\n", irq); 1032 1059 if (irq < 0) { 1033 - dev_err(&fluke_gpib_pdev->dev, "fluke_gpib: request for IRQ failed\n"); 1060 + dev_err(&fluke_gpib_pdev->dev, "failed to obtain IRQ\n"); 1034 1061 return -EBUSY; 1035 1062 } 1036 1063 retval = request_irq(irq, fluke_gpib_interrupt, isr_flags, fluke_gpib_pdev->name, board); ··· 1041 1078 dma_cap_set(DMA_SLAVE, dma_cap); 1042 1079 e_priv->dma_channel = dma_request_channel(dma_cap, gpib_dma_channel_filter, NULL); 1043 1080 if (!e_priv->dma_channel) { 1044 - pr_err("fluke_gpib: failed to allocate a dma channel.\n"); 1081 + dev_err(board->gpib_dev, "failed to allocate a dma channel.\n"); 1045 1082 // we don't error out here because unaccel interface will still 1046 1083 // work without dma 1047 1084 } ··· 1049 1086 return fluke_init(e_priv, board, handshake_mode); 1050 1087 } 1051 1088 1052 - int fluke_attach_holdoff_all(gpib_board_t *board, const gpib_board_config_t *config) 1089 + int fluke_attach_holdoff_all(struct gpib_board *board, const gpib_board_config_t *config) 1053 1090 { 1054 1091 return fluke_attach_impl(board, config, HR_HLDA); 1055 1092 } 1056 1093 1057 - int fluke_attach_holdoff_end(gpib_board_t *board, const gpib_board_config_t *config) 1094 + int fluke_attach_holdoff_end(struct gpib_board *board, const gpib_board_config_t *config) 1058 1095 { 1059 1096 return fluke_attach_impl(board, config, HR_HLDE); 1060 1097 } 1061 1098 1062 - void fluke_detach(gpib_board_t *board) 1099 + void fluke_detach(struct gpib_board *board) 1063 1100 { 1064 1101 struct fluke_priv *e_priv = board->private_data; 1065 1102 struct nec7210_priv *nec_priv; ··· 1105 1142 1106 1143 static struct platform_driver fluke_gpib_platform_driver = { 1107 1144 .driver = { 1108 - .name = "fluke_gpib", 1109 - .owner = THIS_MODULE, 1145 + .name = DRV_NAME, 1110 1146 .of_match_table = fluke_gpib_of_match, 1111 1147 }, 1112 1148 .probe = &fluke_gpib_probe ··· 1117 1155 1118 1156 result = platform_driver_register(&fluke_gpib_platform_driver); 1119 1157 if (result) { 1120 - pr_err("fluke_gpib: platform_driver_register failed: error = %d\n", result); 1158 + pr_err("platform_driver_register failed: error = %d\n", result); 1121 1159 return result; 1122 1160 } 1123 1161 1124 1162 result = gpib_register_driver(&fluke_unaccel_interface, THIS_MODULE); 1125 1163 if (result) { 1126 - pr_err("fluke_gpib: gpib_register_driver failed: error = %d\n", result); 1164 + pr_err("gpib_register_driver failed: error = %d\n", result); 1127 1165 goto err_unaccel; 1128 1166 } 1129 1167 1130 1168 result = gpib_register_driver(&fluke_hybrid_interface, THIS_MODULE); 1131 1169 if (result) { 1132 - pr_err("fluke_gpib: gpib_register_driver failed: error = %d\n", result); 1170 + pr_err("gpib_register_driver failed: error = %d\n", result); 1133 1171 goto err_hybrid; 1134 1172 } 1135 1173 1136 1174 result = gpib_register_driver(&fluke_interface, THIS_MODULE); 1137 1175 if (result) { 1138 - pr_err("fluke_gpib: gpib_register_driver failed: error = %d\n", result); 1176 + pr_err("gpib_register_driver failed: error = %d\n", result); 1139 1177 goto err_interface; 1140 1178 } 1141 1179
+124 -156
drivers/staging/gpib/fmh_gpib/fmh_gpib.c
··· 12 12 * (C) 2017 Frank Mori Hess 13 13 ***************************************************************************/ 14 14 15 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 16 + #define dev_fmt pr_fmt 17 + #define DRV_NAME KBUILD_MODNAME 18 + 15 19 #include "fmh_gpib.h" 16 20 17 21 #include "gpibP.h" ··· 32 28 MODULE_AUTHOR("Frank Mori Hess <fmh6jj@gmail.com>"); 33 29 34 30 static irqreturn_t fmh_gpib_interrupt(int irq, void *arg); 35 - static int fmh_gpib_attach_holdoff_all(gpib_board_t *board, const gpib_board_config_t *config); 36 - static int fmh_gpib_attach_holdoff_end(gpib_board_t *board, const gpib_board_config_t *config); 37 - static void fmh_gpib_detach(gpib_board_t *board); 38 - static int fmh_gpib_pci_attach_holdoff_all(gpib_board_t *board, const gpib_board_config_t *config); 39 - static int fmh_gpib_pci_attach_holdoff_end(gpib_board_t *board, const gpib_board_config_t *config); 40 - static void fmh_gpib_pci_detach(gpib_board_t *board); 41 - static int fmh_gpib_config_dma(gpib_board_t *board, int output); 42 - static irqreturn_t fmh_gpib_internal_interrupt(gpib_board_t *board); 31 + static int fmh_gpib_attach_holdoff_all(struct gpib_board *board, const gpib_board_config_t *config); 32 + static int fmh_gpib_attach_holdoff_end(struct gpib_board *board, const gpib_board_config_t *config); 33 + static void fmh_gpib_detach(struct gpib_board *board); 34 + static int fmh_gpib_pci_attach_holdoff_all(struct gpib_board *board, 35 + const gpib_board_config_t *config); 36 + static int fmh_gpib_pci_attach_holdoff_end(struct gpib_board *board, 37 + const gpib_board_config_t *config); 38 + static void fmh_gpib_pci_detach(struct gpib_board *board); 39 + static int fmh_gpib_config_dma(struct gpib_board *board, int output); 40 + static irqreturn_t fmh_gpib_internal_interrupt(struct gpib_board *board); 43 41 static struct platform_driver fmh_gpib_platform_driver; 44 42 static struct pci_driver fmh_gpib_pci_driver; 45 43 46 44 // wrappers for interface functions 47 - static int fmh_gpib_read(gpib_board_t *board, uint8_t *buffer, size_t length, 45 + static int fmh_gpib_read(struct gpib_board *board, uint8_t *buffer, size_t length, 48 46 int *end, size_t *bytes_read) 49 47 { 50 48 struct fmh_priv *priv = board->private_data; ··· 54 48 return nec7210_read(board, &priv->nec7210_priv, buffer, length, end, bytes_read); 55 49 } 56 50 57 - static int fmh_gpib_write(gpib_board_t *board, uint8_t *buffer, size_t length, 51 + static int fmh_gpib_write(struct gpib_board *board, uint8_t *buffer, size_t length, 58 52 int send_eoi, size_t *bytes_written) 59 53 { 60 54 struct fmh_priv *priv = board->private_data; ··· 62 56 return nec7210_write(board, &priv->nec7210_priv, buffer, length, send_eoi, bytes_written); 63 57 } 64 58 65 - static int fmh_gpib_command(gpib_board_t *board, uint8_t *buffer, size_t length, 59 + static int fmh_gpib_command(struct gpib_board *board, uint8_t *buffer, size_t length, 66 60 size_t *bytes_written) 67 61 { 68 62 struct fmh_priv *priv = board->private_data; ··· 70 64 return nec7210_command(board, &priv->nec7210_priv, buffer, length, bytes_written); 71 65 } 72 66 73 - static int fmh_gpib_take_control(gpib_board_t *board, int synchronous) 67 + static int fmh_gpib_take_control(struct gpib_board *board, int synchronous) 74 68 { 75 69 struct fmh_priv *priv = board->private_data; 76 70 77 71 return nec7210_take_control(board, &priv->nec7210_priv, synchronous); 78 72 } 79 73 80 - static int fmh_gpib_go_to_standby(gpib_board_t *board) 74 + static int fmh_gpib_go_to_standby(struct gpib_board *board) 81 75 { 82 76 struct fmh_priv *priv = board->private_data; 83 77 84 78 return nec7210_go_to_standby(board, &priv->nec7210_priv); 85 79 } 86 80 87 - static void fmh_gpib_request_system_control(gpib_board_t *board, int request_control) 81 + static void fmh_gpib_request_system_control(struct gpib_board *board, int request_control) 88 82 { 89 83 struct fmh_priv *priv = board->private_data; 90 84 struct nec7210_priv *nec_priv = &priv->nec7210_priv; ··· 92 86 nec7210_request_system_control(board, nec_priv, request_control); 93 87 } 94 88 95 - static void fmh_gpib_interface_clear(gpib_board_t *board, int assert) 89 + static void fmh_gpib_interface_clear(struct gpib_board *board, int assert) 96 90 { 97 91 struct fmh_priv *priv = board->private_data; 98 92 99 93 nec7210_interface_clear(board, &priv->nec7210_priv, assert); 100 94 } 101 95 102 - static void fmh_gpib_remote_enable(gpib_board_t *board, int enable) 96 + static void fmh_gpib_remote_enable(struct gpib_board *board, int enable) 103 97 { 104 98 struct fmh_priv *priv = board->private_data; 105 99 106 100 nec7210_remote_enable(board, &priv->nec7210_priv, enable); 107 101 } 108 102 109 - static int fmh_gpib_enable_eos(gpib_board_t *board, uint8_t eos_byte, int compare_8_bits) 103 + static int fmh_gpib_enable_eos(struct gpib_board *board, uint8_t eos_byte, int compare_8_bits) 110 104 { 111 105 struct fmh_priv *priv = board->private_data; 112 106 113 107 return nec7210_enable_eos(board, &priv->nec7210_priv, eos_byte, compare_8_bits); 114 108 } 115 109 116 - static void fmh_gpib_disable_eos(gpib_board_t *board) 110 + static void fmh_gpib_disable_eos(struct gpib_board *board) 117 111 { 118 112 struct fmh_priv *priv = board->private_data; 119 113 120 114 nec7210_disable_eos(board, &priv->nec7210_priv); 121 115 } 122 116 123 - static unsigned int fmh_gpib_update_status(gpib_board_t *board, unsigned int clear_mask) 117 + static unsigned int fmh_gpib_update_status(struct gpib_board *board, unsigned int clear_mask) 124 118 { 125 119 struct fmh_priv *priv = board->private_data; 126 120 127 121 return nec7210_update_status(board, &priv->nec7210_priv, clear_mask); 128 122 } 129 123 130 - static int fmh_gpib_primary_address(gpib_board_t *board, unsigned int address) 124 + static int fmh_gpib_primary_address(struct gpib_board *board, unsigned int address) 131 125 { 132 126 struct fmh_priv *priv = board->private_data; 133 127 134 128 return nec7210_primary_address(board, &priv->nec7210_priv, address); 135 129 } 136 130 137 - static int fmh_gpib_secondary_address(gpib_board_t *board, unsigned int address, int enable) 131 + static int fmh_gpib_secondary_address(struct gpib_board *board, unsigned int address, int enable) 138 132 { 139 133 struct fmh_priv *priv = board->private_data; 140 134 141 135 return nec7210_secondary_address(board, &priv->nec7210_priv, address, enable); 142 136 } 143 137 144 - static int fmh_gpib_parallel_poll(gpib_board_t *board, uint8_t *result) 138 + static int fmh_gpib_parallel_poll(struct gpib_board *board, uint8_t *result) 145 139 { 146 140 struct fmh_priv *priv = board->private_data; 147 141 148 142 return nec7210_parallel_poll(board, &priv->nec7210_priv, result); 149 143 } 150 144 151 - static void fmh_gpib_parallel_poll_configure(gpib_board_t *board, uint8_t configuration) 145 + static void fmh_gpib_parallel_poll_configure(struct gpib_board *board, uint8_t configuration) 152 146 { 153 147 struct fmh_priv *priv = board->private_data; 154 148 155 149 nec7210_parallel_poll_configure(board, &priv->nec7210_priv, configuration); 156 150 } 157 151 158 - static void fmh_gpib_parallel_poll_response(gpib_board_t *board, int ist) 152 + static void fmh_gpib_parallel_poll_response(struct gpib_board *board, int ist) 159 153 { 160 154 struct fmh_priv *priv = board->private_data; 161 155 162 156 nec7210_parallel_poll_response(board, &priv->nec7210_priv, ist); 163 157 } 164 158 165 - static void fmh_gpib_local_parallel_poll_mode(gpib_board_t *board, int local) 159 + static void fmh_gpib_local_parallel_poll_mode(struct gpib_board *board, int local) 166 160 { 167 161 struct fmh_priv *priv = board->private_data; 168 162 ··· 177 171 } 178 172 } 179 173 180 - static void fmh_gpib_serial_poll_response2(gpib_board_t *board, uint8_t status, 174 + static void fmh_gpib_serial_poll_response2(struct gpib_board *board, uint8_t status, 181 175 int new_reason_for_service) 182 176 { 183 177 struct fmh_priv *priv = board->private_data; ··· 212 206 spin_unlock_irqrestore(&board->spinlock, flags); 213 207 } 214 208 215 - static uint8_t fmh_gpib_serial_poll_status(gpib_board_t *board) 209 + static uint8_t fmh_gpib_serial_poll_status(struct gpib_board *board) 216 210 { 217 211 struct fmh_priv *priv = board->private_data; 218 212 219 213 return nec7210_serial_poll_status(board, &priv->nec7210_priv); 220 214 } 221 215 222 - static void fmh_gpib_return_to_local(gpib_board_t *board) 216 + static void fmh_gpib_return_to_local(struct gpib_board *board) 223 217 { 224 218 struct fmh_priv *priv = board->private_data; 225 219 struct nec7210_priv *nec_priv = &priv->nec7210_priv; ··· 229 223 write_byte(nec_priv, AUX_RTL, AUXMR); 230 224 } 231 225 232 - static int fmh_gpib_line_status(const gpib_board_t *board) 226 + static int fmh_gpib_line_status(const struct gpib_board *board) 233 227 { 234 - int status = ValidALL; 228 + int status = VALID_ALL; 235 229 int bsr_bits; 236 230 struct fmh_priv *e_priv; 237 231 struct nec7210_priv *nec_priv; ··· 242 236 bsr_bits = read_byte(nec_priv, BUS_STATUS_REG); 243 237 244 238 if ((bsr_bits & BSR_REN_BIT) == 0) 245 - status |= BusREN; 239 + status |= BUS_REN; 246 240 if ((bsr_bits & BSR_IFC_BIT) == 0) 247 - status |= BusIFC; 241 + status |= BUS_IFC; 248 242 if ((bsr_bits & BSR_SRQ_BIT) == 0) 249 - status |= BusSRQ; 243 + status |= BUS_SRQ; 250 244 if ((bsr_bits & BSR_EOI_BIT) == 0) 251 - status |= BusEOI; 245 + status |= BUS_EOI; 252 246 if ((bsr_bits & BSR_NRFD_BIT) == 0) 253 - status |= BusNRFD; 247 + status |= BUS_NRFD; 254 248 if ((bsr_bits & BSR_NDAC_BIT) == 0) 255 - status |= BusNDAC; 249 + status |= BUS_NDAC; 256 250 if ((bsr_bits & BSR_DAV_BIT) == 0) 257 - status |= BusDAV; 251 + status |= BUS_DAV; 258 252 if ((bsr_bits & BSR_ATN_BIT) == 0) 259 - status |= BusATN; 253 + status |= BUS_ATN; 260 254 261 255 return status; 262 256 } 263 257 264 - static unsigned int fmh_gpib_t1_delay(gpib_board_t *board, unsigned int nano_sec) 258 + static int fmh_gpib_t1_delay(struct gpib_board *board, unsigned int nano_sec) 265 259 { 266 260 struct fmh_priv *e_priv = board->private_data; 267 261 struct nec7210_priv *nec_priv = &e_priv->nec7210_priv; ··· 278 272 return retval; 279 273 } 280 274 281 - static int lacs_or_read_ready(gpib_board_t *board) 275 + static int lacs_or_read_ready(struct gpib_board *board) 282 276 { 283 277 const struct fmh_priv *e_priv = board->private_data; 284 278 const struct nec7210_priv *nec_priv = &e_priv->nec7210_priv; ··· 293 287 return retval; 294 288 } 295 289 296 - static int wait_for_read(gpib_board_t *board) 290 + static int wait_for_read(struct gpib_board *board) 297 291 { 298 292 struct fmh_priv *e_priv = board->private_data; 299 293 struct nec7210_priv *nec_priv = &e_priv->nec7210_priv; ··· 312 306 return retval; 313 307 } 314 308 315 - static int wait_for_rx_fifo_half_full_or_end(gpib_board_t *board) 309 + static int wait_for_rx_fifo_half_full_or_end(struct gpib_board *board) 316 310 { 317 311 struct fmh_priv *e_priv = board->private_data; 318 312 struct nec7210_priv *nec_priv = &e_priv->nec7210_priv; ··· 335 329 336 330 /* Wait until the gpib chip is ready to accept a data out byte. 337 331 */ 338 - static int wait_for_data_out_ready(gpib_board_t *board) 332 + static int wait_for_data_out_ready(struct gpib_board *board) 339 333 { 340 334 struct fmh_priv *e_priv = board->private_data; 341 335 struct nec7210_priv *nec_priv = &e_priv->nec7210_priv; 342 336 int retval = 0; 343 - // printk("%s: enter\n", __FUNCTION__); 344 337 345 338 if (wait_event_interruptible(board->wait, 346 339 (test_bit(TACS_NUM, &board->status) && ··· 353 348 retval = -ETIMEDOUT; 354 349 if (test_and_clear_bit(DEV_CLEAR_BN, &nec_priv->state)) 355 350 retval = -EINTR; 356 - // printk("%s: exit, retval=%i\n", __FUNCTION__, retval); 351 + 357 352 return retval; 358 353 } 359 354 360 355 static void fmh_gpib_dma_callback(void *arg) 361 356 { 362 - gpib_board_t *board = arg; 357 + struct gpib_board *board = arg; 363 358 struct fmh_priv *e_priv = board->private_data; 364 359 struct nec7210_priv *nec_priv = &e_priv->nec7210_priv; 365 360 unsigned long flags; 366 361 367 362 spin_lock_irqsave(&board->spinlock, flags); 368 - // printk("%s: enter\n", __FUNCTION__); 369 363 370 364 nec7210_set_reg_bits(nec_priv, IMR1, HR_DOIE | HR_DIIE, HR_DOIE | HR_DIIE); 371 365 wake_up_interruptible(&board->wait); ··· 374 370 clear_bit(DMA_WRITE_IN_PROGRESS_BN, &nec_priv->state); 375 371 clear_bit(DMA_READ_IN_PROGRESS_BN, &nec_priv->state); 376 372 377 - // printk("%s: exit\n", __FUNCTION__); 378 373 spin_unlock_irqrestore(&board->spinlock, flags); 379 374 } 380 375 ··· 391 388 return 1; 392 389 } 393 390 394 - static int fmh_gpib_dma_write(gpib_board_t *board, uint8_t *buffer, size_t length, 391 + static int fmh_gpib_dma_write(struct gpib_board *board, uint8_t *buffer, size_t length, 395 392 size_t *bytes_written) 396 393 { 397 394 struct fmh_priv *e_priv = board->private_data; ··· 402 399 struct dma_async_tx_descriptor *tx_desc; 403 400 404 401 *bytes_written = 0; 405 - // printk("%s: enter\n", __FUNCTION__); 406 402 if (WARN_ON_ONCE(length > e_priv->dma_buffer_size)) 407 403 return -EFAULT; 408 404 dmaengine_terminate_all(e_priv->dma_channel); 409 405 memcpy(e_priv->dma_buffer, buffer, length); 410 406 address = dma_map_single(board->dev, e_priv->dma_buffer, length, DMA_TO_DEVICE); 411 407 if (dma_mapping_error(board->dev, address)) 412 - pr_err("dma mapping error in dma write!\n"); 408 + dev_err(board->gpib_dev, "dma mapping error in dma write!\n"); 413 409 /* program dma controller */ 414 410 retval = fmh_gpib_config_dma(board, 1); 415 411 if (retval) ··· 417 415 tx_desc = dmaengine_prep_slave_single(e_priv->dma_channel, address, length, DMA_MEM_TO_DEV, 418 416 DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 419 417 if (!tx_desc) { 420 - pr_err("fmh_gpib_gpib: failed to allocate dma transmit descriptor\n"); 418 + dev_err(board->gpib_dev, "failed to allocate dma transmit descriptor\n"); 421 419 retval = -ENOMEM; 422 420 goto cleanup; 423 421 } ··· 434 432 dma_async_issue_pending(e_priv->dma_channel); 435 433 clear_bit(WRITE_READY_BN, &nec_priv->state); 436 434 set_bit(DMA_WRITE_IN_PROGRESS_BN, &nec_priv->state); 437 - // printk("%s: in spin lock\n", __FUNCTION__); 435 + 438 436 spin_unlock_irqrestore(&board->spinlock, flags); 439 437 440 - // printk("%s: waiting for write.\n", __FUNCTION__); 441 438 // suspend until message is sent 442 439 if (wait_event_interruptible(board->wait, 443 440 fmh_gpib_all_bytes_are_sent(e_priv) || 444 441 test_bit(BUS_ERROR_BN, &nec_priv->state) || 445 442 test_bit(DEV_CLEAR_BN, &nec_priv->state) || 446 - test_bit(TIMO_NUM, &board->status))) { 447 - dev_dbg(board->gpib_dev, "gpib write interrupted!\n"); 443 + test_bit(TIMO_NUM, &board->status))) 448 444 retval = -ERESTARTSYS; 449 - } 445 + 450 446 if (test_bit(TIMO_NUM, &board->status)) 451 447 retval = -ETIMEDOUT; 452 448 if (test_and_clear_bit(DEV_CLEAR_BN, &nec_priv->state)) ··· 464 464 fifo_xfer_counter_mask); 465 465 if (WARN_ON_ONCE(*bytes_written > length)) 466 466 return -EFAULT; 467 - /* printk("length=%i, *bytes_written=%i, residue=%i, retval=%i\n", 468 - * length, *bytes_written, get_dma_residue(e_priv->dma_channel), retval); 469 - */ 470 467 cleanup: 471 468 dma_unmap_single(board->dev, address, length, DMA_TO_DEVICE); 472 - // printk("%s: exit, retval=%d\n", __FUNCTION__, retval); 473 469 return retval; 474 470 } 475 471 476 - static int fmh_gpib_accel_write(gpib_board_t *board, uint8_t *buffer, 472 + static int fmh_gpib_accel_write(struct gpib_board *board, uint8_t *buffer, 477 473 size_t length, int send_eoi, size_t *bytes_written) 478 474 { 479 475 struct fmh_priv *e_priv = board->private_data; ··· 480 484 size_t dma_remainder = remainder; 481 485 482 486 if (!e_priv->dma_channel) { 483 - pr_err("fmh_gpib_gpib: No dma channel available, cannot do accel write."); 487 + dev_err(board->gpib_dev, "No dma channel available, cannot do accel write."); 484 488 return -ENXIO; 485 489 } 486 490 ··· 494 498 495 499 if (send_eoi) 496 500 --dma_remainder; 497 - // printk("%s: entering while loop\n", __FUNCTION__); 498 501 499 502 while (dma_remainder > 0) { 500 503 size_t num_bytes; ··· 519 524 //handle sending of last byte with eoi 520 525 if (send_eoi) { 521 526 size_t num_bytes; 522 - // printk("%s: handling last byte\n", __FUNCTION__); 527 + 523 528 if (WARN_ON_ONCE(remainder != 1)) 524 529 return -EFAULT; 525 530 ··· 540 545 return retval; 541 546 remainder -= num_bytes; 542 547 } 543 - // printk("%s: bytes send=%i\n", __FUNCTION__, (int)(length - remainder)); 544 548 return 0; 545 549 } 546 550 ··· 550 556 551 557 result = dmaengine_pause(chan); 552 558 if (result < 0) { 553 - pr_err("fmh_gpib_gpib: dma pause failed?\n"); 559 + pr_err("dma pause failed?\n"); 554 560 return result; 555 561 } 556 562 dmaengine_tx_status(chan, cookie, &state); ··· 559 565 return state.residue; 560 566 } 561 567 562 - static int wait_for_tx_fifo_half_empty(gpib_board_t *board) 568 + static int wait_for_tx_fifo_half_empty(struct gpib_board *board) 563 569 { 564 570 struct fmh_priv *e_priv = board->private_data; 565 571 struct nec7210_priv *nec_priv = &e_priv->nec7210_priv; 566 572 int retval = 0; 567 - // printk("%s: enter\n", __FUNCTION__); 568 573 569 574 if (wait_event_interruptible(board->wait, 570 575 (test_bit(TACS_NUM, &board->status) && ··· 577 584 retval = -ETIMEDOUT; 578 585 if (test_and_clear_bit(DEV_CLEAR_BN, &nec_priv->state)) 579 586 retval = -EINTR; 580 - // printk("%s: exit, retval=%i\n", __FUNCTION__, retval); 587 + 581 588 return retval; 582 589 } 583 590 584 591 /* supports writing a chunk of data whose length must fit into the hardware'd xfer counter, 585 592 * called in a loop by fmh_gpib_fifo_write() 586 593 */ 587 - static int fmh_gpib_fifo_write_countable(gpib_board_t *board, uint8_t *buffer, 594 + static int fmh_gpib_fifo_write_countable(struct gpib_board *board, uint8_t *buffer, 588 595 size_t length, int send_eoi, size_t *bytes_written) 589 596 { 590 597 struct fmh_priv *e_priv = board->private_data; ··· 593 600 unsigned int remainder; 594 601 595 602 *bytes_written = 0; 596 - // printk("%s: enter\n", __FUNCTION__); 597 603 if (WARN_ON_ONCE(length > fifo_xfer_counter_mask)) 598 604 return -EFAULT; 599 605 ··· 627 635 fmh_gpib_all_bytes_are_sent(e_priv) || 628 636 test_bit(BUS_ERROR_BN, &nec_priv->state) || 629 637 test_bit(DEV_CLEAR_BN, &nec_priv->state) || 630 - test_bit(TIMO_NUM, &board->status))) { 631 - dev_dbg(board->gpib_dev, "gpib write interrupted!\n"); 638 + test_bit(TIMO_NUM, &board->status))) 632 639 retval = -ERESTARTSYS; 633 - } 640 + 634 641 if (test_bit(TIMO_NUM, &board->status)) 635 642 retval = -ETIMEDOUT; 636 643 if (test_and_clear_bit(DEV_CLEAR_BN, &nec_priv->state)) ··· 646 655 fifo_xfer_counter_mask); 647 656 if (WARN_ON_ONCE(*bytes_written > length)) 648 657 return -EFAULT; 649 - /* printk("length=%i, *bytes_written=%i, residue=%i, retval=%i\n", 650 - * length, *bytes_written, get_dma_residue(e_priv->dma_channel), retval); 651 - */ 652 658 653 - // printk("%s: exit, retval=%d\n", __FUNCTION__, retval); 654 659 return retval; 655 660 } 656 661 657 - static int fmh_gpib_fifo_write(gpib_board_t *board, uint8_t *buffer, size_t length, 662 + static int fmh_gpib_fifo_write(struct gpib_board *board, uint8_t *buffer, size_t length, 658 663 int send_eoi, size_t *bytes_written) 659 664 { 660 665 struct fmh_priv *e_priv = board->private_data; ··· 664 677 return 0; 665 678 666 679 clear_bit(DEV_CLEAR_BN, &nec_priv->state); // XXX FIXME 667 - 668 - // printk("%s: entering while loop\n", __FUNCTION__); 669 680 670 681 while (remainder > 0) { 671 682 size_t num_bytes; ··· 693 708 if (need_resched()) 694 709 schedule(); 695 710 } 696 - // printk("%s: bytes send=%i\n", __FUNCTION__, (int)(length - remainder)); 711 + 697 712 return retval; 698 713 } 699 714 700 - static int fmh_gpib_dma_read(gpib_board_t *board, uint8_t *buffer, 715 + static int fmh_gpib_dma_read(struct gpib_board *board, uint8_t *buffer, 701 716 size_t length, int *end, size_t *bytes_read) 702 717 { 703 718 struct fmh_priv *e_priv = board->private_data; ··· 710 725 struct dma_async_tx_descriptor *tx_desc; 711 726 dma_cookie_t dma_cookie; 712 727 713 - // printk("%s: enter, bus_address=0x%x, length=%i\n", __FUNCTION__, 714 - //(unsigned)bus_address, 715 - // (int)length); 716 - 717 728 *bytes_read = 0; 718 729 *end = 0; 719 730 if (length == 0) ··· 718 737 bus_address = dma_map_single(board->dev, e_priv->dma_buffer, 719 738 length, DMA_FROM_DEVICE); 720 739 if (dma_mapping_error(board->dev, bus_address)) 721 - pr_err("dma mapping error in dma read!"); 740 + dev_err(board->gpib_dev, "dma mapping error in dma read!"); 722 741 723 742 /* program dma controller */ 724 743 retval = fmh_gpib_config_dma(board, 0); ··· 730 749 length, DMA_DEV_TO_MEM, 731 750 DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 732 751 if (!tx_desc) { 733 - pr_err("fmh_gpib_gpib: failed to allocate dma transmit descriptor\n"); 752 + dev_err(board->gpib_dev, "failed to allocate dma transmit descriptor\n"); 734 753 dma_unmap_single(board->dev, bus_address, length, DMA_FROM_DEVICE); 735 754 return -EIO; 736 755 } ··· 750 769 set_bit(DMA_READ_IN_PROGRESS_BN, &nec_priv->state); 751 770 752 771 spin_unlock_irqrestore(&board->spinlock, flags); 753 - // printk("waiting for data transfer.\n"); 772 + 754 773 // wait for data to transfer 755 774 wait_retval = wait_event_interruptible(board->wait, 756 775 test_bit(DMA_READ_IN_PROGRESS_BN, &nec_priv->state) ··· 758 777 test_bit(RECEIVED_END_BN, &nec_priv->state) || 759 778 test_bit(DEV_CLEAR_BN, &nec_priv->state) || 760 779 test_bit(TIMO_NUM, &board->status)); 761 - if (wait_retval) { 762 - pr_warn("fmh_gpib: dma read wait interrupted\n"); 780 + if (wait_retval) 763 781 retval = -ERESTARTSYS; 764 - } 782 + 765 783 if (test_bit(TIMO_NUM, &board->status)) 766 784 retval = -ETIMEDOUT; 767 785 if (test_bit(DEV_CLEAR_BN, &nec_priv->state)) ··· 805 825 *end = 1; 806 826 } 807 827 spin_unlock_irqrestore(&board->spinlock, flags); 808 - // printk("\tbytes_read=%i, residue=%i, end=%i, retval=%i, wait_retval=%i\n", 809 - // *bytes_read, residue, *end, retval, wait_retval); 810 828 811 829 return retval; 812 830 } 813 831 814 - static void fmh_gpib_release_rfd_holdoff(gpib_board_t *board, struct fmh_priv *e_priv) 832 + static void fmh_gpib_release_rfd_holdoff(struct gpib_board *board, struct fmh_priv *e_priv) 815 833 { 816 834 struct nec7210_priv *nec_priv = &e_priv->nec7210_priv; 817 835 unsigned int ext_status_1; ··· 846 868 spin_unlock_irqrestore(&board->spinlock, flags); 847 869 } 848 870 849 - static int fmh_gpib_accel_read(gpib_board_t *board, uint8_t *buffer, size_t length, 871 + static int fmh_gpib_accel_read(struct gpib_board *board, uint8_t *buffer, size_t length, 850 872 int *end, size_t *bytes_read) 851 873 { 852 874 struct fmh_priv *e_priv = board->private_data; ··· 896 918 /* Read a chunk of data whose length is within the limits of the hardware's 897 919 * xfer counter. Called in a loop from fmh_gpib_fifo_read(). 898 920 */ 899 - static int fmh_gpib_fifo_read_countable(gpib_board_t *board, uint8_t *buffer, 921 + static int fmh_gpib_fifo_read_countable(struct gpib_board *board, uint8_t *buffer, 900 922 size_t length, int *end, size_t *bytes_read) 901 923 { 902 924 struct fmh_priv *e_priv = board->private_data; 903 925 struct nec7210_priv *nec_priv = &e_priv->nec7210_priv; 904 926 int retval = 0; 905 - 906 - // printk("%s: enter, bus_address=0x%x, length=%i\n", __FUNCTION__, 907 - // (unsigned)bus_address, 908 - // (int)length); 909 927 910 928 *bytes_read = 0; 911 929 *end = 0; ··· 951 977 *end = 1; 952 978 } 953 979 954 - // printk("\tbytes_read=%i, end=%i, retval=%i, wait_retval=%i\n", 955 - // *bytes_read, *end, retval, wait_retval); 956 - 957 980 return retval; 958 981 } 959 982 960 - static int fmh_gpib_fifo_read(gpib_board_t *board, uint8_t *buffer, size_t length, 983 + static int fmh_gpib_fifo_read(struct gpib_board *board, uint8_t *buffer, size_t length, 961 984 int *end, size_t *bytes_read) 962 985 { 963 986 struct fmh_priv *e_priv = board->private_data; ··· 1123 1152 .return_to_local = fmh_gpib_return_to_local, 1124 1153 }; 1125 1154 1126 - irqreturn_t fmh_gpib_internal_interrupt(gpib_board_t *board) 1155 + irqreturn_t fmh_gpib_internal_interrupt(struct gpib_board *board) 1127 1156 { 1128 1157 unsigned int status0, status1, status2, ext_status_1, fifo_status; 1129 1158 struct fmh_priv *priv = board->private_data; ··· 1213 1242 1214 1243 irqreturn_t fmh_gpib_interrupt(int irq, void *arg) 1215 1244 { 1216 - gpib_board_t *board = arg; 1245 + struct gpib_board *board = arg; 1217 1246 unsigned long flags; 1218 1247 irqreturn_t retval; 1219 1248 ··· 1223 1252 return retval; 1224 1253 } 1225 1254 1226 - static int fmh_gpib_allocate_private(gpib_board_t *board) 1255 + static int fmh_gpib_allocate_private(struct gpib_board *board) 1227 1256 { 1228 1257 struct fmh_priv *priv; 1229 1258 ··· 1240 1269 return 0; 1241 1270 } 1242 1271 1243 - static void fmh_gpib_generic_detach(gpib_board_t *board) 1272 + static void fmh_gpib_generic_detach(struct gpib_board *board) 1244 1273 { 1245 1274 if (board->private_data) { 1246 1275 struct fmh_priv *e_priv = board->private_data; ··· 1254 1283 } 1255 1284 1256 1285 // generic part of attach functions 1257 - static int fmh_gpib_generic_attach(gpib_board_t *board) 1286 + static int fmh_gpib_generic_attach(struct gpib_board *board) 1258 1287 { 1259 1288 struct fmh_priv *e_priv; 1260 1289 struct nec7210_priv *nec_priv; ··· 1274 1303 return 0; 1275 1304 } 1276 1305 1277 - static int fmh_gpib_config_dma(gpib_board_t *board, int output) 1306 + static int fmh_gpib_config_dma(struct gpib_board *board, int output) 1278 1307 { 1279 1308 struct fmh_priv *e_priv = board->private_data; 1280 1309 struct dma_slave_config config; ··· 1304 1333 return dmaengine_slave_config(e_priv->dma_channel, &config); 1305 1334 } 1306 1335 1307 - static int fmh_gpib_init(struct fmh_priv *e_priv, gpib_board_t *board, int handshake_mode) 1336 + static int fmh_gpib_init(struct fmh_priv *e_priv, struct gpib_board *board, int handshake_mode) 1308 1337 { 1309 1338 struct nec7210_priv *nec_priv = &e_priv->nec7210_priv; 1310 1339 unsigned long flags; ··· 1347 1376 if (config->serial_number) 1348 1377 return 0; 1349 1378 1350 - dev_notice(dev, "matched: %s\n", of_node_full_name(dev_of_node((dev)))); 1379 + dev_dbg(dev, "matched: %s\n", of_node_full_name(dev_of_node((dev)))); 1351 1380 return 1; 1352 1381 } 1353 1382 1354 - static int fmh_gpib_attach_impl(gpib_board_t *board, const gpib_board_config_t *config, 1383 + static int fmh_gpib_attach_impl(struct gpib_board *board, const gpib_board_config_t *config, 1355 1384 unsigned int handshake_mode, int acquire_dma) 1356 1385 { 1357 1386 struct fmh_priv *e_priv; ··· 1364 1393 board->dev = driver_find_device(&fmh_gpib_platform_driver.driver, 1365 1394 NULL, (const void *)config, &fmh_gpib_device_match); 1366 1395 if (!board->dev) { 1367 - pr_err("No matching fmh_gpib_core device was found, attach failed."); 1396 + dev_err(board->gpib_dev, "No matching fmh_gpib_core device was found, attach failed."); 1368 1397 return -ENODEV; 1369 1398 } 1370 1399 // currently only used to mark the device as already attached ··· 1380 1409 1381 1410 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "gpib_control_status"); 1382 1411 if (!res) { 1383 - dev_err(board->dev, "Unable to locate mmio resource for cb7210 gpib\n"); 1412 + dev_err(board->dev, "Unable to locate mmio resource\n"); 1384 1413 return -ENODEV; 1385 1414 } 1386 1415 ··· 1393 1422 e_priv->gpib_iomem_res = res; 1394 1423 1395 1424 nec_priv->mmiobase = ioremap(e_priv->gpib_iomem_res->start, 1396 - resource_size(e_priv->gpib_iomem_res)); 1425 + resource_size(e_priv->gpib_iomem_res)); 1397 1426 if (!nec_priv->mmiobase) { 1398 - dev_err(board->dev, "Could not map I/O memory for gpib\n"); 1427 + dev_err(board->dev, "Could not map I/O memory\n"); 1399 1428 return -ENOMEM; 1400 1429 } 1401 - dev_info(board->dev, "iobase %pr remapped to %p\n", 1402 - e_priv->gpib_iomem_res, nec_priv->mmiobase); 1430 + dev_dbg(board->dev, "iobase %pr remapped to %p\n", 1431 + e_priv->gpib_iomem_res, nec_priv->mmiobase); 1403 1432 1404 1433 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dma_fifos"); 1405 1434 if (!res) { ··· 1419 1448 dev_err(board->dev, "Could not map I/O memory for fifos\n"); 1420 1449 return -ENOMEM; 1421 1450 } 1422 - dev_info(board->dev, "dma fifos 0x%lx remapped to %p, length=%ld\n", 1423 - (unsigned long)e_priv->dma_port_res->start, e_priv->fifo_base, 1424 - (unsigned long)resource_size(e_priv->dma_port_res)); 1451 + dev_dbg(board->dev, "dma fifos 0x%lx remapped to %p, length=%ld\n", 1452 + (unsigned long)e_priv->dma_port_res->start, e_priv->fifo_base, 1453 + (unsigned long)resource_size(e_priv->dma_port_res)); 1425 1454 1426 1455 irq = platform_get_irq(pdev, 0); 1427 - pr_info("gpib: irq %d\n", irq); 1428 1456 if (irq < 0) { 1429 - dev_err(board->dev, "fmh_gpib_gpib: request for IRQ failed\n"); 1457 + dev_err(board->dev, "request for IRQ failed\n"); 1430 1458 return -EBUSY; 1431 1459 } 1432 1460 retval = request_irq(irq, fmh_gpib_interrupt, IRQF_SHARED, pdev->name, board); ··· 1454 1484 return fmh_gpib_init(e_priv, board, handshake_mode); 1455 1485 } 1456 1486 1457 - int fmh_gpib_attach_holdoff_all(gpib_board_t *board, const gpib_board_config_t *config) 1487 + int fmh_gpib_attach_holdoff_all(struct gpib_board *board, const gpib_board_config_t *config) 1458 1488 { 1459 1489 return fmh_gpib_attach_impl(board, config, HR_HLDA, 0); 1460 1490 } 1461 1491 1462 - int fmh_gpib_attach_holdoff_end(gpib_board_t *board, const gpib_board_config_t *config) 1492 + int fmh_gpib_attach_holdoff_end(struct gpib_board *board, const gpib_board_config_t *config) 1463 1493 { 1464 1494 return fmh_gpib_attach_impl(board, config, HR_HLDE, 1); 1465 1495 } 1466 1496 1467 - void fmh_gpib_detach(gpib_board_t *board) 1497 + void fmh_gpib_detach(struct gpib_board *board) 1468 1498 { 1469 1499 struct fmh_priv *e_priv = board->private_data; 1470 1500 struct nec7210_priv *nec_priv; ··· 1497 1527 fmh_gpib_generic_detach(board); 1498 1528 } 1499 1529 1500 - static int fmh_gpib_pci_attach_impl(gpib_board_t *board, const gpib_board_config_t *config, 1530 + static int fmh_gpib_pci_attach_impl(struct gpib_board *board, const gpib_board_config_t *config, 1501 1531 unsigned int handshake_mode) 1502 1532 { 1503 1533 struct fmh_priv *e_priv; ··· 1516 1546 pci_device = gpib_pci_get_device(config, BOGUS_PCI_VENDOR_ID_FLUKE, 1517 1547 BOGUS_PCI_DEVICE_ID_FLUKE_BLADERUNNER, NULL); 1518 1548 if (!pci_device) { 1519 - pr_err("No matching fmh_gpib_core pci device was found, attach failed."); 1549 + dev_err(board->gpib_dev, "No matching fmh_gpib_core pci device was found, attach failed."); 1520 1550 return -ENODEV; 1521 1551 } 1522 1552 board->dev = &pci_device->dev; ··· 1533 1563 return -EIO; 1534 1564 } 1535 1565 e_priv->gpib_iomem_res = &pci_device->resource[gpib_control_status_pci_resource_index]; 1536 - e_priv->dma_port_res = &pci_device->resource[gpib_fifo_pci_resource_index]; 1566 + e_priv->dma_port_res = &pci_device->resource[gpib_fifo_pci_resource_index]; 1537 1567 1538 1568 nec_priv->mmiobase = ioremap(pci_resource_start(pci_device, 1539 - gpib_control_status_pci_resource_index), 1540 - pci_resource_len(pci_device, 1541 - gpib_control_status_pci_resource_index)); 1542 - dev_info(board->dev, "base address for gpib control/status registers remapped to 0x%p\n", 1543 - nec_priv->mmiobase); 1569 + gpib_control_status_pci_resource_index), 1570 + pci_resource_len(pci_device, 1571 + gpib_control_status_pci_resource_index)); 1572 + dev_dbg(board->dev, "base address for gpib control/status registers remapped to 0x%p\n", 1573 + nec_priv->mmiobase); 1544 1574 1545 1575 if (e_priv->dma_port_res->flags & IORESOURCE_MEM) { 1546 1576 e_priv->fifo_base = ioremap(pci_resource_start(pci_device, 1547 1577 gpib_fifo_pci_resource_index), 1548 1578 pci_resource_len(pci_device, 1549 1579 gpib_fifo_pci_resource_index)); 1550 - dev_info(board->dev, "base address for gpib fifo registers remapped to 0x%p\n", 1551 - e_priv->fifo_base); 1580 + dev_dbg(board->dev, "base address for gpib fifo registers remapped to 0x%p\n", 1581 + e_priv->fifo_base); 1552 1582 } else { 1553 1583 e_priv->fifo_base = NULL; 1554 - dev_info(board->dev, "hardware has no gpib fifo registers.\n"); 1584 + dev_dbg(board->dev, "hardware has no gpib fifo registers.\n"); 1555 1585 } 1556 1586 1557 1587 if (pci_device->irq) { 1558 1588 retval = request_irq(pci_device->irq, fmh_gpib_interrupt, IRQF_SHARED, 1559 1589 KBUILD_MODNAME, board); 1560 1590 if (retval) { 1561 - dev_err(board->dev, 1562 - "cannot register interrupt handler err=%d\n", 1563 - retval); 1591 + dev_err(board->dev, "cannot register interrupt handler err=%d\n", retval); 1564 1592 return retval; 1565 1593 } 1566 1594 } ··· 1570 1602 return fmh_gpib_init(e_priv, board, handshake_mode); 1571 1603 } 1572 1604 1573 - int fmh_gpib_pci_attach_holdoff_all(gpib_board_t *board, const gpib_board_config_t *config) 1605 + int fmh_gpib_pci_attach_holdoff_all(struct gpib_board *board, const gpib_board_config_t *config) 1574 1606 { 1575 1607 return fmh_gpib_pci_attach_impl(board, config, HR_HLDA); 1576 1608 } 1577 1609 1578 - int fmh_gpib_pci_attach_holdoff_end(gpib_board_t *board, const gpib_board_config_t *config) 1610 + int fmh_gpib_pci_attach_holdoff_end(struct gpib_board *board, const gpib_board_config_t *config) 1579 1611 { 1580 1612 int retval; 1581 1613 struct fmh_priv *e_priv; ··· 1583 1615 retval = fmh_gpib_pci_attach_impl(board, config, HR_HLDE); 1584 1616 e_priv = board->private_data; 1585 1617 if (retval == 0 && e_priv && e_priv->supports_fifo_interrupts == 0) { 1586 - pr_err("fmh_gpib: your fmh_gpib_core does not appear to support fifo interrupts. Try the fmh_gpib_pci_unaccel board type instead."); 1618 + dev_err(board->gpib_dev, "your fmh_gpib_core does not appear to support fifo interrupts. Try the fmh_gpib_pci_unaccel board type instead."); 1587 1619 return -EIO; 1588 1620 } 1589 1621 return retval; 1590 1622 } 1591 1623 1592 - void fmh_gpib_pci_detach(gpib_board_t *board) 1624 + void fmh_gpib_pci_detach(struct gpib_board *board) 1593 1625 { 1594 1626 struct fmh_priv *e_priv = board->private_data; 1595 1627 struct nec7210_priv *nec_priv; ··· 1630 1662 1631 1663 static struct platform_driver fmh_gpib_platform_driver = { 1632 1664 .driver = { 1633 - .name = "fmh_gpib", 1665 + .name = DRV_NAME, 1634 1666 .owner = THIS_MODULE, 1635 1667 .of_match_table = fmh_gpib_of_match, 1636 1668 }, ··· 1649 1681 MODULE_DEVICE_TABLE(pci, fmh_gpib_pci_match); 1650 1682 1651 1683 static struct pci_driver fmh_gpib_pci_driver = { 1652 - .name = "fmh_gpib", 1684 + .name = DRV_NAME, 1653 1685 .id_table = fmh_gpib_pci_match, 1654 1686 .probe = &fmh_gpib_pci_probe 1655 1687 }; ··· 1660 1692 1661 1693 result = platform_driver_register(&fmh_gpib_platform_driver); 1662 1694 if (result) { 1663 - pr_err("fmh_gpib: platform_driver_register failed: error = %d\n", result); 1695 + pr_err("platform_driver_register failed: error = %d\n", result); 1664 1696 return result; 1665 1697 } 1666 1698 1667 1699 result = pci_register_driver(&fmh_gpib_pci_driver); 1668 1700 if (result) { 1669 - pr_err("fmh_gpib: pci_register_driver failed: error = %d\n", result); 1701 + pr_err("pci_register_driver failed: error = %d\n", result); 1670 1702 goto err_pci_driver; 1671 1703 } 1672 1704 1673 1705 result = gpib_register_driver(&fmh_gpib_unaccel_interface, THIS_MODULE); 1674 1706 if (result) { 1675 - pr_err("fmh_gpib: gpib_register_driver failed: error = %d\n", result); 1707 + pr_err("gpib_register_driver failed: error = %d\n", result); 1676 1708 goto err_unaccel; 1677 1709 } 1678 1710 1679 1711 result = gpib_register_driver(&fmh_gpib_interface, THIS_MODULE); 1680 1712 if (result) { 1681 - pr_err("fmh_gpib: gpib_register_driver failed: error = %d\n", result); 1713 + pr_err("gpib_register_driver failed: error = %d\n", result); 1682 1714 goto err_interface; 1683 1715 } 1684 1716 1685 1717 result = gpib_register_driver(&fmh_gpib_pci_unaccel_interface, THIS_MODULE); 1686 1718 if (result) { 1687 - pr_err("fmh_gpib: gpib_register_driver failed: error = %d\n", result); 1719 + pr_err("gpib_register_driver failed: error = %d\n", result); 1688 1720 goto err_pci_unaccel; 1689 1721 } 1690 1722 1691 1723 result = gpib_register_driver(&fmh_gpib_pci_interface, THIS_MODULE); 1692 1724 if (result) { 1693 - pr_err("fmh_gpib: gpib_register_driver failed: error = %d\n", result); 1725 + pr_err("gpib_register_driver failed: error = %d\n", result); 1694 1726 goto err_pci; 1695 1727 } 1696 1728
+67 -77
drivers/staging/gpib/gpio/gpib_bitbang.c
··· 25 25 * device support (non master operation) 26 26 */ 27 27 28 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 29 + #define dev_fmt pr_fmt 28 30 #define NAME KBUILD_MODNAME 29 31 30 32 #define ENABLE_IRQ(IRQ, TYPE) irq_set_irq_type(IRQ, TYPE) ··· 43 41 */ 44 42 #define dbg_printk(level, frm, ...) \ 45 43 do { if (debug >= (level)) \ 46 - pr_info("%s:%s - " frm, NAME, __func__, ## __VA_ARGS__); } \ 44 + dev_dbg(board->gpib_dev, frm, ## __VA_ARGS__); } \ 47 45 while (0) 48 46 49 47 #define LINVAL gpiod_get_value(DAV), \ ··· 318 316 }; 319 317 320 318 static inline long usec_diff(struct timespec64 *a, struct timespec64 *b); 321 - static void bb_buffer_print(unsigned char *buffer, size_t length, int cmd, int eoi); 319 + static void bb_buffer_print(struct gpib_board *board, unsigned char *buffer, size_t length, 320 + int cmd, int eoi); 322 321 static void set_data_lines(u8 byte); 323 322 static u8 get_data_lines(void); 324 323 static void set_data_lines_input(void); 325 324 static void set_data_lines_output(void); 326 325 static inline int check_for_eos(struct bb_priv *priv, uint8_t byte); 327 - static void set_atn(struct bb_priv *priv, int atn_asserted); 326 + static void set_atn(struct gpib_board *board, int atn_asserted); 328 327 329 328 static inline void SET_DIR_WRITE(struct bb_priv *priv); 330 329 static inline void SET_DIR_READ(struct bb_priv *priv); ··· 337 334 MODULE_DESCRIPTION("GPIB helper functions for bitbanging I/O"); 338 335 339 336 /**** global variables ****/ 340 - #ifdef CONFIG_GPIB_DEBUG 341 - static int debug = 1; 342 - #else 343 337 static int debug; 344 - #endif 345 338 module_param(debug, int, 0644); 346 339 347 340 static char printable(char x) ··· 353 354 * * 354 355 ***************************************************************************/ 355 356 356 - static int bb_read(gpib_board_t *board, uint8_t *buffer, size_t length, 357 + static int bb_read(struct gpib_board *board, uint8_t *buffer, size_t length, 357 358 int *end, size_t *bytes_read) 358 359 { 359 360 struct bb_priv *priv = board->private_data; ··· 425 426 426 427 static irqreturn_t bb_DAV_interrupt(int irq, void *arg) 427 428 { 428 - gpib_board_t *board = arg; 429 + struct gpib_board *board = arg; 429 430 struct bb_priv *priv = board->private_data; 430 431 int val; 431 432 unsigned long flags; ··· 491 492 * * 492 493 ***************************************************************************/ 493 494 494 - static int bb_write(gpib_board_t *board, uint8_t *buffer, size_t length, 495 + static int bb_write(struct gpib_board *board, uint8_t *buffer, size_t length, 495 496 int send_eoi, size_t *bytes_written) 496 497 { 497 498 unsigned long flags; ··· 507 508 board, mutex_is_locked(&board->user_mutex), length); 508 509 509 510 if (debug > 1) 510 - bb_buffer_print(buffer, length, priv->cmd, send_eoi); 511 + bb_buffer_print(board, buffer, length, priv->cmd, send_eoi); 511 512 priv->count = 0; 512 513 priv->phase = 300; 513 514 ··· 549 550 dbg_printk(1, "timeout after %zu/%zu at %d " LINFMT " eoi: %d\n", 550 551 priv->w_cnt, length, priv->phase, LINVAL, send_eoi); 551 552 } else { 552 - // dbg_printk(1,"written %zu\n", priv->w_cnt); 553 553 retval = priv->w_cnt; 554 554 } 555 555 } else { ··· 580 582 581 583 static irqreturn_t bb_NRFD_interrupt(int irq, void *arg) 582 584 { 583 - gpib_board_t *board = arg; 585 + struct gpib_board *board = arg; 584 586 struct bb_priv *priv = board->private_data; 585 587 unsigned long flags; 586 588 int nrfd; ··· 653 655 654 656 static irqreturn_t bb_NDAC_interrupt(int irq, void *arg) 655 657 { 656 - gpib_board_t *board = arg; 658 + struct gpib_board *board = arg; 657 659 struct bb_priv *priv = board->private_data; 658 660 unsigned long flags; 659 661 int ndac; ··· 714 716 715 717 static irqreturn_t bb_SRQ_interrupt(int irq, void *arg) 716 718 { 717 - gpib_board_t *board = arg; 719 + struct gpib_board *board = arg; 718 720 719 721 int val = gpiod_get_value(SRQ); 720 722 ··· 728 730 return IRQ_HANDLED; 729 731 } 730 732 731 - static int bb_command(gpib_board_t *board, uint8_t *buffer, 733 + static int bb_command(struct gpib_board *board, uint8_t *buffer, 732 734 size_t length, size_t *bytes_written) 733 735 { 734 736 size_t ret; ··· 809 811 "CFE" // 0x1f 810 812 }; 811 813 812 - static void bb_buffer_print(unsigned char *buffer, size_t length, int cmd, int eoi) 814 + static void bb_buffer_print(struct gpib_board *board, unsigned char *buffer, size_t length, 815 + int cmd, int eoi) 813 816 { 814 817 int i; 815 818 ··· 842 843 * STATUS Management * 843 844 * * 844 845 ***************************************************************************/ 845 - static void set_atn(struct bb_priv *priv, int atn_asserted) 846 + static void set_atn(struct gpib_board *board, int atn_asserted) 846 847 { 848 + struct bb_priv *priv = board->private_data; 849 + 847 850 if (priv->listener_state != listener_idle && 848 851 priv->talker_state != talker_idle) { 849 - dbg_printk(0, "listener/talker state machine conflict\n"); 852 + dev_err(board->gpib_dev, "listener/talker state machine conflict\n"); 850 853 } 851 854 if (atn_asserted) { 852 855 if (priv->listener_state == listener_active) ··· 867 866 priv->atn_asserted = atn_asserted; 868 867 } 869 868 870 - static int bb_take_control(gpib_board_t *board, int synchronous) 869 + static int bb_take_control(struct gpib_board *board, int synchronous) 871 870 { 872 871 dbg_printk(2, "%d\n", synchronous); 873 - set_atn(board->private_data, 1); 872 + set_atn(board, 1); 874 873 set_bit(CIC_NUM, &board->status); 875 874 return 0; 876 875 } 877 876 878 - static int bb_go_to_standby(gpib_board_t *board) 877 + static int bb_go_to_standby(struct gpib_board *board) 879 878 { 880 879 dbg_printk(2, "\n"); 881 - set_atn(board->private_data, 0); 880 + set_atn(board, 0); 882 881 return 0; 883 882 } 884 883 885 - static void bb_request_system_control(gpib_board_t *board, int request_control) 884 + static void bb_request_system_control(struct gpib_board *board, int request_control) 886 885 { 887 886 dbg_printk(2, "%d\n", request_control); 888 887 if (request_control) { ··· 894 893 } 895 894 } 896 895 897 - static void bb_interface_clear(gpib_board_t *board, int assert) 896 + static void bb_interface_clear(struct gpib_board *board, int assert) 898 897 { 899 898 struct bb_priv *priv = board->private_data; 900 899 ··· 908 907 } 909 908 } 910 909 911 - static void bb_remote_enable(gpib_board_t *board, int enable) 910 + static void bb_remote_enable(struct gpib_board *board, int enable) 912 911 { 913 912 dbg_printk(2, "%d\n", enable); 914 913 if (enable) { ··· 920 919 } 921 920 } 922 921 923 - static int bb_enable_eos(gpib_board_t *board, uint8_t eos_byte, int compare_8_bits) 922 + static int bb_enable_eos(struct gpib_board *board, uint8_t eos_byte, int compare_8_bits) 924 923 { 925 924 struct bb_priv *priv = board->private_data; 926 925 ··· 933 932 return 0; 934 933 } 935 934 936 - static void bb_disable_eos(gpib_board_t *board) 935 + static void bb_disable_eos(struct gpib_board *board) 937 936 { 938 937 struct bb_priv *priv = board->private_data; 939 938 ··· 941 940 priv->eos_flags &= ~REOS; 942 941 } 943 942 944 - static unsigned int bb_update_status(gpib_board_t *board, unsigned int clear_mask) 943 + static unsigned int bb_update_status(struct gpib_board *board, unsigned int clear_mask) 945 944 { 946 945 struct bb_priv *priv = board->private_data; 947 946 ··· 972 971 return board->status; 973 972 } 974 973 975 - static int bb_primary_address(gpib_board_t *board, unsigned int address) 974 + static int bb_primary_address(struct gpib_board *board, unsigned int address) 976 975 { 977 976 dbg_printk(2, "%d\n", address); 978 977 board->pad = address; 979 978 return 0; 980 979 } 981 980 982 - static int bb_secondary_address(gpib_board_t *board, unsigned int address, int enable) 981 + static int bb_secondary_address(struct gpib_board *board, unsigned int address, int enable) 983 982 { 984 983 dbg_printk(2, "%d %d\n", address, enable); 985 984 if (enable) ··· 987 986 return 0; 988 987 } 989 988 990 - static int bb_parallel_poll(gpib_board_t *board, uint8_t *result) 989 + static int bb_parallel_poll(struct gpib_board *board, uint8_t *result) 991 990 { 992 - dbg_printk(1, "%s\n", "not implemented"); 993 - return -EPERM; 991 + return -ENOENT; 994 992 } 995 993 996 - static void bb_parallel_poll_configure(gpib_board_t *board, uint8_t config) 997 - { 998 - dbg_printk(1, "%s\n", "not implemented"); 999 - } 1000 - 1001 - static void bb_parallel_poll_response(gpib_board_t *board, int ist) 994 + static void bb_parallel_poll_configure(struct gpib_board *board, uint8_t config) 1002 995 { 1003 996 } 1004 997 1005 - static void bb_serial_poll_response(gpib_board_t *board, uint8_t status) 998 + static void bb_parallel_poll_response(struct gpib_board *board, int ist) 1006 999 { 1007 - dbg_printk(1, "%s\n", "not implemented"); 1008 1000 } 1009 1001 1010 - static uint8_t bb_serial_poll_status(gpib_board_t *board) 1002 + static void bb_serial_poll_response(struct gpib_board *board, uint8_t status) 1011 1003 { 1012 - dbg_printk(1, "%s\n", "not implemented"); 1013 - return 0; // -ENOSYS; 1014 1004 } 1015 1005 1016 - static unsigned int bb_t1_delay(gpib_board_t *board, unsigned int nano_sec) 1006 + static uint8_t bb_serial_poll_status(struct gpib_board *board) 1007 + { 1008 + return 0; // -ENOENT; 1009 + } 1010 + 1011 + static int bb_t1_delay(struct gpib_board *board, unsigned int nano_sec) 1017 1012 { 1018 1013 struct bb_priv *priv = board->private_data; 1019 1014 ··· 1025 1028 return priv->t1_delay; 1026 1029 } 1027 1030 1028 - static void bb_return_to_local(gpib_board_t *board) 1031 + static void bb_return_to_local(struct gpib_board *board) 1029 1032 { 1030 - dbg_printk(1, "%s\n", "not implemented"); 1031 1033 } 1032 1034 1033 - static int bb_line_status(const gpib_board_t *board) 1035 + static int bb_line_status(const struct gpib_board *board) 1034 1036 { 1035 - int line_status = ValidALL; 1036 - 1037 - // dbg_printk(1,"\n"); 1037 + int line_status = VALID_ALL; 1038 1038 1039 1039 if (gpiod_get_value(REN) == 0) 1040 - line_status |= BusREN; 1040 + line_status |= BUS_REN; 1041 1041 if (gpiod_get_value(IFC) == 0) 1042 - line_status |= BusIFC; 1042 + line_status |= BUS_IFC; 1043 1043 if (gpiod_get_value(NDAC) == 0) 1044 - line_status |= BusNDAC; 1044 + line_status |= BUS_NDAC; 1045 1045 if (gpiod_get_value(NRFD) == 0) 1046 - line_status |= BusNRFD; 1046 + line_status |= BUS_NRFD; 1047 1047 if (gpiod_get_value(DAV) == 0) 1048 - line_status |= BusDAV; 1048 + line_status |= BUS_DAV; 1049 1049 if (gpiod_get_value(EOI) == 0) 1050 - line_status |= BusEOI; 1050 + line_status |= BUS_EOI; 1051 1051 if (gpiod_get_value(_ATN) == 0) 1052 - line_status |= BusATN; 1052 + line_status |= BUS_ATN; 1053 1053 if (gpiod_get_value(SRQ) == 0) 1054 - line_status |= BusSRQ; 1054 + line_status |= BUS_SRQ; 1055 1055 1056 1056 dbg_printk(2, "status lines: %4x\n", line_status); 1057 1057 ··· 1061 1067 * * 1062 1068 ***************************************************************************/ 1063 1069 1064 - static int allocate_private(gpib_board_t *board) 1070 + static int allocate_private(struct gpib_board *board) 1065 1071 { 1066 1072 board->private_data = kzalloc(sizeof(struct bb_priv), GFP_KERNEL); 1067 1073 if (!board->private_data) ··· 1069 1075 return 0; 1070 1076 } 1071 1077 1072 - static void free_private(gpib_board_t *board) 1078 + static void free_private(struct gpib_board *board) 1073 1079 { 1074 1080 kfree(board->private_data); 1075 1081 board->private_data = NULL; 1076 1082 } 1077 1083 1078 - static int bb_get_irq(gpib_board_t *board, char *name, 1084 + static int bb_get_irq(struct gpib_board *board, char *name, 1079 1085 struct gpio_desc *gpio, int *irq, 1080 1086 irq_handler_t handler, irq_handler_t thread_fn, unsigned long flags) 1081 1087 { ··· 1085 1091 *irq = gpiod_to_irq(gpio); 1086 1092 dbg_printk(2, "IRQ %s: %d\n", name, *irq); 1087 1093 if (*irq < 0) { 1088 - dbg_printk(0, "gpib: can't get IRQ for %s\n", name); 1094 + dev_err(board->gpib_dev, "can't get IRQ for %s\n", name); 1089 1095 return -1; 1090 1096 } 1091 1097 if (request_threaded_irq(*irq, handler, thread_fn, flags, name, board)) { 1092 - dbg_printk(0, "gpib: can't request IRQ for %s %d\n", name, *irq); 1098 + dev_err(board->gpib_dev, "can't request IRQ for %s %d\n", name, *irq); 1093 1099 *irq = 0; 1094 1100 return -1; 1095 1101 } ··· 1097 1103 return 0; 1098 1104 } 1099 1105 1100 - static void bb_free_irq(gpib_board_t *board, int *irq, char *name) 1106 + static void bb_free_irq(struct gpib_board *board, int *irq, char *name) 1101 1107 { 1102 1108 if (*irq) { 1103 1109 free_irq(*irq, board); ··· 1118 1124 } 1119 1125 } 1120 1126 1121 - static int allocate_gpios(gpib_board_t *board) 1127 + static int allocate_gpios(struct gpib_board *board) 1122 1128 { 1123 1129 int j, retval = 0; 1124 1130 bool error = false; ··· 1157 1163 gpiod_add_lookup_table(lookup_table); 1158 1164 goto try_again; 1159 1165 } 1160 - dbg_printk(0, "Unable to obtain gpio descriptor for pin %d error %ld\n", 1161 - gpios_vector[j], PTR_ERR(desc)); 1166 + dev_err(board->gpib_dev, "Unable to obtain gpio descriptor for pin %d error %ld\n", 1167 + gpios_vector[j], PTR_ERR(desc)); 1162 1168 error = true; 1163 1169 break; 1164 1170 } ··· 1176 1182 return retval; 1177 1183 } 1178 1184 1179 - static void bb_detach(gpib_board_t *board) 1185 + static void bb_detach(struct gpib_board *board) 1180 1186 { 1181 1187 struct bb_priv *priv = board->private_data; 1182 1188 ··· 1206 1212 free_private(board); 1207 1213 } 1208 1214 1209 - static int bb_attach(gpib_board_t *board, const gpib_board_config_t *config) 1215 + static int bb_attach(struct gpib_board *board, const gpib_board_config_t *config) 1210 1216 { 1211 1217 struct bb_priv *priv; 1212 1218 int retval = 0; ··· 1247 1253 gpios_vector[&(DC) - &all_descriptors[0]] = -1; 1248 1254 gpios_vector[&(ACT_LED) - &all_descriptors[0]] = -1; 1249 1255 } else { 1250 - dbg_printk(0, "Unrecognized pin mapping.\n"); 1256 + dev_err(board->gpib_dev, "Unrecognized pin map %s\n", pin_map); 1251 1257 goto bb_attach_fail; 1252 1258 } 1253 1259 dbg_printk(0, "Using pin map \"%s\" %s\n", pin_map, (sn7516x) ? ··· 1338 1344 int result = gpib_register_driver(&bb_interface, THIS_MODULE); 1339 1345 1340 1346 if (result) { 1341 - pr_err("gpib_bitbang: gpib_register_driver failed: error = %d\n", result); 1347 + pr_err("gpib_register_driver failed: error = %d\n", result); 1342 1348 return result; 1343 1349 } 1344 1350 1345 - dbg_printk(0, "module loaded with pin map \"%s\"%s\n", 1346 - pin_map, (sn7516x_used) ? " and SN7516x driver support" : ""); 1347 1351 return 0; 1348 1352 } 1349 1353 1350 1354 static void __exit bb_exit_module(void) 1351 1355 { 1352 - dbg_printk(0, "module unloaded!"); 1353 - 1354 1356 gpib_unregister_driver(&bb_interface); 1355 1357 } 1356 1358
+43 -40
drivers/staging/gpib/hp_82335/hp82335.c
··· 8 8 * implement recovery from bus errors (if necessary) 9 9 */ 10 10 11 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 12 + #define dev_fmt pr_fmt 13 + #define DRV_NAME KBUILD_MODNAME 14 + 11 15 #include "hp82335.h" 12 16 #include <linux/io.h> 13 17 #include <linux/ioport.h> ··· 24 20 MODULE_LICENSE("GPL"); 25 21 MODULE_DESCRIPTION("GPIB driver for HP 82335 interface cards"); 26 22 27 - static int hp82335_attach(gpib_board_t *board, const gpib_board_config_t *config); 28 - 29 - static void hp82335_detach(gpib_board_t *board); 23 + static int hp82335_attach(struct gpib_board *board, const gpib_board_config_t *config); 24 + static void hp82335_detach(struct gpib_board *board); 25 + static irqreturn_t hp82335_interrupt(int irq, void *arg); 30 26 31 27 // wrappers for interface functions 32 - int hp82335_read(gpib_board_t *board, uint8_t *buffer, size_t length, int *end, size_t *bytes_read) 28 + static int hp82335_read(struct gpib_board *board, uint8_t *buffer, size_t length, 29 + int *end, size_t *bytes_read) 33 30 { 34 31 struct hp82335_priv *priv = board->private_data; 35 32 36 33 return tms9914_read(board, &priv->tms9914_priv, buffer, length, end, bytes_read); 37 34 } 38 35 39 - int hp82335_write(gpib_board_t *board, uint8_t *buffer, size_t length, int send_eoi, 40 - size_t *bytes_written) 36 + static int hp82335_write(struct gpib_board *board, uint8_t *buffer, size_t length, int send_eoi, 37 + size_t *bytes_written) 41 38 { 42 39 struct hp82335_priv *priv = board->private_data; 43 40 44 41 return tms9914_write(board, &priv->tms9914_priv, buffer, length, send_eoi, bytes_written); 45 42 } 46 43 47 - int hp82335_command(gpib_board_t *board, uint8_t *buffer, size_t length, size_t *bytes_written) 44 + static int hp82335_command(struct gpib_board *board, uint8_t *buffer, size_t length, 45 + size_t *bytes_written) 48 46 { 49 47 struct hp82335_priv *priv = board->private_data; 50 48 51 49 return tms9914_command(board, &priv->tms9914_priv, buffer, length, bytes_written); 52 50 } 53 51 54 - int hp82335_take_control(gpib_board_t *board, int synchronous) 52 + static int hp82335_take_control(struct gpib_board *board, int synchronous) 55 53 { 56 54 struct hp82335_priv *priv = board->private_data; 57 55 58 56 return tms9914_take_control(board, &priv->tms9914_priv, synchronous); 59 57 } 60 58 61 - int hp82335_go_to_standby(gpib_board_t *board) 59 + static int hp82335_go_to_standby(struct gpib_board *board) 62 60 { 63 61 struct hp82335_priv *priv = board->private_data; 64 62 65 63 return tms9914_go_to_standby(board, &priv->tms9914_priv); 66 64 } 67 65 68 - void hp82335_request_system_control(gpib_board_t *board, int request_control) 66 + static void hp82335_request_system_control(struct gpib_board *board, int request_control) 69 67 { 70 68 struct hp82335_priv *priv = board->private_data; 71 69 72 70 tms9914_request_system_control(board, &priv->tms9914_priv, request_control); 73 71 } 74 72 75 - void hp82335_interface_clear(gpib_board_t *board, int assert) 73 + static void hp82335_interface_clear(struct gpib_board *board, int assert) 76 74 { 77 75 struct hp82335_priv *priv = board->private_data; 78 76 79 77 tms9914_interface_clear(board, &priv->tms9914_priv, assert); 80 78 } 81 79 82 - void hp82335_remote_enable(gpib_board_t *board, int enable) 80 + static void hp82335_remote_enable(struct gpib_board *board, int enable) 83 81 { 84 82 struct hp82335_priv *priv = board->private_data; 85 83 86 84 tms9914_remote_enable(board, &priv->tms9914_priv, enable); 87 85 } 88 86 89 - int hp82335_enable_eos(gpib_board_t *board, uint8_t eos_byte, int compare_8_bits) 87 + static int hp82335_enable_eos(struct gpib_board *board, uint8_t eos_byte, int compare_8_bits) 90 88 { 91 89 struct hp82335_priv *priv = board->private_data; 92 90 93 91 return tms9914_enable_eos(board, &priv->tms9914_priv, eos_byte, compare_8_bits); 94 92 } 95 93 96 - void hp82335_disable_eos(gpib_board_t *board) 94 + static void hp82335_disable_eos(struct gpib_board *board) 97 95 { 98 96 struct hp82335_priv *priv = board->private_data; 99 97 100 98 tms9914_disable_eos(board, &priv->tms9914_priv); 101 99 } 102 100 103 - unsigned int hp82335_update_status(gpib_board_t *board, unsigned int clear_mask) 101 + static unsigned int hp82335_update_status(struct gpib_board *board, unsigned int clear_mask) 104 102 { 105 103 struct hp82335_priv *priv = board->private_data; 106 104 107 105 return tms9914_update_status(board, &priv->tms9914_priv, clear_mask); 108 106 } 109 107 110 - int hp82335_primary_address(gpib_board_t *board, unsigned int address) 108 + static int hp82335_primary_address(struct gpib_board *board, unsigned int address) 111 109 { 112 110 struct hp82335_priv *priv = board->private_data; 113 111 114 112 return tms9914_primary_address(board, &priv->tms9914_priv, address); 115 113 } 116 114 117 - int hp82335_secondary_address(gpib_board_t *board, unsigned int address, int enable) 115 + static int hp82335_secondary_address(struct gpib_board *board, unsigned int address, int enable) 118 116 { 119 117 struct hp82335_priv *priv = board->private_data; 120 118 121 119 return tms9914_secondary_address(board, &priv->tms9914_priv, address, enable); 122 120 } 123 121 124 - int hp82335_parallel_poll(gpib_board_t *board, uint8_t *result) 122 + static int hp82335_parallel_poll(struct gpib_board *board, uint8_t *result) 125 123 { 126 124 struct hp82335_priv *priv = board->private_data; 127 125 128 126 return tms9914_parallel_poll(board, &priv->tms9914_priv, result); 129 127 } 130 128 131 - void hp82335_parallel_poll_configure(gpib_board_t *board, uint8_t config) 129 + static void hp82335_parallel_poll_configure(struct gpib_board *board, uint8_t config) 132 130 { 133 131 struct hp82335_priv *priv = board->private_data; 134 132 135 133 tms9914_parallel_poll_configure(board, &priv->tms9914_priv, config); 136 134 } 137 135 138 - void hp82335_parallel_poll_response(gpib_board_t *board, int ist) 136 + static void hp82335_parallel_poll_response(struct gpib_board *board, int ist) 139 137 { 140 138 struct hp82335_priv *priv = board->private_data; 141 139 142 140 tms9914_parallel_poll_response(board, &priv->tms9914_priv, ist); 143 141 } 144 142 145 - void hp82335_serial_poll_response(gpib_board_t *board, uint8_t status) 143 + static void hp82335_serial_poll_response(struct gpib_board *board, uint8_t status) 146 144 { 147 145 struct hp82335_priv *priv = board->private_data; 148 146 149 147 tms9914_serial_poll_response(board, &priv->tms9914_priv, status); 150 148 } 151 149 152 - static uint8_t hp82335_serial_poll_status(gpib_board_t *board) 150 + static uint8_t hp82335_serial_poll_status(struct gpib_board *board) 153 151 { 154 152 struct hp82335_priv *priv = board->private_data; 155 153 156 154 return tms9914_serial_poll_status(board, &priv->tms9914_priv); 157 155 } 158 156 159 - static int hp82335_line_status(const gpib_board_t *board) 157 + static int hp82335_line_status(const struct gpib_board *board) 160 158 { 161 159 struct hp82335_priv *priv = board->private_data; 162 160 163 161 return tms9914_line_status(board, &priv->tms9914_priv); 164 162 } 165 163 166 - static unsigned int hp82335_t1_delay(gpib_board_t *board, unsigned int nano_sec) 164 + static int hp82335_t1_delay(struct gpib_board *board, unsigned int nano_sec) 167 165 { 168 166 struct hp82335_priv *priv = board->private_data; 169 167 170 168 return tms9914_t1_delay(board, &priv->tms9914_priv, nano_sec); 171 169 } 172 170 173 - void hp82335_return_to_local(gpib_board_t *board) 171 + static void hp82335_return_to_local(struct gpib_board *board) 174 172 { 175 173 struct hp82335_priv *priv = board->private_data; 176 174 ··· 207 201 .return_to_local = hp82335_return_to_local, 208 202 }; 209 203 210 - int hp82335_allocate_private(gpib_board_t *board) 204 + static int hp82335_allocate_private(struct gpib_board *board) 211 205 { 212 206 board->private_data = kzalloc(sizeof(struct hp82335_priv), GFP_KERNEL); 213 207 if (!board->private_data) ··· 215 209 return 0; 216 210 } 217 211 218 - void hp82335_free_private(gpib_board_t *board) 212 + static void hp82335_free_private(struct gpib_board *board) 219 213 { 220 214 kfree(board->private_data); 221 215 board->private_data = NULL; ··· 243 237 writeb(0, tms_priv->mmiobase + HPREG_INTR_CLEAR); 244 238 } 245 239 246 - int hp82335_attach(gpib_board_t *board, const gpib_board_config_t *config) 240 + static int hp82335_attach(struct gpib_board *board, const gpib_board_config_t *config) 247 241 { 248 242 struct hp82335_priv *hp_priv; 249 243 struct tms9914_priv *tms_priv; ··· 278 272 case 0xfc000: 279 273 break; 280 274 default: 281 - pr_err("hp82335: invalid base io address 0x%u\n", config->ibbase); 275 + dev_err(board->gpib_dev, "invalid base io address 0x%x\n", config->ibbase); 282 276 return -EINVAL; 283 277 } 284 278 if (!request_mem_region(upper_iomem_base, hp82335_upper_iomem_size, "hp82335")) { 285 - pr_err("hp82335: failed to allocate io memory region 0x%lx-0x%lx\n", 286 - upper_iomem_base, upper_iomem_base + hp82335_upper_iomem_size - 1); 279 + dev_err(board->gpib_dev, "failed to allocate io memory region 0x%lx-0x%lx\n", 280 + upper_iomem_base, upper_iomem_base + hp82335_upper_iomem_size - 1); 287 281 return -EBUSY; 288 282 } 289 283 hp_priv->raw_iobase = upper_iomem_base; 290 284 tms_priv->mmiobase = ioremap(upper_iomem_base, hp82335_upper_iomem_size); 291 - pr_info("hp82335: upper half of 82335 iomem region 0x%lx remapped to 0x%p\n", 292 - hp_priv->raw_iobase, tms_priv->mmiobase); 293 285 294 - retval = request_irq(config->ibirq, hp82335_interrupt, 0, "hp82335", board); 286 + retval = request_irq(config->ibirq, hp82335_interrupt, 0, DRV_NAME, board); 295 287 if (retval) { 296 - pr_err("hp82335: can't request IRQ %d\n", config->ibirq); 288 + dev_err(board->gpib_dev, "can't request IRQ %d\n", config->ibirq); 297 289 return retval; 298 290 } 299 291 hp_priv->irq = config->ibirq; 300 - pr_info("hp82335: IRQ %d\n", config->ibirq); 301 292 302 293 tms9914_board_reset(tms_priv); 303 294 ··· 307 304 return 0; 308 305 } 309 306 310 - void hp82335_detach(gpib_board_t *board) 307 + static void hp82335_detach(struct gpib_board *board) 311 308 { 312 309 struct hp82335_priv *hp_priv = board->private_data; 313 310 struct tms9914_priv *tms_priv; ··· 332 329 int result = gpib_register_driver(&hp82335_interface, THIS_MODULE); 333 330 334 331 if (result) { 335 - pr_err("hp82335: gpib_register_driver failed: error = %d\n", result); 332 + pr_err("gpib_register_driver failed: error = %d\n", result); 336 333 return result; 337 334 } 338 335 ··· 351 348 * GPIB interrupt service routines 352 349 */ 353 350 354 - irqreturn_t hp82335_interrupt(int irq, void *arg) 351 + static irqreturn_t hp82335_interrupt(int irq, void *arg) 355 352 { 356 353 int status1, status2; 357 - gpib_board_t *board = arg; 354 + struct gpib_board *board = arg; 358 355 struct hp82335_priv *priv = board->private_data; 359 356 unsigned long flags; 360 357 irqreturn_t retval;
-30
drivers/staging/gpib/hp_82335/hp82335.h
··· 17 17 unsigned long raw_iobase; 18 18 }; 19 19 20 - // interface functions 21 - int hp82335_read(gpib_board_t *board, uint8_t *buffer, size_t length, int *end, size_t *bytes_read); 22 - int hp82335_write(gpib_board_t *board, uint8_t *buffer, size_t length, 23 - int send_eoi, size_t *bytes_written); 24 - int hp82335_command(gpib_board_t *board, uint8_t *buffer, size_t length, size_t *bytes_written); 25 - int hp82335_take_control(gpib_board_t *board, int synchronous); 26 - int hp82335_go_to_standby(gpib_board_t *board); 27 - void hp82335_request_system_control(gpib_board_t *board, int request_control); 28 - void hp82335_interface_clear(gpib_board_t *board, int assert); 29 - void hp82335_remote_enable(gpib_board_t *board, int enable); 30 - int hp82335_enable_eos(gpib_board_t *board, uint8_t eos_byte, int 31 - compare_8_bits); 32 - void hp82335_disable_eos(gpib_board_t *board); 33 - unsigned int hp82335_update_status(gpib_board_t *board, unsigned int clear_mask); 34 - int hp82335_primary_address(gpib_board_t *board, unsigned int address); 35 - int hp82335_secondary_address(gpib_board_t *board, unsigned int address, int 36 - enable); 37 - int hp82335_parallel_poll(gpib_board_t *board, uint8_t *result); 38 - void hp82335_parallel_poll_configure(gpib_board_t *board, uint8_t config); 39 - void hp82335_parallel_poll_response(gpib_board_t *board, int ist); 40 - void hp82335_serial_poll_response(gpib_board_t *board, uint8_t status); 41 - void hp82335_return_to_local(gpib_board_t *board); 42 - 43 - // interrupt service routines 44 - irqreturn_t hp82335_interrupt(int irq, void *arg); 45 - 46 - // utility functions 47 - int hp82335_allocate_private(gpib_board_t *board); 48 - void hp82335_free_private(gpib_board_t *board); 49 - 50 20 // size of io memory region used 51 21 static const int hp82335_rom_size = 0x2000; 52 22 static const int hp82335_upper_iomem_size = 0x2000;
+82 -79
drivers/staging/gpib/hp_82341/hp_82341.c
··· 6 6 * copyright : (C) 2002, 2005 by Frank Mori Hess * 7 7 ***************************************************************************/ 8 8 9 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 10 + #define dev_fmt pr_fmt 11 + #define DRV_NAME KBUILD_MODNAME 12 + 9 13 #include "hp_82341.h" 10 14 #include <linux/delay.h> 11 15 #include <linux/ioport.h> ··· 20 16 #include <linux/isapnp.h> 21 17 22 18 MODULE_LICENSE("GPL"); 19 + MODULE_DESCRIPTION("GPIB driver for hp 82341a/b/c/d boards"); 23 20 24 - int hp_82341_accel_read(gpib_board_t *board, uint8_t *buffer, size_t length, int *end, 25 - size_t *bytes_read) 21 + static unsigned short read_and_clear_event_status(struct gpib_board *board); 22 + static void set_transfer_counter(struct hp_82341_priv *hp_priv, int count); 23 + static int read_transfer_counter(struct hp_82341_priv *hp_priv); 24 + static int hp_82341_write(struct gpib_board *board, uint8_t *buffer, size_t length, int send_eoi, 25 + size_t *bytes_written); 26 + static irqreturn_t hp_82341_interrupt(int irq, void *arg); 27 + 28 + static int hp_82341_accel_read(struct gpib_board *board, uint8_t *buffer, size_t length, int *end, 29 + size_t *bytes_read) 26 30 { 27 31 struct hp_82341_priv *hp_priv = board->private_data; 28 32 struct tms9914_priv *tms_priv = &hp_priv->tms9914_priv; ··· 62 50 retval = tms9914_read(board, tms_priv, buffer, 1, end, &num_bytes); 63 51 *bytes_read += num_bytes; 64 52 if (retval < 0) 65 - pr_err("tms9914_read failed retval=%i\n", retval); 53 + dev_err(board->gpib_dev, "tms9914_read failed retval=%i\n", retval); 66 54 if (retval < 0 || *end) 67 55 return retval; 68 56 ++buffer; ··· 98 86 test_bit(DEV_CLEAR_BN, &tms_priv->state) || 99 87 test_bit(TIMO_NUM, &board->status)); 100 88 if (retval) { 101 - pr_warn("%s: read wait interrupted\n", __func__); 102 89 retval = -ERESTARTSYS; 103 90 break; 104 91 } ··· 122 111 tms_priv->holdoff_active = 1; 123 112 } 124 113 if (test_bit(TIMO_NUM, &board->status)) { 125 - pr_debug("%s: minor %i: read timed out\n", __FILE__, board->minor); 126 114 retval = -ETIMEDOUT; 127 115 break; 128 116 } 129 117 if (test_bit(DEV_CLEAR_BN, &tms_priv->state)) { 130 - pr_warn("%s: device clear interrupted read\n", __FILE__); 131 118 retval = -EINTR; 132 119 break; 133 120 } ··· 147 138 return 0; 148 139 } 149 140 150 - static int restart_write_fifo(gpib_board_t *board, struct hp_82341_priv *hp_priv) 141 + static int restart_write_fifo(struct gpib_board *board, struct hp_82341_priv *hp_priv) 151 142 { 152 143 struct tms9914_priv *tms_priv = &hp_priv->tms9914_priv; 153 144 ··· 158 149 159 150 //restart doesn't work if data holdoff is in effect 160 151 status = tms9914_line_status(board, tms_priv); 161 - if ((status & BusNRFD) == 0) { 152 + if ((status & BUS_NRFD) == 0) { 162 153 outb(RESTART_STREAM_BIT, hp_priv->iobase[0] + STREAM_STATUS_REG); 163 154 return 0; 164 155 } ··· 172 163 return 0; 173 164 } 174 165 175 - int hp_82341_accel_write(gpib_board_t *board, uint8_t *buffer, size_t length, 176 - int send_eoi, size_t *bytes_written) 166 + static int hp_82341_accel_write(struct gpib_board *board, uint8_t *buffer, size_t length, 167 + int send_eoi, size_t *bytes_written) 177 168 { 178 169 struct hp_82341_priv *hp_priv = board->private_data; 179 170 struct tms9914_priv *tms_priv = &hp_priv->tms9914_priv; ··· 213 204 outb(ENABLE_TI_BUFFER_BIT, hp_priv->iobase[3] + BUFFER_CONTROL_REG); 214 205 retval = restart_write_fifo(board, hp_priv); 215 206 if (retval < 0) { 216 - pr_err("hp82341: failed to restart write stream\n"); 207 + dev_err(board->gpib_dev, "failed to restart write stream\n"); 217 208 break; 218 209 } 219 210 retval = wait_event_interruptible(board->wait, ··· 225 216 outb(0, hp_priv->iobase[3] + BUFFER_CONTROL_REG); 226 217 *bytes_written += block_size - read_transfer_counter(hp_priv); 227 218 if (retval) { 228 - pr_warn("%s: write wait interrupted\n", __FILE__); 229 219 retval = -ERESTARTSYS; 230 220 break; 231 221 } 232 222 if (test_bit(TIMO_NUM, &board->status)) { 233 - pr_debug("%s: minor %i: write timed out\n", __FILE__, board->minor); 234 223 retval = -ETIMEDOUT; 235 224 break; 236 225 } 237 226 if (test_bit(DEV_CLEAR_BN, &tms_priv->state)) { 238 - pr_warn("%s: device clear interrupted write\n", __FILE__); 239 227 retval = -EINTR; 240 228 break; 241 229 } ··· 250 244 return 0; 251 245 } 252 246 253 - static int hp_82341_attach(gpib_board_t *board, const gpib_board_config_t *config); 247 + static int hp_82341_attach(struct gpib_board *board, const gpib_board_config_t *config); 254 248 255 - static void hp_82341_detach(gpib_board_t *board); 249 + static void hp_82341_detach(struct gpib_board *board); 256 250 257 251 // wrappers for interface functions 258 - int hp_82341_read(gpib_board_t *board, uint8_t *buffer, size_t length, int *end, size_t *bytes_read) 252 + static int hp_82341_read(struct gpib_board *board, uint8_t *buffer, size_t length, int *end, 253 + size_t *bytes_read) 259 254 { 260 255 struct hp_82341_priv *priv = board->private_data; 261 256 262 257 return tms9914_read(board, &priv->tms9914_priv, buffer, length, end, bytes_read); 263 258 } 264 259 265 - int hp_82341_write(gpib_board_t *board, uint8_t *buffer, size_t length, int send_eoi, 266 - size_t *bytes_written) 260 + static int hp_82341_write(struct gpib_board *board, uint8_t *buffer, size_t length, int send_eoi, 261 + size_t *bytes_written) 267 262 { 268 263 struct hp_82341_priv *priv = board->private_data; 269 264 270 265 return tms9914_write(board, &priv->tms9914_priv, buffer, length, send_eoi, bytes_written); 271 266 } 272 267 273 - int hp_82341_command(gpib_board_t *board, uint8_t *buffer, size_t length, size_t *bytes_written) 268 + static int hp_82341_command(struct gpib_board *board, uint8_t *buffer, size_t length, 269 + size_t *bytes_written) 274 270 { 275 271 struct hp_82341_priv *priv = board->private_data; 276 272 277 273 return tms9914_command(board, &priv->tms9914_priv, buffer, length, bytes_written); 278 274 } 279 275 280 - int hp_82341_take_control(gpib_board_t *board, int synchronous) 276 + static int hp_82341_take_control(struct gpib_board *board, int synchronous) 281 277 { 282 278 struct hp_82341_priv *priv = board->private_data; 283 279 284 280 return tms9914_take_control(board, &priv->tms9914_priv, synchronous); 285 281 } 286 282 287 - int hp_82341_go_to_standby(gpib_board_t *board) 283 + static int hp_82341_go_to_standby(struct gpib_board *board) 288 284 { 289 285 struct hp_82341_priv *priv = board->private_data; 290 286 291 287 return tms9914_go_to_standby(board, &priv->tms9914_priv); 292 288 } 293 289 294 - void hp_82341_request_system_control(gpib_board_t *board, int request_control) 290 + static void hp_82341_request_system_control(struct gpib_board *board, int request_control) 295 291 { 296 292 struct hp_82341_priv *priv = board->private_data; 297 293 ··· 305 297 tms9914_request_system_control(board, &priv->tms9914_priv, request_control); 306 298 } 307 299 308 - void hp_82341_interface_clear(gpib_board_t *board, int assert) 300 + static void hp_82341_interface_clear(struct gpib_board *board, int assert) 309 301 { 310 302 struct hp_82341_priv *priv = board->private_data; 311 303 312 304 tms9914_interface_clear(board, &priv->tms9914_priv, assert); 313 305 } 314 306 315 - void hp_82341_remote_enable(gpib_board_t *board, int enable) 307 + static void hp_82341_remote_enable(struct gpib_board *board, int enable) 316 308 { 317 309 struct hp_82341_priv *priv = board->private_data; 318 310 319 311 tms9914_remote_enable(board, &priv->tms9914_priv, enable); 320 312 } 321 313 322 - int hp_82341_enable_eos(gpib_board_t *board, uint8_t eos_byte, int compare_8_bits) 314 + static int hp_82341_enable_eos(struct gpib_board *board, uint8_t eos_byte, int compare_8_bits) 323 315 { 324 316 struct hp_82341_priv *priv = board->private_data; 325 317 326 318 return tms9914_enable_eos(board, &priv->tms9914_priv, eos_byte, compare_8_bits); 327 319 } 328 320 329 - void hp_82341_disable_eos(gpib_board_t *board) 321 + static void hp_82341_disable_eos(struct gpib_board *board) 330 322 { 331 323 struct hp_82341_priv *priv = board->private_data; 332 324 333 325 tms9914_disable_eos(board, &priv->tms9914_priv); 334 326 } 335 327 336 - unsigned int hp_82341_update_status(gpib_board_t *board, unsigned int clear_mask) 328 + static unsigned int hp_82341_update_status(struct gpib_board *board, unsigned int clear_mask) 337 329 { 338 330 struct hp_82341_priv *priv = board->private_data; 339 331 340 332 return tms9914_update_status(board, &priv->tms9914_priv, clear_mask); 341 333 } 342 334 343 - int hp_82341_primary_address(gpib_board_t *board, unsigned int address) 335 + static int hp_82341_primary_address(struct gpib_board *board, unsigned int address) 344 336 { 345 337 struct hp_82341_priv *priv = board->private_data; 346 338 347 339 return tms9914_primary_address(board, &priv->tms9914_priv, address); 348 340 } 349 341 350 - int hp_82341_secondary_address(gpib_board_t *board, unsigned int address, int enable) 342 + static int hp_82341_secondary_address(struct gpib_board *board, unsigned int address, int enable) 351 343 { 352 344 struct hp_82341_priv *priv = board->private_data; 353 345 354 346 return tms9914_secondary_address(board, &priv->tms9914_priv, address, enable); 355 347 } 356 348 357 - int hp_82341_parallel_poll(gpib_board_t *board, uint8_t *result) 349 + static int hp_82341_parallel_poll(struct gpib_board *board, uint8_t *result) 358 350 { 359 351 struct hp_82341_priv *priv = board->private_data; 360 352 361 353 return tms9914_parallel_poll(board, &priv->tms9914_priv, result); 362 354 } 363 355 364 - void hp_82341_parallel_poll_configure(gpib_board_t *board, uint8_t config) 356 + static void hp_82341_parallel_poll_configure(struct gpib_board *board, uint8_t config) 365 357 { 366 358 struct hp_82341_priv *priv = board->private_data; 367 359 368 360 tms9914_parallel_poll_configure(board, &priv->tms9914_priv, config); 369 361 } 370 362 371 - void hp_82341_parallel_poll_response(gpib_board_t *board, int ist) 363 + static void hp_82341_parallel_poll_response(struct gpib_board *board, int ist) 372 364 { 373 365 struct hp_82341_priv *priv = board->private_data; 374 366 375 367 tms9914_parallel_poll_response(board, &priv->tms9914_priv, ist); 376 368 } 377 369 378 - void hp_82341_serial_poll_response(gpib_board_t *board, uint8_t status) 370 + static void hp_82341_serial_poll_response(struct gpib_board *board, uint8_t status) 379 371 { 380 372 struct hp_82341_priv *priv = board->private_data; 381 373 382 374 tms9914_serial_poll_response(board, &priv->tms9914_priv, status); 383 375 } 384 376 385 - static uint8_t hp_82341_serial_poll_status(gpib_board_t *board) 377 + static uint8_t hp_82341_serial_poll_status(struct gpib_board *board) 386 378 { 387 379 struct hp_82341_priv *priv = board->private_data; 388 380 389 381 return tms9914_serial_poll_status(board, &priv->tms9914_priv); 390 382 } 391 383 392 - static int hp_82341_line_status(const gpib_board_t *board) 384 + static int hp_82341_line_status(const struct gpib_board *board) 393 385 { 394 386 struct hp_82341_priv *priv = board->private_data; 395 387 396 388 return tms9914_line_status(board, &priv->tms9914_priv); 397 389 } 398 390 399 - static unsigned int hp_82341_t1_delay(gpib_board_t *board, unsigned int nano_sec) 391 + static int hp_82341_t1_delay(struct gpib_board *board, unsigned int nano_sec) 400 392 { 401 393 struct hp_82341_priv *priv = board->private_data; 402 394 403 395 return tms9914_t1_delay(board, &priv->tms9914_priv, nano_sec); 404 396 } 405 397 406 - void hp_82341_return_to_local(gpib_board_t *board) 398 + static void hp_82341_return_to_local(struct gpib_board *board) 407 399 { 408 400 struct hp_82341_priv *priv = board->private_data; 409 401 ··· 465 457 .return_to_local = hp_82341_return_to_local, 466 458 }; 467 459 468 - int hp_82341_allocate_private(gpib_board_t *board) 460 + static int hp_82341_allocate_private(struct gpib_board *board) 469 461 { 470 462 board->private_data = kzalloc(sizeof(struct hp_82341_priv), GFP_KERNEL); 471 463 if (!board->private_data) ··· 473 465 return 0; 474 466 } 475 467 476 - void hp_82341_free_private(gpib_board_t *board) 468 + static void hp_82341_free_private(struct gpib_board *board) 477 469 { 478 470 kfree(board->private_data); 479 471 board->private_data = NULL; ··· 494 486 *dev = pnp_find_dev(NULL, ISAPNP_VENDOR('H', 'W', 'P'), 495 487 ISAPNP_FUNCTION(0x1411), NULL); 496 488 if (!*dev || !(*dev)->card) { 497 - pr_err("hp_82341: failed to find isapnp board\n"); 489 + pr_err("failed to find isapnp board\n"); 498 490 return -ENODEV; 499 491 } 500 492 if (pnp_device_attach(*dev) < 0) { 501 - pr_err("hp_82341: board already active, skipping\n"); 493 + pr_err("board already active, skipping\n"); 502 494 return -EBUSY; 503 495 } 504 496 if (pnp_activate_dev(*dev) < 0) { 505 497 pnp_device_detach(*dev); 506 - pr_err("hp_82341: failed to activate() atgpib/tnt, aborting\n"); 498 + pr_err("failed to activate(), aborting\n"); 507 499 return -EAGAIN; 508 500 } 509 501 if (!pnp_port_valid(*dev, 0) || !pnp_irq_valid(*dev, 0)) { 510 502 pnp_device_detach(*dev); 511 - pr_err("hp_82341: invalid port or irq for atgpib/tnt, aborting\n"); 503 + pr_err("invalid port or irq, aborting\n"); 512 504 return -ENOMEM; 513 505 } 514 506 return 0; ··· 529 521 else 530 522 return 0; 531 523 default: 532 - pr_err("hp_82341: %s: bug! unknown hw_version\n", __func__); 524 + pr_err("bug! unknown hw_version\n"); 533 525 break; 534 526 } 535 527 return 0; ··· 549 541 else 550 542 return 0; 551 543 default: 552 - pr_err("hp_82341: %s: bug! unknown hw_version\n", __func__); 544 + pr_err("bug! unknown hw_version\n"); 553 545 break; 554 546 } 555 547 return 0; ··· 570 562 case 15: 571 563 return 1; 572 564 default: 573 - pr_err("hp_82341: invalid irq=%i for 82341C, irq must be 3, 5, 7, 9, 10, 11, 12, or 15.\n", 565 + pr_err("invalid irq=%i for 82341C, irq must be 3, 5, 7, 9, 10, 11, 12, or 15.\n", 574 566 irq); 575 567 return 0; 576 568 } ··· 578 570 case HW_VERSION_82341D: 579 571 return 1; 580 572 default: 581 - pr_err("hp_82341: %s: bug! unknown hw_version\n", __func__); 573 + pr_err("bug! unknown hw_version\n"); 582 574 break; 583 575 } 584 576 return 0; ··· 600 592 usleep_range(10, 15); 601 593 } 602 594 if (j == timeout) { 603 - pr_err("hp_82341: timed out waiting for Xilinx ready.\n"); 595 + pr_err("timed out waiting for Xilinx ready.\n"); 604 596 return -ETIMEDOUT; 605 597 } 606 598 outb(firmware_data[i], hp_priv->iobase[0] + XILINX_DATA_REG); ··· 613 605 usleep_range(10, 15); 614 606 } 615 607 if (j == timeout) { 616 - pr_err("hp_82341: timed out waiting for Xilinx done.\n"); 608 + pr_err("timed out waiting for Xilinx done.\n"); 617 609 return -ETIMEDOUT; 618 610 } 619 611 return 0; ··· 624 616 if (config->init_data_length == 0) { 625 617 if (xilinx_done(hp_priv)) 626 618 return 0; 627 - pr_err("hp_82341: board needs be initialized with firmware upload.\n" 619 + pr_err("board needs be initialized with firmware upload.\n" 628 620 "\tUse the --init-data option of gpib_config.\n"); 629 621 return -EINVAL; 630 622 } 631 623 switch (hp_priv->hw_version) { 632 624 case HW_VERSION_82341C: 633 625 if (config->init_data_length != hp_82341c_firmware_length) { 634 - pr_err("hp_82341: bad firmware length=%i for 82341c (expected %i).\n", 626 + pr_err("bad firmware length=%i for 82341c (expected %i).\n", 635 627 config->init_data_length, hp_82341c_firmware_length); 636 628 return -EINVAL; 637 629 } 638 630 break; 639 631 case HW_VERSION_82341D: 640 632 if (config->init_data_length != hp_82341d_firmware_length) { 641 - pr_err("hp_82341: bad firmware length=%i for 82341d (expected %i).\n", 633 + pr_err("bad firmware length=%i for 82341d (expected %i).\n", 642 634 config->init_data_length, hp_82341d_firmware_length); 643 635 return -EINVAL; 644 636 } 645 637 break; 646 638 default: 647 - pr_err("hp_82341: %s: bug! unknown hw_version\n", __func__); 639 + pr_err("bug! unknown hw_version\n"); 648 640 break; 649 641 } 650 642 return hp_82341_load_firmware_array(hp_priv, config->init_data, config->init_data_length); ··· 686 678 return 0; 687 679 } 688 680 689 - int hp_82341_attach(gpib_board_t *board, const gpib_board_config_t *config) 681 + static int hp_82341_attach(struct gpib_board *board, const gpib_board_config_t *config) 690 682 { 691 683 struct hp_82341_priv *hp_priv; 692 684 struct tms9914_priv *tms_priv; ··· 722 714 hp_priv->hw_version = HW_VERSION_82341C; 723 715 hp_priv->io_region_offset = 0x400; 724 716 } 725 - pr_info("hp_82341: base io 0x%u\n", iobase); 726 717 for (i = 0; i < hp_82341_num_io_regions; ++i) { 727 718 start_addr = iobase + i * hp_priv->io_region_offset; 728 - if (!request_region(start_addr, hp_82341_region_iosize, "hp_82341")) { 729 - pr_err("hp_82341: failed to allocate io ports 0x%lx-0x%lx\n", 730 - start_addr, 731 - start_addr + hp_82341_region_iosize - 1); 719 + if (!request_region(start_addr, hp_82341_region_iosize, DRV_NAME)) { 720 + dev_err(board->gpib_dev, "failed to allocate io ports 0x%x-0x%x\n", 721 + start_addr, 722 + start_addr + hp_82341_region_iosize - 1); 732 723 return -EIO; 733 724 } 734 725 hp_priv->iobase[i] = start_addr; ··· 737 730 retval = isapnp_cfg_begin(hp_priv->pnp_dev->card->number, 738 731 hp_priv->pnp_dev->number); 739 732 if (retval < 0) { 740 - pr_err("hp_82341: isapnp_cfg_begin returned error\n"); 733 + dev_err(board->gpib_dev, "isapnp_cfg_begin returned error\n"); 741 734 return retval; 742 735 } 743 736 isapnp_write_byte(PIO_DIRECTION_REG, HP_82341D_XILINX_READY_BIT | ··· 753 746 return retval; 754 747 if (irq_valid(hp_priv, irq) == 0) 755 748 return -EINVAL; 756 - if (request_irq(irq, hp_82341_interrupt, 0, "hp_82341", board)) { 757 - pr_err("hp_82341: failed to allocate IRQ %d\n", irq); 749 + if (request_irq(irq, hp_82341_interrupt, 0, DRV_NAME, board)) { 750 + dev_err(board->gpib_dev, "failed to allocate IRQ %d\n", irq); 758 751 return -EIO; 759 752 } 760 753 hp_priv->irq = irq; 761 - pr_info("hp_82341: IRQ %d\n", irq); 762 754 hp_priv->config_control_bits &= ~IRQ_SELECT_MASK; 763 755 hp_priv->config_control_bits |= IRQ_SELECT_BITS(irq); 764 756 outb(hp_priv->config_control_bits, hp_priv->iobase[0] + CONFIG_CONTROL_STATUS_REG); ··· 774 768 hp_priv->iobase[0] + EVENT_STATUS_REG); 775 769 776 770 tms9914_online(board, tms_priv); 777 - pr_info("hp_82341: board id %x %x %x %x\n", inb(hp_priv->iobase[1] + ID0_REG), 778 - inb(hp_priv->iobase[1] + ID1_REG), inb(hp_priv->iobase[2] + ID2_REG), 779 - inb(hp_priv->iobase[2] + ID3_REG)); 771 + 780 772 return 0; 781 773 } 782 774 783 - void hp_82341_detach(gpib_board_t *board) 775 + static void hp_82341_detach(struct gpib_board *board) 784 776 { 785 777 struct hp_82341_priv *hp_priv = board->private_data; 786 778 struct tms9914_priv *tms_priv; ··· 803 799 hp_82341_free_private(board); 804 800 } 805 801 802 + #if 0 803 + /* unused, will be needed when the driver is turned into a pnp_driver */ 806 804 static const struct pnp_device_id hp_82341_pnp_table[] = { 807 805 {.id = "HWP1411"}, 808 806 {.id = ""} 809 807 }; 810 808 MODULE_DEVICE_TABLE(pnp, hp_82341_pnp_table); 809 + #endif 811 810 812 811 static int __init hp_82341_init_module(void) 813 812 { ··· 818 811 819 812 ret = gpib_register_driver(&hp_82341_unaccel_interface, THIS_MODULE); 820 813 if (ret) { 821 - pr_err("hp_82341: gpib_register_driver failed: error = %d\n", ret); 814 + pr_err("gpib_register_driver failed: error = %d\n", ret); 822 815 return ret; 823 816 } 824 817 825 818 ret = gpib_register_driver(&hp_82341_interface, THIS_MODULE); 826 819 if (ret) { 827 - pr_err("hp_82341: gpib_register_driver failed: error = %d\n", ret); 820 + pr_err("gpib_register_driver failed: error = %d\n", ret); 828 821 gpib_unregister_driver(&hp_82341_unaccel_interface); 829 822 return ret; 830 823 } ··· 844 837 /* 845 838 * GPIB interrupt service routines 846 839 */ 847 - unsigned short read_and_clear_event_status(gpib_board_t *board) 840 + static unsigned short read_and_clear_event_status(struct gpib_board *board) 848 841 { 849 842 struct hp_82341_priv *hp_priv = board->private_data; 850 843 unsigned long flags; ··· 857 850 return status; 858 851 } 859 852 860 - irqreturn_t hp_82341_interrupt(int irq, void *arg) 853 + static irqreturn_t hp_82341_interrupt(int irq, void *arg) 861 854 { 862 855 int status1, status2; 863 - gpib_board_t *board = arg; 856 + struct gpib_board *board = arg; 864 857 struct hp_82341_priv *hp_priv = board->private_data; 865 858 struct tms9914_priv *tms_priv = &hp_priv->tms9914_priv; 866 859 unsigned long flags; ··· 869 862 870 863 spin_lock_irqsave(&board->spinlock, flags); 871 864 event_status = inb(hp_priv->iobase[0] + EVENT_STATUS_REG); 872 - // printk("hp_82341: interrupt event_status=0x%x\n", event_status); 873 865 if (event_status & INTERRUPT_PENDING_EVENT_BIT) 874 866 retval = IRQ_HANDLED; 875 867 //write-clear status bits ··· 883 877 status1 = read_byte(tms_priv, ISR0); 884 878 status2 = read_byte(tms_priv, ISR1); 885 879 tms9914_interrupt_have_status(board, tms_priv, status1, status2); 886 - /* printk("hp_82341: interrupt status1=0x%x status2=0x%x\n", 887 - * status1, status2); 888 - */ 889 880 } 890 881 spin_unlock_irqrestore(&board->spinlock, flags); 891 882 return retval; 892 883 } 893 884 894 - int read_transfer_counter(struct hp_82341_priv *hp_priv) 885 + static int read_transfer_counter(struct hp_82341_priv *hp_priv) 895 886 { 896 887 int lo, mid, value; 897 888 ··· 899 896 return value; 900 897 } 901 898 902 - void set_transfer_counter(struct hp_82341_priv *hp_priv, int count) 899 + static void set_transfer_counter(struct hp_82341_priv *hp_priv, int count) 903 900 { 904 901 int complement = -count; 905 902
-40
drivers/staging/gpib/hp_82341/hp_82341.h
··· 26 26 enum hp_82341_hardware_version hw_version; 27 27 }; 28 28 29 - 30 - // interface functions 31 - int hp_82341_accel_read(gpib_board_t *board, uint8_t *buffer, size_t length, int *end, 32 - size_t *bytes_read); 33 - int hp_82341_accel_write(gpib_board_t *board, uint8_t *buffer, size_t length, int send_eoi, 34 - size_t *bytes_written); 35 - int hp_82341_read(gpib_board_t *board, uint8_t *buffer, size_t length, int *end, 36 - size_t *bytes_read); 37 - int hp_82341_write(gpib_board_t *board, uint8_t *buffer, size_t length, int send_eoi, 38 - size_t *bytes_written); 39 - int hp_82341_command(gpib_board_t *board, uint8_t *buffer, size_t length, size_t *bytes_written); 40 - int hp_82341_take_control(gpib_board_t *board, int synchronous); 41 - int hp_82341_go_to_standby(gpib_board_t *board); 42 - void hp_82341_request_system_control(gpib_board_t *board, int request_control); 43 - void hp_82341_interface_clear(gpib_board_t *board, int assert); 44 - void hp_82341_remote_enable(gpib_board_t *board, int enable); 45 - int hp_82341_enable_eos(gpib_board_t *board, uint8_t eos_byte, int 46 - compare_8_bits); 47 - void hp_82341_disable_eos(gpib_board_t *board); 48 - unsigned int hp_82341_update_status(gpib_board_t *board, unsigned int clear_mask); 49 - int hp_82341_primary_address(gpib_board_t *board, unsigned int address); 50 - int hp_82341_secondary_address(gpib_board_t *board, unsigned int address, int 51 - enable); 52 - int hp_82341_parallel_poll(gpib_board_t *board, uint8_t *result); 53 - void hp_82341_parallel_poll_configure(gpib_board_t *board, uint8_t config); 54 - void hp_82341_parallel_poll_response(gpib_board_t *board, int ist); 55 - void hp_82341_serial_poll_response(gpib_board_t *board, uint8_t status); 56 - void hp_82341_return_to_local(gpib_board_t *board); 57 - 58 - // interrupt service routines 59 - irqreturn_t hp_82341_interrupt(int irq, void *arg); 60 - 61 - // utility functions 62 - int hp_82341_allocate_private(gpib_board_t *board); 63 - void hp_82341_free_private(gpib_board_t *board); 64 - 65 29 static const int hp_82341_region_iosize = 0x8; 66 30 static const int hp_82341_num_io_regions = 4; 67 31 static const int hp_82341_fifo_size = 0xffe; ··· 163 199 HP_82341D_LEGACY_MODE_BIT = 0x4, 164 200 HP_82341D_NOT_PROG_BIT = 0x8, // clear to reinitialize xilinx 165 201 }; 166 - 167 - unsigned short read_and_clear_event_status(gpib_board_t *board); 168 - int read_transfer_counter(struct hp_82341_priv *hp_priv); 169 - void set_transfer_counter(struct hp_82341_priv *hp_priv, int count);
+5 -5
drivers/staging/gpib/include/gpibP.h
··· 26 26 unsigned int device_id, unsigned int ss_vendor, 27 27 unsigned int ss_device, struct pci_dev *from); 28 28 unsigned int num_gpib_events(const gpib_event_queue_t *queue); 29 - int push_gpib_event(gpib_board_t *board, short event_type); 30 - int pop_gpib_event(gpib_board_t *board, gpib_event_queue_t *queue, short *event_type); 31 - int gpib_request_pseudo_irq(gpib_board_t *board, irqreturn_t (*handler)(int, void *)); 32 - void gpib_free_pseudo_irq(gpib_board_t *board); 29 + int push_gpib_event(struct gpib_board *board, short event_type); 30 + int pop_gpib_event(struct gpib_board *board, gpib_event_queue_t *queue, short *event_type); 31 + int gpib_request_pseudo_irq(struct gpib_board *board, irqreturn_t (*handler)(int, void *)); 32 + void gpib_free_pseudo_irq(struct gpib_board *board); 33 33 int gpib_match_device_path(struct device *dev, const char *device_path_in); 34 34 35 - extern gpib_board_t board_array[GPIB_MAX_NUM_BOARDS]; 35 + extern struct gpib_board board_array[GPIB_MAX_NUM_BOARDS]; 36 36 37 37 extern struct list_head registered_drivers; 38 38
+29 -29
drivers/staging/gpib/include/gpib_proto.h
··· 10 10 long ibioctl(struct file *filep, unsigned int cmd, unsigned long arg); 11 11 int osInit(void); 12 12 void osReset(void); 13 - void os_start_timer(gpib_board_t *board, unsigned int usec_timeout); 14 - void os_remove_timer(gpib_board_t *board); 13 + void os_start_timer(struct gpib_board *board, unsigned int usec_timeout); 14 + void os_remove_timer(struct gpib_board *board); 15 15 void osSendEOI(void); 16 16 void osSendEOI(void); 17 - void init_gpib_board(gpib_board_t *board); 17 + void init_gpib_board(struct gpib_board *board); 18 18 static inline unsigned long usec_to_jiffies(unsigned int usec) 19 19 { 20 20 unsigned long usec_per_jiffy = 1000000 / HZ; ··· 22 22 return 1 + (usec + usec_per_jiffy - 1) / usec_per_jiffy; 23 23 }; 24 24 25 - int serial_poll_all(gpib_board_t *board, unsigned int usec_timeout); 25 + int serial_poll_all(struct gpib_board *board, unsigned int usec_timeout); 26 26 void init_gpib_descriptor(gpib_descriptor_t *desc); 27 - int dvrsp(gpib_board_t *board, unsigned int pad, int sad, 27 + int dvrsp(struct gpib_board *board, unsigned int pad, int sad, 28 28 unsigned int usec_timeout, uint8_t *result); 29 - int ibAPWait(gpib_board_t *board, int pad); 30 - int ibAPrsp(gpib_board_t *board, int padsad, char *spb); 31 - void ibAPE(gpib_board_t *board, int pad, int v); 32 - int ibcac(gpib_board_t *board, int sync, int fallback_to_async); 33 - int ibcmd(gpib_board_t *board, uint8_t *buf, size_t length, size_t *bytes_written); 34 - int ibgts(gpib_board_t *board); 35 - int ibonline(gpib_board_t *board); 36 - int iboffline(gpib_board_t *board); 37 - int iblines(const gpib_board_t *board, short *lines); 38 - int ibrd(gpib_board_t *board, uint8_t *buf, size_t length, int *end_flag, size_t *bytes_read); 39 - int ibrpp(gpib_board_t *board, uint8_t *buf); 40 - int ibrsv2(gpib_board_t *board, uint8_t status_byte, int new_reason_for_service); 41 - void ibrsc(gpib_board_t *board, int request_control); 42 - int ibsic(gpib_board_t *board, unsigned int usec_duration); 43 - int ibsre(gpib_board_t *board, int enable); 44 - int ibpad(gpib_board_t *board, unsigned int addr); 45 - int ibsad(gpib_board_t *board, int addr); 46 - int ibeos(gpib_board_t *board, int eos, int eosflags); 47 - int ibwait(gpib_board_t *board, int wait_mask, int clear_mask, int set_mask, 29 + int ibAPWait(struct gpib_board *board, int pad); 30 + int ibAPrsp(struct gpib_board *board, int padsad, char *spb); 31 + void ibAPE(struct gpib_board *board, int pad, int v); 32 + int ibcac(struct gpib_board *board, int sync, int fallback_to_async); 33 + int ibcmd(struct gpib_board *board, uint8_t *buf, size_t length, size_t *bytes_written); 34 + int ibgts(struct gpib_board *board); 35 + int ibonline(struct gpib_board *board); 36 + int iboffline(struct gpib_board *board); 37 + int iblines(const struct gpib_board *board, short *lines); 38 + int ibrd(struct gpib_board *board, uint8_t *buf, size_t length, int *end_flag, size_t *bytes_read); 39 + int ibrpp(struct gpib_board *board, uint8_t *buf); 40 + int ibrsv2(struct gpib_board *board, uint8_t status_byte, int new_reason_for_service); 41 + void ibrsc(struct gpib_board *board, int request_control); 42 + int ibsic(struct gpib_board *board, unsigned int usec_duration); 43 + int ibsre(struct gpib_board *board, int enable); 44 + int ibpad(struct gpib_board *board, unsigned int addr); 45 + int ibsad(struct gpib_board *board, int addr); 46 + int ibeos(struct gpib_board *board, int eos, int eosflags); 47 + int ibwait(struct gpib_board *board, int wait_mask, int clear_mask, int set_mask, 48 48 int *status, unsigned long usec_timeout, gpib_descriptor_t *desc); 49 - int ibwrt(gpib_board_t *board, uint8_t *buf, size_t cnt, int send_eoi, size_t *bytes_written); 50 - int ibstatus(gpib_board_t *board); 51 - int general_ibstatus(gpib_board_t *board, const gpib_status_queue_t *device, 49 + int ibwrt(struct gpib_board *board, uint8_t *buf, size_t cnt, int send_eoi, size_t *bytes_written); 50 + int ibstatus(struct gpib_board *board); 51 + int general_ibstatus(struct gpib_board *board, const gpib_status_queue_t *device, 52 52 int clear_mask, int set_mask, gpib_descriptor_t *desc); 53 - int io_timed_out(gpib_board_t *board); 54 - int ibppc(gpib_board_t *board, uint8_t configuration); 53 + int io_timed_out(struct gpib_board *board); 54 + int ibppc(struct gpib_board *board, uint8_t configuration); 55 55 56 56 #endif /* GPIB_PROTO_INCLUDED */
+29 -29
drivers/staging/gpib/include/gpib_types.h
··· 23 23 #include <linux/interrupt.h> 24 24 25 25 typedef struct gpib_interface_struct gpib_interface_t; 26 - typedef struct gpib_board_struct gpib_board_t; 26 + struct gpib_board; 27 27 28 28 /* config parameters that are only used by driver attach functions */ 29 29 typedef struct { ··· 55 55 /* name of board */ 56 56 char *name; 57 57 /* attach() initializes board and allocates resources */ 58 - int (*attach)(gpib_board_t *board, const gpib_board_config_t *config); 58 + int (*attach)(struct gpib_board *board, const gpib_board_config_t *config); 59 59 /* detach() shuts down board and frees resources */ 60 - void (*detach)(gpib_board_t *board); 60 + void (*detach)(struct gpib_board *board); 61 61 /* read() should read at most 'length' bytes from the bus into 62 62 * 'buffer'. It should return when it fills the buffer or 63 63 * encounters an END (EOI and or EOS if appropriate). It should set 'end' ··· 68 68 * return indicates error. 69 69 * nbytes returns number of bytes read 70 70 */ 71 - int (*read)(gpib_board_t *board, uint8_t *buffer, size_t length, int *end, 71 + int (*read)(struct gpib_board *board, uint8_t *buffer, size_t length, int *end, 72 72 size_t *bytes_read); 73 73 /* write() should write 'length' bytes from buffer to the bus. 74 74 * If the boolean value send_eoi is nonzero, then EOI should 75 75 * be sent along with the last byte. Returns number of bytes 76 76 * written or negative value on error. 77 77 */ 78 - int (*write)(gpib_board_t *board, uint8_t *buffer, size_t length, int send_eoi, 78 + int (*write)(struct gpib_board *board, uint8_t *buffer, size_t length, int send_eoi, 79 79 size_t *bytes_written); 80 80 /* command() writes the command bytes in 'buffer' to the bus 81 81 * Returns zero on success or negative value on error. 82 82 */ 83 - int (*command)(gpib_board_t *board, uint8_t *buffer, size_t length, 83 + int (*command)(struct gpib_board *board, uint8_t *buffer, size_t length, 84 84 size_t *bytes_written); 85 85 /* Take control (assert ATN). If 'asyncronous' is nonzero, take 86 86 * control asyncronously (assert ATN immediately without waiting ··· 88 88 * until board becomes controller in charge. Returns zero no success, 89 89 * nonzero on error. 90 90 */ 91 - int (*take_control)(gpib_board_t *board, int asyncronous); 91 + int (*take_control)(struct gpib_board *board, int asyncronous); 92 92 /* De-assert ATN. Returns zero on success, nonzer on error. 93 93 */ 94 - int (*go_to_standby)(gpib_board_t *board); 94 + int (*go_to_standby)(struct gpib_board *board); 95 95 /* request/release control of the IFC and REN lines (system controller) */ 96 - void (*request_system_control)(gpib_board_t *board, int request_control); 96 + void (*request_system_control)(struct gpib_board *board, int request_control); 97 97 /* Asserts or de-asserts 'interface clear' (IFC) depending on 98 98 * boolean value of 'assert' 99 99 */ 100 - void (*interface_clear)(gpib_board_t *board, int assert); 100 + void (*interface_clear)(struct gpib_board *board, int assert); 101 101 /* Sends remote enable command if 'enable' is nonzero, disables remote mode 102 102 * if 'enable' is zero 103 103 */ 104 - void (*remote_enable)(gpib_board_t *board, int enable); 104 + void (*remote_enable)(struct gpib_board *board, int enable); 105 105 /* enable END for reads, when byte 'eos' is received. If 106 106 * 'compare_8_bits' is nonzero, then all 8 bits are compared 107 107 * with the eos bytes. Otherwise only the 7 least significant 108 108 * bits are compared. 109 109 */ 110 - int (*enable_eos)(gpib_board_t *board, uint8_t eos, int compare_8_bits); 110 + int (*enable_eos)(struct gpib_board *board, uint8_t eos, int compare_8_bits); 111 111 /* disable END on eos byte (END on EOI only)*/ 112 - void (*disable_eos)(gpib_board_t *board); 112 + void (*disable_eos)(struct gpib_board *board); 113 113 /* configure parallel poll */ 114 - void (*parallel_poll_configure)(gpib_board_t *board, uint8_t configuration); 114 + void (*parallel_poll_configure)(struct gpib_board *board, uint8_t configuration); 115 115 /* conduct parallel poll */ 116 - int (*parallel_poll)(gpib_board_t *board, uint8_t *result); 116 + int (*parallel_poll)(struct gpib_board *board, uint8_t *result); 117 117 /* set/clear ist (individual status bit) */ 118 - void (*parallel_poll_response)(gpib_board_t *board, int ist); 118 + void (*parallel_poll_response)(struct gpib_board *board, int ist); 119 119 /* select local parallel poll configuration mode PP2 versus remote PP1 */ 120 - void (*local_parallel_poll_mode)(gpib_board_t *board, int local); 120 + void (*local_parallel_poll_mode)(struct gpib_board *board, int local); 121 121 /* Returns current status of the bus lines. Should be set to 122 122 * NULL if your board does not have the ability to query the 123 123 * state of the bus lines. 124 124 */ 125 - int (*line_status)(const gpib_board_t *board); 125 + int (*line_status)(const struct gpib_board *board); 126 126 /* updates and returns the board's current status. 127 127 * The meaning of the bits are specified in gpib_user.h 128 128 * in the IBSTA section. The driver does not need to 129 129 * worry about setting the CMPL, END, TIMO, or ERR bits. 130 130 */ 131 - unsigned int (*update_status)(gpib_board_t *board, unsigned int clear_mask); 131 + unsigned int (*update_status)(struct gpib_board *board, unsigned int clear_mask); 132 132 /* Sets primary address 0-30 for gpib interface card. 133 133 */ 134 - int (*primary_address)(gpib_board_t *board, unsigned int address); 134 + int (*primary_address)(struct gpib_board *board, unsigned int address); 135 135 /* Sets and enables, or disables secondary address 0-30 136 136 * for gpib interface card. 137 137 */ 138 - int (*secondary_address)(gpib_board_t *board, unsigned int address, 138 + int (*secondary_address)(struct gpib_board *board, unsigned int address, 139 139 int enable); 140 140 /* Sets the byte the board should send in response to a serial poll. 141 141 * This function should also start or stop requests for service via ··· 149 149 * by IEEE 488.2 section 11.3.3.4.3 "Allowed Coupled Control of 150 150 * STB, reqt, and reqf". 151 151 */ 152 - void (*serial_poll_response)(gpib_board_t *board, uint8_t status_byte); 152 + void (*serial_poll_response)(struct gpib_board *board, uint8_t status_byte); 153 153 /* Sets the byte the board should send in response to a serial poll. 154 154 * This function should also request service via IEEE 488.2 reqt/reqf 155 155 * based on MSS (bit 6 of the status_byte) and new_reason_for_service. ··· 164 164 * If this method is left NULL by the driver, then the user library 165 165 * function ibrsv2 will not work. 166 166 */ 167 - void (*serial_poll_response2)(gpib_board_t *board, uint8_t status_byte, 167 + void (*serial_poll_response2)(struct gpib_board *board, uint8_t status_byte, 168 168 int new_reason_for_service); 169 169 /* returns the byte the board will send in response to a serial poll. 170 170 */ 171 - uint8_t (*serial_poll_status)(gpib_board_t *board); 171 + uint8_t (*serial_poll_status)(struct gpib_board *board); 172 172 /* adjust T1 delay */ 173 - unsigned int (*t1_delay)(gpib_board_t *board, unsigned int nano_sec); 173 + int (*t1_delay)(struct gpib_board *board, unsigned int nano_sec); 174 174 /* go to local mode */ 175 - void (*return_to_local)(gpib_board_t *board); 175 + void (*return_to_local)(struct gpib_board *board); 176 176 /* board does not support 7 bit eos comparisons */ 177 177 unsigned no_7_bit_eos : 1; 178 178 /* skip check for listeners before trying to send command bytes */ ··· 198 198 struct gpib_pseudo_irq { 199 199 struct timer_list timer; 200 200 irqreturn_t (*handler)(int irq, void *arg); 201 - gpib_board_t *board; 201 + struct gpib_board *board; 202 202 atomic_t active; 203 203 }; 204 204 ··· 216 216 struct module *module; 217 217 } gpib_interface_list_t; 218 218 219 - /* One gpib_board_t is allocated for each physical board in the computer. 219 + /* One struct gpib_board is allocated for each physical board in the computer. 220 220 * It provides storage for variables local to each board, and interface 221 221 * functions for performing operations on the board 222 222 */ 223 - struct gpib_board_struct { 223 + struct gpib_board { 224 224 /* functions used by this board */ 225 225 gpib_interface_t *interface; 226 226 /* Pointer to module whose use count we should increment when
+30 -30
drivers/staging/gpib/include/nec7210.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 1 + //* SPDX-License-Identifier: GPL-2.0 */ 2 2 3 3 /*************************************************************************** 4 4 * copyright : (C) 2002 by Frank Mori Hess ··· 78 78 }; 79 79 80 80 // interface functions 81 - int nec7210_read(gpib_board_t *board, struct nec7210_priv *priv, uint8_t *buffer, 81 + int nec7210_read(struct gpib_board *board, struct nec7210_priv *priv, uint8_t *buffer, 82 82 size_t length, int *end, size_t *bytes_read); 83 - int nec7210_write(gpib_board_t *board, struct nec7210_priv *priv, uint8_t *buffer, 83 + int nec7210_write(struct gpib_board *board, struct nec7210_priv *priv, uint8_t *buffer, 84 84 size_t length, int send_eoi, size_t *bytes_written); 85 - int nec7210_command(gpib_board_t *board, struct nec7210_priv *priv, uint8_t *buffer, 85 + int nec7210_command(struct gpib_board *board, struct nec7210_priv *priv, uint8_t *buffer, 86 86 size_t length, size_t *bytes_written); 87 - int nec7210_take_control(gpib_board_t *board, struct nec7210_priv *priv, int syncronous); 88 - int nec7210_go_to_standby(gpib_board_t *board, struct nec7210_priv *priv); 89 - void nec7210_request_system_control(gpib_board_t *board, 87 + int nec7210_take_control(struct gpib_board *board, struct nec7210_priv *priv, int syncronous); 88 + int nec7210_go_to_standby(struct gpib_board *board, struct nec7210_priv *priv); 89 + void nec7210_request_system_control(struct gpib_board *board, 90 90 struct nec7210_priv *priv, int request_control); 91 - void nec7210_interface_clear(gpib_board_t *board, struct nec7210_priv *priv, int assert); 92 - void nec7210_remote_enable(gpib_board_t *board, struct nec7210_priv *priv, int enable); 93 - int nec7210_enable_eos(gpib_board_t *board, struct nec7210_priv *priv, uint8_t eos_bytes, 91 + void nec7210_interface_clear(struct gpib_board *board, struct nec7210_priv *priv, int assert); 92 + void nec7210_remote_enable(struct gpib_board *board, struct nec7210_priv *priv, int enable); 93 + int nec7210_enable_eos(struct gpib_board *board, struct nec7210_priv *priv, uint8_t eos_bytes, 94 94 int compare_8_bits); 95 - void nec7210_disable_eos(gpib_board_t *board, struct nec7210_priv *priv); 96 - unsigned int nec7210_update_status(gpib_board_t *board, struct nec7210_priv *priv, 95 + void nec7210_disable_eos(struct gpib_board *board, struct nec7210_priv *priv); 96 + unsigned int nec7210_update_status(struct gpib_board *board, struct nec7210_priv *priv, 97 97 unsigned int clear_mask); 98 - unsigned int nec7210_update_status_nolock(gpib_board_t *board, struct nec7210_priv *priv); 99 - int nec7210_primary_address(const gpib_board_t *board, 98 + unsigned int nec7210_update_status_nolock(struct gpib_board *board, struct nec7210_priv *priv); 99 + int nec7210_primary_address(const struct gpib_board *board, 100 100 struct nec7210_priv *priv, unsigned int address); 101 - int nec7210_secondary_address(const gpib_board_t *board, struct nec7210_priv *priv, 101 + int nec7210_secondary_address(const struct gpib_board *board, struct nec7210_priv *priv, 102 102 unsigned int address, int enable); 103 - int nec7210_parallel_poll(gpib_board_t *board, struct nec7210_priv *priv, uint8_t *result); 104 - void nec7210_serial_poll_response(gpib_board_t *board, struct nec7210_priv *priv, uint8_t status); 105 - void nec7210_parallel_poll_configure(gpib_board_t *board, 103 + int nec7210_parallel_poll(struct gpib_board *board, struct nec7210_priv *priv, uint8_t *result); 104 + void nec7210_serial_poll_response(struct gpib_board *board, struct nec7210_priv *priv, uint8_t status); 105 + void nec7210_parallel_poll_configure(struct gpib_board *board, 106 106 struct nec7210_priv *priv, unsigned int configuration); 107 - void nec7210_parallel_poll_response(gpib_board_t *board, 107 + void nec7210_parallel_poll_response(struct gpib_board *board, 108 108 struct nec7210_priv *priv, int ist); 109 - uint8_t nec7210_serial_poll_status(gpib_board_t *board, 109 + uint8_t nec7210_serial_poll_status(struct gpib_board *board, 110 110 struct nec7210_priv *priv); 111 - unsigned int nec7210_t1_delay(gpib_board_t *board, 112 - struct nec7210_priv *priv, unsigned int nano_sec); 113 - void nec7210_return_to_local(const gpib_board_t *board, struct nec7210_priv *priv); 111 + int nec7210_t1_delay(struct gpib_board *board, 112 + struct nec7210_priv *priv, unsigned int nano_sec); 113 + void nec7210_return_to_local(const struct gpib_board *board, struct nec7210_priv *priv); 114 114 115 115 // utility functions 116 - void nec7210_board_reset(struct nec7210_priv *priv, const gpib_board_t *board); 117 - void nec7210_board_online(struct nec7210_priv *priv, const gpib_board_t *board); 116 + void nec7210_board_reset(struct nec7210_priv *priv, const struct gpib_board *board); 117 + void nec7210_board_online(struct nec7210_priv *priv, const struct gpib_board *board); 118 118 unsigned int nec7210_set_reg_bits(struct nec7210_priv *priv, unsigned int reg, 119 119 unsigned int mask, unsigned int bits); 120 - void nec7210_set_handshake_mode(gpib_board_t *board, struct nec7210_priv *priv, int mode); 121 - void nec7210_release_rfd_holdoff(gpib_board_t *board, struct nec7210_priv *priv); 122 - uint8_t nec7210_read_data_in(gpib_board_t *board, struct nec7210_priv *priv, int *end); 120 + void nec7210_set_handshake_mode(struct gpib_board *board, struct nec7210_priv *priv, int mode); 121 + void nec7210_release_rfd_holdoff(struct gpib_board *board, struct nec7210_priv *priv); 122 + uint8_t nec7210_read_data_in(struct gpib_board *board, struct nec7210_priv *priv, int *end); 123 123 124 124 // wrappers for io functions 125 125 uint8_t nec7210_ioport_read_byte(struct nec7210_priv *priv, unsigned int register_num); ··· 134 134 unsigned int register_num); 135 135 136 136 // interrupt service routine 137 - irqreturn_t nec7210_interrupt(gpib_board_t *board, struct nec7210_priv *priv); 138 - irqreturn_t nec7210_interrupt_have_status(gpib_board_t *board, 137 + irqreturn_t nec7210_interrupt(struct gpib_board *board, struct nec7210_priv *priv); 138 + irqreturn_t nec7210_interrupt_have_status(struct gpib_board *board, 139 139 struct nec7210_priv *priv, int status1, int status2); 140 140 141 141 #endif //_NEC7210_H
+26 -26
drivers/staging/gpib/include/tms9914.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 1 + //* SPDX-License-Identifier: GPL-2.0 */ 2 2 3 3 /*************************************************************************** 4 4 * copyright : (C) 2002 by Frank Mori Hess ··· 79 79 }; 80 80 81 81 // interface functions 82 - int tms9914_read(gpib_board_t *board, struct tms9914_priv *priv, uint8_t *buffer, 82 + int tms9914_read(struct gpib_board *board, struct tms9914_priv *priv, uint8_t *buffer, 83 83 size_t length, int *end, size_t *bytes_read); 84 - int tms9914_write(gpib_board_t *board, struct tms9914_priv *priv, uint8_t *buffer, 84 + int tms9914_write(struct gpib_board *board, struct tms9914_priv *priv, uint8_t *buffer, 85 85 size_t length, int send_eoi, size_t *bytes_written); 86 - int tms9914_command(gpib_board_t *board, struct tms9914_priv *priv, uint8_t *buffer, 86 + int tms9914_command(struct gpib_board *board, struct tms9914_priv *priv, uint8_t *buffer, 87 87 size_t length, size_t *bytes_written); 88 - int tms9914_take_control(gpib_board_t *board, struct tms9914_priv *priv, int syncronous); 88 + int tms9914_take_control(struct gpib_board *board, struct tms9914_priv *priv, int syncronous); 89 89 /* alternate version of tms9914_take_control which works around buggy tcs 90 90 * implementation. 91 91 */ 92 - int tms9914_take_control_workaround(gpib_board_t *board, struct tms9914_priv *priv, 92 + int tms9914_take_control_workaround(struct gpib_board *board, struct tms9914_priv *priv, 93 93 int syncronous); 94 - int tms9914_go_to_standby(gpib_board_t *board, struct tms9914_priv *priv); 95 - void tms9914_request_system_control(gpib_board_t *board, struct tms9914_priv *priv, 94 + int tms9914_go_to_standby(struct gpib_board *board, struct tms9914_priv *priv); 95 + void tms9914_request_system_control(struct gpib_board *board, struct tms9914_priv *priv, 96 96 int request_control); 97 - void tms9914_interface_clear(gpib_board_t *board, struct tms9914_priv *priv, int assert); 98 - void tms9914_remote_enable(gpib_board_t *board, struct tms9914_priv *priv, int enable); 99 - int tms9914_enable_eos(gpib_board_t *board, struct tms9914_priv *priv, uint8_t eos_bytes, 97 + void tms9914_interface_clear(struct gpib_board *board, struct tms9914_priv *priv, int assert); 98 + void tms9914_remote_enable(struct gpib_board *board, struct tms9914_priv *priv, int enable); 99 + int tms9914_enable_eos(struct gpib_board *board, struct tms9914_priv *priv, uint8_t eos_bytes, 100 100 int compare_8_bits); 101 - void tms9914_disable_eos(gpib_board_t *board, struct tms9914_priv *priv); 102 - unsigned int tms9914_update_status(gpib_board_t *board, struct tms9914_priv *priv, 101 + void tms9914_disable_eos(struct gpib_board *board, struct tms9914_priv *priv); 102 + unsigned int tms9914_update_status(struct gpib_board *board, struct tms9914_priv *priv, 103 103 unsigned int clear_mask); 104 - int tms9914_primary_address(gpib_board_t *board, 104 + int tms9914_primary_address(struct gpib_board *board, 105 105 struct tms9914_priv *priv, unsigned int address); 106 - int tms9914_secondary_address(gpib_board_t *board, struct tms9914_priv *priv, 106 + int tms9914_secondary_address(struct gpib_board *board, struct tms9914_priv *priv, 107 107 unsigned int address, int enable); 108 - int tms9914_parallel_poll(gpib_board_t *board, struct tms9914_priv *priv, uint8_t *result); 109 - void tms9914_parallel_poll_configure(gpib_board_t *board, 108 + int tms9914_parallel_poll(struct gpib_board *board, struct tms9914_priv *priv, uint8_t *result); 109 + void tms9914_parallel_poll_configure(struct gpib_board *board, 110 110 struct tms9914_priv *priv, uint8_t config); 111 - void tms9914_parallel_poll_response(gpib_board_t *board, 111 + void tms9914_parallel_poll_response(struct gpib_board *board, 112 112 struct tms9914_priv *priv, int ist); 113 - void tms9914_serial_poll_response(gpib_board_t *board, struct tms9914_priv *priv, uint8_t status); 114 - uint8_t tms9914_serial_poll_status(gpib_board_t *board, struct tms9914_priv *priv); 115 - int tms9914_line_status(const gpib_board_t *board, struct tms9914_priv *priv); 116 - unsigned int tms9914_t1_delay(gpib_board_t *board, struct tms9914_priv *priv, 113 + void tms9914_serial_poll_response(struct gpib_board *board, struct tms9914_priv *priv, uint8_t status); 114 + uint8_t tms9914_serial_poll_status(struct gpib_board *board, struct tms9914_priv *priv); 115 + int tms9914_line_status(const struct gpib_board *board, struct tms9914_priv *priv); 116 + unsigned int tms9914_t1_delay(struct gpib_board *board, struct tms9914_priv *priv, 117 117 unsigned int nano_sec); 118 - void tms9914_return_to_local(const gpib_board_t *board, struct tms9914_priv *priv); 118 + void tms9914_return_to_local(const struct gpib_board *board, struct tms9914_priv *priv); 119 119 120 120 // utility functions 121 121 void tms9914_board_reset(struct tms9914_priv *priv); 122 - void tms9914_online(gpib_board_t *board, struct tms9914_priv *priv); 122 + void tms9914_online(struct gpib_board *board, struct tms9914_priv *priv); 123 123 void tms9914_release_holdoff(struct tms9914_priv *priv); 124 124 void tms9914_set_holdoff_mode(struct tms9914_priv *priv, enum tms9914_holdoff_mode mode); 125 125 ··· 130 130 void tms9914_iomem_write_byte(struct tms9914_priv *priv, uint8_t data, unsigned int register_num); 131 131 132 132 // interrupt service routine 133 - irqreturn_t tms9914_interrupt(gpib_board_t *board, struct tms9914_priv *priv); 134 - irqreturn_t tms9914_interrupt_have_status(gpib_board_t *board, struct tms9914_priv *priv, 133 + irqreturn_t tms9914_interrupt(struct gpib_board *board, struct tms9914_priv *priv); 134 + irqreturn_t tms9914_interrupt_have_status(struct gpib_board *board, struct tms9914_priv *priv, 135 135 int status1, int status2); 136 136 137 137 // tms9914 has 8 registers
-1
drivers/staging/gpib/ines/Makefile
··· 1 - ccflags-$(CONFIG_GPIB_PCMCIA) := -DGPIB_PCMCIA 2 1 obj-$(CONFIG_GPIB_INES) += ines_gpib.o 3 2 4 3
+27 -27
drivers/staging/gpib/ines/ines.h
··· 36 36 }; 37 37 38 38 // interface functions 39 - int ines_read(gpib_board_t *board, uint8_t *buffer, size_t length, int *end, size_t *bytes_read); 40 - int ines_write(gpib_board_t *board, uint8_t *buffer, size_t length, 39 + int ines_read(struct gpib_board *board, uint8_t *buffer, size_t length, int *end, size_t *bytes_read); 40 + int ines_write(struct gpib_board *board, uint8_t *buffer, size_t length, 41 41 int send_eoi, size_t *bytes_written); 42 - int ines_accel_read(gpib_board_t *board, uint8_t *buffer, size_t length, 42 + int ines_accel_read(struct gpib_board *board, uint8_t *buffer, size_t length, 43 43 int *end, size_t *bytes_read); 44 - int ines_accel_write(gpib_board_t *board, uint8_t *buffer, size_t length, 44 + int ines_accel_write(struct gpib_board *board, uint8_t *buffer, size_t length, 45 45 int send_eoi, size_t *bytes_written); 46 - int ines_command(gpib_board_t *board, uint8_t *buffer, size_t length, size_t *bytes_written); 47 - int ines_take_control(gpib_board_t *board, int synchronous); 48 - int ines_go_to_standby(gpib_board_t *board); 49 - void ines_request_system_control(gpib_board_t *board, int request_control); 50 - void ines_interface_clear(gpib_board_t *board, int assert); 51 - void ines_remote_enable(gpib_board_t *board, int enable); 52 - int ines_enable_eos(gpib_board_t *board, uint8_t eos_byte, int compare_8_bits); 53 - void ines_disable_eos(gpib_board_t *board); 54 - unsigned int ines_update_status(gpib_board_t *board, unsigned int clear_mask); 55 - int ines_primary_address(gpib_board_t *board, unsigned int address); 56 - int ines_secondary_address(gpib_board_t *board, unsigned int address, int enable); 57 - int ines_parallel_poll(gpib_board_t *board, uint8_t *result); 58 - void ines_parallel_poll_configure(gpib_board_t *board, uint8_t config); 59 - void ines_parallel_poll_response(gpib_board_t *board, int ist); 60 - void ines_serial_poll_response(gpib_board_t *board, uint8_t status); 61 - uint8_t ines_serial_poll_status(gpib_board_t *board); 62 - int ines_line_status(const gpib_board_t *board); 63 - unsigned int ines_t1_delay(gpib_board_t *board, unsigned int nano_sec); 64 - void ines_return_to_local(gpib_board_t *board); 46 + int ines_command(struct gpib_board *board, uint8_t *buffer, size_t length, size_t *bytes_written); 47 + int ines_take_control(struct gpib_board *board, int synchronous); 48 + int ines_go_to_standby(struct gpib_board *board); 49 + void ines_request_system_control(struct gpib_board *board, int request_control); 50 + void ines_interface_clear(struct gpib_board *board, int assert); 51 + void ines_remote_enable(struct gpib_board *board, int enable); 52 + int ines_enable_eos(struct gpib_board *board, uint8_t eos_byte, int compare_8_bits); 53 + void ines_disable_eos(struct gpib_board *board); 54 + unsigned int ines_update_status(struct gpib_board *board, unsigned int clear_mask); 55 + int ines_primary_address(struct gpib_board *board, unsigned int address); 56 + int ines_secondary_address(struct gpib_board *board, unsigned int address, int enable); 57 + int ines_parallel_poll(struct gpib_board *board, uint8_t *result); 58 + void ines_parallel_poll_configure(struct gpib_board *board, uint8_t config); 59 + void ines_parallel_poll_response(struct gpib_board *board, int ist); 60 + void ines_serial_poll_response(struct gpib_board *board, uint8_t status); 61 + uint8_t ines_serial_poll_status(struct gpib_board *board); 62 + int ines_line_status(const struct gpib_board *board); 63 + int ines_t1_delay(struct gpib_board *board, unsigned int nano_sec); 64 + void ines_return_to_local(struct gpib_board *board); 65 65 66 66 // interrupt service routines 67 67 irqreturn_t ines_pci_interrupt(int irq, void *arg); 68 - irqreturn_t ines_interrupt(gpib_board_t *board); 68 + irqreturn_t ines_interrupt(struct gpib_board *board); 69 69 70 70 // utility functions 71 - void ines_free_private(gpib_board_t *board); 72 - int ines_generic_attach(gpib_board_t *board); 73 - void ines_online(struct ines_priv *priv, const gpib_board_t *board, int use_accel); 71 + void ines_free_private(struct gpib_board *board); 72 + int ines_generic_attach(struct gpib_board *board); 73 + void ines_online(struct ines_priv *priv, const struct gpib_board *board, int use_accel); 74 74 void ines_set_xfer_counter(struct ines_priv *priv, unsigned int count); 75 75 76 76 /* inb/outb wrappers */
+111 -129
drivers/staging/gpib/ines/ines_gpib.c
··· 5 5 * (C) 2002 by Frank Mori Hess 6 6 ***************************************************************************/ 7 7 8 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 9 + #define dev_fmt pr_fmt 10 + #define DRV_NAME KBUILD_MODNAME 11 + 8 12 #include "ines.h" 9 13 10 14 #include <linux/pci.h> ··· 25 21 MODULE_LICENSE("GPL"); 26 22 MODULE_DESCRIPTION("GPIB driver for Ines iGPIB 72010"); 27 23 28 - int ines_line_status(const gpib_board_t *board) 24 + int ines_line_status(const struct gpib_board *board) 29 25 { 30 - int status = ValidALL; 26 + int status = VALID_ALL; 31 27 int bcm_bits; 32 28 struct ines_priv *ines_priv; 33 - struct nec7210_priv *nec_priv; 34 29 35 30 ines_priv = board->private_data; 36 - nec_priv = &ines_priv->nec7210_priv; 37 31 38 32 bcm_bits = ines_inb(ines_priv, BUS_CONTROL_MONITOR); 39 33 40 34 if (bcm_bits & BCM_REN_BIT) 41 - status |= BusREN; 35 + status |= BUS_REN; 42 36 if (bcm_bits & BCM_IFC_BIT) 43 - status |= BusIFC; 37 + status |= BUS_IFC; 44 38 if (bcm_bits & BCM_SRQ_BIT) 45 - status |= BusSRQ; 39 + status |= BUS_SRQ; 46 40 if (bcm_bits & BCM_EOI_BIT) 47 - status |= BusEOI; 41 + status |= BUS_EOI; 48 42 if (bcm_bits & BCM_NRFD_BIT) 49 - status |= BusNRFD; 43 + status |= BUS_NRFD; 50 44 if (bcm_bits & BCM_NDAC_BIT) 51 - status |= BusNDAC; 45 + status |= BUS_NDAC; 52 46 if (bcm_bits & BCM_DAV_BIT) 53 - status |= BusDAV; 47 + status |= BUS_DAV; 54 48 if (bcm_bits & BCM_ATN_BIT) 55 - status |= BusATN; 49 + status |= BUS_ATN; 56 50 57 51 return status; 58 52 } ··· 58 56 void ines_set_xfer_counter(struct ines_priv *priv, unsigned int count) 59 57 { 60 58 if (count > 0xffff) { 61 - pr_err("ines: bug! tried to set xfer counter > 0xffff\n"); 59 + pr_err("bug! tried to set xfer counter > 0xffff\n"); 62 60 return; 63 61 } 64 62 ines_outb(priv, (count >> 8) & 0xff, XFER_COUNT_UPPER); 65 63 ines_outb(priv, count & 0xff, XFER_COUNT_LOWER); 66 64 } 67 65 68 - unsigned int ines_t1_delay(gpib_board_t *board, unsigned int nano_sec) 66 + int ines_t1_delay(struct gpib_board *board, unsigned int nano_sec) 69 67 { 70 68 struct ines_priv *ines_priv = board->private_data; 71 69 struct nec7210_priv *nec_priv = &ines_priv->nec7210_priv; ··· 95 93 return ines_inb(ines_priv, IN_FIFO_COUNT); 96 94 } 97 95 98 - static ssize_t pio_read(gpib_board_t *board, struct ines_priv *ines_priv, uint8_t *buffer, 96 + static ssize_t pio_read(struct gpib_board *board, struct ines_priv *ines_priv, uint8_t *buffer, 99 97 size_t length, size_t *nbytes) 100 98 { 101 99 ssize_t retval = 0; ··· 108 106 num_in_fifo_bytes(ines_priv) || 109 107 test_bit(RECEIVED_END_BN, &nec_priv->state) || 110 108 test_bit(DEV_CLEAR_BN, &nec_priv->state) || 111 - test_bit(TIMO_NUM, &board->status))) { 112 - pr_warn("gpib: pio read wait interrupted\n"); 109 + test_bit(TIMO_NUM, &board->status))) 113 110 return -ERESTARTSYS; 114 - } 111 + 115 112 if (test_bit(TIMO_NUM, &board->status)) 116 113 return -ETIMEDOUT; 117 114 if (test_bit(DEV_CLEAR_BN, &nec_priv->state)) 118 115 return -EINTR; 119 116 120 117 num_fifo_bytes = num_in_fifo_bytes(ines_priv); 121 - if (num_fifo_bytes + *nbytes > length) { 122 - pr_warn("ines: counter allowed %li extra byte(s)\n", 123 - (long)(num_fifo_bytes - (length - *nbytes))); 118 + if (num_fifo_bytes + *nbytes > length) 124 119 num_fifo_bytes = length - *nbytes; 125 - } 120 + 126 121 for (i = 0; i < num_fifo_bytes; i++) 127 122 buffer[(*nbytes)++] = read_byte(nec_priv, DIR); 128 123 if (test_bit(RECEIVED_END_BN, &nec_priv->state) && ··· 133 134 return retval; 134 135 } 135 136 136 - int ines_accel_read(gpib_board_t *board, uint8_t *buffer, 137 + int ines_accel_read(struct gpib_board *board, uint8_t *buffer, 137 138 size_t length, int *end, size_t *bytes_read) 138 139 { 139 140 ssize_t retval = 0; ··· 190 191 return ines_inb(ines_priv, OUT_FIFO_COUNT); 191 192 } 192 193 193 - static int ines_write_wait(gpib_board_t *board, struct ines_priv *ines_priv, 194 + static int ines_write_wait(struct gpib_board *board, struct ines_priv *ines_priv, 194 195 unsigned int fifo_threshold) 195 196 { 196 197 struct nec7210_priv *nec_priv = &ines_priv->nec7210_priv; ··· 200 201 num_out_fifo_bytes(ines_priv) < fifo_threshold || 201 202 test_bit(BUS_ERROR_BN, &nec_priv->state) || 202 203 test_bit(DEV_CLEAR_BN, &nec_priv->state) || 203 - test_bit(TIMO_NUM, &board->status))) { 204 - dev_dbg(board->gpib_dev, "gpib write interrupted\n"); 204 + test_bit(TIMO_NUM, &board->status))) 205 205 return -ERESTARTSYS; 206 - } 206 + 207 207 if (test_bit(BUS_ERROR_BN, &nec_priv->state)) 208 208 return -EIO; 209 209 if (test_bit(DEV_CLEAR_BN, &nec_priv->state)) ··· 213 215 return 0; 214 216 } 215 217 216 - int ines_accel_write(gpib_board_t *board, uint8_t *buffer, size_t length, 218 + int ines_accel_write(struct gpib_board *board, uint8_t *buffer, size_t length, 217 219 int send_eoi, size_t *bytes_written) 218 220 { 219 221 size_t count = 0; ··· 266 268 267 269 irqreturn_t ines_pci_interrupt(int irq, void *arg) 268 270 { 269 - gpib_board_t *board = arg; 271 + struct gpib_board *board = arg; 270 272 struct ines_priv *priv = board->private_data; 271 273 struct nec7210_priv *nec_priv = &priv->nec7210_priv; 272 274 ··· 281 283 return ines_interrupt(board); 282 284 } 283 285 284 - irqreturn_t ines_interrupt(gpib_board_t *board) 286 + irqreturn_t ines_interrupt(struct gpib_board *board) 285 287 { 286 288 struct ines_priv *priv = board->private_data; 287 289 struct nec7210_priv *nec_priv = &priv->nec7210_priv; ··· 299 301 wake++; 300 302 } 301 303 if (isr3_bits & FIFO_ERROR_BIT) 302 - pr_err("ines gpib: fifo error\n"); 304 + dev_err(board->gpib_dev, "fifo error\n"); 303 305 if (isr3_bits & XFER_COUNT_BIT) 304 306 wake++; 305 307 ··· 313 315 return IRQ_HANDLED; 314 316 } 315 317 316 - static int ines_pci_attach(gpib_board_t *board, const gpib_board_config_t *config); 317 - static int ines_pci_accel_attach(gpib_board_t *board, const gpib_board_config_t *config); 318 - static int ines_isa_attach(gpib_board_t *board, const gpib_board_config_t *config); 318 + static int ines_pci_attach(struct gpib_board *board, const gpib_board_config_t *config); 319 + static int ines_pci_accel_attach(struct gpib_board *board, const gpib_board_config_t *config); 320 + static int ines_isa_attach(struct gpib_board *board, const gpib_board_config_t *config); 319 321 320 - static void ines_pci_detach(gpib_board_t *board); 321 - static void ines_isa_detach(gpib_board_t *board); 322 + static void ines_pci_detach(struct gpib_board *board); 323 + static void ines_isa_detach(struct gpib_board *board); 322 324 323 325 enum ines_pci_vendor_ids { 324 326 PCI_VENDOR_ID_INES_QUICKLOGIC = 0x16da ··· 393 395 static const int num_pci_chips = ARRAY_SIZE(pci_ids); 394 396 395 397 // wrappers for interface functions 396 - int ines_read(gpib_board_t *board, uint8_t *buffer, size_t length, int *end, size_t *bytes_read) 398 + int ines_read(struct gpib_board *board, uint8_t *buffer, size_t length, 399 + int *end, size_t *bytes_read) 397 400 { 398 401 struct ines_priv *priv = board->private_data; 399 402 struct nec7210_priv *nec_priv = &priv->nec7210_priv; ··· 412 413 return retval; 413 414 } 414 415 415 - int ines_write(gpib_board_t *board, uint8_t *buffer, size_t length, int send_eoi, 416 + int ines_write(struct gpib_board *board, uint8_t *buffer, size_t length, int send_eoi, 416 417 size_t *bytes_written) 417 418 { 418 419 struct ines_priv *priv = board->private_data; ··· 420 421 return nec7210_write(board, &priv->nec7210_priv, buffer, length, send_eoi, bytes_written); 421 422 } 422 423 423 - int ines_command(gpib_board_t *board, uint8_t *buffer, size_t length, size_t *bytes_written) 424 + int ines_command(struct gpib_board *board, uint8_t *buffer, size_t length, size_t *bytes_written) 424 425 { 425 426 struct ines_priv *priv = board->private_data; 426 427 427 428 return nec7210_command(board, &priv->nec7210_priv, buffer, length, bytes_written); 428 429 } 429 430 430 - int ines_take_control(gpib_board_t *board, int synchronous) 431 + int ines_take_control(struct gpib_board *board, int synchronous) 431 432 { 432 433 struct ines_priv *priv = board->private_data; 433 434 434 435 return nec7210_take_control(board, &priv->nec7210_priv, synchronous); 435 436 } 436 437 437 - int ines_go_to_standby(gpib_board_t *board) 438 + int ines_go_to_standby(struct gpib_board *board) 438 439 { 439 440 struct ines_priv *priv = board->private_data; 440 441 441 442 return nec7210_go_to_standby(board, &priv->nec7210_priv); 442 443 } 443 444 444 - void ines_request_system_control(gpib_board_t *board, int request_control) 445 + void ines_request_system_control(struct gpib_board *board, int request_control) 445 446 { 446 447 struct ines_priv *priv = board->private_data; 447 448 448 449 nec7210_request_system_control(board, &priv->nec7210_priv, request_control); 449 450 } 450 451 451 - void ines_interface_clear(gpib_board_t *board, int assert) 452 + void ines_interface_clear(struct gpib_board *board, int assert) 452 453 { 453 454 struct ines_priv *priv = board->private_data; 454 455 455 456 nec7210_interface_clear(board, &priv->nec7210_priv, assert); 456 457 } 457 458 458 - void ines_remote_enable(gpib_board_t *board, int enable) 459 + void ines_remote_enable(struct gpib_board *board, int enable) 459 460 { 460 461 struct ines_priv *priv = board->private_data; 461 462 462 463 nec7210_remote_enable(board, &priv->nec7210_priv, enable); 463 464 } 464 465 465 - int ines_enable_eos(gpib_board_t *board, uint8_t eos_byte, int compare_8_bits) 466 + int ines_enable_eos(struct gpib_board *board, uint8_t eos_byte, int compare_8_bits) 466 467 { 467 468 struct ines_priv *priv = board->private_data; 468 469 469 470 return nec7210_enable_eos(board, &priv->nec7210_priv, eos_byte, compare_8_bits); 470 471 } 471 472 472 - void ines_disable_eos(gpib_board_t *board) 473 + void ines_disable_eos(struct gpib_board *board) 473 474 { 474 475 struct ines_priv *priv = board->private_data; 475 476 476 477 nec7210_disable_eos(board, &priv->nec7210_priv); 477 478 } 478 479 479 - unsigned int ines_update_status(gpib_board_t *board, unsigned int clear_mask) 480 + unsigned int ines_update_status(struct gpib_board *board, unsigned int clear_mask) 480 481 { 481 482 struct ines_priv *priv = board->private_data; 482 483 483 484 return nec7210_update_status(board, &priv->nec7210_priv, clear_mask); 484 485 } 485 486 486 - int ines_primary_address(gpib_board_t *board, unsigned int address) 487 + int ines_primary_address(struct gpib_board *board, unsigned int address) 487 488 { 488 489 struct ines_priv *priv = board->private_data; 489 490 490 491 return nec7210_primary_address(board, &priv->nec7210_priv, address); 491 492 } 492 493 493 - int ines_secondary_address(gpib_board_t *board, unsigned int address, int enable) 494 + int ines_secondary_address(struct gpib_board *board, unsigned int address, int enable) 494 495 { 495 496 struct ines_priv *priv = board->private_data; 496 497 497 498 return nec7210_secondary_address(board, &priv->nec7210_priv, address, enable); 498 499 } 499 500 500 - int ines_parallel_poll(gpib_board_t *board, uint8_t *result) 501 + int ines_parallel_poll(struct gpib_board *board, uint8_t *result) 501 502 { 502 503 struct ines_priv *priv = board->private_data; 503 504 504 505 return nec7210_parallel_poll(board, &priv->nec7210_priv, result); 505 506 } 506 507 507 - void ines_parallel_poll_configure(gpib_board_t *board, uint8_t config) 508 + void ines_parallel_poll_configure(struct gpib_board *board, uint8_t config) 508 509 { 509 510 struct ines_priv *priv = board->private_data; 510 511 511 512 nec7210_parallel_poll_configure(board, &priv->nec7210_priv, config); 512 513 } 513 514 514 - void ines_parallel_poll_response(gpib_board_t *board, int ist) 515 + void ines_parallel_poll_response(struct gpib_board *board, int ist) 515 516 { 516 517 struct ines_priv *priv = board->private_data; 517 518 518 519 nec7210_parallel_poll_response(board, &priv->nec7210_priv, ist); 519 520 } 520 521 521 - void ines_serial_poll_response(gpib_board_t *board, uint8_t status) 522 + void ines_serial_poll_response(struct gpib_board *board, uint8_t status) 522 523 { 523 524 struct ines_priv *priv = board->private_data; 524 525 525 526 nec7210_serial_poll_response(board, &priv->nec7210_priv, status); 526 527 } 527 528 528 - uint8_t ines_serial_poll_status(gpib_board_t *board) 529 + uint8_t ines_serial_poll_status(struct gpib_board *board) 529 530 { 530 531 struct ines_priv *priv = board->private_data; 531 532 532 533 return nec7210_serial_poll_status(board, &priv->nec7210_priv); 533 534 } 534 535 535 - void ines_return_to_local(gpib_board_t *board) 536 + void ines_return_to_local(struct gpib_board *board) 536 537 { 537 538 struct ines_priv *priv = board->private_data; 538 539 ··· 651 652 .return_to_local = ines_return_to_local, 652 653 }; 653 654 654 - static int ines_allocate_private(gpib_board_t *board) 655 + static int ines_allocate_private(struct gpib_board *board) 655 656 { 656 657 struct ines_priv *priv; 657 658 ··· 664 665 return 0; 665 666 } 666 667 667 - void ines_free_private(gpib_board_t *board) 668 + void ines_free_private(struct gpib_board *board) 668 669 { 669 670 kfree(board->private_data); 670 671 board->private_data = NULL; 671 672 } 672 673 673 - int ines_generic_attach(gpib_board_t *board) 674 + int ines_generic_attach(struct gpib_board *board) 674 675 { 675 676 struct ines_priv *ines_priv; 676 677 struct nec7210_priv *nec_priv; ··· 690 691 return 0; 691 692 } 692 693 693 - void ines_online(struct ines_priv *ines_priv, const gpib_board_t *board, int use_accel) 694 + void ines_online(struct ines_priv *ines_priv, const struct gpib_board *board, int use_accel) 694 695 { 695 696 struct nec7210_priv *nec_priv = &ines_priv->nec7210_priv; 696 697 ··· 724 725 nec7210_set_reg_bits(nec_priv, IMR1, HR_DOIE | HR_DIIE, 0); 725 726 } 726 727 727 - static int ines_common_pci_attach(gpib_board_t *board, const gpib_board_config_t *config) 728 + static int ines_common_pci_attach(struct gpib_board *board, const gpib_board_config_t *config) 728 729 { 729 730 struct ines_priv *ines_priv; 730 731 struct nec7210_priv *nec_priv; ··· 768 769 } while (1); 769 770 } 770 771 if (!ines_priv->pci_device) { 771 - pr_err("gpib: could not find ines PCI board\n"); 772 + dev_err(board->gpib_dev, "could not find ines PCI board\n"); 772 773 return -1; 773 774 } 774 775 775 776 if (pci_enable_device(ines_priv->pci_device)) { 776 - pr_err("error enabling pci device\n"); 777 + dev_err(board->gpib_dev, "error enabling pci device\n"); 777 778 return -1; 778 779 } 779 780 780 - if (pci_request_regions(ines_priv->pci_device, "ines-gpib")) 781 + if (pci_request_regions(ines_priv->pci_device, DRV_NAME)) 781 782 return -1; 782 783 nec_priv->iobase = pci_resource_start(ines_priv->pci_device, 783 784 found_id.gpib_region); ··· 796 797 case PCI_CHIP_QUICKLOGIC5030: 797 798 break; 798 799 default: 799 - pr_err("gpib: unspecified chip type? (bug)\n"); 800 + dev_err(board->gpib_dev, "unspecified chip type? (bug)\n"); 800 801 nec_priv->iobase = 0; 801 802 pci_release_regions(ines_priv->pci_device); 802 803 return -1; ··· 812 813 #endif 813 814 isr_flags |= IRQF_SHARED; 814 815 if (request_irq(ines_priv->pci_device->irq, ines_pci_interrupt, isr_flags, 815 - "pci-gpib", board)) { 816 - pr_err("gpib: can't request IRQ %d\n", ines_priv->pci_device->irq); 816 + DRV_NAME, board)) { 817 + dev_err(board->gpib_dev, "can't request IRQ %d\n", ines_priv->pci_device->irq); 817 818 return -1; 818 819 } 819 820 ines_priv->irq = ines_priv->pci_device->irq; ··· 845 846 case PCI_CHIP_QUICKLOGIC5030: 846 847 break; 847 848 default: 848 - pr_err("gpib: unspecified chip type? (bug)\n"); 849 + dev_err(board->gpib_dev, "unspecified chip type? (bug)\n"); 849 850 return -1; 850 851 } 851 852 852 853 return 0; 853 854 } 854 855 855 - int ines_pci_attach(gpib_board_t *board, const gpib_board_config_t *config) 856 + int ines_pci_attach(struct gpib_board *board, const gpib_board_config_t *config) 856 857 { 857 858 struct ines_priv *ines_priv; 858 859 int retval; ··· 867 868 return 0; 868 869 } 869 870 870 - int ines_pci_accel_attach(gpib_board_t *board, const gpib_board_config_t *config) 871 + int ines_pci_accel_attach(struct gpib_board *board, const gpib_board_config_t *config) 871 872 { 872 873 struct ines_priv *ines_priv; 873 874 int retval; ··· 884 885 885 886 static const int ines_isa_iosize = 0x20; 886 887 887 - int ines_isa_attach(gpib_board_t *board, const gpib_board_config_t *config) 888 + int ines_isa_attach(struct gpib_board *board, const gpib_board_config_t *config) 888 889 { 889 890 struct ines_priv *ines_priv; 890 891 struct nec7210_priv *nec_priv; ··· 898 899 ines_priv = board->private_data; 899 900 nec_priv = &ines_priv->nec7210_priv; 900 901 901 - if (!request_region(config->ibbase, ines_isa_iosize, "ines_gpib")) { 902 - pr_err("ines_gpib: ioports at 0x%x already in use\n", config->ibbase); 903 - return -1; 902 + if (!request_region(config->ibbase, ines_isa_iosize, DRV_NAME)) { 903 + dev_err(board->gpib_dev, "ioports at 0x%x already in use\n", 904 + config->ibbase); 905 + return -EBUSY; 904 906 } 905 907 nec_priv->iobase = config->ibbase; 906 908 nec_priv->offset = 1; 907 909 nec7210_board_reset(nec_priv, board); 908 - if (request_irq(config->ibirq, ines_pci_interrupt, isr_flags, "ines_gpib", board)) { 909 - pr_err("ines_gpib: failed to allocate IRQ %d\n", config->ibirq); 910 + if (request_irq(config->ibirq, ines_pci_interrupt, isr_flags, DRV_NAME, board)) { 911 + dev_err(board->gpib_dev, "failed to allocate IRQ %d\n", config->ibirq); 910 912 return -1; 911 913 } 912 914 ines_priv->irq = config->ibirq; ··· 915 915 return 0; 916 916 } 917 917 918 - void ines_pci_detach(gpib_board_t *board) 918 + void ines_pci_detach(struct gpib_board *board) 919 919 { 920 920 struct ines_priv *ines_priv = board->private_data; 921 921 struct nec7210_priv *nec_priv; ··· 949 949 ines_free_private(board); 950 950 } 951 951 952 - void ines_isa_detach(gpib_board_t *board) 952 + void ines_isa_detach(struct gpib_board *board) 953 953 { 954 954 struct ines_priv *ines_priv = board->private_data; 955 955 struct nec7210_priv *nec_priv; ··· 977 977 .probe = &ines_pci_probe 978 978 }; 979 979 980 - #ifdef GPIB_PCMCIA 980 + #ifdef CONFIG_GPIB_PCMCIA 981 981 982 982 #include <linux/kernel.h> 983 983 #include <linux/ptrace.h> ··· 987 987 #include <pcmcia/cistpl.h> 988 988 #include <pcmcia/ds.h> 989 989 #include <pcmcia/cisreg.h> 990 - 991 - #ifdef PCMCIA_DEBUG 992 - static int pc_debug = PCMCIA_DEBUG; 993 - #define DEBUG(n, args...) do {if (pc_debug > (n)) pr_debug(args)} while (0) 994 - #else 995 - #define DEBUG(args...) 996 - #endif 997 990 998 991 static const int ines_pcmcia_iosize = 0x20; 999 992 ··· 1000 1007 1001 1008 static int ines_gpib_config(struct pcmcia_device *link); 1002 1009 static void ines_gpib_release(struct pcmcia_device *link); 1003 - static int ines_pcmcia_attach(gpib_board_t *board, const gpib_board_config_t *config); 1004 - static int ines_pcmcia_accel_attach(gpib_board_t *board, const gpib_board_config_t *config); 1005 - static void ines_pcmcia_detach(gpib_board_t *board); 1010 + static int ines_pcmcia_attach(struct gpib_board *board, const gpib_board_config_t *config); 1011 + static int ines_pcmcia_accel_attach(struct gpib_board *board, const gpib_board_config_t *config); 1012 + static void ines_pcmcia_detach(struct gpib_board *board); 1006 1013 static irqreturn_t ines_pcmcia_interrupt(int irq, void *arg); 1007 - static int ines_common_pcmcia_attach(gpib_board_t *board); 1014 + static int ines_common_pcmcia_attach(struct gpib_board *board); 1008 1015 /* 1009 1016 * A linked list of "instances" of the gpib device. Each actual 1010 1017 * PCMCIA card corresponds to one device instance, and is described ··· 1036 1043 1037 1044 struct local_info { 1038 1045 struct pcmcia_device *p_dev; 1039 - gpib_board_t *dev; 1046 + struct gpib_board *dev; 1040 1047 u_short manfid; 1041 1048 u_short cardid; 1042 1049 }; ··· 1055 1062 struct local_info *info; 1056 1063 1057 1064 // int ret, i; 1058 - 1059 - DEBUG(0, "%s(0x%p)\n", __func__ link); 1060 1065 1061 1066 /* Allocate space for private device-specific data */ 1062 1067 info = kzalloc(sizeof(*info), GFP_KERNEL); ··· 1087 1096 static void ines_gpib_remove(struct pcmcia_device *link) 1088 1097 { 1089 1098 struct local_info *info = link->priv; 1090 - //struct gpib_board_t *dev = info->dev; 1091 - 1092 - DEBUG(0, "%s(0x%p)\n", __func__, link); 1099 + //struct struct gpib_board *dev = info->dev; 1093 1100 1094 1101 if (info->dev) 1095 1102 ines_pcmcia_detach(info->dev); ··· 1114 1125 void __iomem *virt; 1115 1126 1116 1127 dev = link->priv; 1117 - DEBUG(0, "%s(0x%p)\n", __func__, link); 1118 1128 1119 1129 retval = pcmcia_loop_config(link, &ines_gpib_config_iteration, NULL); 1120 1130 if (retval) { ··· 1122 1134 return -ENODEV; 1123 1135 } 1124 1136 1125 - pr_debug("ines_cs: manufacturer: 0x%x card: 0x%x\n", 1126 - link->manf_id, link->card_id); 1137 + dev_dbg(&link->dev, "ines_cs: manufacturer: 0x%x card: 0x%x\n", 1138 + link->manf_id, link->card_id); 1127 1139 1128 1140 /* for the ines card we have to setup the configuration registers in 1129 1141 * attribute memory here ··· 1155 1167 ines_gpib_release(link); 1156 1168 return -ENODEV; 1157 1169 } 1158 - pr_info("ines gpib device loaded\n"); 1159 1170 return 0; 1160 1171 } /* gpib_config */ 1161 1172 ··· 1166 1179 1167 1180 static void ines_gpib_release(struct pcmcia_device *link) 1168 1181 { 1169 - DEBUG(0, "%s(0x%p)\n", __func__, link); 1170 1182 pcmcia_disable_device(link); 1171 1183 } /* gpib_release */ 1172 1184 1173 1185 static int ines_gpib_suspend(struct pcmcia_device *link) 1174 1186 { 1175 1187 //struct local_info *info = link->priv; 1176 - //struct gpib_board_t *dev = info->dev; 1177 - DEBUG(0, "%s(0x%p)\n", __func__, link); 1188 + //struct struct gpib_board *dev = info->dev; 1178 1189 1179 1190 if (link->open) 1180 - pr_err("Device still open ???\n"); 1191 + dev_err(&link->dev, "Device still open\n"); 1181 1192 //netif_device_detach(dev); 1182 1193 1183 1194 return 0; ··· 1184 1199 static int ines_gpib_resume(struct pcmcia_device *link) 1185 1200 { 1186 1201 //struct local_info_t *info = link->priv; 1187 - //struct gpib_board_t *dev = info->dev; 1188 - DEBUG(0, "%s(0x%p)\n", __func__, link); 1202 + //struct struct gpib_board *dev = info->dev; 1189 1203 1190 1204 /*if (link->open) { 1191 1205 * ni_gpib_probe(dev); / really? 1192 - * printk("Gpib resumed ???\n"); 1193 1206 * //netif_device_attach(dev); 1194 1207 *} 1195 1208 */ ··· 1212 1229 1213 1230 void ines_pcmcia_cleanup_module(void) 1214 1231 { 1215 - DEBUG(0, "ines_cs: unloading\n"); 1216 1232 pcmcia_unregister_driver(&ines_gpib_cs_driver); 1217 1233 } 1218 1234 ··· 1301 1319 1302 1320 irqreturn_t ines_pcmcia_interrupt(int irq, void *arg) 1303 1321 { 1304 - gpib_board_t *board = arg; 1322 + struct gpib_board *board = arg; 1305 1323 1306 1324 return ines_interrupt(board); 1307 1325 } 1308 1326 1309 - int ines_common_pcmcia_attach(gpib_board_t *board) 1327 + int ines_common_pcmcia_attach(struct gpib_board *board) 1310 1328 { 1311 1329 struct ines_priv *ines_priv; 1312 1330 struct nec7210_priv *nec_priv; 1313 1331 int retval; 1314 1332 1315 1333 if (!curr_dev) { 1316 - pr_err("no ines pcmcia cards found\n"); 1334 + dev_err(board->gpib_dev, "no ines pcmcia cards found\n"); 1317 1335 return -1; 1318 1336 } 1319 1337 ··· 1325 1343 nec_priv = &ines_priv->nec7210_priv; 1326 1344 1327 1345 if (!request_region(curr_dev->resource[0]->start, 1328 - resource_size(curr_dev->resource[0]), "ines_gpib")) { 1329 - pr_err("ines_gpib: ioports at 0x%lx already in use\n", 1330 - (unsigned long)(curr_dev->resource[0]->start)); 1346 + resource_size(curr_dev->resource[0]), DRV_NAME)) { 1347 + dev_err(board->gpib_dev, "ioports at 0x%lx already in use\n", 1348 + (unsigned long)(curr_dev->resource[0]->start)); 1331 1349 return -1; 1332 1350 } 1333 1351 ··· 1337 1355 1338 1356 if (request_irq(curr_dev->irq, ines_pcmcia_interrupt, IRQF_SHARED, 1339 1357 "pcmcia-gpib", board)) { 1340 - pr_err("gpib: can't request IRQ %d\n", curr_dev->irq); 1358 + dev_err(board->gpib_dev, "can't request IRQ %d\n", curr_dev->irq); 1341 1359 return -1; 1342 1360 } 1343 1361 ines_priv->irq = curr_dev->irq; ··· 1345 1363 return 0; 1346 1364 } 1347 1365 1348 - int ines_pcmcia_attach(gpib_board_t *board, const gpib_board_config_t *config) 1366 + int ines_pcmcia_attach(struct gpib_board *board, const gpib_board_config_t *config) 1349 1367 { 1350 1368 struct ines_priv *ines_priv; 1351 1369 int retval; ··· 1360 1378 return 0; 1361 1379 } 1362 1380 1363 - int ines_pcmcia_accel_attach(gpib_board_t *board, const gpib_board_config_t *config) 1381 + int ines_pcmcia_accel_attach(struct gpib_board *board, const gpib_board_config_t *config) 1364 1382 { 1365 1383 struct ines_priv *ines_priv; 1366 1384 int retval; ··· 1375 1393 return 0; 1376 1394 } 1377 1395 1378 - void ines_pcmcia_detach(gpib_board_t *board) 1396 + void ines_pcmcia_detach(struct gpib_board *board) 1379 1397 { 1380 1398 struct ines_priv *ines_priv = board->private_data; 1381 1399 struct nec7210_priv *nec_priv; ··· 1392 1410 ines_free_private(board); 1393 1411 } 1394 1412 1395 - #endif /* GPIB_PCMCIA */ 1413 + #endif /* CONFIG_GPIB_PCMCIA */ 1396 1414 1397 1415 static int __init ines_init_module(void) 1398 1416 { ··· 1400 1418 1401 1419 ret = pci_register_driver(&ines_pci_driver); 1402 1420 if (ret) { 1403 - pr_err("ines_gpib: pci_register_driver failed: error = %d\n", ret); 1421 + pr_err("pci_register_driver failed: error = %d\n", ret); 1404 1422 return ret; 1405 1423 } 1406 1424 1407 1425 ret = gpib_register_driver(&ines_pci_interface, THIS_MODULE); 1408 1426 if (ret) { 1409 - pr_err("ines_gpib: gpib_register_driver failed: error = %d\n", ret); 1427 + pr_err("gpib_register_driver failed: error = %d\n", ret); 1410 1428 goto err_pci; 1411 1429 } 1412 1430 1413 1431 ret = gpib_register_driver(&ines_pci_unaccel_interface, THIS_MODULE); 1414 1432 if (ret) { 1415 - pr_err("ines_gpib: gpib_register_driver failed: error = %d\n", ret); 1433 + pr_err("gpib_register_driver failed: error = %d\n", ret); 1416 1434 goto err_pci_unaccel; 1417 1435 } 1418 1436 1419 1437 ret = gpib_register_driver(&ines_pci_accel_interface, THIS_MODULE); 1420 1438 if (ret) { 1421 - pr_err("ines_gpib: gpib_register_driver failed: error = %d\n", ret); 1439 + pr_err("gpib_register_driver failed: error = %d\n", ret); 1422 1440 goto err_pci_accel; 1423 1441 } 1424 1442 1425 1443 ret = gpib_register_driver(&ines_isa_interface, THIS_MODULE); 1426 1444 if (ret) { 1427 - pr_err("ines_gpib: gpib_register_driver failed: error = %d\n", ret); 1445 + pr_err("gpib_register_driver failed: error = %d\n", ret); 1428 1446 goto err_isa; 1429 1447 } 1430 1448 1431 - #ifdef GPIB_PCMCIA 1449 + #ifdef CONFIG_GPIB_PCMCIA 1432 1450 ret = gpib_register_driver(&ines_pcmcia_interface, THIS_MODULE); 1433 1451 if (ret) { 1434 - pr_err("ines_gpib: gpib_register_driver failed: error = %d\n", ret); 1452 + pr_err("gpib_register_driver failed: error = %d\n", ret); 1435 1453 goto err_pcmcia; 1436 1454 } 1437 1455 1438 1456 ret = gpib_register_driver(&ines_pcmcia_unaccel_interface, THIS_MODULE); 1439 1457 if (ret) { 1440 - pr_err("ines_gpib: gpib_register_driver failed: error = %d\n", ret); 1458 + pr_err("gpib_register_driver failed: error = %d\n", ret); 1441 1459 goto err_pcmcia_unaccel; 1442 1460 } 1443 1461 1444 1462 ret = gpib_register_driver(&ines_pcmcia_accel_interface, THIS_MODULE); 1445 1463 if (ret) { 1446 - pr_err("ines_gpib: gpib_register_driver failed: error = %d\n", ret); 1464 + pr_err("gpib_register_driver failed: error = %d\n", ret); 1447 1465 goto err_pcmcia_accel; 1448 1466 } 1449 1467 1450 1468 ret = pcmcia_register_driver(&ines_gpib_cs_driver); 1451 1469 if (ret) { 1452 - pr_err("ines_gpib: pcmcia_register_driver failed: error = %d\n", ret); 1470 + pr_err("pcmcia_register_driver failed: error = %d\n", ret); 1453 1471 goto err_pcmcia_driver; 1454 1472 } 1455 1473 #endif 1456 1474 1457 1475 return 0; 1458 1476 1459 - #ifdef GPIB_PCMCIA 1477 + #ifdef CONFIG_GPIB_PCMCIA 1460 1478 err_pcmcia_driver: 1461 1479 gpib_unregister_driver(&ines_pcmcia_accel_interface); 1462 1480 err_pcmcia_accel:
+124 -239
drivers/staging/gpib/lpvo_usb_gpib/lpvo_usb_gpib.c
··· 8 8 * copyright : (C) 2011 Marcello Carla' * 9 9 ***************************************************************************/ 10 10 11 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 12 + #define dev_fmt pr_fmt 13 + #define NAME KBUILD_MODNAME 14 + 11 15 /* base module includes */ 12 16 13 17 #include <linux/module.h> ··· 35 31 MODULE_LICENSE("GPL"); 36 32 MODULE_DESCRIPTION("GPIB driver for LPVO usb devices"); 37 33 38 - #define NAME "lpvo_usb_gpib" 39 - 40 34 /* 41 35 * Table of devices that work with this driver. 42 36 * ··· 57 55 58 56 /* 59 57 * *** Diagnostics and Debug *** 60 - * 58 + * To enable the diagnostic and debug messages either compile with DEBUG set 59 + * or control via the dynamic debug mechanisms. 61 60 * The module parameter "debug" controls the sending of debug messages to 62 - * syslog. By default it is set to 0 or 1 according to GPIB_CONFIG_KERNEL_DEBUG. 63 - * debug = 0: only register/deregister messages are generated 61 + * syslog. By default it is set to 0 62 + * debug = 0: only attach/detach messages are sent 64 63 * 1: every action is logged 65 64 * 2: extended logging; each single exchanged byte is documented 66 65 * (about twice the log volume of [1]) ··· 73 70 static int debug; 74 71 module_param(debug, int, 0644); 75 72 76 - #define DIA_LOG(level, format, ...) \ 73 + #define DIA_LOG(level, format, ...) \ 77 74 do { if (debug >= (level)) \ 78 - pr_alert("%s:%s - " format, NAME, __func__, ## __VA_ARGS__); } \ 75 + dev_dbg(board->gpib_dev, format, ## __VA_ARGS__); } \ 79 76 while (0) 77 + 78 + #define WQT wait_queue_entry_t 79 + #define WQH head 80 + #define WQE entry 80 81 81 82 /* standard and extended command sets of the usb-gpib adapter */ 82 83 ··· 142 135 }; 143 136 144 137 struct usb_gpib_priv { /* private data to the device */ 145 - u8 eos; /* eos character */ 138 + u8 eos; /* eos character */ 146 139 short eos_flags; /* eos mode */ 147 140 int timeout; /* current value for timeout */ 148 141 void *dev; /* the usb device private data structure */ ··· 150 143 151 144 #define GPIB_DEV (((struct usb_gpib_priv *)board->private_data)->dev) 152 145 153 - #define SHOW_STATUS(board) { \ 154 - DIA_LOG(2, "# - board %p\n", board); \ 155 - DIA_LOG(2, "# - buffer_length %d\n", board->buffer_length); \ 156 - DIA_LOG(2, "# - status %lx\n", board->status); \ 157 - DIA_LOG(2, "# - use_count %d\n", board->use_count); \ 158 - DIA_LOG(2, "# - pad %x\n", board->pad); \ 159 - DIA_LOG(2, "# - sad %x\n", board->sad); \ 160 - DIA_LOG(2, "# - timeout %d\n", board->usec_timeout); \ 161 - DIA_LOG(2, "# - ppc %d\n", board->parallel_poll_configuration); \ 162 - DIA_LOG(2, "# - t1delay %d\n", board->t1_nano_sec); \ 163 - DIA_LOG(2, "# - online %d\n", board->online); \ 164 - DIA_LOG(2, "# - autopoll %d\n", board->autospollers); \ 165 - DIA_LOG(2, "# - autopoll task %p\n", board->autospoll_task); \ 166 - DIA_LOG(2, "# - minor %d\n", board->minor); \ 167 - DIA_LOG(2, "# - master %d\n", board->master); \ 168 - DIA_LOG(2, "# - list %d\n", board->ist); \ 169 - } 170 - /* 171 - * n = 0; 172 - * list_for_each (l, &board->device_list) n++; 173 - * TTY_LOG ("%s:%s - devices in list %d\n", a, b, n); 174 - */ 175 - 176 - /* 177 - * TTY_LOG - write a message to the current work terminal (if any) 178 - */ 179 - 180 - #define TTY_LOG(format, ...) { \ 181 - char buf[128]; \ 182 - struct tty_struct *tty = get_current_tty(); \ 183 - if (tty) { \ 184 - snprintf(buf, 128, format, __VA_ARGS__); \ 185 - tty->driver->ops->write(tty, buf, strlen(buf)); \ 186 - tty->driver->ops->write(tty, "\r", 1); \ 187 - } \ 188 - } 146 + static void show_status(struct gpib_board *board) 147 + { 148 + DIA_LOG(2, "# - buffer_length %d\n", board->buffer_length); 149 + DIA_LOG(2, "# - status %lx\n", board->status); 150 + DIA_LOG(2, "# - use_count %d\n", board->use_count); 151 + DIA_LOG(2, "# - pad %x\n", board->pad); 152 + DIA_LOG(2, "# - sad %x\n", board->sad); 153 + DIA_LOG(2, "# - timeout %d\n", board->usec_timeout); 154 + DIA_LOG(2, "# - ppc %d\n", board->parallel_poll_configuration); 155 + DIA_LOG(2, "# - t1delay %d\n", board->t1_nano_sec); 156 + DIA_LOG(2, "# - online %d\n", board->online); 157 + DIA_LOG(2, "# - autopoll %d\n", board->autospollers); 158 + DIA_LOG(2, "# - autopoll task %p\n", board->autospoll_task); 159 + DIA_LOG(2, "# - minor %d\n", board->minor); 160 + DIA_LOG(2, "# - master %d\n", board->master); 161 + DIA_LOG(2, "# - list %d\n", board->ist); 162 + } 189 163 190 164 /* 191 165 * GLOBAL VARIABLES: required for ··· 188 200 struct usb_skel; 189 201 static ssize_t skel_do_write(struct usb_skel *, const char *, size_t); 190 202 static ssize_t skel_do_read(struct usb_skel *, char *, size_t); 191 - static int skel_do_open(gpib_board_t *, int); 192 - static int skel_do_release(gpib_board_t *); 203 + static int skel_do_open(struct gpib_board *, int); 204 + static int skel_do_release(struct gpib_board *); 193 205 194 206 /* 195 207 * usec_diff : take difference in MICROsec between two 'timespec' ··· 217 229 218 230 static int write_loop(void *dev, char *msg, int leng) 219 231 { 220 - // int nchar = 0, val; 221 - 222 - // do { 223 - 224 232 return skel_do_write(dev, msg, leng); 225 - 226 - // if (val < 1) { 227 - // printk (KERN_ALERT "%s:%s - write error: %d %d/%d\n", 228 - // NAME, __func__, val, nchar, leng); 229 - // return -EIO; 230 - // } 231 - // nchar +=val; 232 - // } while (nchar < leng); 233 - // return leng; 234 - } 235 - 236 - static char printable(char x) 237 - { 238 - if (x < 32 || x > 126) 239 - return ' '; 240 - return x; 241 233 } 242 234 243 235 /** ··· 225 257 * 226 258 * @board: the gpib_board_struct data area for this gpib interface 227 259 * @msg: the byte sequence. 228 - * @leng the byte sequence length; can be given as zero and is 260 + * @leng: the byte sequence length; can be given as zero and is 229 261 * computed automatically, but if 'msg' contains a zero byte, 230 262 * it has to be given explicitly. 231 263 */ 232 264 233 - static int send_command(gpib_board_t *board, char *msg, int leng) 265 + static int send_command(struct gpib_board *board, char *msg, int leng) 234 266 { 235 267 char buffer[64]; 236 - int nchar, j; 268 + int nchar; 237 269 int retval; 238 270 struct timespec64 before, after; 239 271 ··· 248 280 nchar = skel_do_read(GPIB_DEV, buffer, 64); 249 281 250 282 if (nchar < 0) { 251 - DIA_LOG(0, " return from read: %d\n", nchar); 283 + dev_err(board->gpib_dev, " return from read: %d\n", nchar); 252 284 return nchar; 253 285 } else if (nchar != 1) { 254 - for (j = 0 ; j < leng ; j++) { 255 - DIA_LOG(0, " Irregular reply to command: %d %x %c\n", 256 - j, msg[j], printable(msg[j])); 257 - } 258 - for (j = 0 ; j < nchar ; j++) { 259 - DIA_LOG(0, " Irregular command reply: %d %x %c\n", 260 - j, buffer[j] & 0xff, printable(buffer[j])); 261 - } 286 + dev_err(board->gpib_dev, " Irregular reply to command: %s\n", msg); 262 287 return -EIO; 263 288 } 264 289 ktime_get_real_ts64 (&after); ··· 271 310 * 272 311 */ 273 312 274 - static int set_control_line(gpib_board_t *board, int line, int value) 313 + static int set_control_line(struct gpib_board *board, int line, int value) 275 314 { 276 315 char msg[] = USB_GPIB_SET_LINES; 277 316 int retval; ··· 298 337 /* 299 338 * one_char() - read one single byte from input buffer 300 339 * 301 - * @board: the gpib_board_struct data area for this gpib interface 302 - * @char_buf: the routine private data structure 340 + * @board: the gpib_board_struct data area for this gpib interface 341 + * @char_buf: the routine private data structure 303 342 */ 304 343 305 - static int one_char(gpib_board_t *board, struct char_buf *b) 344 + static int one_char(struct gpib_board *board, struct char_buf *b) 306 345 { 307 346 struct timespec64 before, after; 308 347 ··· 321 360 if (b->nchar > 0) { 322 361 DIA_LOG(2, "--> %x\n", b->inbuf[b->last - b->nchar]); 323 362 return b->inbuf[b->last - b->nchar--]; 324 - } else if (b->nchar == 0) { 325 - dev_alert(board->gpib_dev, "%s:%s - read returned EOF\n", NAME, __func__); 326 - return -EIO; 327 363 } 328 - dev_alert(board->gpib_dev, "%s:%s - read error %d\n", NAME, __func__, b->nchar); 329 - TTY_LOG("\n *** %s *** Read Error - %s\n", NAME, 330 - "Reset the adapter with 'gpib_config'\n"); 331 364 return -EIO; 332 365 } 333 366 ··· 336 381 * not supported. 337 382 */ 338 383 339 - static void set_timeout(gpib_board_t *board) 384 + static void set_timeout(struct gpib_board *board) 340 385 { 341 386 int n, val; 342 387 char command[sizeof(USB_GPIB_TTMO) + 6]; ··· 361 406 val = send_command(board, command, 0); 362 407 } 363 408 364 - if (val != ACK) { 365 - dev_alert(board->gpib_dev, "%s:%s - error in timeout set: <%s>\n", 366 - NAME, __func__, command); 367 - } else { 409 + if (val != ACK) 410 + dev_err(board->gpib_dev, "error in timeout set: <%s>\n", command); 411 + else 368 412 data->timeout = board->usec_timeout; 369 - } 370 413 } 371 414 372 415 /* ··· 384 431 * detach() will be called. Always. 385 432 */ 386 433 387 - static int usb_gpib_attach(gpib_board_t *board, const gpib_board_config_t *config) 434 + static int usb_gpib_attach(struct gpib_board *board, const gpib_board_config_t *config) 388 435 { 389 436 int retval, j; 390 437 u32 base = config->ibbase; ··· 404 451 405 452 if (config->device_path) { 406 453 /* if config->device_path given, try that first */ 407 - dev_alert(board->gpib_dev, "%s:%s - Looking for device_path: %s\n", 408 - NAME, __func__, config->device_path); 409 454 for (j = 0 ; j < MAX_DEV ; j++) { 410 455 if ((assigned_usb_minors & 1 << j) == 0) 411 456 continue; ··· 438 487 mutex_unlock(&minors_lock); 439 488 440 489 if (j == MAX_DEV) { 441 - dev_alert(board->gpib_dev, "%s:%s - Requested device is not registered.\n", 442 - NAME, __func__); 490 + dev_err(board->gpib_dev, "Requested device is not registered.\n"); 443 491 return -EIO; 444 492 } 445 493 ··· 451 501 DIA_LOG(1, "Skel open: %d\n", retval); 452 502 453 503 if (retval) { 454 - TTY_LOG("%s:%s - skel open failed.\n", NAME, __func__); 504 + dev_err(board->gpib_dev, "skel open failed.\n"); 455 505 kfree(board->private_data); 456 506 board->private_data = NULL; 457 507 return -ENODEV; 458 508 } 459 509 460 - SHOW_STATUS(board); 510 + show_status(board); 461 511 462 512 retval = send_command(board, USB_GPIB_ON, 0); 463 513 DIA_LOG(1, "USB_GPIB_ON returns %x\n", retval); ··· 491 541 if (retval != ACK) 492 542 return -EIO; 493 543 494 - SHOW_STATUS(board); 495 - TTY_LOG("Module '%s' has been sucesfully configured\n", NAME); 544 + show_status(board); 545 + DIA_LOG(0, "attached\n"); 496 546 return 0; 497 547 } 498 548 ··· 503 553 * 504 554 */ 505 555 506 - static void usb_gpib_detach(gpib_board_t *board) 556 + static void usb_gpib_detach(struct gpib_board *board) 507 557 { 508 558 int retval; 509 559 510 - SHOW_STATUS(board); 560 + show_status(board); 511 561 512 - DIA_LOG(0, "detaching %p\n", board); 562 + DIA_LOG(0, "detaching\n"); 513 563 514 564 if (board->private_data) { 515 565 if (GPIB_DEV) { ··· 523 573 board->private_data = NULL; 524 574 } 525 575 526 - DIA_LOG(0, "done %p\n", board); 527 - TTY_LOG("Module '%s' has been detached\n", NAME); 576 + DIA_LOG(0, "detached\n"); 528 577 } 529 578 530 579 /* 531 580 * Other functions follow in alphabetical order 532 581 */ 533 582 /* command */ 534 - static int usb_gpib_command(gpib_board_t *board, 583 + static int usb_gpib_command(struct gpib_board *board, 535 584 u8 *buffer, 536 585 size_t length, 537 586 size_t *bytes_written) ··· 563 614 * Cannot do nothing here, but remember for future use. 564 615 */ 565 616 566 - static void usb_gpib_disable_eos(gpib_board_t *board) 617 + static void usb_gpib_disable_eos(struct gpib_board *board) 567 618 { 568 619 ((struct usb_gpib_priv *)board->private_data)->eos_flags &= ~REOS; 569 620 DIA_LOG(1, "done: %x\n", ··· 579 630 * 580 631 */ 581 632 582 - static int usb_gpib_enable_eos(gpib_board_t *board, 633 + static int usb_gpib_enable_eos(struct gpib_board *board, 583 634 u8 eos_byte, 584 635 int compare_8_bits) 585 636 { ··· 599 650 * @board: the gpib_board data area for this gpib interface 600 651 */ 601 652 602 - static int usb_gpib_go_to_standby(gpib_board_t *board) 653 + static int usb_gpib_go_to_standby(struct gpib_board *board) 603 654 { 604 655 int retval = set_control_line(board, IB_BUS_ATN, 0); 605 656 ··· 614 665 * usb_gpib_interface_clear() - Assert or de-assert IFC 615 666 * 616 667 * @board: the gpib_board data area for this gpib interface 617 - * assert: 1: assert IFC; 0: de-assert IFC 668 + * @assert: 1: assert IFC; 0: de-assert IFC 618 669 * 619 670 * Currently on the assert request we issue the lpvo IBZ 620 671 * command that cycles IFC low for 100 usec, then we ignore 621 672 * the de-assert request. 622 673 */ 623 674 624 - static void usb_gpib_interface_clear(gpib_board_t *board, int assert) 675 + static void usb_gpib_interface_clear(struct gpib_board *board, int assert) 625 676 { 626 677 int retval = 0; 627 678 ··· 637 688 } 638 689 639 690 /** 640 - * line_status() - Read the status of the bus lines. 691 + * usb_gpib_line_status() - Read the status of the bus lines. 641 692 * 642 693 * @board: the gpib_board data area for this gpib interface 643 694 * 644 695 * We can read all lines. 645 696 */ 646 - 647 - #define WQT wait_queue_entry_t 648 - #define WQH head 649 - #define WQE entry 650 - 651 - static int usb_gpib_line_status(const gpib_board_t *board) 697 + static int usb_gpib_line_status(const struct gpib_board *board) 652 698 { 653 699 int buffer; 654 - int line_status = ValidALL; /* all lines will be read */ 700 + int line_status = VALID_ALL; /* all lines will be read */ 655 701 struct list_head *p, *q; 656 702 WQT *item; 657 703 unsigned long flags; ··· 674 730 msleep(sleep); 675 731 } 676 732 677 - buffer = send_command((gpib_board_t *)board, USB_GPIB_STATUS, 0); 733 + buffer = send_command((struct gpib_board *)board, USB_GPIB_STATUS, 0); 678 734 679 735 if (buffer < 0) { 680 - dev_alert(board->gpib_dev, "%s:%s - line status read failed with %d\n", 681 - NAME, __func__, buffer); 736 + dev_err(board->gpib_dev, "line status read failed with %d\n", buffer); 682 737 return -1; 683 738 } 684 739 685 740 if ((buffer & 0x01) == 0) 686 - line_status |= BusREN; 741 + line_status |= BUS_REN; 687 742 if ((buffer & 0x02) == 0) 688 - line_status |= BusIFC; 743 + line_status |= BUS_IFC; 689 744 if ((buffer & 0x04) == 0) 690 - line_status |= BusNDAC; 745 + line_status |= BUS_NDAC; 691 746 if ((buffer & 0x08) == 0) 692 - line_status |= BusNRFD; 747 + line_status |= BUS_NRFD; 693 748 if ((buffer & 0x10) == 0) 694 - line_status |= BusDAV; 749 + line_status |= BUS_DAV; 695 750 if ((buffer & 0x20) == 0) 696 - line_status |= BusEOI; 751 + line_status |= BUS_EOI; 697 752 if ((buffer & 0x40) == 0) 698 - line_status |= BusATN; 753 + line_status |= BUS_ATN; 699 754 if ((buffer & 0x80) == 0) 700 - line_status |= BusSRQ; 755 + line_status |= BUS_SRQ; 701 756 702 757 DIA_LOG(1, "done with %x %x\n", buffer, line_status); 703 758 ··· 705 762 706 763 /* parallel_poll */ 707 764 708 - static int usb_gpib_parallel_poll(gpib_board_t *board, uint8_t *result) 765 + static int usb_gpib_parallel_poll(struct gpib_board *board, uint8_t *result) 709 766 { 710 767 /* request parallel poll asserting ATN | EOI; 711 768 * we suppose ATN already asserted ··· 716 773 DIA_LOG(1, "enter %p\n", board); 717 774 718 775 retval = set_control_line(board, IB_BUS_EOI, 1); 719 - if (retval != ACK) { 720 - dev_alert(board->gpib_dev, "%s:%s - assert EOI failed\n", NAME, __func__); 776 + if (retval != ACK) 721 777 return -EIO; 722 - } 723 778 724 779 *result = send_command(board, USB_GPIB_READ_DATA, 0); 725 780 726 781 DIA_LOG(1, "done with %x\n", *result); 727 782 728 783 retval = set_control_line(board, IB_BUS_EOI, 0); 729 - if (retval != 0x06) { 730 - dev_alert(board->gpib_dev, "%s:%s - unassert EOI failed\n", NAME, __func__); 784 + if (retval != 0x06) 731 785 return -EIO; 732 - } 733 786 734 787 return 0; 735 788 } 736 789 737 790 /* read */ 738 791 739 - static int usb_gpib_read(gpib_board_t *board, 792 + static int usb_gpib_read(struct gpib_board *board, 740 793 u8 *buffer, 741 794 size_t length, 742 795 int *end, ··· 805 866 goto read_return; 806 867 807 868 if (one_char(board, &b) != DLE || one_char(board, &b) != STX) { 808 - dev_alert(board->gpib_dev, "%s:%s - wrong <DLE><STX> sequence\n", 809 - NAME, __func__); 869 + dev_err(board->gpib_dev, "wrong <DLE><STX> sequence\n"); 810 870 retval = -EIO; 811 871 goto read_return; 812 872 } ··· 845 907 retval = 0; 846 908 goto read_return; 847 909 } else { 848 - dev_alert(board->gpib_dev, "%s:%s - %s %x\n", 849 - NAME, __func__, 850 - "Wrong end of message", c); 910 + dev_err(board->gpib_dev, "wrong end of message %x", c); 851 911 retval = -ETIME; 852 912 goto read_return; 853 913 } 854 914 } else { 855 - dev_alert(board->gpib_dev, "%s:%s - %s\n", NAME, __func__, 856 - "lone <DLE> in stream"); 915 + dev_err(board->gpib_dev, "lone <DLE> in stream"); 857 916 retval = -EIO; 858 917 goto read_return; 859 918 } ··· 869 934 c = one_char(board, &b); 870 935 if (c == ACK) { 871 936 if (MAX_READ_EXCESS - read_count > 1) 872 - dev_alert(board->gpib_dev, "%s:%s - %s\n", NAME, __func__, 873 - "small buffer - maybe some data lost"); 937 + dev_dbg(board->gpib_dev, "small buffer - maybe some data lost"); 874 938 retval = 0; 875 939 goto read_return; 876 940 } ··· 877 943 } 878 944 } 879 945 880 - dev_alert(board->gpib_dev, "%s:%s - no input end - GPIB board in odd state\n", 881 - NAME, __func__); 946 + dev_err(board->gpib_dev, "no input end - board in odd state\n"); 882 947 retval = -EIO; 883 948 884 949 read_return: 885 950 kfree(b.inbuf); 886 951 887 - DIA_LOG(1, "done with byte/status: %d %x %d\n", 888 - (int)*bytes_read, retval, *end); 952 + DIA_LOG(1, "done with byte/status: %d %x %d\n", (int)*bytes_read, retval, *end); 889 953 890 954 if (retval == 0 || retval == -ETIME) { 891 955 if (send_command(board, USB_GPIB_UNTALK, sizeof(USB_GPIB_UNTALK)) == 0x06) ··· 896 964 897 965 /* remote_enable */ 898 966 899 - static void usb_gpib_remote_enable(gpib_board_t *board, int enable) 967 + static void usb_gpib_remote_enable(struct gpib_board *board, int enable) 900 968 { 901 969 int retval; 902 970 903 971 retval = set_control_line(board, IB_BUS_REN, enable ? 1 : 0); 904 972 if (retval != ACK) 905 - dev_alert(board->gpib_dev, "%s:%s - could not set REN line: %x\n", 906 - NAME, __func__, retval); 973 + dev_err(board->gpib_dev, "could not set REN line: %x\n", retval); 907 974 908 975 DIA_LOG(1, "done with %x\n", retval); 909 976 } 910 977 911 978 /* request_system_control */ 912 979 913 - static void usb_gpib_request_system_control(gpib_board_t *board, 980 + static void usb_gpib_request_system_control(struct gpib_board *board, 914 981 int request_control) 915 982 { 916 983 if (request_control) ··· 923 992 /* take_control */ 924 993 /* beware: the sync flag is ignored; what is its real meaning? */ 925 994 926 - static int usb_gpib_take_control(gpib_board_t *board, int sync) 995 + static int usb_gpib_take_control(struct gpib_board *board, int sync) 927 996 { 928 997 int retval; 929 998 ··· 938 1007 939 1008 /* update_status */ 940 1009 941 - static unsigned int usb_gpib_update_status(gpib_board_t *board, 1010 + static unsigned int usb_gpib_update_status(struct gpib_board *board, 942 1011 unsigned int clear_mask) 943 1012 { 944 1013 /* There is nothing we can do here, I guess */ ··· 953 1022 /* write */ 954 1023 /* beware: DLE characters are not escaped - can only send ASCII data */ 955 1024 956 - static int usb_gpib_write(gpib_board_t *board, 1025 + static int usb_gpib_write(struct gpib_board *board, 957 1026 u8 *buffer, 958 1027 size_t length, 959 1028 int send_eoi, ··· 984 1053 985 1054 *bytes_written = length; 986 1055 987 - if (send_command(board, USB_GPIB_UNLISTEN, sizeof(USB_GPIB_UNLISTEN)) 988 - != 0x06) 989 - return -EPIPE; 1056 + if (send_command(board, USB_GPIB_UNLISTEN, sizeof(USB_GPIB_UNLISTEN)) != 0x06) 1057 + return -EPIPE; 990 1058 991 1059 return length; 992 1060 } ··· 996 1066 997 1067 /* parallel_poll configure */ 998 1068 999 - static void usb_gpib_parallel_poll_configure(gpib_board_t *board, 1069 + static void usb_gpib_parallel_poll_configure(struct gpib_board *board, 1000 1070 uint8_t configuration) 1001 1071 { 1002 - dev_alert(board->gpib_dev, "%s:%s - currently a NOP\n", NAME, __func__); 1003 1072 } 1004 1073 1005 1074 /* parallel_poll_response */ 1006 1075 1007 - static void usb_gpib_parallel_poll_response(gpib_board_t *board, int ist) 1076 + static void usb_gpib_parallel_poll_response(struct gpib_board *board, int ist) 1008 1077 { 1009 - dev_alert(board->gpib_dev, "%s:%s - currently a NOP\n", NAME, __func__); 1010 1078 } 1011 1079 1012 1080 /* primary_address */ 1013 1081 1014 - static int usb_gpib_primary_address(gpib_board_t *board, unsigned int address) 1082 + static int usb_gpib_primary_address(struct gpib_board *board, unsigned int address) 1015 1083 { 1016 - dev_alert(board->gpib_dev, "%s:%s - currently a NOP\n", NAME, __func__); 1017 1084 return 0; 1018 1085 } 1019 1086 1020 1087 /* return_to_local */ 1021 1088 1022 - static void usb_gpib_return_to_local(gpib_board_t *board) 1089 + static void usb_gpib_return_to_local(struct gpib_board *board) 1023 1090 { 1024 - dev_alert(board->gpib_dev, "%s:%s - currently a NOP\n", NAME, __func__); 1025 1091 } 1026 1092 1027 1093 /* secondary_address */ 1028 1094 1029 - static int usb_gpib_secondary_address(gpib_board_t *board, 1095 + static int usb_gpib_secondary_address(struct gpib_board *board, 1030 1096 unsigned int address, 1031 1097 int enable) 1032 1098 { 1033 - dev_alert(board->gpib_dev, "%s:%s - currently a NOP\n", NAME, __func__); 1034 1099 return 0; 1035 1100 } 1036 1101 1037 1102 /* serial_poll_response */ 1038 1103 1039 - static void usb_gpib_serial_poll_response(gpib_board_t *board, uint8_t status) 1104 + static void usb_gpib_serial_poll_response(struct gpib_board *board, uint8_t status) 1040 1105 { 1041 - dev_alert(board->gpib_dev, "%s:%s - currently a NOP\n", NAME, __func__); 1042 1106 } 1043 1107 1044 1108 /* serial_poll_status */ 1045 1109 1046 - static uint8_t usb_gpib_serial_poll_status(gpib_board_t *board) 1110 + static uint8_t usb_gpib_serial_poll_status(struct gpib_board *board) 1047 1111 { 1048 - dev_alert(board->gpib_dev, "%s:%s - currently a NOP\n", NAME, __func__); 1049 1112 return 0; 1050 1113 } 1051 1114 1052 1115 /* t1_delay */ 1053 1116 1054 - static unsigned int usb_gpib_t1_delay(gpib_board_t *board, unsigned int nano_sec) 1117 + static int usb_gpib_t1_delay(struct gpib_board *board, unsigned int nano_sec) 1055 1118 { 1056 - dev_alert(board->gpib_dev, "%s:%s - currently a NOP\n", NAME, __func__); 1057 1119 return 0; 1058 1120 } 1059 1121 ··· 1103 1181 if (!assigned_usb_minors) { 1104 1182 rv = gpib_register_driver(&usb_gpib_interface, THIS_MODULE); 1105 1183 if (rv) { 1106 - pr_err("lpvo_usb_gpib: gpib_register_driver failed: error = %d\n", rv); 1184 + pr_err("gpib_register_driver failed: error = %d\n", rv); 1107 1185 goto exit; 1108 1186 } 1109 1187 } else { ··· 1113 1191 1114 1192 for (j = 0 ; j < MAX_DEV ; j++) { 1115 1193 if (usb_minors[j] == interface->minor && assigned_usb_minors & 1 << j) { 1116 - pr_alert("%s:%s - CODE BUG: USB minor %d registered at %d.\n", 1117 - NAME, __func__, interface->minor, j); 1194 + pr_err("CODE BUG: USB minor %d registered at %d.\n", 1195 + interface->minor, j); 1118 1196 rv = -1; 1119 1197 goto exit; 1120 1198 } ··· 1129 1207 usb_minors[j] = interface->minor; 1130 1208 lpvo_usb_interfaces[j] = interface; 1131 1209 assigned_usb_minors |= mask; 1132 - DIA_LOG(0, "usb minor %d registered at %d\n", interface->minor, j); 1133 1210 rv = 0; 1134 1211 goto exit; 1135 1212 } 1136 1213 } 1137 - pr_alert("%s:%s - No slot available for interface %p minor %d\n", 1138 - NAME, __func__, interface, interface->minor); 1214 + pr_err("No slot available for interface %p minor %d\n", interface, interface->minor); 1139 1215 rv = -1; 1140 1216 1141 1217 exit: ··· 1155 1235 goto exit; 1156 1236 } 1157 1237 } 1158 - pr_alert("%s:%s - CODE BUG: USB minor %d not found.\n", NAME, __func__, minor); 1238 + pr_err("CODE BUG: USB minor %d not found.\n", minor); 1159 1239 1160 1240 exit: 1161 1241 mutex_unlock(&minors_lock); ··· 1187 1267 LATENCY_TIMER, LATENCY_CHANNEL, 1188 1268 NULL, 0, WDR_TIMEOUT); 1189 1269 if (rv < 0) 1190 - pr_alert("Unable to write latency timer: %i\n", rv); 1270 + dev_err(&udev->dev, "Unable to write latency timer: %i\n", rv); 1191 1271 return rv; 1192 1272 } 1193 1273 ··· 1283 1363 * skel_do_open() - to be called by usb_gpib_attach 1284 1364 */ 1285 1365 1286 - static int skel_do_open(gpib_board_t *board, int subminor) 1366 + static int skel_do_open(struct gpib_board *board, int subminor) 1287 1367 { 1288 1368 struct usb_skel *dev; 1289 1369 struct usb_interface *interface; 1290 1370 int retval = 0; 1291 1371 1292 - DIA_LOG(0, "Required minor: %d\n", subminor); 1293 - 1294 1372 interface = usb_find_interface(&skel_driver, subminor); 1295 1373 if (!interface) { 1296 - pr_err("%s - error, can't find device for minor %d\n", 1297 - __func__, subminor); 1374 + dev_err(board->gpib_dev, "can't find device for minor %d\n", subminor); 1298 1375 retval = -ENODEV; 1299 1376 goto exit; 1300 1377 } ··· 1320 1403 * skel_do_release() - to be called by usb_gpib_detach 1321 1404 */ 1322 1405 1323 - static int skel_do_release(gpib_board_t *board) 1406 + static int skel_do_release(struct gpib_board *board) 1324 1407 { 1325 1408 struct usb_skel *dev; 1326 1409 ··· 1356 1439 if (!(urb->status == -ENOENT || 1357 1440 urb->status == -ECONNRESET || 1358 1441 urb->status == -ESHUTDOWN)) 1359 - dev_err(&dev->interface->dev, 1360 - "%s - nonzero read bulk status received: %d\n", 1361 - __func__, urb->status); 1442 + dev_err(&dev->interface->dev, "nonzero read bulk status received: %d\n", 1443 + urb->status); 1362 1444 1363 1445 dev->errors = urb->status; 1364 1446 } else { ··· 1394 1478 /* do it */ 1395 1479 rv = usb_submit_urb(dev->bulk_in_urb, GFP_KERNEL); 1396 1480 if (rv < 0) { 1397 - dev_err(&dev->interface->dev, 1398 - "%s - failed submitting read urb, error %d\n", 1399 - __func__, rv); 1481 + dev_err(&dev->interface->dev, "failed submitting read urb, error %d\n", rv); 1400 1482 rv = (rv == -ENOMEM) ? rv : -EIO; 1401 1483 spin_lock_irq(&dev->err_lock); 1402 1484 dev->ongoing_read = 0; ··· 1418 1504 if (!dev->bulk_in_urb || !count) 1419 1505 return 0; 1420 1506 1421 - DIA_LOG(1, "enter for %zu.\n", count); 1422 - 1423 1507 restart: /* added to comply with ftdi timeout technique */ 1424 1508 1425 1509 /* no concurrent readers */ 1426 - 1427 - DIA_LOG(2, "restart with %zd %zd.\n", dev->bulk_in_filled, dev->bulk_in_copied); 1428 1510 1429 1511 rv = mutex_lock_interruptible(&dev->io_mutex); 1430 1512 if (rv < 0) ··· 1436 1526 spin_lock_irq(&dev->err_lock); 1437 1527 ongoing_io = dev->ongoing_read; 1438 1528 spin_unlock_irq(&dev->err_lock); 1439 - 1440 - DIA_LOG(2, "retry with %d.\n", ongoing_io); 1441 1529 1442 1530 if (ongoing_io) { 1443 1531 // /* nonblocking IO shall not wait */ ··· 1477 1569 // size_t chunk = min(available, count); /* compute chunk later */ 1478 1570 size_t chunk; 1479 1571 1480 - DIA_LOG(2, "we have data: %zu %zu.\n", dev->bulk_in_filled, dev->bulk_in_copied); 1481 - 1482 1572 if (!available) { 1483 1573 /* 1484 1574 * all data has been used ··· 1502 1596 */ 1503 1597 1504 1598 if (dev->bulk_in_copied) { 1505 - int j; 1506 - 1507 - for (j = 0 ; j < dev->bulk_in_filled ; j++) { 1508 - pr_alert("copy -> %x %zu %x\n", 1509 - j, dev->bulk_in_copied, dev->bulk_in_buffer[j]); 1510 - } 1511 1599 chunk = min(available, count); 1512 1600 memcpy(buffer, dev->bulk_in_buffer + dev->bulk_in_copied, chunk); 1513 1601 rv = chunk; ··· 1513 1613 /* account for two bytes to be discarded */ 1514 1614 chunk = min(available, count + 2); 1515 1615 if (chunk < 2) { 1516 - pr_alert("BAD READ - chunk: %zu\n", chunk); 1616 + dev_err(&dev->udev->dev, "BAD READ - chunk: %zu\n", chunk); 1517 1617 rv = -EIO; 1518 1618 goto exit; 1519 1619 } ··· 1533 1633 // if (available < count) 1534 1634 // skel_do_read_io(dev, dev->bulk_in_size); 1535 1635 } else { 1536 - DIA_LOG(1, "no data - start read - copied: %zd.\n", dev->bulk_in_copied); 1537 - 1538 1636 /* no data in the buffer */ 1539 1637 rv = skel_do_read_io(dev, dev->bulk_in_size); 1540 1638 if (rv < 0) ··· 1543 1645 exit: 1544 1646 mutex_unlock(&dev->io_mutex); 1545 1647 if (rv == 2) 1546 - goto restart; /* ftdi chip returns two status bytes after a latency anyhow */ 1547 - DIA_LOG(1, "exit with %d.\n", rv); 1648 + goto restart; /* ftdi chip returns two status bytes after a latency anyhow */ 1649 + 1548 1650 if (rv > 0) 1549 - return rv - 2; /* account for 2 discarded bytes in a valid buffer */ 1651 + return rv - 2; /* account for 2 discarded bytes in a valid buffer */ 1550 1652 return rv; 1551 1653 } 1552 1654 ··· 1567 1669 urb->status == -ECONNRESET || 1568 1670 urb->status == -ESHUTDOWN)) 1569 1671 dev_err(&dev->interface->dev, 1570 - "%s - nonzero write bulk status received: %d\n", 1571 - __func__, urb->status); 1672 + "nonzero write bulk status received: %d\n", urb->status); 1572 1673 1573 1674 spin_lock_irqsave(&dev->err_lock, flags); 1574 1675 dev->errors = urb->status; ··· 1660 1763 retval = usb_submit_urb(urb, GFP_KERNEL); 1661 1764 mutex_unlock(&dev->io_mutex); 1662 1765 if (retval) { 1663 - dev_err(&dev->interface->dev, 1664 - "%s - failed submitting write urb, error %d\n", 1665 - __func__, retval); 1766 + dev_err(&dev->interface->dev, "failed submitting write urb, error %d\n", retval); 1666 1767 goto error_unanchor; 1667 1768 } 1668 1769 ··· 1726 1831 1727 1832 interface = usb_find_interface(&skel_driver, subminor); 1728 1833 if (!interface) { 1729 - pr_err("%s - error, can't find device for minor %d\n", 1730 - __func__, subminor); 1834 + pr_err("can't find device for minor %d\n", subminor); 1731 1835 retval = -ENODEV; 1732 1836 goto exit; 1733 1837 } ··· 1788 1894 return -ENOMEM; 1789 1895 1790 1896 rv = skel_do_read(dev, buf, count); 1791 - 1792 - pr_alert("%s - return with %zu\n", __func__, rv); 1793 1897 1794 1898 if (rv > 0) { 1795 1899 if (copy_to_user(buffer, buf, rv)) { ··· 1907 2015 /* let the world know */ 1908 2016 1909 2017 device_path = kobject_get_path(&dev->udev->dev.kobj, GFP_KERNEL); 1910 - pr_alert("%s:%s - New lpvo_usb_device -> bus: %d dev: %d path: %s\n", NAME, __func__, 1911 - dev->udev->bus->busnum, dev->udev->devnum, device_path); 2018 + dev_dbg(&interface->dev, "New lpvo_usb_device -> bus: %d dev: %d path: %s\n", 2019 + dev->udev->bus->busnum, dev->udev->devnum, device_path); 1912 2020 kfree(device_path); 1913 2021 1914 2022 #if USER_DEVICE ··· 1921 2029 usb_set_intfdata(interface, NULL); 1922 2030 goto error; 1923 2031 } 1924 - 1925 - /* let the user know what node this device is now attached to */ 1926 - dev_info(&interface->dev, 1927 - "lpvo_usb_gpib device now attached to lpvo_raw%d", 1928 - interface->minor); 1929 2032 #endif 1930 2033 1931 - write_latency_timer(dev->udev); /* adjust the latency timer */ 2034 + write_latency_timer(dev->udev); /* adjust the latency timer */ 1932 2035 1933 2036 usb_gpib_init_module(interface); /* last, init the lpvo for this minor */ 1934 2037 ··· 1960 2073 1961 2074 /* decrement our usage count */ 1962 2075 kref_put(&dev->kref, skel_delete); 1963 - 1964 - dev_info(&interface->dev, "USB lpvo_raw #%d now disconnected", minor); 1965 2076 } 1966 2077 1967 2078 static void skel_draw_down(struct usb_skel *dev)
+63 -84
drivers/staging/gpib/nec7210/nec7210.c
··· 4 4 * copyright : (C) 2001, 2002 by Frank Mori Hess 5 5 ***************************************************************************/ 6 6 7 + #define dev_fmt(fmt) KBUILD_MODNAME ": " fmt 8 + 7 9 #include "board.h" 8 10 #include <linux/ioport.h> 9 11 #include <linux/sched.h> ··· 23 21 MODULE_LICENSE("GPL"); 24 22 MODULE_DESCRIPTION("GPIB library code for NEC uPD7210"); 25 23 26 - int nec7210_enable_eos(gpib_board_t *board, struct nec7210_priv *priv, uint8_t eos_byte, 24 + int nec7210_enable_eos(struct gpib_board *board, struct nec7210_priv *priv, uint8_t eos_byte, 27 25 int compare_8_bits) 28 26 { 29 27 write_byte(priv, eos_byte, EOSR); ··· 37 35 } 38 36 EXPORT_SYMBOL(nec7210_enable_eos); 39 37 40 - void nec7210_disable_eos(gpib_board_t *board, struct nec7210_priv *priv) 38 + void nec7210_disable_eos(struct gpib_board *board, struct nec7210_priv *priv) 41 39 { 42 40 priv->auxa_bits &= ~HR_REOS; 43 41 write_byte(priv, priv->auxa_bits, AUXMR); 44 42 } 45 43 EXPORT_SYMBOL(nec7210_disable_eos); 46 44 47 - int nec7210_parallel_poll(gpib_board_t *board, struct nec7210_priv *priv, uint8_t *result) 45 + int nec7210_parallel_poll(struct gpib_board *board, struct nec7210_priv *priv, uint8_t *result) 48 46 { 49 47 int ret; 50 48 ··· 64 62 } 65 63 EXPORT_SYMBOL(nec7210_parallel_poll); 66 64 67 - void nec7210_parallel_poll_configure(gpib_board_t *board, 65 + void nec7210_parallel_poll_configure(struct gpib_board *board, 68 66 struct nec7210_priv *priv, unsigned int configuration) 69 67 { 70 68 write_byte(priv, PPR | configuration, AUXMR); 71 69 } 72 70 EXPORT_SYMBOL(nec7210_parallel_poll_configure); 73 71 74 - void nec7210_parallel_poll_response(gpib_board_t *board, struct nec7210_priv *priv, int ist) 72 + void nec7210_parallel_poll_response(struct gpib_board *board, struct nec7210_priv *priv, int ist) 75 73 { 76 74 if (ist) 77 75 write_byte(priv, AUX_SPPF, AUXMR); ··· 85 83 * the 488.2 capability (for example with NI chips), or we need to implement the 86 84 * 488.2 set srv state machine in the driver (if that is even viable). 87 85 */ 88 - void nec7210_serial_poll_response(gpib_board_t *board, struct nec7210_priv *priv, uint8_t status) 86 + void nec7210_serial_poll_response(struct gpib_board *board, 87 + struct nec7210_priv *priv, uint8_t status) 89 88 { 90 89 unsigned long flags; 91 90 ··· 103 100 } 104 101 EXPORT_SYMBOL(nec7210_serial_poll_response); 105 102 106 - uint8_t nec7210_serial_poll_status(gpib_board_t *board, struct nec7210_priv *priv) 103 + uint8_t nec7210_serial_poll_status(struct gpib_board *board, struct nec7210_priv *priv) 107 104 { 108 105 return read_byte(priv, SPSR); 109 106 } 110 107 EXPORT_SYMBOL(nec7210_serial_poll_status); 111 108 112 - int nec7210_primary_address(const gpib_board_t *board, struct nec7210_priv *priv, 109 + int nec7210_primary_address(const struct gpib_board *board, struct nec7210_priv *priv, 113 110 unsigned int address) 114 111 { 115 112 // put primary address in address0 ··· 118 115 } 119 116 EXPORT_SYMBOL(nec7210_primary_address); 120 117 121 - int nec7210_secondary_address(const gpib_board_t *board, struct nec7210_priv *priv, 118 + int nec7210_secondary_address(const struct gpib_board *board, struct nec7210_priv *priv, 122 119 unsigned int address, int enable) 123 120 { 124 121 if (enable) { ··· 167 164 } 168 165 } 169 166 170 - unsigned int nec7210_update_status_nolock(gpib_board_t *board, struct nec7210_priv *priv) 167 + unsigned int nec7210_update_status_nolock(struct gpib_board *board, struct nec7210_priv *priv) 171 168 { 172 169 int address_status_bits; 173 170 u8 spoll_status; ··· 201 198 priv->srq_pending = 0; 202 199 set_bit(SPOLL_NUM, &board->status); 203 200 } 204 - // dev_dbg(board->gpib_dev, "status 0x%x, state 0x%x\n", board->status, priv->state); 205 201 206 202 /* we rely on the interrupt handler to set the 207 203 * rest of the status bits ··· 210 208 } 211 209 EXPORT_SYMBOL(nec7210_update_status_nolock); 212 210 213 - unsigned int nec7210_update_status(gpib_board_t *board, struct nec7210_priv *priv, 211 + unsigned int nec7210_update_status(struct gpib_board *board, struct nec7210_priv *priv, 214 212 unsigned int clear_mask) 215 213 { 216 214 unsigned long flags; ··· 235 233 } 236 234 EXPORT_SYMBOL(nec7210_set_reg_bits); 237 235 238 - void nec7210_set_handshake_mode(gpib_board_t *board, struct nec7210_priv *priv, int mode) 236 + void nec7210_set_handshake_mode(struct gpib_board *board, struct nec7210_priv *priv, int mode) 239 237 { 240 238 unsigned long flags; 241 239 ··· 251 249 } 252 250 EXPORT_SYMBOL(nec7210_set_handshake_mode); 253 251 254 - uint8_t nec7210_read_data_in(gpib_board_t *board, struct nec7210_priv *priv, int *end) 252 + uint8_t nec7210_read_data_in(struct gpib_board *board, struct nec7210_priv *priv, int *end) 255 253 { 256 254 unsigned long flags; 257 255 u8 data; ··· 269 267 } 270 268 EXPORT_SYMBOL(nec7210_read_data_in); 271 269 272 - int nec7210_take_control(gpib_board_t *board, struct nec7210_priv *priv, int syncronous) 270 + int nec7210_take_control(struct gpib_board *board, struct nec7210_priv *priv, int syncronous) 273 271 { 274 272 int i; 275 273 const int timeout = 100; ··· 296 294 } 297 295 EXPORT_SYMBOL(nec7210_take_control); 298 296 299 - int nec7210_go_to_standby(gpib_board_t *board, struct nec7210_priv *priv) 297 + int nec7210_go_to_standby(struct gpib_board *board, struct nec7210_priv *priv) 300 298 { 301 299 int i; 302 300 const int timeout = 1000; ··· 321 319 if (adsr_bits & HR_NATN) 322 320 break; 323 321 } 324 - if (i == HZ) { 325 - pr_err("nec7210: error waiting for NATN\n"); 322 + if (i == HZ) 326 323 return -ETIMEDOUT; 327 - } 328 324 } 329 325 330 326 clear_bit(COMMAND_READY_BN, &priv->state); ··· 330 330 } 331 331 EXPORT_SYMBOL(nec7210_go_to_standby); 332 332 333 - void nec7210_request_system_control(gpib_board_t *board, struct nec7210_priv *priv, 333 + void nec7210_request_system_control(struct gpib_board *board, struct nec7210_priv *priv, 334 334 int request_control) 335 335 { 336 336 if (request_control == 0) { ··· 341 341 } 342 342 EXPORT_SYMBOL(nec7210_request_system_control); 343 343 344 - void nec7210_interface_clear(gpib_board_t *board, struct nec7210_priv *priv, int assert) 344 + void nec7210_interface_clear(struct gpib_board *board, struct nec7210_priv *priv, int assert) 345 345 { 346 346 if (assert) 347 347 write_byte(priv, AUX_SIFC, AUXMR); ··· 350 350 } 351 351 EXPORT_SYMBOL(nec7210_interface_clear); 352 352 353 - void nec7210_remote_enable(gpib_board_t *board, struct nec7210_priv *priv, int enable) 353 + void nec7210_remote_enable(struct gpib_board *board, struct nec7210_priv *priv, int enable) 354 354 { 355 355 if (enable) 356 356 write_byte(priv, AUX_SREN, AUXMR); ··· 359 359 } 360 360 EXPORT_SYMBOL(nec7210_remote_enable); 361 361 362 - void nec7210_release_rfd_holdoff(gpib_board_t *board, struct nec7210_priv *priv) 362 + void nec7210_release_rfd_holdoff(struct gpib_board *board, struct nec7210_priv *priv) 363 363 { 364 364 unsigned long flags; 365 365 ··· 373 373 } 374 374 EXPORT_SYMBOL(nec7210_release_rfd_holdoff); 375 375 376 - unsigned int nec7210_t1_delay(gpib_board_t *board, struct nec7210_priv *priv, 377 - unsigned int nano_sec) 376 + int nec7210_t1_delay(struct gpib_board *board, struct nec7210_priv *priv, 377 + unsigned int nano_sec) 378 378 { 379 379 unsigned int retval; 380 380 ··· 391 391 } 392 392 EXPORT_SYMBOL(nec7210_t1_delay); 393 393 394 - void nec7210_return_to_local(const gpib_board_t *board, struct nec7210_priv *priv) 394 + void nec7210_return_to_local(const struct gpib_board *board, struct nec7210_priv *priv) 395 395 { 396 396 write_byte(priv, AUX_RTL, AUXMR); 397 397 } 398 398 EXPORT_SYMBOL(nec7210_return_to_local); 399 399 400 - static inline short nec7210_atn_has_changed(gpib_board_t *board, struct nec7210_priv *priv) 400 + static inline short nec7210_atn_has_changed(struct gpib_board *board, struct nec7210_priv *priv) 401 401 { 402 402 short address_status_bits = read_byte(priv, ADSR); 403 403 ··· 415 415 return -1; 416 416 } 417 417 418 - int nec7210_command(gpib_board_t *board, struct nec7210_priv *priv, uint8_t 418 + int nec7210_command(struct gpib_board *board, struct nec7210_priv *priv, uint8_t 419 419 *buffer, size_t length, size_t *bytes_written) 420 420 { 421 421 int retval = 0; ··· 430 430 test_bit(COMMAND_READY_BN, &priv->state) || 431 431 test_bit(BUS_ERROR_BN, &priv->state) || 432 432 test_bit(TIMO_NUM, &board->status))) { 433 - dev_dbg(board->gpib_dev, "gpib command wait interrupted\n"); 433 + dev_dbg(board->gpib_dev, "command wait interrupted\n"); 434 434 retval = -ERESTARTSYS; 435 435 break; 436 436 } 437 437 if (test_bit(TIMO_NUM, &board->status)) 438 438 break; 439 - if (test_and_clear_bit(BUS_ERROR_BN, &priv->state)) { 440 - pr_err("nec7210: bus error on command byte\n"); 439 + if (test_and_clear_bit(BUS_ERROR_BN, &priv->state)) 441 440 break; 442 - } 443 - 444 441 spin_lock_irqsave(&board->spinlock, flags); 445 442 clear_bit(COMMAND_READY_BN, &priv->state); 446 443 write_byte(priv, buffer[*bytes_written], CDOR); ··· 451 454 // wait for last byte to get sent 452 455 if (wait_event_interruptible(board->wait, test_bit(COMMAND_READY_BN, &priv->state) || 453 456 test_bit(BUS_ERROR_BN, &priv->state) || 454 - test_bit(TIMO_NUM, &board->status))) { 455 - dev_dbg(board->gpib_dev, "gpib command wait interrupted\n"); 457 + test_bit(TIMO_NUM, &board->status))) 456 458 retval = -ERESTARTSYS; 457 - } 458 - if (test_bit(TIMO_NUM, &board->status)) { 459 - dev_dbg(board->gpib_dev, "gpib command timed out\n"); 459 + 460 + if (test_bit(TIMO_NUM, &board->status)) 460 461 retval = -ETIMEDOUT; 461 - } 462 - if (test_and_clear_bit(BUS_ERROR_BN, &priv->state)) { 463 - pr_err("nec7210: bus error on command byte\n"); 462 + 463 + if (test_and_clear_bit(BUS_ERROR_BN, &priv->state)) 464 464 retval = -EIO; 465 - } 466 465 467 466 return retval; 468 467 } 469 468 EXPORT_SYMBOL(nec7210_command); 470 469 471 - static int pio_read(gpib_board_t *board, struct nec7210_priv *priv, uint8_t *buffer, 470 + static int pio_read(struct gpib_board *board, struct nec7210_priv *priv, uint8_t *buffer, 472 471 size_t length, int *end, size_t *bytes_read) 473 472 { 474 473 ssize_t retval = 0; ··· 477 484 test_bit(READ_READY_BN, &priv->state) || 478 485 test_bit(DEV_CLEAR_BN, &priv->state) || 479 486 test_bit(TIMO_NUM, &board->status))) { 480 - dev_dbg(board->gpib_dev, "nec7210: pio read wait interrupted\n"); 481 487 retval = -ERESTARTSYS; 482 488 break; 483 489 } ··· 495 503 break; 496 504 } 497 505 if (test_bit(TIMO_NUM, &board->status)) { 498 - dev_dbg(board->gpib_dev, "interrupted by timeout\n"); 499 506 retval = -ETIMEDOUT; 500 507 break; 501 508 } 502 509 if (test_bit(DEV_CLEAR_BN, &priv->state)) { 503 - dev_dbg(board->gpib_dev, "interrupted by device clear\n"); 504 510 retval = -EINTR; 505 511 break; 506 512 } ··· 513 523 } 514 524 515 525 #ifdef NEC_DMA 516 - static ssize_t __dma_read(gpib_board_t *board, struct nec7210_priv *priv, size_t length) 526 + static ssize_t __dma_read(struct gpib_board *board, struct nec7210_priv *priv, size_t length) 517 527 { 518 528 ssize_t retval = 0; 519 529 size_t count = 0; ··· 547 557 if (wait_event_interruptible(board->wait, 548 558 test_bit(DMA_READ_IN_PROGRESS_BN, &priv->state) == 0 || 549 559 test_bit(DEV_CLEAR_BN, &priv->state) || 550 - test_bit(TIMO_NUM, &board->status))) { 551 - dev_dbg(board->gpib_dev, "nec7210: dma read wait interrupted\n"); 560 + test_bit(TIMO_NUM, &board->status))) 552 561 retval = -ERESTARTSYS; 553 - } 562 + 554 563 if (test_bit(TIMO_NUM, &board->status)) 555 564 retval = -ETIMEDOUT; 556 565 if (test_bit(DEV_CLEAR_BN, &priv->state)) ··· 568 579 return retval ? retval : count; 569 580 } 570 581 571 - static ssize_t dma_read(gpib_board_t *board, struct nec7210_priv *priv, uint8_t *buffer, 582 + static ssize_t dma_read(struct gpib_board *board, struct nec7210_priv *priv, uint8_t *buffer, 572 583 size_t length) 573 584 { 574 585 size_t remain = length; ··· 595 606 } 596 607 #endif 597 608 598 - int nec7210_read(gpib_board_t *board, struct nec7210_priv *priv, uint8_t *buffer, 609 + int nec7210_read(struct gpib_board *board, struct nec7210_priv *priv, uint8_t *buffer, 599 610 size_t length, int *end, size_t *bytes_read) 600 611 { 601 612 ssize_t retval = 0; ··· 616 627 } 617 628 EXPORT_SYMBOL(nec7210_read); 618 629 619 - static int pio_write_wait(gpib_board_t *board, struct nec7210_priv *priv, 630 + static int pio_write_wait(struct gpib_board *board, struct nec7210_priv *priv, 620 631 short wake_on_lacs, short wake_on_atn, short wake_on_bus_error) 621 632 { 622 633 // wait until byte is ready to be sent ··· 627 638 (wake_on_bus_error && test_bit(BUS_ERROR_BN, &priv->state)) || 628 639 (wake_on_lacs && test_bit(LACS_NUM, &board->status)) || 629 640 (wake_on_atn && test_bit(ATN_NUM, &board->status)) || 630 - test_bit(TIMO_NUM, &board->status))) { 631 - dev_dbg(board->gpib_dev, "gpib write interrupted\n"); 641 + test_bit(TIMO_NUM, &board->status))) 632 642 return -ERESTARTSYS; 633 - } 634 - if (test_bit(TIMO_NUM, &board->status)) { 635 - dev_dbg(board->gpib_dev, "nec7210: write timed out\n"); 643 + 644 + if (test_bit(TIMO_NUM, &board->status)) 636 645 return -ETIMEDOUT; 637 - } 638 - if (test_bit(DEV_CLEAR_BN, &priv->state)) { 639 - dev_dbg(board->gpib_dev, "nec7210: write interrupted by clear\n"); 646 + 647 + if (test_bit(DEV_CLEAR_BN, &priv->state)) 640 648 return -EINTR; 641 - } 642 - if (wake_on_bus_error && test_and_clear_bit(BUS_ERROR_BN, &priv->state)) { 643 - dev_dbg(board->gpib_dev, "nec7210: bus error on write\n"); 649 + 650 + if (wake_on_bus_error && test_and_clear_bit(BUS_ERROR_BN, &priv->state)) 644 651 return -EIO; 645 - } 652 + 646 653 return 0; 647 654 } 648 655 649 - static int pio_write(gpib_board_t *board, struct nec7210_priv *priv, uint8_t *buffer, 656 + static int pio_write(struct gpib_board *board, struct nec7210_priv *priv, uint8_t *buffer, 650 657 size_t length, size_t *bytes_written) 651 658 { 652 659 size_t last_count = 0; ··· 662 677 if (retval == -EIO) { 663 678 /* resend last byte on bus error */ 664 679 *bytes_written = last_count; 665 - dev_dbg(board->gpib_dev, "resending %c\n", buffer[*bytes_written]); 666 680 /* we can get unrecoverable bus errors, 667 681 * so give up after a while 668 682 */ ··· 685 701 } 686 702 687 703 #ifdef NEC_DMA 688 - static ssize_t __dma_write(gpib_board_t *board, struct nec7210_priv *priv, dma_addr_t address, 704 + static ssize_t __dma_write(struct gpib_board *board, struct nec7210_priv *priv, dma_addr_t address, 689 705 size_t length) 690 706 { 691 707 unsigned long flags, dma_irq_flags; ··· 717 733 test_bit(DMA_WRITE_IN_PROGRESS_BN, &priv->state) == 0 || 718 734 test_bit(BUS_ERROR_BN, &priv->state) || 719 735 test_bit(DEV_CLEAR_BN, &priv->state) || 720 - test_bit(TIMO_NUM, &board->status))) { 721 - dev_dbg(board->gpib_dev, "gpib write interrupted!\n"); 736 + test_bit(TIMO_NUM, &board->status))) 722 737 retval = -ERESTARTSYS; 723 - } 738 + 724 739 if (test_bit(TIMO_NUM, &board->status)) 725 740 retval = -ETIMEDOUT; 726 741 if (test_and_clear_bit(DEV_CLEAR_BN, &priv->state)) ··· 742 759 return retval ? retval : length; 743 760 } 744 761 745 - static ssize_t dma_write(gpib_board_t *board, struct nec7210_priv *priv, uint8_t *buffer, 762 + static ssize_t dma_write(struct gpib_board *board, struct nec7210_priv *priv, uint8_t *buffer, 746 763 size_t length) 747 764 { 748 765 size_t remain = length; ··· 766 783 return length - remain; 767 784 } 768 785 #endif 769 - int nec7210_write(gpib_board_t *board, struct nec7210_priv *priv, uint8_t *buffer, size_t length, 770 - int send_eoi, size_t *bytes_written) 786 + int nec7210_write(struct gpib_board *board, struct nec7210_priv *priv, 787 + uint8_t *buffer, size_t length, int send_eoi, 788 + size_t *bytes_written) 771 789 { 772 790 int retval = 0; 773 791 ··· 829 845 /* 830 846 * interrupt service routine 831 847 */ 832 - irqreturn_t nec7210_interrupt(gpib_board_t *board, struct nec7210_priv *priv) 848 + irqreturn_t nec7210_interrupt(struct gpib_board *board, struct nec7210_priv *priv) 833 849 { 834 850 int status1, status2; 835 851 ··· 841 857 } 842 858 EXPORT_SYMBOL(nec7210_interrupt); 843 859 844 - irqreturn_t nec7210_interrupt_have_status(gpib_board_t *board, 860 + irqreturn_t nec7210_interrupt_have_status(struct gpib_board *board, 845 861 struct nec7210_priv *priv, int status1, int status2) 846 862 { 847 863 #ifdef NEC_DMA ··· 921 937 set_bit(COMMAND_READY_BN, &priv->state); 922 938 923 939 // command pass through received 924 - if (status1 & HR_CPT) { 925 - unsigned int command; 926 - 927 - command = read_byte(priv, CPTR) & gpib_command_mask; 940 + if (status1 & HR_CPT) 928 941 write_byte(priv, AUX_NVAL, AUXMR); 929 - // printk("gpib: command pass through 0x%x\n", command); 930 - } 931 942 932 943 if (status1 & HR_ERR) 933 944 set_bit(BUS_ERROR_BN, &priv->state); ··· 959 980 } 960 981 EXPORT_SYMBOL(nec7210_interrupt_have_status); 961 982 962 - void nec7210_board_reset(struct nec7210_priv *priv, const gpib_board_t *board) 983 + void nec7210_board_reset(struct nec7210_priv *priv, const struct gpib_board *board) 963 984 { 964 985 /* 7210 chip reset */ 965 986 write_byte(priv, AUX_CR, AUXMR); ··· 993 1014 } 994 1015 EXPORT_SYMBOL(nec7210_board_reset); 995 1016 996 - void nec7210_board_online(struct nec7210_priv *priv, const gpib_board_t *board) 1017 + void nec7210_board_online(struct nec7210_priv *priv, const struct gpib_board *board) 997 1018 { 998 1019 /* set GPIB address */ 999 1020 nec7210_primary_address(board, priv, board->pad);
+308 -303
drivers/staging/gpib/ni_usb/ni_usb_gpib.c
··· 5 5 * copyright : (C) 2004 by Frank Mori Hess 6 6 ***************************************************************************/ 7 7 8 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 9 + #define dev_fmt pr_fmt 10 + #define DRV_NAME KBUILD_MODNAME 11 + 8 12 #include <linux/kernel.h> 9 13 #include <linux/module.h> 10 14 #include <linux/slab.h> ··· 24 20 static struct usb_interface *ni_usb_driver_interfaces[MAX_NUM_NI_USB_INTERFACES]; 25 21 26 22 static int ni_usb_parse_status_block(const u8 *buffer, struct ni_usb_status_block *status); 27 - static int ni_usb_set_interrupt_monitor(gpib_board_t *board, unsigned int monitored_bits); 23 + static int ni_usb_set_interrupt_monitor(struct gpib_board *board, unsigned int monitored_bits); 28 24 static void ni_usb_stop(struct ni_usb_priv *ni_priv); 29 25 30 26 static DEFINE_MUTEX(ni_usb_hotplug_lock); ··· 79 75 */ 80 76 else if (usec <= 1000000000) 81 77 return 0x02; 82 - pr_err("%s: bug? usec is greater than 1e9\n", __func__); 78 + pr_err("bug? usec is greater than 1e9\n"); 83 79 return 0xf0; 84 80 } 85 81 ··· 87 83 { 88 84 struct ni_usb_urb_ctx *context = urb->context; 89 85 90 - // printk("debug: %s: status=0x%x, error_count=%i, actual_length=%i\n", __func__, 91 - // urb->status, urb->error_count, urb->actual_length); 92 86 complete(&context->complete); 93 87 } 94 88 ··· 139 137 del_timer_sync(&ni_priv->bulk_timer); 140 138 usb_free_urb(ni_priv->bulk_urb); 141 139 ni_priv->bulk_urb = NULL; 142 - dev_err(&usb_dev->dev, "%s: failed to submit bulk out urb, retval=%i\n", 143 - __func__, retval); 140 + dev_err(&usb_dev->dev, "failed to submit bulk out urb, retval=%i\n", 141 + retval); 144 142 mutex_unlock(&ni_priv->bulk_transfer_lock); 145 143 return retval; 146 144 } ··· 148 146 wait_for_completion(&context->complete); // wait for ni_usb_bulk_complete 149 147 if (context->timed_out) { 150 148 usb_kill_urb(ni_priv->bulk_urb); 151 - dev_err(&usb_dev->dev, "%s: killed urb due to timeout\n", __func__); 149 + dev_err(&usb_dev->dev, "killed urb due to timeout\n"); 152 150 retval = -ETIMEDOUT; 153 151 } else { 154 152 retval = ni_priv->bulk_urb->status; ··· 220 218 if (timeout_msecs) 221 219 mod_timer(&ni_priv->bulk_timer, jiffies + msecs_to_jiffies(timeout_msecs)); 222 220 223 - //printk("%s: submitting urb\n", __func__); 224 221 retval = usb_submit_urb(ni_priv->bulk_urb, GFP_KERNEL); 225 222 if (retval) { 226 223 del_timer_sync(&ni_priv->bulk_timer); 227 224 usb_free_urb(ni_priv->bulk_urb); 228 225 ni_priv->bulk_urb = NULL; 229 - dev_err(&usb_dev->dev, "%s: failed to submit bulk out urb, retval=%i\n", 230 - __func__, retval); 226 + dev_err(&usb_dev->dev, "failed to submit bulk in urb, retval=%i\n", retval); 231 227 mutex_unlock(&ni_priv->bulk_transfer_lock); 232 228 return retval; 233 229 } ··· 250 250 } 251 251 if (context->timed_out) { 252 252 usb_kill_urb(ni_priv->bulk_urb); 253 - dev_err(&usb_dev->dev, "%s: killed urb due to timeout\n", __func__); 253 + dev_err(&usb_dev->dev, "killed urb due to timeout\n"); 254 254 retval = -ETIMEDOUT; 255 255 } else { 256 256 if (ni_priv->bulk_urb->status) ··· 310 310 return retval; 311 311 } 312 312 313 - static void ni_usb_soft_update_status(gpib_board_t *board, unsigned int ni_usb_ibsta, 313 + static void ni_usb_soft_update_status(struct gpib_board *board, unsigned int ni_usb_ibsta, 314 314 unsigned int clear_mask) 315 315 { 316 316 static const unsigned int ni_usb_ibsta_mask = SRQI | ATN | CIC | REM | LACS | TACS | LOK; ··· 330 330 ni_priv->monitored_ibsta_bits &= ~ni_usb_ibsta; 331 331 need_monitoring_bits &= ~ni_priv->monitored_ibsta_bits; /* mm - monitored set */ 332 332 spin_unlock_irqrestore(&board->spinlock, flags); 333 - dev_dbg(&usb_dev->dev, "%s: need_monitoring_bits=0x%x\n", __func__, need_monitoring_bits); 333 + dev_dbg(&usb_dev->dev, "need_monitoring_bits=0x%x\n", need_monitoring_bits); 334 334 335 335 if (need_monitoring_bits & ~ni_usb_ibsta) 336 336 ni_usb_set_interrupt_monitor(board, ni_usb_ibsta_monitor_mask); 337 337 else if (need_monitoring_bits & ni_usb_ibsta) 338 338 wake_up_interruptible(&board->wait); 339 339 340 - dev_dbg(&usb_dev->dev, "%s: ni_usb_ibsta=0x%x\n", __func__, ni_usb_ibsta); 340 + dev_dbg(&usb_dev->dev, "ibsta=0x%x\n", ni_usb_ibsta); 341 341 } 342 342 343 343 static int ni_usb_parse_status_block(const u8 *buffer, struct ni_usb_status_block *status) ··· 371 371 int k; 372 372 373 373 if (raw_data[i++] != NIUSB_REGISTER_READ_DATA_START_ID) { 374 - pr_err("%s: parse error: wrong start id\n", __func__); 374 + pr_err("parse error: wrong start id\n"); 375 375 unexpected = 1; 376 376 } 377 377 for (k = 0; k < results_per_chunk && j < num_results; ++k) ··· 380 380 while (i % 4) 381 381 i++; 382 382 if (raw_data[i++] != NIUSB_REGISTER_READ_DATA_END_ID) { 383 - pr_err("%s: parse error: wrong end id\n", __func__); 383 + pr_err("parse error: wrong end id\n"); 384 384 unexpected = 1; 385 385 } 386 386 if (raw_data[i++] % results_per_chunk != num_results % results_per_chunk) { 387 - pr_err("%s: parse error: wrong count=%i for NIUSB_REGISTER_READ_DATA_END\n", 388 - __func__, (int)raw_data[i - 1]); 387 + pr_err("parse error: wrong count=%i for NIUSB_REGISTER_READ_DATA_END\n", 388 + (int)raw_data[i - 1]); 389 389 unexpected = 1; 390 390 } 391 391 while (i % 4) { 392 392 if (raw_data[i++] != 0) { 393 - pr_err("%s: unexpected data: raw_data[%i]=0x%x, expected 0\n", 394 - __func__, i - 1, (int)raw_data[i - 1]); 393 + pr_err("unexpected data: raw_data[%i]=0x%x, expected 0\n", 394 + i - 1, (int)raw_data[i - 1]); 395 395 unexpected = 1; 396 396 } 397 397 } ··· 408 408 buffer[i++] != 0x0 || 409 409 buffer[i++] != 0x0 || 410 410 buffer[i++] != 0x0) { 411 - pr_err("%s: received unexpected termination block\n", __func__); 412 - pr_err(" expected: 0x%x 0x%x 0x%x 0x%x\n", 413 - NIUSB_TERM_ID, 0x0, 0x0, 0x0); 411 + pr_err("received unexpected termination block\n"); 412 + pr_err(" expected: 0x%x 0x%x 0x%x 0x%x\n", NIUSB_TERM_ID, 0x0, 0x0, 0x0); 414 413 pr_err(" received: 0x%x 0x%x 0x%x 0x%x\n", 415 414 buffer[i - 4], buffer[i - 3], buffer[i - 2], buffer[i - 1]); 416 415 } ··· 426 427 int i = 0; 427 428 int j = 0; 428 429 int k; 429 - unsigned int adr1_bits; 430 430 int num_data_blocks = 0; 431 431 struct ni_usb_status_block register_write_status; 432 432 int unexpected = 0; ··· 436 438 } else if (raw_data[i] == NIUSB_IBRD_EXTENDED_DATA_ID) { 437 439 data_block_length = ibrd_extended_data_block_length; 438 440 if (raw_data[++i] != 0) { 439 - pr_err("%s: unexpected data: raw_data[%i]=0x%x, expected 0\n", 440 - __func__, i, (int)raw_data[i]); 441 + pr_err("unexpected data: raw_data[%i]=0x%x, expected 0\n", 442 + i, (int)raw_data[i]); 441 443 unexpected = 1; 442 444 } 443 445 } else { 444 - pr_err("%s: logic bug!\n", __func__); 446 + pr_err("Unexpected NIUSB_IBRD ID\n"); 445 447 return -EINVAL; 446 448 } 447 449 ++i; ··· 455 457 } 456 458 i += ni_usb_parse_status_block(&raw_data[i], status); 457 459 if (status->id != NIUSB_IBRD_STATUS_ID) { 458 - pr_err("%s: bug: status->id=%i, != ibrd_status_id\n", __func__, status->id); 460 + pr_err("bug: status->id=%i, != ibrd_status_id\n", status->id); 459 461 return -EIO; 460 462 } 461 - adr1_bits = raw_data[i++]; 463 + i++; 462 464 if (num_data_blocks) { 463 465 *actual_bytes_read = (num_data_blocks - 1) * data_block_length + raw_data[i++]; 464 466 } else { ··· 466 468 *actual_bytes_read = 0; 467 469 } 468 470 if (*actual_bytes_read > j) 469 - pr_err("%s: bug: discarded data. actual_bytes_read=%i, j=%i\n", 470 - __func__, *actual_bytes_read, j); 471 + pr_err("bug: discarded data. actual_bytes_read=%i, j=%i\n", *actual_bytes_read, j); 471 472 for (k = 0; k < 2; k++) 472 473 if (raw_data[i++] != 0) { 473 - pr_err("%s: unexpected data: raw_data[%i]=0x%x, expected 0\n", 474 - __func__, i - 1, (int)raw_data[i - 1]); 474 + pr_err("unexpected data: raw_data[%i]=0x%x, expected 0\n", 475 + i - 1, (int)raw_data[i - 1]); 475 476 unexpected = 1; 476 477 } 477 478 i += ni_usb_parse_status_block(&raw_data[i], &register_write_status); 478 479 if (register_write_status.id != NIUSB_REG_WRITE_ID) { 479 - pr_err("%s: unexpected data: register write status id=0x%x, expected 0x%x\n", 480 - __func__, register_write_status.id, NIUSB_REG_WRITE_ID); 480 + pr_err("unexpected data: register write status id=0x%x, expected 0x%x\n", 481 + register_write_status.id, NIUSB_REG_WRITE_ID); 481 482 unexpected = 1; 482 483 } 483 484 if (raw_data[i++] != 2) { 484 - pr_err("%s: unexpected data: register write count=%i, expected 2\n", 485 - __func__, (int)raw_data[i - 1]); 485 + pr_err("unexpected data: register write count=%i, expected 2\n", 486 + (int)raw_data[i - 1]); 486 487 unexpected = 1; 487 488 } 488 489 for (k = 0; k < 3; k++) 489 490 if (raw_data[i++] != 0) { 490 - pr_err("%s: unexpected data: raw_data[%i]=0x%x, expected 0\n", 491 - __func__, i - 1, (int)raw_data[i - 1]); 491 + pr_err("unexpected data: raw_data[%i]=0x%x, expected 0\n", 492 + i - 1, (int)raw_data[i - 1]); 492 493 unexpected = 1; 493 494 } 494 495 i += ni_usb_parse_termination_block(&raw_data[i]); ··· 527 530 528 531 out_data_length = num_writes * bytes_per_write + 0x10; 529 532 out_data = kmalloc(out_data_length, GFP_KERNEL); 530 - if (!out_data) { 531 - dev_err(&usb_dev->dev, "%s: kmalloc failed\n", __func__); 533 + if (!out_data) 532 534 return -ENOMEM; 533 - } 534 535 i += ni_usb_bulk_register_write_header(&out_data[i], num_writes); 535 536 for (j = 0; j < num_writes; j++) 536 537 i += ni_usb_bulk_register_write(&out_data[i], writes[j]); 537 538 while (i % 4) 538 539 out_data[i++] = 0x00; 539 540 i += ni_usb_bulk_termination(&out_data[i]); 540 - if (i > out_data_length) 541 - dev_err(&usb_dev->dev, "%s: bug! buffer overrun\n", __func__); 542 541 543 542 mutex_lock(&ni_priv->addressed_transfer_lock); 544 543 ··· 542 549 kfree(out_data); 543 550 if (retval) { 544 551 mutex_unlock(&ni_priv->addressed_transfer_lock); 545 - dev_err(&usb_dev->dev, "%s: ni_usb_send_bulk_msg returned %i, bytes_written=%i, i=%i\n", 546 - __func__, retval, bytes_written, i); 552 + dev_err(&usb_dev->dev, "send_bulk_msg returned %i, bytes_written=%i, i=%i\n", 553 + retval, bytes_written, i); 547 554 return retval; 548 555 } 549 556 550 557 in_data = kmalloc(in_data_length, GFP_KERNEL); 551 558 if (!in_data) { 552 559 mutex_unlock(&ni_priv->addressed_transfer_lock); 553 - dev_err(&usb_dev->dev, "%s: kmalloc failed\n", __func__); 554 560 return -ENOMEM; 555 561 } 556 562 retval = ni_usb_receive_bulk_msg(ni_priv, in_data, in_data_length, &bytes_read, 1000, 0); 557 563 if (retval || bytes_read != 16) { 558 564 mutex_unlock(&ni_priv->addressed_transfer_lock); 559 - dev_err(&usb_dev->dev, "%s: ni_usb_receive_bulk_msg returned %i, bytes_read=%i\n", 560 - __func__, retval, bytes_read); 565 + dev_err(&usb_dev->dev, "receive_bulk_msg returned %i, bytes_read=%i\n", 566 + retval, bytes_read); 561 567 ni_usb_dump_raw_block(in_data, bytes_read); 562 568 kfree(in_data); 563 569 return retval; ··· 568 576 //FIXME parse extra 09 status bits and termination 569 577 kfree(in_data); 570 578 if (status.id != NIUSB_REG_WRITE_ID) { 571 - dev_err(&usb_dev->dev, "%s: parse error, id=0x%x != NIUSB_REG_WRITE_ID\n", 572 - __func__, status.id); 579 + dev_err(&usb_dev->dev, "parse error, id=0x%x != NIUSB_REG_WRITE_ID\n", status.id); 573 580 return -EIO; 574 581 } 575 582 if (status.error_code) { 576 - dev_err(&usb_dev->dev, "%s: nonzero error code 0x%x\n", 577 - __func__, status.error_code); 583 + dev_err(&usb_dev->dev, "nonzero error code 0x%x\n", status.error_code); 578 584 return -EIO; 579 585 } 580 586 if (reg_writes_completed != num_writes) { 581 - dev_err(&usb_dev->dev, "%s: reg_writes_completed=%i, num_writes=%i\n", 582 - __func__, reg_writes_completed, num_writes); 587 + dev_err(&usb_dev->dev, "reg_writes_completed=%i, num_writes=%i\n", 588 + reg_writes_completed, num_writes); 583 589 return -EIO; 584 590 } 585 591 if (ibsta) ··· 586 596 } 587 597 588 598 // interface functions 589 - static int ni_usb_read(gpib_board_t *board, uint8_t *buffer, size_t length, 599 + static int ni_usb_read(struct gpib_board *board, uint8_t *buffer, size_t length, 590 600 int *end, size_t *bytes_read) 591 601 { 592 602 int retval, parse_retval; 593 603 struct ni_usb_priv *ni_priv = board->private_data; 594 - struct usb_device *usb_dev = interface_to_usbdev(ni_priv->bus_interface); 604 + struct usb_device *usb_dev; 595 605 u8 *out_data, *in_data; 596 606 static const int out_data_length = 0x20; 597 607 int in_data_length; ··· 604 614 struct ni_usb_register reg; 605 615 606 616 *bytes_read = 0; 607 - if (length > max_read_length) { 608 - length = max_read_length; 609 - dev_err(&usb_dev->dev, "%s: read length too long\n", __func__); 610 - } 617 + if (!ni_priv->bus_interface) 618 + return -ENODEV; 619 + if (length > max_read_length) 620 + return -EINVAL; 621 + usb_dev = interface_to_usbdev(ni_priv->bus_interface); 611 622 out_data = kmalloc(out_data_length, GFP_KERNEL); 612 623 if (!out_data) 613 624 return -ENOMEM; ··· 640 649 if (retval || usb_bytes_written != i) { 641 650 if (retval == 0) 642 651 retval = -EIO; 643 - dev_err(&usb_dev->dev, "%s: ni_usb_send_bulk_msg returned %i, usb_bytes_written=%i, i=%i\n", 644 - __func__, retval, usb_bytes_written, i); 652 + dev_err(&usb_dev->dev, "send_bulk_msg returned %i, usb_bytes_written=%i, i=%i\n", 653 + retval, usb_bytes_written, i); 645 654 mutex_unlock(&ni_priv->addressed_transfer_lock); 646 655 return retval; 647 656 } ··· 659 668 660 669 if (retval == -ERESTARTSYS) { 661 670 } else if (retval) { 662 - dev_err(&usb_dev->dev, "%s: ni_usb_receive_bulk_msg returned %i, usb_bytes_read=%i\n", 663 - __func__, retval, usb_bytes_read); 671 + dev_err(&usb_dev->dev, "receive_bulk_msg returned %i, usb_bytes_read=%i\n", 672 + retval, usb_bytes_read); 664 673 kfree(in_data); 665 674 return retval; 666 675 } ··· 668 677 if (parse_retval != usb_bytes_read) { 669 678 if (parse_retval >= 0) 670 679 parse_retval = -EIO; 671 - dev_err(&usb_dev->dev, "%s: retval=%i usb_bytes_read=%i\n", 672 - __func__, parse_retval, usb_bytes_read); 680 + dev_err(&usb_dev->dev, "retval=%i usb_bytes_read=%i\n", 681 + parse_retval, usb_bytes_read); 673 682 kfree(in_data); 674 683 return parse_retval; 675 684 } 676 685 if (actual_length != length - status.count) { 677 - dev_err(&usb_dev->dev, "%s: actual_length=%i expected=%li\n", 678 - __func__, actual_length, (long)(length - status.count)); 686 + dev_err(&usb_dev->dev, "actual_length=%i expected=%li\n", 687 + actual_length, (long)(length - status.count)); 679 688 ni_usb_dump_raw_block(in_data, usb_bytes_read); 680 689 } 681 690 kfree(in_data); ··· 690 699 break; 691 700 case NIUSB_ATN_STATE_ERROR: 692 701 retval = -EIO; 693 - dev_err(&usb_dev->dev, "%s: read when ATN set\n", __func__); 702 + dev_err(&usb_dev->dev, "read when ATN set\n"); 694 703 break; 695 704 case NIUSB_ADDRESSING_ERROR: 696 705 retval = -EIO; ··· 699 708 retval = -ETIMEDOUT; 700 709 break; 701 710 case NIUSB_EOSMODE_ERROR: 702 - dev_err(&usb_dev->dev, "%s: driver bug, we should have been able to avoid NIUSB_EOSMODE_ERROR.\n", 703 - __func__); 711 + dev_err(&usb_dev->dev, "driver bug, we should have been able to avoid NIUSB_EOSMODE_ERROR.\n"); 704 712 retval = -EINVAL; 705 713 break; 706 714 default: 707 - dev_err(&usb_dev->dev, "%s: unknown error code=%i\n", __func__, status.error_code); 715 + dev_err(&usb_dev->dev, "unknown error code=%i\n", status.error_code); 708 716 retval = -EIO; 709 717 break; 710 718 } ··· 716 726 return retval; 717 727 } 718 728 719 - static int ni_usb_write(gpib_board_t *board, uint8_t *buffer, size_t length, 729 + static int ni_usb_write(struct gpib_board *board, uint8_t *buffer, size_t length, 720 730 int send_eoi, size_t *bytes_written) 721 731 { 722 732 int retval; 723 733 struct ni_usb_priv *ni_priv = board->private_data; 724 - struct usb_device *usb_dev = interface_to_usbdev(ni_priv->bus_interface); 734 + struct usb_device *usb_dev; 725 735 u8 *out_data, *in_data; 726 736 int out_data_length; 727 737 static const int in_data_length = 0x10; ··· 731 741 struct ni_usb_status_block status; 732 742 static const int max_write_length = 0xffff; 733 743 734 - *bytes_written = 0; 735 - if (length > max_write_length) { 736 - length = max_write_length; 737 - send_eoi = 0; 738 - dev_err(&usb_dev->dev, "%s: write length too long\n", __func__); 739 - } 744 + if (!ni_priv->bus_interface) 745 + return -ENODEV; 746 + if (length > max_write_length) 747 + return -EINVAL; 748 + usb_dev = interface_to_usbdev(ni_priv->bus_interface); 740 749 out_data_length = length + 0x10; 741 750 out_data = kmalloc(out_data_length, GFP_KERNEL); 742 751 if (!out_data) ··· 766 777 kfree(out_data); 767 778 if (retval || usb_bytes_written != i) { 768 779 mutex_unlock(&ni_priv->addressed_transfer_lock); 769 - dev_err(&usb_dev->dev, "%s: ni_usb_send_bulk_msg returned %i, usb_bytes_written=%i, i=%i\n", 770 - __func__, retval, usb_bytes_written, i); 780 + dev_err(&usb_dev->dev, "send_bulk_msg returned %i, usb_bytes_written=%i, i=%i\n", 781 + retval, usb_bytes_written, i); 771 782 return retval; 772 783 } 773 784 ··· 782 793 mutex_unlock(&ni_priv->addressed_transfer_lock); 783 794 784 795 if ((retval && retval != -ERESTARTSYS) || usb_bytes_read != 12) { 785 - dev_err(&usb_dev->dev, "%s: ni_usb_receive_bulk_msg returned %i, usb_bytes_read=%i\n", 786 - __func__, retval, usb_bytes_read); 796 + dev_err(&usb_dev->dev, "receive_bulk_msg returned %i, usb_bytes_read=%i\n", 797 + retval, usb_bytes_read); 787 798 kfree(in_data); 788 799 return retval; 789 800 } ··· 799 810 */ 800 811 break; 801 812 case NIUSB_ADDRESSING_ERROR: 802 - dev_err(&usb_dev->dev, "%s: Addressing error retval %d error code=%i\n", 803 - __func__, retval, status.error_code); 813 + dev_err(&usb_dev->dev, "Addressing error retval %d error code=%i\n", 814 + retval, status.error_code); 804 815 retval = -ENXIO; 805 816 break; 806 817 case NIUSB_NO_LISTENER_ERROR: ··· 810 821 retval = -ETIMEDOUT; 811 822 break; 812 823 default: 813 - dev_err(&usb_dev->dev, "%s: unknown error code=%i\n", 814 - __func__, status.error_code); 824 + dev_err(&usb_dev->dev, "unknown error code=%i\n", status.error_code); 815 825 retval = -EPIPE; 816 826 break; 817 827 } ··· 819 831 return retval; 820 832 } 821 833 822 - static int ni_usb_command_chunk(gpib_board_t *board, uint8_t *buffer, size_t length, 834 + static int ni_usb_command_chunk(struct gpib_board *board, uint8_t *buffer, size_t length, 823 835 size_t *command_bytes_written) 824 836 { 825 837 int retval; 826 838 struct ni_usb_priv *ni_priv = board->private_data; 827 - struct usb_device *usb_dev = interface_to_usbdev(ni_priv->bus_interface); 839 + struct usb_device *usb_dev; 828 840 u8 *out_data, *in_data; 829 841 int out_data_length; 830 842 static const int in_data_length = 0x10; ··· 836 848 static const int max_command_length = 0x10; 837 849 838 850 *command_bytes_written = 0; 851 + if (!ni_priv->bus_interface) 852 + return -ENODEV; 839 853 if (length > max_command_length) 840 854 length = max_command_length; 855 + usb_dev = interface_to_usbdev(ni_priv->bus_interface); 841 856 out_data_length = length + 0x10; 842 857 out_data = kmalloc(out_data_length, GFP_KERNEL); 843 858 if (!out_data) ··· 864 873 kfree(out_data); 865 874 if (retval || bytes_written != i) { 866 875 mutex_unlock(&ni_priv->addressed_transfer_lock); 867 - dev_err(&usb_dev->dev, "%s: ni_usb_send_bulk_msg returned %i, bytes_written=%i, i=%i\n", 868 - __func__, retval, bytes_written, i); 876 + dev_err(&usb_dev->dev, "send_bulk_msg returned %i, bytes_written=%i, i=%i\n", 877 + retval, bytes_written, i); 869 878 return retval; 870 879 } 871 880 ··· 881 890 mutex_unlock(&ni_priv->addressed_transfer_lock); 882 891 883 892 if ((retval && retval != -ERESTARTSYS) || bytes_read != 12) { 884 - dev_err(&usb_dev->dev, "%s: ni_usb_receive_bulk_msg returned %i, bytes_read=%i\n", 885 - __func__, retval, bytes_read); 893 + dev_err(&usb_dev->dev, "receive_bulk_msg returned %i, bytes_read=%i\n", 894 + retval, bytes_read); 886 895 kfree(in_data); 887 896 return retval; 888 897 } ··· 900 909 case NIUSB_NO_BUS_ERROR: 901 910 return -ENOTCONN; 902 911 case NIUSB_EOSMODE_ERROR: 903 - dev_err(&usb_dev->dev, "%s: got eosmode error. Driver bug?\n", __func__); 912 + dev_err(&usb_dev->dev, "got eosmode error. Driver bug?\n"); 904 913 return -EIO; 905 914 case NIUSB_TIMEOUT_ERROR: 906 915 return -ETIMEDOUT; 907 916 default: 908 - dev_err(&usb_dev->dev, "%s: unknown error code=%i\n", __func__, status.error_code); 917 + dev_err(&usb_dev->dev, "unknown error code=%i\n", status.error_code); 909 918 return -EIO; 910 919 } 911 920 ni_usb_soft_update_status(board, status.ibsta, 0); 912 921 return 0; 913 922 } 914 923 915 - static int ni_usb_command(gpib_board_t *board, uint8_t *buffer, size_t length, 924 + static int ni_usb_command(struct gpib_board *board, uint8_t *buffer, size_t length, 916 925 size_t *bytes_written) 917 926 { 918 927 size_t count; ··· 929 938 return 0; 930 939 } 931 940 932 - static int ni_usb_take_control(gpib_board_t *board, int synchronous) 941 + static int ni_usb_take_control(struct gpib_board *board, int synchronous) 933 942 { 934 943 int retval; 935 944 struct ni_usb_priv *ni_priv = board->private_data; 936 - struct usb_device *usb_dev = interface_to_usbdev(ni_priv->bus_interface); 945 + struct usb_device *usb_dev; 937 946 u8 *out_data, *in_data; 938 947 static const int out_data_length = 0x10; 939 948 static const int in_data_length = 0x10; ··· 941 950 int i = 0; 942 951 struct ni_usb_status_block status; 943 952 953 + if (!ni_priv->bus_interface) 954 + return -ENODEV; 955 + usb_dev = interface_to_usbdev(ni_priv->bus_interface); 944 956 out_data = kmalloc(out_data_length, GFP_KERNEL); 945 957 if (!out_data) 946 958 return -ENOMEM; ··· 962 968 kfree(out_data); 963 969 if (retval || bytes_written != i) { 964 970 mutex_unlock(&ni_priv->addressed_transfer_lock); 965 - dev_err(&usb_dev->dev, "%s: ni_usb_send_bulk_msg returned %i, bytes_written=%i, i=%i\n", 966 - __func__, retval, bytes_written, i); 971 + dev_err(&usb_dev->dev, "send_bulk_msg returned %i, bytes_written=%i, i=%i\n", 972 + retval, bytes_written, i); 967 973 return retval; 968 974 } 969 975 970 976 in_data = kmalloc(in_data_length, GFP_KERNEL); 971 977 if (!in_data) { 972 978 mutex_unlock(&ni_priv->addressed_transfer_lock); 973 - dev_err(&usb_dev->dev, "%s: kmalloc failed\n", __func__); 974 979 return -ENOMEM; 975 980 } 976 981 retval = ni_usb_receive_bulk_msg(ni_priv, in_data, in_data_length, &bytes_read, 1000, 1); ··· 979 986 if ((retval && retval != -ERESTARTSYS) || bytes_read != 12) { 980 987 if (retval == 0) 981 988 retval = -EIO; 982 - dev_err(&usb_dev->dev, "%s: ni_usb_receive_bulk_msg returned %i, bytes_read=%i\n", 983 - __func__, retval, bytes_read); 989 + dev_err(&usb_dev->dev, "receive_bulk_msg returned %i, bytes_read=%i\n", 990 + retval, bytes_read); 984 991 kfree(in_data); 985 992 return retval; 986 993 } ··· 990 997 return retval; 991 998 } 992 999 993 - static int ni_usb_go_to_standby(gpib_board_t *board) 1000 + static int ni_usb_go_to_standby(struct gpib_board *board) 994 1001 { 995 1002 int retval; 996 1003 struct ni_usb_priv *ni_priv = board->private_data; 997 - struct usb_device *usb_dev = interface_to_usbdev(ni_priv->bus_interface); 1004 + struct usb_device *usb_dev; 998 1005 u8 *out_data, *in_data; 999 1006 static const int out_data_length = 0x10; 1000 1007 static const int in_data_length = 0x20; ··· 1002 1009 int i = 0; 1003 1010 struct ni_usb_status_block status; 1004 1011 1012 + if (!ni_priv->bus_interface) 1013 + return -ENODEV; 1014 + usb_dev = interface_to_usbdev(ni_priv->bus_interface); 1005 1015 out_data = kmalloc(out_data_length, GFP_KERNEL); 1006 1016 if (!out_data) 1007 1017 return -ENOMEM; ··· 1021 1025 kfree(out_data); 1022 1026 if (retval || bytes_written != i) { 1023 1027 mutex_unlock(&ni_priv->addressed_transfer_lock); 1024 - dev_err(&usb_dev->dev, "%s: ni_usb_send_bulk_msg returned %i, bytes_written=%i, i=%i\n", 1025 - __func__, retval, bytes_written, i); 1028 + dev_err(&usb_dev->dev, "send_bulk_msg returned %i, bytes_written=%i, i=%i\n", 1029 + retval, bytes_written, i); 1026 1030 return retval; 1027 1031 } 1028 1032 1029 1033 in_data = kmalloc(in_data_length, GFP_KERNEL); 1030 1034 if (!in_data) { 1031 1035 mutex_unlock(&ni_priv->addressed_transfer_lock); 1032 - dev_err(&usb_dev->dev, "%s: kmalloc failed\n", __func__); 1033 1036 return -ENOMEM; 1034 1037 } 1035 1038 retval = ni_usb_receive_bulk_msg(ni_priv, in_data, in_data_length, &bytes_read, 1000, 0); ··· 1036 1041 mutex_unlock(&ni_priv->addressed_transfer_lock); 1037 1042 1038 1043 if (retval || bytes_read != 12) { 1039 - dev_err(&usb_dev->dev, "%s: ni_usb_receive_bulk_msg returned %i, bytes_read=%i\n", 1040 - __func__, retval, bytes_read); 1044 + dev_err(&usb_dev->dev, "receive_bulk_msg returned %i, bytes_read=%i\n", 1045 + retval, bytes_read); 1041 1046 kfree(in_data); 1042 1047 return retval; 1043 1048 } 1044 1049 ni_usb_parse_status_block(in_data, &status); 1045 1050 kfree(in_data); 1046 1051 if (status.id != NIUSB_IBGTS_ID) 1047 - dev_err(&usb_dev->dev, "%s: bug: status.id 0x%x != INUSB_IBGTS_ID\n", 1048 - __func__, status.id); 1052 + dev_err(&usb_dev->dev, "bug: status.id 0x%x != INUSB_IBGTS_ID\n", status.id); 1049 1053 ni_usb_soft_update_status(board, status.ibsta, 0); 1050 1054 return 0; 1051 1055 } 1052 1056 1053 - static void ni_usb_request_system_control(gpib_board_t *board, int request_control) 1057 + static void ni_usb_request_system_control(struct gpib_board *board, int request_control) 1054 1058 { 1055 1059 int retval; 1056 1060 struct ni_usb_priv *ni_priv = board->private_data; 1057 - struct usb_device *usb_dev = interface_to_usbdev(ni_priv->bus_interface); 1061 + struct usb_device *usb_dev; 1058 1062 int i = 0; 1059 1063 struct ni_usb_register writes[4]; 1060 1064 unsigned int ibsta; 1061 1065 1066 + if (!ni_priv->bus_interface) 1067 + return; // -ENODEV; 1068 + usb_dev = interface_to_usbdev(ni_priv->bus_interface); 1062 1069 if (request_control) { 1063 1070 writes[i].device = NIUSB_SUBDEV_TNT4882; 1064 1071 writes[i].address = CMDR; ··· 1090 1093 } 1091 1094 retval = ni_usb_write_registers(ni_priv, writes, i, &ibsta); 1092 1095 if (retval < 0) { 1093 - dev_err(&usb_dev->dev, "%s: register write failed, retval=%i\n", __func__, retval); 1096 + dev_err(&usb_dev->dev, "register write failed, retval=%i\n", retval); 1094 1097 return; // retval; 1095 1098 } 1096 1099 if (!request_control) ··· 1100 1103 } 1101 1104 1102 1105 //FIXME maybe the interface should have a "pulse interface clear" function that can return an error? 1103 - static void ni_usb_interface_clear(gpib_board_t *board, int assert) 1106 + static void ni_usb_interface_clear(struct gpib_board *board, int assert) 1104 1107 { 1105 1108 int retval; 1106 1109 struct ni_usb_priv *ni_priv = board->private_data; 1107 - struct usb_device *usb_dev = interface_to_usbdev(ni_priv->bus_interface); 1110 + struct usb_device *usb_dev; 1108 1111 u8 *out_data, *in_data; 1109 1112 static const int out_data_length = 0x10; 1110 1113 static const int in_data_length = 0x10; ··· 1112 1115 int i = 0; 1113 1116 struct ni_usb_status_block status; 1114 1117 1115 - // FIXME: we are going to pulse when assert is true, and ignore otherwise 1118 + if (!ni_priv->bus_interface) 1119 + return; // -ENODEV; 1120 + usb_dev = interface_to_usbdev(ni_priv->bus_interface); 1121 + // FIXME: we are going to pulse when assert is true, and ignore otherwise 1116 1122 if (assert == 0) 1117 1123 return; 1118 1124 out_data = kmalloc(out_data_length, GFP_KERNEL); 1119 - if (!out_data) { 1120 - dev_err(&usb_dev->dev, "%s: kmalloc failed\n", __func__); 1125 + if (!out_data) 1121 1126 return; 1122 - } 1123 1127 out_data[i++] = NIUSB_IBSIC_ID; 1124 1128 out_data[i++] = 0x0; 1125 1129 out_data[i++] = 0x0; ··· 1129 1131 retval = ni_usb_send_bulk_msg(ni_priv, out_data, i, &bytes_written, 1000); 1130 1132 kfree(out_data); 1131 1133 if (retval || bytes_written != i) { 1132 - dev_err(&usb_dev->dev, "%s: ni_usb_send_bulk_msg returned %i, bytes_written=%i, i=%i\n", 1133 - __func__, retval, bytes_written, i); 1134 + dev_err(&usb_dev->dev, "send_bulk_msg returned %i, bytes_written=%i, i=%i\n", 1135 + retval, bytes_written, i); 1134 1136 return; 1135 1137 } 1136 1138 in_data = kmalloc(in_data_length, GFP_KERNEL); ··· 1139 1141 1140 1142 retval = ni_usb_receive_bulk_msg(ni_priv, in_data, in_data_length, &bytes_read, 1000, 0); 1141 1143 if (retval || bytes_read != 12) { 1142 - dev_err(&usb_dev->dev, "%s: ni_usb_receive_bulk_msg returned %i, bytes_read=%i\n", 1143 - __func__, retval, bytes_read); 1144 + dev_err(&usb_dev->dev, "receive_bulk_msg returned %i, bytes_read=%i\n", 1145 + retval, bytes_read); 1144 1146 kfree(in_data); 1145 1147 return; 1146 1148 } ··· 1149 1151 ni_usb_soft_update_status(board, status.ibsta, 0); 1150 1152 } 1151 1153 1152 - static void ni_usb_remote_enable(gpib_board_t *board, int enable) 1154 + static void ni_usb_remote_enable(struct gpib_board *board, int enable) 1153 1155 { 1154 1156 int retval; 1155 1157 struct ni_usb_priv *ni_priv = board->private_data; 1156 - struct usb_device *usb_dev = interface_to_usbdev(ni_priv->bus_interface); 1158 + struct usb_device *usb_dev; 1157 1159 struct ni_usb_register reg; 1158 1160 unsigned int ibsta; 1159 1161 1162 + if (!ni_priv->bus_interface) 1163 + return; // -ENODEV; 1164 + usb_dev = interface_to_usbdev(ni_priv->bus_interface); 1160 1165 reg.device = NIUSB_SUBDEV_TNT4882; 1161 1166 reg.address = nec7210_to_tnt4882_offset(AUXMR); 1162 1167 if (enable) ··· 1168 1167 reg.value = AUX_CREN; 1169 1168 retval = ni_usb_write_registers(ni_priv, &reg, 1, &ibsta); 1170 1169 if (retval < 0) { 1171 - dev_err(&usb_dev->dev, "%s: register write failed, retval=%i\n", __func__, retval); 1170 + dev_err(&usb_dev->dev, "register write failed, retval=%i\n", retval); 1172 1171 return; //retval; 1173 1172 } 1174 1173 ni_priv->ren_state = enable; ··· 1176 1175 return;// 0; 1177 1176 } 1178 1177 1179 - static int ni_usb_enable_eos(gpib_board_t *board, uint8_t eos_byte, int compare_8_bits) 1178 + static int ni_usb_enable_eos(struct gpib_board *board, uint8_t eos_byte, int compare_8_bits) 1180 1179 { 1181 1180 struct ni_usb_priv *ni_priv = board->private_data; 1182 1181 ··· 1189 1188 return 0; 1190 1189 } 1191 1190 1192 - static void ni_usb_disable_eos(gpib_board_t *board) 1191 + static void ni_usb_disable_eos(struct gpib_board *board) 1193 1192 { 1194 1193 struct ni_usb_priv *ni_priv = board->private_data; 1195 1194 /* adapter gets unhappy if you don't zero all the bits ··· 1199 1198 ni_priv->eos_char = 0; 1200 1199 } 1201 1200 1202 - static unsigned int ni_usb_update_status(gpib_board_t *board, unsigned int clear_mask) 1201 + static unsigned int ni_usb_update_status(struct gpib_board *board, unsigned int clear_mask) 1203 1202 { 1204 1203 int retval; 1205 1204 struct ni_usb_priv *ni_priv = board->private_data; 1206 - struct usb_device *usb_dev = interface_to_usbdev(ni_priv->bus_interface); 1205 + struct usb_device *usb_dev; 1207 1206 static const int buffer_length = 8; 1208 1207 u8 *buffer; 1209 1208 struct ni_usb_status_block status; 1210 1209 1211 - //printk("%s: receive control pipe is %i\n", __func__, pipe); 1210 + if (!ni_priv->bus_interface) 1211 + return -ENODEV; 1212 + usb_dev = interface_to_usbdev(ni_priv->bus_interface); 1212 1213 buffer = kmalloc(buffer_length, GFP_KERNEL); 1213 1214 if (!buffer) 1214 1215 return board->status; ··· 1219 1216 USB_TYPE_VENDOR | USB_RECIP_DEVICE, 1220 1217 0x200, 0x0, buffer, buffer_length, 1000); 1221 1218 if (retval != buffer_length) { 1222 - dev_err(&usb_dev->dev, "%s: usb_control_msg returned %i\n", __func__, retval); 1219 + dev_err(&usb_dev->dev, "usb_control_msg returned %i\n", retval); 1223 1220 kfree(buffer); 1224 1221 return board->status; 1225 1222 } ··· 1238 1235 u8 *buffer; 1239 1236 struct ni_usb_status_block status; 1240 1237 1241 - //printk("%s: receive control pipe is %i\n", __func__, pipe); 1242 1238 buffer = kmalloc(buffer_length, GFP_KERNEL); 1243 1239 if (!buffer) 1244 1240 return; ··· 1246 1244 USB_TYPE_VENDOR | USB_RECIP_DEVICE, 1247 1245 0x0, 0x0, buffer, buffer_length, 1000); 1248 1246 if (retval != buffer_length) { 1249 - dev_err(&usb_dev->dev, "%s: usb_control_msg returned %i\n", __func__, retval); 1247 + dev_err(&usb_dev->dev, "usb_control_msg returned %i\n", retval); 1250 1248 kfree(buffer); 1251 1249 return; 1252 1250 } ··· 1254 1252 kfree(buffer); 1255 1253 } 1256 1254 1257 - static int ni_usb_primary_address(gpib_board_t *board, unsigned int address) 1255 + static int ni_usb_primary_address(struct gpib_board *board, unsigned int address) 1258 1256 { 1259 1257 int retval; 1260 1258 struct ni_usb_priv *ni_priv = board->private_data; 1261 - struct usb_device *usb_dev = interface_to_usbdev(ni_priv->bus_interface); 1259 + struct usb_device *usb_dev; 1262 1260 int i = 0; 1263 1261 struct ni_usb_register writes[2]; 1264 1262 unsigned int ibsta; 1265 1263 1264 + if (!ni_priv->bus_interface) 1265 + return -ENODEV; 1266 + usb_dev = interface_to_usbdev(ni_priv->bus_interface); 1266 1267 writes[i].device = NIUSB_SUBDEV_TNT4882; 1267 1268 writes[i].address = nec7210_to_tnt4882_offset(ADR); 1268 1269 writes[i].value = address; ··· 1276 1271 i++; 1277 1272 retval = ni_usb_write_registers(ni_priv, writes, i, &ibsta); 1278 1273 if (retval < 0) { 1279 - dev_err(&usb_dev->dev, "%s: register write failed, retval=%i\n", __func__, retval); 1274 + dev_err(&usb_dev->dev, "register write failed, retval=%i\n", retval); 1280 1275 return retval; 1281 1276 } 1282 1277 ni_usb_soft_update_status(board, ibsta, 0); ··· 1312 1307 return i; 1313 1308 } 1314 1309 1315 - static int ni_usb_secondary_address(gpib_board_t *board, unsigned int address, int enable) 1310 + static int ni_usb_secondary_address(struct gpib_board *board, unsigned int address, int enable) 1316 1311 { 1317 1312 int retval; 1318 1313 struct ni_usb_priv *ni_priv = board->private_data; 1319 - struct usb_device *usb_dev = interface_to_usbdev(ni_priv->bus_interface); 1314 + struct usb_device *usb_dev; 1320 1315 int i = 0; 1321 1316 struct ni_usb_register writes[3]; 1322 1317 unsigned int ibsta; 1323 1318 1319 + if (!ni_priv->bus_interface) 1320 + return -ENODEV; 1321 + usb_dev = interface_to_usbdev(ni_priv->bus_interface); 1324 1322 i += ni_usb_write_sad(writes, address, enable); 1325 1323 retval = ni_usb_write_registers(ni_priv, writes, i, &ibsta); 1326 1324 if (retval < 0) { 1327 - dev_err(&usb_dev->dev, "%s: register write failed, retval=%i\n", __func__, retval); 1325 + dev_err(&usb_dev->dev, "register write failed, retval=%i\n", retval); 1328 1326 return retval; 1329 1327 } 1330 1328 ni_usb_soft_update_status(board, ibsta, 0); 1331 1329 return 0; 1332 1330 } 1333 1331 1334 - static int ni_usb_parallel_poll(gpib_board_t *board, uint8_t *result) 1332 + static int ni_usb_parallel_poll(struct gpib_board *board, uint8_t *result) 1335 1333 { 1336 1334 int retval; 1337 1335 struct ni_usb_priv *ni_priv = board->private_data; 1338 - struct usb_device *usb_dev = interface_to_usbdev(ni_priv->bus_interface); 1336 + struct usb_device *usb_dev; 1339 1337 u8 *out_data, *in_data; 1340 1338 static const int out_data_length = 0x10; 1341 1339 static const int in_data_length = 0x20; ··· 1347 1339 int j = 0; 1348 1340 struct ni_usb_status_block status; 1349 1341 1342 + if (!ni_priv->bus_interface) 1343 + return -ENODEV; 1344 + usb_dev = interface_to_usbdev(ni_priv->bus_interface); 1350 1345 out_data = kmalloc(out_data_length, GFP_KERNEL); 1351 1346 if (!out_data) 1352 1347 return -ENOMEM; ··· 1364 1353 1365 1354 kfree(out_data); 1366 1355 if (retval || bytes_written != i) { 1367 - dev_err(&usb_dev->dev, "%s: ni_usb_send_bulk_msg returned %i, bytes_written=%i, i=%i\n", 1368 - __func__, retval, bytes_written, i); 1356 + dev_err(&usb_dev->dev, "send_bulk_msg returned %i, bytes_written=%i, i=%i\n", 1357 + retval, bytes_written, i); 1369 1358 return retval; 1370 1359 } 1371 1360 in_data = kmalloc(in_data_length, GFP_KERNEL); ··· 1377 1366 &bytes_read, 1000, 1); 1378 1367 1379 1368 if (retval && retval != -ERESTARTSYS) { 1380 - dev_err(&usb_dev->dev, "%s: ni_usb_receive_bulk_msg returned %i, bytes_read=%i\n", 1381 - __func__, retval, bytes_read); 1369 + dev_err(&usb_dev->dev, "receive_bulk_msg returned %i, bytes_read=%i\n", 1370 + retval, bytes_read); 1382 1371 kfree(in_data); 1383 1372 return retval; 1384 1373 } ··· 1389 1378 return retval; 1390 1379 } 1391 1380 1392 - static void ni_usb_parallel_poll_configure(gpib_board_t *board, uint8_t config) 1381 + static void ni_usb_parallel_poll_configure(struct gpib_board *board, uint8_t config) 1393 1382 { 1394 1383 int retval; 1395 1384 struct ni_usb_priv *ni_priv = board->private_data; 1396 - struct usb_device *usb_dev = interface_to_usbdev(ni_priv->bus_interface); 1385 + struct usb_device *usb_dev; 1397 1386 int i = 0; 1398 1387 struct ni_usb_register writes[1]; 1399 1388 unsigned int ibsta; 1400 1389 1390 + if (!ni_priv->bus_interface) 1391 + return; // -ENODEV; 1392 + usb_dev = interface_to_usbdev(ni_priv->bus_interface); 1401 1393 writes[i].device = NIUSB_SUBDEV_TNT4882; 1402 1394 writes[i].address = nec7210_to_tnt4882_offset(AUXMR); 1403 1395 writes[i].value = PPR | config; 1404 1396 i++; 1405 1397 retval = ni_usb_write_registers(ni_priv, writes, i, &ibsta); 1406 1398 if (retval < 0) { 1407 - dev_err(&usb_dev->dev, "%s: register write failed, retval=%i\n", __func__, retval); 1399 + dev_err(&usb_dev->dev, "register write failed, retval=%i\n", retval); 1408 1400 return;// retval; 1409 1401 } 1410 1402 ni_usb_soft_update_status(board, ibsta, 0); 1411 1403 return;// 0; 1412 1404 } 1413 1405 1414 - static void ni_usb_parallel_poll_response(gpib_board_t *board, int ist) 1406 + static void ni_usb_parallel_poll_response(struct gpib_board *board, int ist) 1415 1407 { 1416 1408 int retval; 1417 1409 struct ni_usb_priv *ni_priv = board->private_data; 1418 - struct usb_device *usb_dev = interface_to_usbdev(ni_priv->bus_interface); 1410 + struct usb_device *usb_dev; 1419 1411 int i = 0; 1420 1412 struct ni_usb_register writes[1]; 1421 1413 unsigned int ibsta; 1422 1414 1415 + if (!ni_priv->bus_interface) 1416 + return; // -ENODEV; 1417 + usb_dev = interface_to_usbdev(ni_priv->bus_interface); 1423 1418 writes[i].device = NIUSB_SUBDEV_TNT4882; 1424 1419 writes[i].address = nec7210_to_tnt4882_offset(AUXMR); 1425 1420 if (ist) ··· 1435 1418 i++; 1436 1419 retval = ni_usb_write_registers(ni_priv, writes, i, &ibsta); 1437 1420 if (retval < 0) { 1438 - dev_err(&usb_dev->dev, "%s: register write failed, retval=%i\n", __func__, retval); 1421 + dev_err(&usb_dev->dev, "register write failed, retval=%i\n", retval); 1439 1422 return;// retval; 1440 1423 } 1441 1424 ni_usb_soft_update_status(board, ibsta, 0); 1442 1425 return;// 0; 1443 1426 } 1444 1427 1445 - static void ni_usb_serial_poll_response(gpib_board_t *board, u8 status) 1428 + static void ni_usb_serial_poll_response(struct gpib_board *board, u8 status) 1446 1429 { 1447 1430 int retval; 1448 1431 struct ni_usb_priv *ni_priv = board->private_data; 1449 - struct usb_device *usb_dev = interface_to_usbdev(ni_priv->bus_interface); 1432 + struct usb_device *usb_dev; 1450 1433 int i = 0; 1451 1434 struct ni_usb_register writes[1]; 1452 1435 unsigned int ibsta; 1453 1436 1437 + if (!ni_priv->bus_interface) 1438 + return; // -ENODEV; 1439 + usb_dev = interface_to_usbdev(ni_priv->bus_interface); 1454 1440 writes[i].device = NIUSB_SUBDEV_TNT4882; 1455 1441 writes[i].address = nec7210_to_tnt4882_offset(SPMR); 1456 1442 writes[i].value = status; 1457 1443 i++; 1458 1444 retval = ni_usb_write_registers(ni_priv, writes, i, &ibsta); 1459 1445 if (retval < 0) { 1460 - dev_err(&usb_dev->dev, "%s: register write failed, retval=%i\n", __func__, retval); 1446 + dev_err(&usb_dev->dev, "register write failed, retval=%i\n", retval); 1461 1447 return;// retval; 1462 1448 } 1463 1449 ni_usb_soft_update_status(board, ibsta, 0); 1464 1450 return;// 0; 1465 1451 } 1466 1452 1467 - static uint8_t ni_usb_serial_poll_status(gpib_board_t *board) 1453 + static uint8_t ni_usb_serial_poll_status(struct gpib_board *board) 1468 1454 { 1469 1455 return 0; 1470 1456 } 1471 1457 1472 - static void ni_usb_return_to_local(gpib_board_t *board) 1458 + static void ni_usb_return_to_local(struct gpib_board *board) 1473 1459 { 1474 1460 int retval; 1475 1461 struct ni_usb_priv *ni_priv = board->private_data; 1476 - struct usb_device *usb_dev = interface_to_usbdev(ni_priv->bus_interface); 1462 + struct usb_device *usb_dev; 1477 1463 int i = 0; 1478 1464 struct ni_usb_register writes[1]; 1479 1465 unsigned int ibsta; 1480 1466 1467 + if (!ni_priv->bus_interface) 1468 + return; // -ENODEV; 1469 + usb_dev = interface_to_usbdev(ni_priv->bus_interface); 1481 1470 writes[i].device = NIUSB_SUBDEV_TNT4882; 1482 1471 writes[i].address = nec7210_to_tnt4882_offset(AUXMR); 1483 1472 writes[i].value = AUX_RTL; 1484 1473 i++; 1485 1474 retval = ni_usb_write_registers(ni_priv, writes, i, &ibsta); 1486 1475 if (retval < 0) { 1487 - dev_err(&usb_dev->dev, "%s: register write failed, retval=%i\n", __func__, retval); 1476 + dev_err(&usb_dev->dev, "register write failed, retval=%i\n", retval); 1488 1477 return;// retval; 1489 1478 } 1490 1479 ni_usb_soft_update_status(board, ibsta, 0); 1491 1480 return;// 0; 1492 1481 } 1493 1482 1494 - static int ni_usb_line_status(const gpib_board_t *board) 1483 + static int ni_usb_line_status(const struct gpib_board *board) 1495 1484 { 1496 1485 int retval; 1497 1486 struct ni_usb_priv *ni_priv = board->private_data; 1498 - struct usb_device *usb_dev = interface_to_usbdev(ni_priv->bus_interface); 1487 + struct usb_device *usb_dev; 1499 1488 u8 *out_data, *in_data; 1500 1489 static const int out_data_length = 0x20; 1501 1490 static const int in_data_length = 0x20; 1502 1491 int bytes_written = 0, bytes_read = 0; 1503 1492 int i = 0; 1504 1493 unsigned int bsr_bits; 1505 - int line_status = ValidALL; 1494 + int line_status = VALID_ALL; 1506 1495 // NI windows driver reads 0xd(HSSEL), 0xc (ARD0), 0x1f (BSR) 1507 1496 1497 + if (!ni_priv->bus_interface) 1498 + return -ENODEV; 1499 + usb_dev = interface_to_usbdev(ni_priv->bus_interface); 1508 1500 out_data = kmalloc(out_data_length, GFP_KERNEL); 1509 1501 if (!out_data) 1510 1502 return -ENOMEM; ··· 1535 1509 if (retval || bytes_written != i) { 1536 1510 mutex_unlock(&ni_priv->addressed_transfer_lock); 1537 1511 if (retval != -EAGAIN) 1538 - dev_err(&usb_dev->dev, "%s: ni_usb_send_bulk_msg returned %i, bytes_written=%i, i=%i\n", 1539 - __func__, retval, bytes_written, i); 1512 + dev_err(&usb_dev->dev, "send_bulk_msg returned %i, bytes_written=%i, i=%i\n", 1513 + retval, bytes_written, i); 1540 1514 return retval; 1541 1515 } 1542 1516 1543 1517 in_data = kmalloc(in_data_length, GFP_KERNEL); 1544 1518 if (!in_data) { 1545 1519 mutex_unlock(&ni_priv->addressed_transfer_lock); 1546 - dev_err(&usb_dev->dev, "%s: kmalloc failed\n", __func__); 1547 1520 return -ENOMEM; 1548 1521 } 1549 1522 retval = ni_usb_nonblocking_receive_bulk_msg(ni_priv, in_data, in_data_length, ··· 1552 1527 1553 1528 if (retval) { 1554 1529 if (retval != -EAGAIN) 1555 - dev_err(&usb_dev->dev, "%s: ni_usb_receive_bulk_msg returned %i, bytes_read=%i\n", 1556 - __func__, retval, bytes_read); 1530 + dev_err(&usb_dev->dev, "receive_bulk_msg returned %i, bytes_read=%i\n", 1531 + retval, bytes_read); 1557 1532 kfree(in_data); 1558 1533 return retval; 1559 1534 } ··· 1561 1536 ni_usb_parse_register_read_block(in_data, &bsr_bits, 1); 1562 1537 kfree(in_data); 1563 1538 if (bsr_bits & BCSR_REN_BIT) 1564 - line_status |= BusREN; 1539 + line_status |= BUS_REN; 1565 1540 if (bsr_bits & BCSR_IFC_BIT) 1566 - line_status |= BusIFC; 1541 + line_status |= BUS_IFC; 1567 1542 if (bsr_bits & BCSR_SRQ_BIT) 1568 - line_status |= BusSRQ; 1543 + line_status |= BUS_SRQ; 1569 1544 if (bsr_bits & BCSR_EOI_BIT) 1570 - line_status |= BusEOI; 1545 + line_status |= BUS_EOI; 1571 1546 if (bsr_bits & BCSR_NRFD_BIT) 1572 - line_status |= BusNRFD; 1547 + line_status |= BUS_NRFD; 1573 1548 if (bsr_bits & BCSR_NDAC_BIT) 1574 - line_status |= BusNDAC; 1549 + line_status |= BUS_NDAC; 1575 1550 if (bsr_bits & BCSR_DAV_BIT) 1576 - line_status |= BusDAV; 1551 + line_status |= BUS_DAV; 1577 1552 if (bsr_bits & BCSR_ATN_BIT) 1578 - line_status |= BusATN; 1553 + line_status |= BUS_ATN; 1579 1554 return line_status; 1580 1555 } 1581 1556 ··· 1616 1591 return i; 1617 1592 } 1618 1593 1619 - static unsigned int ni_usb_t1_delay(gpib_board_t *board, unsigned int nano_sec) 1594 + static int ni_usb_t1_delay(struct gpib_board *board, unsigned int nano_sec) 1620 1595 { 1621 1596 int retval; 1622 1597 struct ni_usb_priv *ni_priv = board->private_data; 1623 - struct usb_device *usb_dev = interface_to_usbdev(ni_priv->bus_interface); 1598 + struct usb_device *usb_dev; 1624 1599 struct ni_usb_register writes[3]; 1625 1600 unsigned int ibsta; 1626 1601 unsigned int actual_ns; 1627 1602 int i; 1628 1603 1604 + if (!ni_priv->bus_interface) 1605 + return -ENODEV; 1606 + usb_dev = interface_to_usbdev(ni_priv->bus_interface); 1629 1607 i = ni_usb_setup_t1_delay(writes, nano_sec, &actual_ns); 1630 1608 retval = ni_usb_write_registers(ni_priv, writes, i, &ibsta); 1631 1609 if (retval < 0) { 1632 - dev_err(&usb_dev->dev, "%s: register write failed, retval=%i\n", __func__, retval); 1633 - return -1; //FIXME should change return type to int for error reporting 1610 + dev_err(&usb_dev->dev, "register write failed, retval=%i\n", retval); 1611 + return retval; 1634 1612 } 1635 1613 board->t1_nano_sec = actual_ns; 1636 1614 ni_usb_soft_update_status(board, ibsta, 0); 1637 1615 return actual_ns; 1638 1616 } 1639 1617 1640 - static int ni_usb_allocate_private(gpib_board_t *board) 1618 + static int ni_usb_allocate_private(struct gpib_board *board) 1641 1619 { 1642 1620 struct ni_usb_priv *ni_priv; 1643 1621 ··· 1663 1635 } 1664 1636 1665 1637 #define NUM_INIT_WRITES 26 1666 - static int ni_usb_setup_init(gpib_board_t *board, struct ni_usb_register *writes) 1638 + static int ni_usb_setup_init(struct gpib_board *board, struct ni_usb_register *writes) 1667 1639 { 1668 1640 struct ni_usb_priv *ni_priv = board->private_data; 1669 1641 struct usb_device *usb_dev = interface_to_usbdev(ni_priv->bus_interface); ··· 1764 1736 writes[i].value = AUX_CPPF; 1765 1737 i++; 1766 1738 if (i > NUM_INIT_WRITES) { 1767 - dev_err(&usb_dev->dev, "%s: bug!, buffer overrun, i=%i\n", __func__, i); 1739 + dev_err(&usb_dev->dev, "bug!, buffer overrun, i=%i\n", i); 1768 1740 return 0; 1769 1741 } 1770 1742 return i; 1771 1743 } 1772 1744 1773 - static int ni_usb_init(gpib_board_t *board) 1745 + static int ni_usb_init(struct gpib_board *board) 1774 1746 { 1775 1747 int retval; 1776 1748 struct ni_usb_priv *ni_priv = board->private_data; ··· 1790 1762 return -EFAULT; 1791 1763 kfree(writes); 1792 1764 if (retval) { 1793 - dev_err(&usb_dev->dev, "%s: register write failed, retval=%i\n", __func__, retval); 1765 + dev_err(&usb_dev->dev, "register write failed, retval=%i\n", retval); 1794 1766 return retval; 1795 1767 } 1796 1768 ni_usb_soft_update_status(board, ibsta, 0); ··· 1799 1771 1800 1772 static void ni_usb_interrupt_complete(struct urb *urb) 1801 1773 { 1802 - gpib_board_t *board = urb->context; 1774 + struct gpib_board *board = urb->context; 1803 1775 struct ni_usb_priv *ni_priv = board->private_data; 1804 1776 struct usb_device *usb_dev = interface_to_usbdev(ni_priv->bus_interface); 1805 1777 int retval; 1806 1778 struct ni_usb_status_block status; 1807 1779 unsigned long flags; 1808 - 1809 - // printk("debug: %s: status=0x%x, error_count=%i, actual_length=%i\n", __func__, 1810 - // urb->status, urb->error_count, urb->actual_length); 1811 1780 1812 1781 switch (urb->status) { 1813 1782 /* success */ ··· 1818 1793 default: /* other error, resubmit */ 1819 1794 retval = usb_submit_urb(ni_priv->interrupt_urb, GFP_ATOMIC); 1820 1795 if (retval) 1821 - dev_err(&usb_dev->dev, "%s: failed to resubmit interrupt urb\n", __func__); 1796 + dev_err(&usb_dev->dev, "failed to resubmit interrupt urb\n"); 1822 1797 return; 1823 1798 } 1824 1799 1825 1800 ni_usb_parse_status_block(urb->transfer_buffer, &status); 1826 - // printk("debug: ibsta=0x%x\n", status.ibsta); 1827 1801 1828 1802 spin_lock_irqsave(&board->spinlock, flags); 1829 1803 ni_priv->monitored_ibsta_bits &= ~status.ibsta; 1830 - // printk("debug: monitored_ibsta_bits=0x%x\n", ni_priv->monitored_ibsta_bits); 1831 1804 spin_unlock_irqrestore(&board->spinlock, flags); 1832 1805 1833 1806 wake_up_interruptible(&board->wait); 1834 1807 1835 1808 retval = usb_submit_urb(ni_priv->interrupt_urb, GFP_ATOMIC); 1836 1809 if (retval) 1837 - dev_err(&usb_dev->dev, "%s: failed to resubmit interrupt urb\n", __func__); 1810 + dev_err(&usb_dev->dev, "failed to resubmit interrupt urb\n"); 1838 1811 } 1839 1812 1840 - static int ni_usb_set_interrupt_monitor(gpib_board_t *board, unsigned int monitored_bits) 1813 + static int ni_usb_set_interrupt_monitor(struct gpib_board *board, unsigned int monitored_bits) 1841 1814 { 1842 1815 int retval; 1843 1816 struct ni_usb_priv *ni_priv = board->private_data; ··· 1844 1821 u8 *buffer; 1845 1822 struct ni_usb_status_block status; 1846 1823 unsigned long flags; 1847 - //printk("%s: receive control pipe is %i\n", __func__, pipe); 1824 + 1848 1825 buffer = kmalloc(buffer_length, GFP_KERNEL); 1849 1826 if (!buffer) 1850 1827 return -ENOMEM; 1851 1828 1852 1829 spin_lock_irqsave(&board->spinlock, flags); 1853 1830 ni_priv->monitored_ibsta_bits = ni_usb_ibsta_monitor_mask & monitored_bits; 1854 - // dev_err(&usb_dev->dev, "debug: %s: monitored_ibsta_bits=0x%x\n", 1855 - // __func__, ni_priv->monitored_ibsta_bits); 1856 1831 spin_unlock_irqrestore(&board->spinlock, flags); 1857 1832 retval = ni_usb_receive_control_msg(ni_priv, NI_USB_WAIT_REQUEST, USB_DIR_IN | 1858 1833 USB_TYPE_VENDOR | USB_RECIP_DEVICE, 1859 1834 0x300, ni_usb_ibsta_monitor_mask & monitored_bits, 1860 1835 buffer, buffer_length, 1000); 1861 1836 if (retval != buffer_length) { 1862 - dev_err(&usb_dev->dev, "%s: usb_control_msg returned %i\n", __func__, retval); 1837 + dev_err(&usb_dev->dev, "usb_control_msg returned %i\n", retval); 1863 1838 kfree(buffer); 1864 1839 return -1; 1865 1840 } ··· 1866 1845 return 0; 1867 1846 } 1868 1847 1869 - static int ni_usb_setup_urbs(gpib_board_t *board) 1848 + static int ni_usb_setup_urbs(struct gpib_board *board) 1870 1849 { 1871 1850 struct ni_usb_priv *ni_priv = board->private_data; 1872 1851 struct usb_device *usb_dev; ··· 1893 1872 retval = usb_submit_urb(ni_priv->interrupt_urb, GFP_KERNEL); 1894 1873 mutex_unlock(&ni_priv->interrupt_transfer_lock); 1895 1874 if (retval) { 1896 - dev_err(&usb_dev->dev, "%s: failed to submit first interrupt urb, retval=%i\n", 1897 - __func__, retval); 1875 + dev_err(&usb_dev->dev, "failed to submit first interrupt urb, retval=%i\n", retval); 1898 1876 return retval; 1899 1877 } 1900 1878 return 0; ··· 1924 1904 int j; 1925 1905 unsigned int serial_number; 1926 1906 1927 - // printk("%s: %s\n", __func__); 1928 1907 in_data = kmalloc(in_data_length, GFP_KERNEL); 1929 1908 if (!in_data) 1930 1909 return -ENOMEM; ··· 1943 1924 i += ni_usb_bulk_termination(&out_data[i]); 1944 1925 retval = ni_usb_send_bulk_msg(ni_priv, out_data, out_data_length, &bytes_written, 1000); 1945 1926 if (retval) { 1946 - dev_err(&usb_dev->dev, "%s: ni_usb_send_bulk_msg returned %i, bytes_written=%i, i=%li\n", 1947 - __func__, 1927 + dev_err(&usb_dev->dev, "send_bulk_msg returned %i, bytes_written=%i, i=%li\n", 1948 1928 retval, bytes_written, (long)out_data_length); 1949 1929 goto serial_out; 1950 1930 } 1951 1931 retval = ni_usb_receive_bulk_msg(ni_priv, in_data, in_data_length, &bytes_read, 1000, 0); 1952 1932 if (retval) { 1953 - dev_err(&usb_dev->dev, "%s: ni_usb_receive_bulk_msg returned %i, bytes_read=%i\n", 1954 - __func__, retval, bytes_read); 1933 + dev_err(&usb_dev->dev, "receive_bulk_msg returned %i, bytes_read=%i\n", 1934 + retval, bytes_read); 1955 1935 ni_usb_dump_raw_block(in_data, bytes_read); 1956 1936 goto serial_out; 1957 1937 } 1958 1938 if (ARRAY_SIZE(results) < num_reads) { 1959 - dev_err(&usb_dev->dev, "Setup bug\n"); 1939 + dev_err(&usb_dev->dev, "serial number eetup bug\n"); 1960 1940 retval = -EINVAL; 1961 1941 goto serial_out; 1962 1942 } ··· 1963 1945 serial_number = 0; 1964 1946 for (j = 0; j < num_reads; ++j) 1965 1947 serial_number |= (results[j] & 0xff) << (8 * j); 1966 - dev_info(&usb_dev->dev, "%s: board serial number is 0x%x\n", __func__, serial_number); 1948 + dev_dbg(&usb_dev->dev, "board serial number is 0x%x\n", serial_number); 1967 1949 retval = 0; 1968 1950 serial_out: 1969 1951 kfree(in_data); ··· 1991 1973 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 1992 1974 0x0, 0x0, buffer, buffer_size, 1000); 1993 1975 if (retval < 0) { 1994 - dev_err(&usb_dev->dev, "%s: usb_control_msg request 0x%x returned %i\n", 1995 - __func__, NI_USB_SERIAL_NUMBER_REQUEST, retval); 1976 + dev_err(&usb_dev->dev, "usb_control_msg request 0x%x returned %i\n", 1977 + NI_USB_SERIAL_NUMBER_REQUEST, retval); 1996 1978 goto ready_out; 1997 1979 } 1998 1980 j = 0; 1999 1981 if (buffer[j] != NI_USB_SERIAL_NUMBER_REQUEST) { 2000 - dev_err(&usb_dev->dev, "%s: unexpected data: buffer[%i]=0x%x, expected 0x%x\n", 2001 - __func__, j, (int)buffer[j], NI_USB_SERIAL_NUMBER_REQUEST); 1982 + dev_err(&usb_dev->dev, "unexpected data: buffer[%i]=0x%x, expected 0x%x\n", 1983 + j, (int)buffer[j], NI_USB_SERIAL_NUMBER_REQUEST); 2002 1984 unexpected = 1; 2003 1985 } 2004 1986 if (unexpected) 2005 1987 ni_usb_dump_raw_block(buffer, retval); 2006 1988 // NI-USB-HS+ pads the serial with 0x0 to make 16 bytes 2007 1989 if (retval != 5 && retval != 16) { 2008 - dev_err(&usb_dev->dev, "%s: received unexpected number of bytes = %i, expected 5 or 16\n", 2009 - __func__, retval); 1990 + dev_err(&usb_dev->dev, "received unexpected number of bytes = %i, expected 5 or 16\n", 1991 + retval); 2010 1992 ni_usb_dump_raw_block(buffer, retval); 2011 1993 } 2012 1994 serial_number = 0; ··· 2014 1996 serial_number |= (buffer[++j] << 8); 2015 1997 serial_number |= (buffer[++j] << 16); 2016 1998 serial_number |= (buffer[++j] << 24); 2017 - dev_info(&usb_dev->dev, "%s: board serial number is 0x%x\n", __func__, serial_number); 1999 + dev_dbg(&usb_dev->dev, "board serial number is 0x%x\n", serial_number); 2018 2000 for (i = 0; i < timeout; ++i) { 2019 2001 int ready = 0; 2020 2002 ··· 2022 2004 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 2023 2005 0x0, 0x0, buffer, buffer_size, 100); 2024 2006 if (retval < 0) { 2025 - dev_err(&usb_dev->dev, "%s: usb_control_msg request 0x%x returned %i\n", 2026 - __func__, NI_USB_POLL_READY_REQUEST, retval); 2007 + dev_err(&usb_dev->dev, "usb_control_msg request 0x%x returned %i\n", 2008 + NI_USB_POLL_READY_REQUEST, retval); 2027 2009 goto ready_out; 2028 2010 } 2029 2011 j = 0; 2030 2012 unexpected = 0; 2031 2013 if (buffer[j] != NI_USB_POLL_READY_REQUEST) { // [0] 2032 - dev_err(&usb_dev->dev, "%s: unexpected data: buffer[%i]=0x%x, expected 0x%x\n", 2033 - __func__, j, (int)buffer[j], NI_USB_POLL_READY_REQUEST); 2014 + dev_err(&usb_dev->dev, "unexpected data: buffer[%i]=0x%x, expected 0x%x\n", 2015 + j, (int)buffer[j], NI_USB_POLL_READY_REQUEST); 2034 2016 unexpected = 1; 2035 2017 } 2036 2018 ++j; 2037 2019 if (buffer[j] != 0x1 && buffer[j] != 0x0) { // [1] HS+ sends 0x0 2038 - dev_err(&usb_dev->dev, "%s: unexpected data: buffer[%i]=0x%x, expected 0x1 or 0x0\n", 2039 - __func__, j, (int)buffer[j]); 2020 + dev_err(&usb_dev->dev, "unexpected data: buffer[%i]=0x%x, expected 0x1 or 0x0\n", 2021 + j, (int)buffer[j]); 2040 2022 unexpected = 1; 2041 2023 } 2042 2024 if (buffer[++j] != 0x0) { // [2] 2043 - dev_err(&usb_dev->dev, "%s: unexpected data: buffer[%i]=0x%x, expected 0x%x\n", 2044 - __func__, j, (int)buffer[j], 0x0); 2025 + dev_err(&usb_dev->dev, "unexpected data: buffer[%i]=0x%x, expected 0x%x\n", 2026 + j, (int)buffer[j], 0x0); 2045 2027 unexpected = 1; 2046 2028 } 2047 2029 ++j; ··· 2049 2031 // NI-USB-HS+ sends 0x0 2050 2032 if (buffer[j] != 0x1 && buffer[j] != 0x8 && buffer[j] != 0x7 && buffer[j] != 0x0) { 2051 2033 // [3] 2052 - dev_err(&usb_dev->dev, "%s: unexpected data: buffer[%i]=0x%x, expected 0x0, 0x1, 0x7 or 0x8\n", 2053 - __func__, j, (int)buffer[j]); 2034 + dev_err(&usb_dev->dev, "unexpected data: buffer[%i]=0x%x, expected 0x0, 0x1, 0x7 or 0x8\n", 2035 + j, (int)buffer[j]); 2054 2036 unexpected = 1; 2055 2037 } 2056 2038 ++j; 2057 2039 // NI-USB-HS+ sends 0 here 2058 2040 if (buffer[j] != 0x30 && buffer[j] != 0x0) { // [4] 2059 - dev_err(&usb_dev->dev, "%s: unexpected data: buffer[%i]=0x%x, expected 0x0 or 0x30\n", 2060 - __func__, j, (int)buffer[j]); 2041 + dev_err(&usb_dev->dev, "unexpected data: buffer[%i]=0x%x, expected 0x0 or 0x30\n", 2042 + j, (int)buffer[j]); 2061 2043 unexpected = 1; 2062 2044 } 2063 2045 ++j; 2064 2046 // MC usb-488 (and sometimes NI-USB-HS?) and NI-USB-HS+ sends 0x0 here 2065 2047 if (buffer[j] != 0x1 && buffer[j] != 0x0) { // [5] 2066 - dev_err(&usb_dev->dev, "%s: unexpected data: buffer[%i]=0x%x, expected 0x1 or 0x0\n", 2067 - __func__, j, (int)buffer[j]); 2048 + dev_err(&usb_dev->dev, "unexpected data: buffer[%i]=0x%x, expected 0x1 or 0x0\n", 2049 + j, (int)buffer[j]); 2068 2050 unexpected = 1; 2069 2051 } 2070 2052 if (buffer[++j] != 0x0) { // [6] ··· 2072 2054 // NI-USB-HS+ sends 0xf here 2073 2055 if (buffer[j] != 0x2 && buffer[j] != 0xe && buffer[j] != 0xf && 2074 2056 buffer[j] != 0x16) { 2075 - dev_err(&usb_dev->dev, "%s: unexpected data: buffer[%i]=0x%x, expected 0x2, 0xe, 0xf or 0x16\n", 2076 - __func__, j, (int)buffer[j]); 2057 + dev_err(&usb_dev->dev, "unexpected data: buffer[%i]=0x%x, expected 0x2, 0xe, 0xf or 0x16\n", 2058 + j, (int)buffer[j]); 2077 2059 unexpected = 1; 2078 2060 } 2079 2061 } ··· 2082 2064 // MC usb-488 sends 0x5 here; MC usb-488A sends 0x6 here 2083 2065 if (buffer[j] != 0x3 && buffer[j] != 0x5 && buffer[j] != 0x6 && 2084 2066 buffer[j] != 0x8) { 2085 - dev_err(&usb_dev->dev, "%s: unexpected data: buffer[%i]=0x%x, expected 0x3 or 0x5, 0x6 or 0x08\n", 2086 - __func__, j, (int)buffer[j]); 2067 + dev_err(&usb_dev->dev, "unexpected data: buffer[%i]=0x%x, expected 0x3 or 0x5, 0x6 or 0x08\n", 2068 + j, (int)buffer[j]); 2087 2069 unexpected = 1; 2088 2070 } 2089 2071 } 2090 2072 ++j; 2091 2073 if (buffer[j] != 0x0 && buffer[j] != 0x2) { // [8] MC usb-488 sends 0x2 here 2092 - dev_err(&usb_dev->dev, "%s: unexpected data: buffer[%i]=0x%x, expected 0x0 or 0x2\n", 2093 - __func__, j, (int)buffer[j]); 2074 + dev_err(&usb_dev->dev, " unexpected data: buffer[%i]=0x%x, expected 0x0 or 0x2\n", 2075 + j, (int)buffer[j]); 2094 2076 unexpected = 1; 2095 2077 } 2096 2078 ++j; 2097 2079 // MC usb-488A and NI-USB-HS sends 0x3 here; NI-USB-HS+ sends 0x30 here 2098 2080 if (buffer[j] != 0x0 && buffer[j] != 0x3 && buffer[j] != 0x30) { // [9] 2099 - dev_err(&usb_dev->dev, "%s: unexpected data: buffer[%i]=0x%x, expected 0x0, 0x3 or 0x30\n", 2100 - __func__, j, (int)buffer[j]); 2081 + dev_err(&usb_dev->dev, "unexpected data: buffer[%i]=0x%x, expected 0x0, 0x3 or 0x30\n", 2082 + j, (int)buffer[j]); 2101 2083 unexpected = 1; 2102 2084 } 2103 2085 if (buffer[++j] != 0x0) { 2104 2086 ready = 1; 2105 2087 if (buffer[j] != 0x96 && buffer[j] != 0x7 && buffer[j] != 0x6e) { 2106 2088 // [10] MC usb-488 sends 0x7 here 2107 - dev_err(&usb_dev->dev, "%s: unexpected data: buffer[%i]=0x%x, expected 0x96, 0x07 or 0x6e\n", 2108 - __func__, j, (int)buffer[j]); 2089 + dev_err(&usb_dev->dev, "unexpected data: buffer[%i]=0x%x, expected 0x96, 0x07 or 0x6e\n", 2090 + j, (int)buffer[j]); 2109 2091 unexpected = 1; 2110 2092 } 2111 2093 } ··· 2115 2097 break; 2116 2098 retval = msleep_interruptible(msec_sleep_duration); 2117 2099 if (retval) { 2118 - dev_err(&usb_dev->dev, "ni_usb_gpib: msleep interrupted\n"); 2119 2100 retval = -ERESTARTSYS; 2120 2101 goto ready_out; 2121 2102 } ··· 2123 2106 2124 2107 ready_out: 2125 2108 kfree(buffer); 2126 - dev_dbg(&usb_dev->dev, "%s: exit retval=%d\n", __func__, retval); 2109 + dev_dbg(&usb_dev->dev, "exit retval=%d\n", retval); 2127 2110 return retval; 2128 2111 } 2129 2112 ··· 2151 2134 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 2152 2135 0x0, 0x0, buffer, transfer_size, 1000); 2153 2136 if (retval < 0) { 2154 - dev_err(&usb_dev->dev, "%s: usb_control_msg request 0x%x returned %i\n", 2155 - __func__, NI_USB_HS_PLUS_0x48_REQUEST, retval); 2137 + dev_err(&usb_dev->dev, "usb_control_msg request 0x%x returned %i\n", 2138 + NI_USB_HS_PLUS_0x48_REQUEST, retval); 2156 2139 break; 2157 2140 } 2158 2141 // expected response data: 48 f3 30 00 00 00 00 00 00 00 00 00 00 00 00 00 2159 2142 if (buffer[0] != NI_USB_HS_PLUS_0x48_REQUEST) 2160 - dev_err(&usb_dev->dev, "%s: unexpected data: buffer[0]=0x%x, expected 0x%x\n", 2161 - __func__, (int)buffer[0], NI_USB_HS_PLUS_0x48_REQUEST); 2143 + dev_err(&usb_dev->dev, "unexpected data: buffer[0]=0x%x, expected 0x%x\n", 2144 + (int)buffer[0], NI_USB_HS_PLUS_0x48_REQUEST); 2162 2145 2163 2146 transfer_size = 2; 2164 2147 ··· 2166 2149 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 2167 2150 0x1, 0x0, buffer, transfer_size, 1000); 2168 2151 if (retval < 0) { 2169 - dev_err(&usb_dev->dev, "%s: usb_control_msg request 0x%x returned %i\n", 2170 - __func__, NI_USB_HS_PLUS_LED_REQUEST, retval); 2152 + dev_err(&usb_dev->dev, "usb_control_msg request 0x%x returned %i\n", 2153 + NI_USB_HS_PLUS_LED_REQUEST, retval); 2171 2154 break; 2172 2155 } 2173 2156 // expected response data: 4b 00 2174 2157 if (buffer[0] != NI_USB_HS_PLUS_LED_REQUEST) 2175 - dev_err(&usb_dev->dev, "%s: unexpected data: buffer[0]=0x%x, expected 0x%x\n", 2176 - __func__, (int)buffer[0], NI_USB_HS_PLUS_LED_REQUEST); 2158 + dev_err(&usb_dev->dev, "unexpected data: buffer[0]=0x%x, expected 0x%x\n", 2159 + (int)buffer[0], NI_USB_HS_PLUS_LED_REQUEST); 2177 2160 2178 2161 transfer_size = 9; 2179 2162 ··· 2182 2165 USB_RECIP_INTERFACE, 2183 2166 0x0, 0x1, buffer, transfer_size, 1000); 2184 2167 if (retval < 0) { 2185 - dev_err(&usb_dev->dev, "%s: usb_control_msg request 0x%x returned %i\n", 2186 - __func__, NI_USB_HS_PLUS_0xf8_REQUEST, retval); 2168 + dev_err(&usb_dev->dev, "usb_control_msg request 0x%x returned %i\n", 2169 + NI_USB_HS_PLUS_0xf8_REQUEST, retval); 2187 2170 break; 2188 2171 } 2189 2172 // expected response data: f8 01 00 00 00 01 00 00 00 2190 2173 if (buffer[0] != NI_USB_HS_PLUS_0xf8_REQUEST) 2191 - dev_err(&usb_dev->dev, "%s: unexpected data: buffer[0]=0x%x, expected 0x%x\n", 2192 - __func__, (int)buffer[0], NI_USB_HS_PLUS_0xf8_REQUEST); 2193 - 2174 + dev_err(&usb_dev->dev, "unexpected data: buffer[0]=0x%x, expected 0x%x\n", 2175 + (int)buffer[0], NI_USB_HS_PLUS_0xf8_REQUEST); 2194 2176 } while (0); 2195 2177 2196 2178 // cleanup ··· 2205 2189 return 1; 2206 2190 } 2207 2191 2208 - static int ni_usb_attach(gpib_board_t *board, const gpib_board_config_t *config) 2192 + static int ni_usb_attach(struct gpib_board *board, const gpib_board_config_t *config) 2209 2193 { 2210 2194 int retval; 2211 - int i; 2195 + int i, index; 2212 2196 struct ni_usb_priv *ni_priv; 2213 2197 int product_id; 2214 2198 struct usb_device *usb_dev; ··· 2227 2211 ni_priv->bus_interface = ni_usb_driver_interfaces[i]; 2228 2212 usb_set_intfdata(ni_usb_driver_interfaces[i], board); 2229 2213 usb_dev = interface_to_usbdev(ni_priv->bus_interface); 2230 - dev_info(&usb_dev->dev, 2231 - "bus %d dev num %d attached to gpib minor %d, NI usb interface %i\n", 2232 - usb_dev->bus->busnum, usb_dev->devnum, board->minor, i); 2214 + index = i; 2233 2215 break; 2234 2216 } 2235 2217 } 2236 2218 if (i == MAX_NUM_NI_USB_INTERFACES) { 2237 2219 mutex_unlock(&ni_usb_hotplug_lock); 2238 - pr_err("No supported NI usb gpib adapters found, have you loaded its firmware?\n"); 2220 + dev_err(board->gpib_dev, "No supported adapters found, have you loaded its firmware?\n"); 2239 2221 return -ENODEV; 2240 2222 } 2241 2223 if (usb_reset_configuration(interface_to_usbdev(ni_priv->bus_interface))) 2242 - dev_err(&usb_dev->dev, "ni_usb_gpib: usb_reset_configuration() failed.\n"); 2224 + dev_err(&usb_dev->dev, "usb_reset_configuration() failed.\n"); 2243 2225 2244 2226 product_id = le16_to_cpu(usb_dev->descriptor.idProduct); 2245 2227 ni_priv->product_id = product_id; ··· 2310 2296 } 2311 2297 2312 2298 mutex_unlock(&ni_usb_hotplug_lock); 2313 - dev_info(&usb_dev->dev, "%s: attached\n", __func__); 2299 + dev_info(&usb_dev->dev, 2300 + "bus %d dev num %d attached to gpib%d, intf %i\n", 2301 + usb_dev->bus->busnum, usb_dev->devnum, board->minor, index); 2314 2302 return retval; 2315 2303 } 2316 2304 ··· 2320 2304 { 2321 2305 struct usb_device *usb_dev = interface_to_usbdev(ni_priv->bus_interface); 2322 2306 int retval; 2323 - int i = 0; 2324 2307 struct ni_usb_register writes[2]; 2325 2308 static const int writes_length = ARRAY_SIZE(writes); 2326 2309 unsigned int ibsta; 2327 2310 2328 - // printk("%s: %s\n", __func__); 2329 - writes[i].device = NIUSB_SUBDEV_TNT4882; 2330 - writes[i].address = nec7210_to_tnt4882_offset(AUXMR); 2331 - writes[i].value = AUX_CR; 2332 - i++; 2333 - writes[i].device = NIUSB_SUBDEV_UNKNOWN3; 2334 - writes[i].address = 0x10; 2335 - writes[i].value = 0x0; 2336 - i++; 2337 - if (i > writes_length) { 2338 - dev_err(&usb_dev->dev, "%s: bug!, buffer overrun, i=%i\n", __func__, i); 2339 - return -EINVAL; 2340 - } 2341 - retval = ni_usb_write_registers(ni_priv, writes, i, &ibsta); 2311 + writes[0].device = NIUSB_SUBDEV_TNT4882; 2312 + writes[0].address = nec7210_to_tnt4882_offset(AUXMR); 2313 + writes[0].value = AUX_CR; 2314 + writes[1].device = NIUSB_SUBDEV_UNKNOWN3; 2315 + writes[1].address = 0x10; 2316 + writes[1].value = 0x0; 2317 + retval = ni_usb_write_registers(ni_priv, writes, writes_length, &ibsta); 2342 2318 if (retval) { 2343 - dev_err(&usb_dev->dev, "%s: register write failed, retval=%i\n", __func__, retval); 2319 + dev_err(&usb_dev->dev, "register write failed, retval=%i\n", retval); 2344 2320 return retval; 2345 2321 } 2346 2322 return 0; 2347 2323 } 2348 2324 2349 - static void ni_usb_detach(gpib_board_t *board) 2325 + static void ni_usb_detach(struct gpib_board *board) 2350 2326 { 2351 2327 struct ni_usb_priv *ni_priv; 2352 2328 ··· 2421 2413 if (i == MAX_NUM_NI_USB_INTERFACES) { 2422 2414 usb_put_dev(usb_dev); 2423 2415 mutex_unlock(&ni_usb_hotplug_lock); 2424 - dev_err(&usb_dev->dev, "%s: ni_usb_driver_interfaces[] full\n", __func__); 2416 + dev_err(&usb_dev->dev, "ni_usb_driver_interfaces[] full\n"); 2425 2417 return -1; 2426 2418 } 2427 2419 path = kmalloc(path_length, GFP_KERNEL); ··· 2431 2423 return -ENOMEM; 2432 2424 } 2433 2425 usb_make_path(usb_dev, path, path_length); 2434 - dev_info(&usb_dev->dev, "ni_usb_gpib: probe succeeded for path: %s\n", path); 2426 + dev_info(&usb_dev->dev, "probe succeeded for path: %s\n", path); 2435 2427 kfree(path); 2436 2428 mutex_unlock(&ni_usb_hotplug_lock); 2437 2429 return 0; ··· 2445 2437 mutex_lock(&ni_usb_hotplug_lock); 2446 2438 for (i = 0; i < MAX_NUM_NI_USB_INTERFACES; i++) { 2447 2439 if (ni_usb_driver_interfaces[i] == interface) { 2448 - gpib_board_t *board = usb_get_intfdata(interface); 2440 + struct gpib_board *board = usb_get_intfdata(interface); 2449 2441 2450 2442 if (board) { 2451 2443 struct ni_usb_priv *ni_priv = board->private_data; ··· 2466 2458 } 2467 2459 } 2468 2460 if (i == MAX_NUM_NI_USB_INTERFACES) 2469 - dev_err(&usb_dev->dev, "%s: unable to find interface in ni_usb_driver_interfaces[]? bug?\n", 2470 - __func__); 2461 + dev_err(&usb_dev->dev, "unable to find interface bug?\n"); 2471 2462 usb_put_dev(usb_dev); 2472 2463 mutex_unlock(&ni_usb_hotplug_lock); 2473 2464 } ··· 2474 2467 static int ni_usb_driver_suspend(struct usb_interface *interface, pm_message_t message) 2475 2468 { 2476 2469 struct usb_device *usb_dev = interface_to_usbdev(interface); 2477 - gpib_board_t *board; 2470 + struct gpib_board *board; 2478 2471 int i, retval; 2479 2472 2480 2473 mutex_lock(&ni_usb_hotplug_lock); ··· 2505 2498 ni_usb_cleanup_urbs(ni_priv); 2506 2499 mutex_unlock(&ni_priv->interrupt_transfer_lock); 2507 2500 } 2508 - dev_info(&usb_dev->dev, 2509 - "bus %d dev num %d gpib minor %d, ni usb interface %i suspended\n", 2510 - usb_dev->bus->busnum, usb_dev->devnum, board->minor, i); 2501 + dev_dbg(&usb_dev->dev, 2502 + "bus %d dev num %d gpib%d, interface %i suspended\n", 2503 + usb_dev->bus->busnum, usb_dev->devnum, board->minor, i); 2511 2504 } 2512 2505 2513 2506 mutex_unlock(&ni_usb_hotplug_lock); ··· 2518 2511 { 2519 2512 struct usb_device *usb_dev = interface_to_usbdev(interface); 2520 2513 2521 - gpib_board_t *board; 2514 + struct gpib_board *board; 2522 2515 int i, retval; 2523 2516 2524 2517 mutex_lock(&ni_usb_hotplug_lock); ··· 2542 2535 mutex_lock(&ni_priv->interrupt_transfer_lock); 2543 2536 retval = usb_submit_urb(ni_priv->interrupt_urb, GFP_KERNEL); 2544 2537 if (retval) { 2545 - dev_err(&usb_dev->dev, "%s: failed to resubmit interrupt urb, retval=%i\n", 2546 - __func__, retval); 2538 + dev_err(&usb_dev->dev, "resume failed to resubmit interrupt urb, retval=%i\n", 2539 + retval); 2547 2540 mutex_unlock(&ni_priv->interrupt_transfer_lock); 2548 2541 mutex_unlock(&ni_usb_hotplug_lock); 2549 2542 return retval; 2550 2543 } 2551 2544 mutex_unlock(&ni_priv->interrupt_transfer_lock); 2552 2545 } else { 2553 - dev_err(&usb_dev->dev, "%s: bug! int urb not set up\n", __func__); 2546 + dev_err(&usb_dev->dev, "bug! resume int urb not set up\n"); 2554 2547 mutex_unlock(&ni_usb_hotplug_lock); 2555 2548 return -EINVAL; 2556 2549 } ··· 2607 2600 if (ni_priv->ren_state) 2608 2601 ni_usb_remote_enable(board, 1); 2609 2602 2610 - dev_info(&usb_dev->dev, 2611 - "bus %d dev num %d gpib minor %d, ni usb interface %i resumed\n", 2612 - usb_dev->bus->busnum, usb_dev->devnum, board->minor, i); 2603 + dev_dbg(&usb_dev->dev, 2604 + "bus %d dev num %d gpib%d, interface %i resumed\n", 2605 + usb_dev->bus->busnum, usb_dev->devnum, board->minor, i); 2613 2606 } 2614 2607 2615 2608 mutex_unlock(&ni_usb_hotplug_lock); ··· 2617 2610 } 2618 2611 2619 2612 static struct usb_driver ni_usb_bus_driver = { 2620 - .name = "ni_usb_gpib", 2613 + .name = DRV_NAME, 2621 2614 .probe = ni_usb_driver_probe, 2622 2615 .disconnect = ni_usb_driver_disconnect, 2623 2616 .suspend = ni_usb_driver_suspend, ··· 2630 2623 int i; 2631 2624 int ret; 2632 2625 2633 - pr_info("ni_usb_gpib driver loading\n"); 2634 2626 for (i = 0; i < MAX_NUM_NI_USB_INTERFACES; i++) 2635 2627 ni_usb_driver_interfaces[i] = NULL; 2636 2628 2637 2629 ret = usb_register(&ni_usb_bus_driver); 2638 2630 if (ret) { 2639 - pr_err("ni_usb_gpib: usb_register failed: error = %d\n", ret); 2631 + pr_err("usb_register failed: error = %d\n", ret); 2640 2632 return ret; 2641 2633 } 2642 2634 2643 2635 ret = gpib_register_driver(&ni_usb_gpib_interface, THIS_MODULE); 2644 2636 if (ret) { 2645 - pr_err("ni_usb_gpib: gpib_register_driver failed: error = %d\n", ret); 2637 + pr_err("gpib_register_driver failed: error = %d\n", ret); 2646 2638 return ret; 2647 2639 } 2648 2640 ··· 2650 2644 2651 2645 static void __exit ni_usb_exit_module(void) 2652 2646 { 2653 - pr_info("ni_usb_gpib driver unloading\n"); 2654 2647 gpib_unregister_driver(&ni_usb_gpib_interface); 2655 2648 usb_deregister(&ni_usb_bus_driver); 2656 2649 }
+314 -318
drivers/staging/gpib/pc2/pc2_gpib.c
··· 4 4 * copyright : (C) 2001, 2002 by Frank Mori Hess 5 5 ***************************************************************************/ 6 6 7 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 8 + #define dev_fmt pr_fmt 9 + 7 10 #include <linux/ioport.h> 8 11 #include <linux/sched.h> 9 12 #include <linux/module.h> ··· 52 49 MODULE_LICENSE("GPL"); 53 50 MODULE_DESCRIPTION("GPIB driver for PC2/PC2a and compatible devices"); 54 51 55 - static int pc2_attach(gpib_board_t *board, const gpib_board_config_t *config); 56 - static int pc2a_attach(gpib_board_t *board, const gpib_board_config_t *config); 57 - static int pc2a_cb7210_attach(gpib_board_t *board, const gpib_board_config_t *config); 58 - static int pc2_2a_attach(gpib_board_t *board, const gpib_board_config_t *config); 59 - 60 - static void pc2_detach(gpib_board_t *board); 61 - static void pc2a_detach(gpib_board_t *board); 62 - static void pc2_2a_detach(gpib_board_t *board); 63 - 64 52 /* 65 53 * GPIB interrupt service routines 66 54 */ 67 55 68 56 irqreturn_t pc2_interrupt(int irq, void *arg) 69 57 { 70 - gpib_board_t *board = arg; 58 + struct gpib_board *board = arg; 71 59 struct pc2_priv *priv = board->private_data; 72 60 unsigned long flags; 73 61 irqreturn_t retval; ··· 71 77 72 78 irqreturn_t pc2a_interrupt(int irq, void *arg) 73 79 { 74 - gpib_board_t *board = arg; 80 + struct gpib_board *board = arg; 75 81 struct pc2_priv *priv = board->private_data; 76 82 int status1, status2; 77 83 unsigned long flags; ··· 90 96 } 91 97 92 98 // wrappers for interface functions 93 - static int pc2_read(gpib_board_t *board, uint8_t *buffer, size_t length, int *end, 99 + static int pc2_read(struct gpib_board *board, uint8_t *buffer, size_t length, int *end, 94 100 size_t *bytes_read) 95 101 { 96 102 struct pc2_priv *priv = board->private_data; ··· 98 104 return nec7210_read(board, &priv->nec7210_priv, buffer, length, end, bytes_read); 99 105 } 100 106 101 - static int pc2_write(gpib_board_t *board, uint8_t *buffer, size_t length, int send_eoi, 107 + static int pc2_write(struct gpib_board *board, uint8_t *buffer, size_t length, int send_eoi, 102 108 size_t *bytes_written) 103 109 { 104 110 struct pc2_priv *priv = board->private_data; ··· 106 112 return nec7210_write(board, &priv->nec7210_priv, buffer, length, send_eoi, bytes_written); 107 113 } 108 114 109 - static int pc2_command(gpib_board_t *board, uint8_t *buffer, size_t length, size_t *bytes_written) 115 + static int pc2_command(struct gpib_board *board, uint8_t *buffer, size_t length, size_t *bytes_written) 110 116 { 111 117 struct pc2_priv *priv = board->private_data; 112 118 113 119 return nec7210_command(board, &priv->nec7210_priv, buffer, length, bytes_written); 114 120 } 115 121 116 - static int pc2_take_control(gpib_board_t *board, int synchronous) 122 + static int pc2_take_control(struct gpib_board *board, int synchronous) 117 123 { 118 124 struct pc2_priv *priv = board->private_data; 119 125 120 126 return nec7210_take_control(board, &priv->nec7210_priv, synchronous); 121 127 } 122 128 123 - static int pc2_go_to_standby(gpib_board_t *board) 129 + static int pc2_go_to_standby(struct gpib_board *board) 124 130 { 125 131 struct pc2_priv *priv = board->private_data; 126 132 127 133 return nec7210_go_to_standby(board, &priv->nec7210_priv); 128 134 } 129 135 130 - static void pc2_request_system_control(gpib_board_t *board, int request_control) 136 + static void pc2_request_system_control(struct gpib_board *board, int request_control) 131 137 { 132 138 struct pc2_priv *priv = board->private_data; 133 139 134 140 nec7210_request_system_control(board, &priv->nec7210_priv, request_control); 135 141 } 136 142 137 - static void pc2_interface_clear(gpib_board_t *board, int assert) 143 + static void pc2_interface_clear(struct gpib_board *board, int assert) 138 144 { 139 145 struct pc2_priv *priv = board->private_data; 140 146 141 147 nec7210_interface_clear(board, &priv->nec7210_priv, assert); 142 148 } 143 149 144 - static void pc2_remote_enable(gpib_board_t *board, int enable) 150 + static void pc2_remote_enable(struct gpib_board *board, int enable) 145 151 { 146 152 struct pc2_priv *priv = board->private_data; 147 153 148 154 nec7210_remote_enable(board, &priv->nec7210_priv, enable); 149 155 } 150 156 151 - static int pc2_enable_eos(gpib_board_t *board, uint8_t eos_byte, int compare_8_bits) 157 + static int pc2_enable_eos(struct gpib_board *board, uint8_t eos_byte, int compare_8_bits) 152 158 { 153 159 struct pc2_priv *priv = board->private_data; 154 160 155 161 return nec7210_enable_eos(board, &priv->nec7210_priv, eos_byte, compare_8_bits); 156 162 } 157 163 158 - static void pc2_disable_eos(gpib_board_t *board) 164 + static void pc2_disable_eos(struct gpib_board *board) 159 165 { 160 166 struct pc2_priv *priv = board->private_data; 161 167 162 168 nec7210_disable_eos(board, &priv->nec7210_priv); 163 169 } 164 170 165 - static unsigned int pc2_update_status(gpib_board_t *board, unsigned int clear_mask) 171 + static unsigned int pc2_update_status(struct gpib_board *board, unsigned int clear_mask) 166 172 { 167 173 struct pc2_priv *priv = board->private_data; 168 174 169 175 return nec7210_update_status(board, &priv->nec7210_priv, clear_mask); 170 176 } 171 177 172 - static int pc2_primary_address(gpib_board_t *board, unsigned int address) 178 + static int pc2_primary_address(struct gpib_board *board, unsigned int address) 173 179 { 174 180 struct pc2_priv *priv = board->private_data; 175 181 176 182 return nec7210_primary_address(board, &priv->nec7210_priv, address); 177 183 } 178 184 179 - static int pc2_secondary_address(gpib_board_t *board, unsigned int address, int enable) 185 + static int pc2_secondary_address(struct gpib_board *board, unsigned int address, int enable) 180 186 { 181 187 struct pc2_priv *priv = board->private_data; 182 188 183 189 return nec7210_secondary_address(board, &priv->nec7210_priv, address, enable); 184 190 } 185 191 186 - static int pc2_parallel_poll(gpib_board_t *board, uint8_t *result) 192 + static int pc2_parallel_poll(struct gpib_board *board, uint8_t *result) 187 193 { 188 194 struct pc2_priv *priv = board->private_data; 189 195 190 196 return nec7210_parallel_poll(board, &priv->nec7210_priv, result); 191 197 } 192 198 193 - static void pc2_parallel_poll_configure(gpib_board_t *board, uint8_t config) 199 + static void pc2_parallel_poll_configure(struct gpib_board *board, uint8_t config) 194 200 { 195 201 struct pc2_priv *priv = board->private_data; 196 202 197 203 nec7210_parallel_poll_configure(board, &priv->nec7210_priv, config); 198 204 } 199 205 200 - static void pc2_parallel_poll_response(gpib_board_t *board, int ist) 206 + static void pc2_parallel_poll_response(struct gpib_board *board, int ist) 201 207 { 202 208 struct pc2_priv *priv = board->private_data; 203 209 204 210 nec7210_parallel_poll_response(board, &priv->nec7210_priv, ist); 205 211 } 206 212 207 - static void pc2_serial_poll_response(gpib_board_t *board, uint8_t status) 213 + static void pc2_serial_poll_response(struct gpib_board *board, uint8_t status) 208 214 { 209 215 struct pc2_priv *priv = board->private_data; 210 216 211 217 nec7210_serial_poll_response(board, &priv->nec7210_priv, status); 212 218 } 213 219 214 - static uint8_t pc2_serial_poll_status(gpib_board_t *board) 220 + static uint8_t pc2_serial_poll_status(struct gpib_board *board) 215 221 { 216 222 struct pc2_priv *priv = board->private_data; 217 223 218 224 return nec7210_serial_poll_status(board, &priv->nec7210_priv); 219 225 } 220 226 221 - static unsigned int pc2_t1_delay(gpib_board_t *board, unsigned int nano_sec) 227 + static int pc2_t1_delay(struct gpib_board *board, unsigned int nano_sec) 222 228 { 223 229 struct pc2_priv *priv = board->private_data; 224 230 225 231 return nec7210_t1_delay(board, &priv->nec7210_priv, nano_sec); 226 232 } 227 233 228 - static void pc2_return_to_local(gpib_board_t *board) 234 + static void pc2_return_to_local(struct gpib_board *board) 229 235 { 230 236 struct pc2_priv *priv = board->private_data; 231 237 232 238 nec7210_return_to_local(board, &priv->nec7210_priv); 239 + } 240 + 241 + static int allocate_private(struct gpib_board *board) 242 + { 243 + struct pc2_priv *priv; 244 + 245 + board->private_data = kmalloc(sizeof(struct pc2_priv), GFP_KERNEL); 246 + if (!board->private_data) 247 + return -1; 248 + priv = board->private_data; 249 + memset(priv, 0, sizeof(struct pc2_priv)); 250 + init_nec7210_private(&priv->nec7210_priv); 251 + return 0; 252 + } 253 + 254 + static void free_private(struct gpib_board *board) 255 + { 256 + kfree(board->private_data); 257 + board->private_data = NULL; 258 + } 259 + 260 + static int pc2_generic_attach(struct gpib_board *board, const gpib_board_config_t *config, 261 + enum nec7210_chipset chipset) 262 + { 263 + struct pc2_priv *pc2_priv; 264 + struct nec7210_priv *nec_priv; 265 + 266 + board->status = 0; 267 + if (allocate_private(board)) 268 + return -ENOMEM; 269 + pc2_priv = board->private_data; 270 + nec_priv = &pc2_priv->nec7210_priv; 271 + nec_priv->read_byte = nec7210_ioport_read_byte; 272 + nec_priv->write_byte = nec7210_ioport_write_byte; 273 + nec_priv->type = chipset; 274 + 275 + #ifndef PC2_DMA 276 + /* board->dev hasn't been initialized, so forget about DMA until this driver 277 + * is adapted to use isa_register_driver. 278 + */ 279 + if (config->ibdma) 280 + // driver needs to be adapted to use isa_register_driver to get a struct device* 281 + dev_err(board->gpib_dev, "DMA disabled for pc2 gpib"); 282 + #else 283 + if (config->ibdma) { 284 + nec_priv->dma_buffer_length = 0x1000; 285 + nec_priv->dma_buffer = dma_alloc_coherent(board->dev, 286 + nec_priv->dma_buffer_length, & 287 + nec_priv->dma_buffer_addr, GFP_ATOMIC); 288 + if (!nec_priv->dma_buffer) 289 + return -ENOMEM; 290 + 291 + // request isa dma channel 292 + if (request_dma(config->ibdma, "pc2")) { 293 + dev_err(board->gpib_dev, "can't request DMA %d\n", config->ibdma); 294 + return -1; 295 + } 296 + nec_priv->dma_channel = config->ibdma; 297 + } 298 + #endif 299 + 300 + return 0; 301 + } 302 + 303 + static int pc2_attach(struct gpib_board *board, const gpib_board_config_t *config) 304 + { 305 + int isr_flags = 0; 306 + struct pc2_priv *pc2_priv; 307 + struct nec7210_priv *nec_priv; 308 + int retval; 309 + 310 + retval = pc2_generic_attach(board, config, NEC7210); 311 + if (retval) 312 + return retval; 313 + 314 + pc2_priv = board->private_data; 315 + nec_priv = &pc2_priv->nec7210_priv; 316 + nec_priv->offset = pc2_reg_offset; 317 + 318 + if (!request_region(config->ibbase, pc2_iosize, "pc2")) { 319 + dev_err(board->gpib_dev, "ioports are already in use\n"); 320 + return -EBUSY; 321 + } 322 + nec_priv->iobase = config->ibbase; 323 + 324 + nec7210_board_reset(nec_priv, board); 325 + 326 + // install interrupt handler 327 + if (config->ibirq) { 328 + if (request_irq(config->ibirq, pc2_interrupt, isr_flags, "pc2", board)) { 329 + dev_err(board->gpib_dev, "can't request IRQ %d\n", config->ibirq); 330 + return -EBUSY; 331 + } 332 + } 333 + pc2_priv->irq = config->ibirq; 334 + /* poll so we can detect assertion of ATN */ 335 + if (gpib_request_pseudo_irq(board, pc2_interrupt)) { 336 + dev_err(board->gpib_dev, "failed to allocate pseudo_irq\n"); 337 + return -1; 338 + } 339 + /* set internal counter register for 8 MHz input clock */ 340 + write_byte(nec_priv, ICR | 8, AUXMR); 341 + 342 + nec7210_board_online(nec_priv, board); 343 + 344 + return 0; 345 + } 346 + 347 + static void pc2_detach(struct gpib_board *board) 348 + { 349 + struct pc2_priv *pc2_priv = board->private_data; 350 + struct nec7210_priv *nec_priv; 351 + 352 + if (pc2_priv) { 353 + nec_priv = &pc2_priv->nec7210_priv; 354 + #ifdef PC2_DMA 355 + if (nec_priv->dma_channel) 356 + free_dma(nec_priv->dma_channel); 357 + #endif 358 + gpib_free_pseudo_irq(board); 359 + if (pc2_priv->irq) 360 + free_irq(pc2_priv->irq, board); 361 + if (nec_priv->iobase) { 362 + nec7210_board_reset(nec_priv, board); 363 + release_region(nec_priv->iobase, pc2_iosize); 364 + } 365 + if (nec_priv->dma_buffer) { 366 + dma_free_coherent(board->dev, nec_priv->dma_buffer_length, 367 + nec_priv->dma_buffer, nec_priv->dma_buffer_addr); 368 + nec_priv->dma_buffer = NULL; 369 + } 370 + } 371 + free_private(board); 372 + } 373 + 374 + static int pc2a_common_attach(struct gpib_board *board, const gpib_board_config_t *config, 375 + unsigned int num_registers, enum nec7210_chipset chipset) 376 + { 377 + unsigned int i, j; 378 + struct pc2_priv *pc2_priv; 379 + struct nec7210_priv *nec_priv; 380 + int retval; 381 + 382 + retval = pc2_generic_attach(board, config, chipset); 383 + if (retval) 384 + return retval; 385 + 386 + pc2_priv = board->private_data; 387 + nec_priv = &pc2_priv->nec7210_priv; 388 + nec_priv->offset = pc2a_reg_offset; 389 + 390 + switch (config->ibbase) { 391 + case 0x02e1: 392 + case 0x22e1: 393 + case 0x42e1: 394 + case 0x62e1: 395 + break; 396 + default: 397 + dev_err(board->gpib_dev, "PCIIa base range invalid, must be one of 0x[0246]2e1, but is 0x%x\n", 398 + config->ibbase); 399 + return -1; 400 + } 401 + 402 + if (config->ibirq) { 403 + if (config->ibirq < 2 || config->ibirq > 7) { 404 + dev_err(board->gpib_dev, "illegal interrupt level %i\n", 405 + config->ibirq); 406 + return -1; 407 + } 408 + } else { 409 + dev_err(board->gpib_dev, "interrupt disabled, using polling mode (slow)\n"); 410 + } 411 + #ifdef CHECK_IOPORTS 412 + unsigned int err = 0; 413 + 414 + for (i = 0; i < num_registers; i++) { 415 + if (check_region(config->ibbase + i * pc2a_reg_offset, 1)) 416 + err++; 417 + } 418 + if (config->ibirq && check_region(pc2a_clear_intr_iobase + config->ibirq, 1)) 419 + err++; 420 + if (err) { 421 + dev_err(board->gpib_dev, "ioports are already in use"); 422 + return -EBUSY; 423 + } 424 + #endif 425 + for (i = 0; i < num_registers; i++) { 426 + if (!request_region(config->ibbase + 427 + i * pc2a_reg_offset, 1, "pc2a")) { 428 + dev_err(board->gpib_dev, "ioports are already in use"); 429 + for (j = 0; j < i; j++) 430 + release_region(config->ibbase + 431 + j * pc2a_reg_offset, 1); 432 + return -EBUSY; 433 + } 434 + } 435 + nec_priv->iobase = config->ibbase; 436 + if (config->ibirq) { 437 + if (!request_region(pc2a_clear_intr_iobase + config->ibirq, 1, "pc2a")) { 438 + dev_err(board->gpib_dev, "ioports are already in use"); 439 + return -1; 440 + } 441 + pc2_priv->clear_intr_addr = pc2a_clear_intr_iobase + config->ibirq; 442 + if (request_irq(config->ibirq, pc2a_interrupt, 0, "pc2a", board)) { 443 + dev_err(board->gpib_dev, "can't request IRQ %d\n", config->ibirq); 444 + return -EBUSY; 445 + } 446 + } 447 + pc2_priv->irq = config->ibirq; 448 + /* poll so we can detect assertion of ATN */ 449 + if (gpib_request_pseudo_irq(board, pc2_interrupt)) { 450 + dev_err(board->gpib_dev, "failed to allocate pseudo_irq\n"); 451 + return -1; 452 + } 453 + 454 + // make sure interrupt is clear 455 + if (pc2_priv->irq) 456 + outb(0xff, CLEAR_INTR_REG(pc2_priv->irq)); 457 + 458 + nec7210_board_reset(nec_priv, board); 459 + 460 + /* set internal counter register for 8 MHz input clock */ 461 + write_byte(nec_priv, ICR | 8, AUXMR); 462 + 463 + nec7210_board_online(nec_priv, board); 464 + 465 + return 0; 466 + } 467 + 468 + static int pc2a_attach(struct gpib_board *board, const gpib_board_config_t *config) 469 + { 470 + return pc2a_common_attach(board, config, pc2a_iosize, NEC7210); 471 + } 472 + 473 + static int pc2a_cb7210_attach(struct gpib_board *board, const gpib_board_config_t *config) 474 + { 475 + return pc2a_common_attach(board, config, pc2a_iosize, CB7210); 476 + } 477 + 478 + static int pc2_2a_attach(struct gpib_board *board, const gpib_board_config_t *config) 479 + { 480 + return pc2a_common_attach(board, config, pc2_2a_iosize, NAT4882); 481 + } 482 + 483 + static void pc2a_common_detach(struct gpib_board *board, unsigned int num_registers) 484 + { 485 + int i; 486 + struct pc2_priv *pc2_priv = board->private_data; 487 + struct nec7210_priv *nec_priv; 488 + 489 + if (pc2_priv) { 490 + nec_priv = &pc2_priv->nec7210_priv; 491 + #ifdef PC2_DMA 492 + if (nec_priv->dma_channel) 493 + free_dma(nec_priv->dma_channel); 494 + #endif 495 + gpib_free_pseudo_irq(board); 496 + if (pc2_priv->irq) 497 + free_irq(pc2_priv->irq, board); 498 + if (nec_priv->iobase) { 499 + nec7210_board_reset(nec_priv, board); 500 + for (i = 0; i < num_registers; i++) 501 + release_region(nec_priv->iobase + 502 + i * pc2a_reg_offset, 1); 503 + } 504 + if (pc2_priv->clear_intr_addr) 505 + release_region(pc2_priv->clear_intr_addr, 1); 506 + if (nec_priv->dma_buffer) { 507 + dma_free_coherent(board->dev, nec_priv->dma_buffer_length, 508 + nec_priv->dma_buffer, 509 + nec_priv->dma_buffer_addr); 510 + nec_priv->dma_buffer = NULL; 511 + } 512 + } 513 + free_private(board); 514 + } 515 + 516 + static void pc2a_detach(struct gpib_board *board) 517 + { 518 + pc2a_common_detach(board, pc2a_iosize); 519 + } 520 + 521 + static void pc2_2a_detach(struct gpib_board *board) 522 + { 523 + pc2a_common_detach(board, pc2_2a_iosize); 233 524 } 234 525 235 526 static gpib_interface_t pc2_interface = { ··· 629 350 .return_to_local = pc2_return_to_local, 630 351 }; 631 352 632 - static int allocate_private(gpib_board_t *board) 633 - { 634 - struct pc2_priv *priv; 635 - 636 - board->private_data = kmalloc(sizeof(struct pc2_priv), GFP_KERNEL); 637 - if (!board->private_data) 638 - return -1; 639 - priv = board->private_data; 640 - memset(priv, 0, sizeof(struct pc2_priv)); 641 - init_nec7210_private(&priv->nec7210_priv); 642 - return 0; 643 - } 644 - 645 - static void free_private(gpib_board_t *board) 646 - { 647 - kfree(board->private_data); 648 - board->private_data = NULL; 649 - } 650 - 651 - static int pc2_generic_attach(gpib_board_t *board, const gpib_board_config_t *config, 652 - enum nec7210_chipset chipset) 653 - { 654 - struct pc2_priv *pc2_priv; 655 - struct nec7210_priv *nec_priv; 656 - 657 - board->status = 0; 658 - if (allocate_private(board)) 659 - return -ENOMEM; 660 - pc2_priv = board->private_data; 661 - nec_priv = &pc2_priv->nec7210_priv; 662 - nec_priv->read_byte = nec7210_ioport_read_byte; 663 - nec_priv->write_byte = nec7210_ioport_write_byte; 664 - nec_priv->type = chipset; 665 - 666 - #ifndef PC2_DMA 667 - /* board->dev hasn't been initialized, so forget about DMA until this driver 668 - * is adapted to use isa_register_driver. 669 - */ 670 - if (config->ibdma) 671 - pr_err("DMA disabled for pc2 gpib, driver needs to be adapted to use isa_register_driver to get a struct device*"); 672 - #else 673 - if (config->ibdma) { 674 - nec_priv->dma_buffer_length = 0x1000; 675 - nec_priv->dma_buffer = dma_alloc_coherent(board->dev, 676 - nec_priv->dma_buffer_length, & 677 - nec_priv->dma_buffer_addr, GFP_ATOMIC); 678 - if (!nec_priv->dma_buffer) 679 - return -ENOMEM; 680 - 681 - // request isa dma channel 682 - if (request_dma(config->ibdma, "pc2")) { 683 - pr_err("gpib: can't request DMA %d\n", config->ibdma); 684 - return -1; 685 - } 686 - nec_priv->dma_channel = config->ibdma; 687 - } 688 - #endif 689 - 690 - return 0; 691 - } 692 - 693 - int pc2_attach(gpib_board_t *board, const gpib_board_config_t *config) 694 - { 695 - int isr_flags = 0; 696 - struct pc2_priv *pc2_priv; 697 - struct nec7210_priv *nec_priv; 698 - int retval; 699 - 700 - retval = pc2_generic_attach(board, config, NEC7210); 701 - if (retval) 702 - return retval; 703 - 704 - pc2_priv = board->private_data; 705 - nec_priv = &pc2_priv->nec7210_priv; 706 - nec_priv->offset = pc2_reg_offset; 707 - 708 - if (!request_region(config->ibbase, pc2_iosize, "pc2")) { 709 - pr_err("gpib: ioports are already in use\n"); 710 - return -1; 711 - } 712 - nec_priv->iobase = config->ibbase; 713 - 714 - nec7210_board_reset(nec_priv, board); 715 - 716 - // install interrupt handler 717 - if (config->ibirq) { 718 - if (request_irq(config->ibirq, pc2_interrupt, isr_flags, "pc2", board)) { 719 - pr_err("gpib: can't request IRQ %d\n", config->ibirq); 720 - return -1; 721 - } 722 - } 723 - pc2_priv->irq = config->ibirq; 724 - /* poll so we can detect assertion of ATN */ 725 - if (gpib_request_pseudo_irq(board, pc2_interrupt)) { 726 - pr_err("pc2_gpib: failed to allocate pseudo_irq\n"); 727 - return -1; 728 - } 729 - /* set internal counter register for 8 MHz input clock */ 730 - write_byte(nec_priv, ICR | 8, AUXMR); 731 - 732 - nec7210_board_online(nec_priv, board); 733 - 734 - return 0; 735 - } 736 - 737 - void pc2_detach(gpib_board_t *board) 738 - { 739 - struct pc2_priv *pc2_priv = board->private_data; 740 - struct nec7210_priv *nec_priv; 741 - 742 - if (pc2_priv) { 743 - nec_priv = &pc2_priv->nec7210_priv; 744 - #ifdef PC2_DMA 745 - if (nec_priv->dma_channel) 746 - free_dma(nec_priv->dma_channel); 747 - #endif 748 - gpib_free_pseudo_irq(board); 749 - if (pc2_priv->irq) 750 - free_irq(pc2_priv->irq, board); 751 - if (nec_priv->iobase) { 752 - nec7210_board_reset(nec_priv, board); 753 - release_region(nec_priv->iobase, pc2_iosize); 754 - } 755 - if (nec_priv->dma_buffer) { 756 - dma_free_coherent(board->dev, nec_priv->dma_buffer_length, 757 - nec_priv->dma_buffer, nec_priv->dma_buffer_addr); 758 - nec_priv->dma_buffer = NULL; 759 - } 760 - } 761 - free_private(board); 762 - } 763 - 764 - static int pc2a_common_attach(gpib_board_t *board, const gpib_board_config_t *config, 765 - unsigned int num_registers, enum nec7210_chipset chipset) 766 - { 767 - unsigned int i, j; 768 - struct pc2_priv *pc2_priv; 769 - struct nec7210_priv *nec_priv; 770 - int retval; 771 - 772 - retval = pc2_generic_attach(board, config, chipset); 773 - if (retval) 774 - return retval; 775 - 776 - pc2_priv = board->private_data; 777 - nec_priv = &pc2_priv->nec7210_priv; 778 - nec_priv->offset = pc2a_reg_offset; 779 - 780 - switch (config->ibbase) { 781 - case 0x02e1: 782 - case 0x22e1: 783 - case 0x42e1: 784 - case 0x62e1: 785 - break; 786 - default: 787 - pr_err("PCIIa base range invalid, must be one of 0x[0246]2e1, but is 0x%d\n", 788 - config->ibbase); 789 - return -1; 790 - } 791 - 792 - if (config->ibirq) { 793 - if (config->ibirq < 2 || config->ibirq > 7) { 794 - pr_err("pc2_gpib: illegal interrupt level %i\n", config->ibirq); 795 - return -1; 796 - } 797 - } else { 798 - pr_err("pc2_gpib: interrupt disabled, using polling mode (slow)\n"); 799 - } 800 - #ifdef CHECK_IOPORTS 801 - unsigned int err = 0; 802 - 803 - for (i = 0; i < num_registers; i++) { 804 - if (check_region(config->ibbase + i * pc2a_reg_offset, 1)) 805 - err++; 806 - } 807 - if (config->ibirq && check_region(pc2a_clear_intr_iobase + config->ibirq, 1)) 808 - err++; 809 - if (err) { 810 - pr_err("gpib: ioports are already in use"); 811 - return -1; 812 - } 813 - #endif 814 - for (i = 0; i < num_registers; i++) { 815 - if (!request_region(config->ibbase + 816 - i * pc2a_reg_offset, 1, "pc2a")) { 817 - pr_err("gpib: ioports are already in use"); 818 - for (j = 0; j < i; j++) 819 - release_region(config->ibbase + 820 - j * pc2a_reg_offset, 1); 821 - return -1; 822 - } 823 - } 824 - nec_priv->iobase = config->ibbase; 825 - if (config->ibirq) { 826 - if (!request_region(pc2a_clear_intr_iobase + config->ibirq, 1, "pc2a")) { 827 - pr_err("gpib: ioports are already in use"); 828 - return -1; 829 - } 830 - pc2_priv->clear_intr_addr = pc2a_clear_intr_iobase + config->ibirq; 831 - if (request_irq(config->ibirq, pc2a_interrupt, 0, "pc2a", board)) { 832 - pr_err("gpib: can't request IRQ %d\n", config->ibirq); 833 - return -1; 834 - } 835 - } 836 - pc2_priv->irq = config->ibirq; 837 - /* poll so we can detect assertion of ATN */ 838 - if (gpib_request_pseudo_irq(board, pc2_interrupt)) { 839 - pr_err("pc2_gpib: failed to allocate pseudo_irq\n"); 840 - return -1; 841 - } 842 - 843 - // make sure interrupt is clear 844 - if (pc2_priv->irq) 845 - outb(0xff, CLEAR_INTR_REG(pc2_priv->irq)); 846 - 847 - nec7210_board_reset(nec_priv, board); 848 - 849 - /* set internal counter register for 8 MHz input clock */ 850 - write_byte(nec_priv, ICR | 8, AUXMR); 851 - 852 - nec7210_board_online(nec_priv, board); 853 - 854 - return 0; 855 - } 856 - 857 - int pc2a_attach(gpib_board_t *board, const gpib_board_config_t *config) 858 - { 859 - return pc2a_common_attach(board, config, pc2a_iosize, NEC7210); 860 - } 861 - 862 - int pc2a_cb7210_attach(gpib_board_t *board, const gpib_board_config_t *config) 863 - { 864 - return pc2a_common_attach(board, config, pc2a_iosize, CB7210); 865 - } 866 - 867 - int pc2_2a_attach(gpib_board_t *board, const gpib_board_config_t *config) 868 - { 869 - return pc2a_common_attach(board, config, pc2_2a_iosize, NAT4882); 870 - } 871 - 872 - static void pc2a_common_detach(gpib_board_t *board, unsigned int num_registers) 873 - { 874 - int i; 875 - struct pc2_priv *pc2_priv = board->private_data; 876 - struct nec7210_priv *nec_priv; 877 - 878 - if (pc2_priv) { 879 - nec_priv = &pc2_priv->nec7210_priv; 880 - #ifdef PC2_DMA 881 - if (nec_priv->dma_channel) 882 - free_dma(nec_priv->dma_channel); 883 - #endif 884 - gpib_free_pseudo_irq(board); 885 - if (pc2_priv->irq) 886 - free_irq(pc2_priv->irq, board); 887 - if (nec_priv->iobase) { 888 - nec7210_board_reset(nec_priv, board); 889 - for (i = 0; i < num_registers; i++) 890 - release_region(nec_priv->iobase + 891 - i * pc2a_reg_offset, 1); 892 - } 893 - if (pc2_priv->clear_intr_addr) 894 - release_region(pc2_priv->clear_intr_addr, 1); 895 - if (nec_priv->dma_buffer) { 896 - dma_free_coherent(board->dev, nec_priv->dma_buffer_length, 897 - nec_priv->dma_buffer, 898 - nec_priv->dma_buffer_addr); 899 - nec_priv->dma_buffer = NULL; 900 - } 901 - } 902 - free_private(board); 903 - } 904 - 905 - void pc2a_detach(gpib_board_t *board) 906 - { 907 - pc2a_common_detach(board, pc2a_iosize); 908 - } 909 - 910 - void pc2_2a_detach(gpib_board_t *board) 911 - { 912 - pc2a_common_detach(board, pc2_2a_iosize); 913 - } 914 - 915 353 static int __init pc2_init_module(void) 916 354 { 917 355 int ret; 918 356 919 357 ret = gpib_register_driver(&pc2_interface, THIS_MODULE); 920 358 if (ret) { 921 - pr_err("pc2_gpib: gpib_register_driver failed: error = %d\n", ret); 359 + pr_err("gpib_register_driver failed: error = %d\n", ret); 922 360 return ret; 923 361 } 924 362 925 363 ret = gpib_register_driver(&pc2a_interface, THIS_MODULE); 926 364 if (ret) { 927 - pr_err("pc2_gpib: gpib_register_driver failed: error = %d\n", ret); 365 + pr_err("gpib_register_driver failed: error = %d\n", ret); 928 366 goto err_pc2a; 929 367 } 930 368 931 369 ret = gpib_register_driver(&pc2a_cb7210_interface, THIS_MODULE); 932 370 if (ret) { 933 - pr_err("pc2_gpib: gpib_register_driver failed: error = %d\n", ret); 371 + pr_err("gpib_register_driver failed: error = %d\n", ret); 934 372 goto err_cb7210; 935 373 } 936 374 937 375 ret = gpib_register_driver(&pc2_2a_interface, THIS_MODULE); 938 376 if (ret) { 939 - pr_err("pc2_gpib: gpib_register_driver failed: error = %d\n", ret); 377 + pr_err("gpib_register_driver failed: error = %d\n", ret); 940 378 goto err_pc2_2a; 941 379 } 942 380
+56 -61
drivers/staging/gpib/tms9914/tms9914.c
··· 4 4 * copyright : (C) 2001, 2002 by Frank Mori Hess 5 5 ***************************************************************************/ 6 6 7 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 8 + #define dev_fmt pr_fmt 9 + 7 10 #include <linux/ioport.h> 8 11 #include <linux/sched.h> 9 12 #include <linux/module.h> ··· 27 24 MODULE_LICENSE("GPL"); 28 25 MODULE_DESCRIPTION("GPIB library for tms9914"); 29 26 30 - static unsigned int update_status_nolock(gpib_board_t *board, struct tms9914_priv *priv); 27 + static unsigned int update_status_nolock(struct gpib_board *board, struct tms9914_priv *priv); 31 28 32 - int tms9914_take_control(gpib_board_t *board, struct tms9914_priv *priv, int synchronous) 29 + int tms9914_take_control(struct gpib_board *board, struct tms9914_priv *priv, int synchronous) 33 30 { 34 31 int i; 35 32 const int timeout = 100; ··· 66 63 * The rest of the tms9914 based drivers still use tms9914_take_control 67 64 * directly (which does issue tcs). 68 65 */ 69 - int tms9914_take_control_workaround(gpib_board_t *board, struct tms9914_priv *priv, int synchronous) 66 + int tms9914_take_control_workaround(struct gpib_board *board, struct tms9914_priv *priv, int synchronous) 70 67 { 71 68 if (synchronous) 72 69 return -ETIMEDOUT; ··· 74 71 } 75 72 EXPORT_SYMBOL_GPL(tms9914_take_control_workaround); 76 73 77 - int tms9914_go_to_standby(gpib_board_t *board, struct tms9914_priv *priv) 74 + int tms9914_go_to_standby(struct gpib_board *board, struct tms9914_priv *priv) 78 75 { 79 76 int i; 80 77 const int timeout = 1000; ··· 86 83 break; 87 84 udelay(1); 88 85 } 89 - if (i == timeout) { 90 - pr_err("error waiting for NATN\n"); 86 + if (i == timeout) 91 87 return -ETIMEDOUT; 92 - } 93 88 94 89 clear_bit(COMMAND_READY_BN, &priv->state); 95 90 ··· 95 94 } 96 95 EXPORT_SYMBOL_GPL(tms9914_go_to_standby); 97 96 98 - void tms9914_interface_clear(gpib_board_t *board, struct tms9914_priv *priv, int assert) 97 + void tms9914_interface_clear(struct gpib_board *board, struct tms9914_priv *priv, int assert) 99 98 { 100 99 if (assert) { 101 100 write_byte(priv, AUX_SIC | AUX_CS, AUXCR); ··· 107 106 } 108 107 EXPORT_SYMBOL_GPL(tms9914_interface_clear); 109 108 110 - void tms9914_remote_enable(gpib_board_t *board, struct tms9914_priv *priv, int enable) 109 + void tms9914_remote_enable(struct gpib_board *board, struct tms9914_priv *priv, int enable) 111 110 { 112 111 if (enable) 113 112 write_byte(priv, AUX_SRE | AUX_CS, AUXCR); ··· 116 115 } 117 116 EXPORT_SYMBOL_GPL(tms9914_remote_enable); 118 117 119 - void tms9914_request_system_control(gpib_board_t *board, struct tms9914_priv *priv, 118 + void tms9914_request_system_control(struct gpib_board *board, struct tms9914_priv *priv, 120 119 int request_control) 121 120 { 122 121 if (request_control) { ··· 128 127 } 129 128 EXPORT_SYMBOL_GPL(tms9914_request_system_control); 130 129 131 - unsigned int tms9914_t1_delay(gpib_board_t *board, struct tms9914_priv *priv, 130 + unsigned int tms9914_t1_delay(struct gpib_board *board, struct tms9914_priv *priv, 132 131 unsigned int nano_sec) 133 132 { 134 133 static const int clock_period = 200; // assuming 5Mhz input clock ··· 154 153 } 155 154 EXPORT_SYMBOL_GPL(tms9914_t1_delay); 156 155 157 - void tms9914_return_to_local(const gpib_board_t *board, struct tms9914_priv *priv) 156 + void tms9914_return_to_local(const struct gpib_board *board, struct tms9914_priv *priv) 158 157 { 159 158 write_byte(priv, AUX_RTL, AUXCR); 160 159 } ··· 176 175 write_byte(priv, AUX_HLDA | AUX_CS, AUXCR); 177 176 break; 178 177 default: 179 - pr_err("%s: bug! bad holdoff mode %i\n", __func__, mode); 178 + pr_err("bug! bad holdoff mode %i\n", mode); 180 179 break; 181 180 } 182 181 priv->holdoff_mode = mode; ··· 192 191 } 193 192 EXPORT_SYMBOL_GPL(tms9914_release_holdoff); 194 193 195 - int tms9914_enable_eos(gpib_board_t *board, struct tms9914_priv *priv, uint8_t eos_byte, 194 + int tms9914_enable_eos(struct gpib_board *board, struct tms9914_priv *priv, uint8_t eos_byte, 196 195 int compare_8_bits) 197 196 { 198 197 priv->eos = eos_byte; ··· 203 202 } 204 203 EXPORT_SYMBOL(tms9914_enable_eos); 205 204 206 - void tms9914_disable_eos(gpib_board_t *board, struct tms9914_priv *priv) 205 + void tms9914_disable_eos(struct gpib_board *board, struct tms9914_priv *priv) 207 206 { 208 207 priv->eos_flags &= ~REOS; 209 208 } 210 209 EXPORT_SYMBOL(tms9914_disable_eos); 211 210 212 - int tms9914_parallel_poll(gpib_board_t *board, struct tms9914_priv *priv, uint8_t *result) 211 + int tms9914_parallel_poll(struct gpib_board *board, struct tms9914_priv *priv, uint8_t *result) 213 212 { 214 213 // execute parallel poll 215 214 write_byte(priv, AUX_CS | AUX_RPP, AUXCR); ··· 234 233 } 235 234 } 236 235 237 - void tms9914_parallel_poll_configure(gpib_board_t *board, 236 + void tms9914_parallel_poll_configure(struct gpib_board *board, 238 237 struct tms9914_priv *priv, uint8_t config) 239 238 { 240 239 priv->ppoll_enable = (config & PPC_DISABLE) == 0; ··· 244 243 } 245 244 EXPORT_SYMBOL(tms9914_parallel_poll_configure); 246 245 247 - void tms9914_parallel_poll_response(gpib_board_t *board, 246 + void tms9914_parallel_poll_response(struct gpib_board *board, 248 247 struct tms9914_priv *priv, int ist) 249 248 { 250 249 set_ppoll_reg(priv, priv->ppoll_enable, priv->ppoll_line, priv->ppoll_sense, ist); 251 250 } 252 251 EXPORT_SYMBOL(tms9914_parallel_poll_response); 253 252 254 - void tms9914_serial_poll_response(gpib_board_t *board, struct tms9914_priv *priv, uint8_t status) 253 + void tms9914_serial_poll_response(struct gpib_board *board, struct tms9914_priv *priv, uint8_t status) 255 254 { 256 255 unsigned long flags; 257 256 ··· 266 265 } 267 266 EXPORT_SYMBOL(tms9914_serial_poll_response); 268 267 269 - uint8_t tms9914_serial_poll_status(gpib_board_t *board, struct tms9914_priv *priv) 268 + uint8_t tms9914_serial_poll_status(struct gpib_board *board, struct tms9914_priv *priv) 270 269 { 271 270 u8 status; 272 271 unsigned long flags; ··· 279 278 } 280 279 EXPORT_SYMBOL(tms9914_serial_poll_status); 281 280 282 - int tms9914_primary_address(gpib_board_t *board, struct tms9914_priv *priv, unsigned int address) 281 + int tms9914_primary_address(struct gpib_board *board, struct tms9914_priv *priv, unsigned int address) 283 282 { 284 283 // put primary address in address0 285 284 write_byte(priv, address & ADDRESS_MASK, ADR); ··· 287 286 } 288 287 EXPORT_SYMBOL(tms9914_primary_address); 289 288 290 - int tms9914_secondary_address(gpib_board_t *board, struct tms9914_priv *priv, 289 + int tms9914_secondary_address(struct gpib_board *board, struct tms9914_priv *priv, 291 290 unsigned int address, int enable) 292 291 { 293 292 if (enable) ··· 300 299 } 301 300 EXPORT_SYMBOL(tms9914_secondary_address); 302 301 303 - unsigned int tms9914_update_status(gpib_board_t *board, struct tms9914_priv *priv, 302 + unsigned int tms9914_update_status(struct gpib_board *board, struct tms9914_priv *priv, 304 303 unsigned int clear_mask) 305 304 { 306 305 unsigned long flags; ··· 342 341 } 343 342 } 344 343 345 - static unsigned int update_status_nolock(gpib_board_t *board, struct tms9914_priv *priv) 344 + static unsigned int update_status_nolock(struct gpib_board *board, struct tms9914_priv *priv) 346 345 { 347 346 int address_status; 348 347 int bsr_bits; ··· 388 387 return board->status; 389 388 } 390 389 391 - int tms9914_line_status(const gpib_board_t *board, struct tms9914_priv *priv) 390 + int tms9914_line_status(const struct gpib_board *board, struct tms9914_priv *priv) 392 391 { 393 392 int bsr_bits; 394 - int status = ValidALL; 393 + int status = VALID_ALL; 395 394 396 395 bsr_bits = read_byte(priv, BSR); 397 396 398 397 if (bsr_bits & BSR_REN_BIT) 399 - status |= BusREN; 398 + status |= BUS_REN; 400 399 if (bsr_bits & BSR_IFC_BIT) 401 - status |= BusIFC; 400 + status |= BUS_IFC; 402 401 if (bsr_bits & BSR_SRQ_BIT) 403 - status |= BusSRQ; 402 + status |= BUS_SRQ; 404 403 if (bsr_bits & BSR_EOI_BIT) 405 - status |= BusEOI; 404 + status |= BUS_EOI; 406 405 if (bsr_bits & BSR_NRFD_BIT) 407 - status |= BusNRFD; 406 + status |= BUS_NRFD; 408 407 if (bsr_bits & BSR_NDAC_BIT) 409 - status |= BusNDAC; 408 + status |= BUS_NDAC; 410 409 if (bsr_bits & BSR_DAV_BIT) 411 - status |= BusDAV; 410 + status |= BUS_DAV; 412 411 if (bsr_bits & BSR_ATN_BIT) 413 - status |= BusATN; 412 + status |= BUS_ATN; 414 413 415 414 return status; 416 415 } ··· 433 432 return 0; 434 433 } 435 434 436 - static int wait_for_read_byte(gpib_board_t *board, struct tms9914_priv *priv) 435 + static int wait_for_read_byte(struct gpib_board *board, struct tms9914_priv *priv) 437 436 { 438 437 if (wait_event_interruptible(board->wait, 439 438 test_bit(READ_READY_BN, &priv->state) || 440 439 test_bit(DEV_CLEAR_BN, &priv->state) || 441 - test_bit(TIMO_NUM, &board->status))) { 442 - pr_debug("gpib: pio read wait interrupted\n"); 440 + test_bit(TIMO_NUM, &board->status))) 443 441 return -ERESTARTSYS; 444 - } 442 + 445 443 if (test_bit(TIMO_NUM, &board->status)) 446 444 return -ETIMEDOUT; 447 445 ··· 449 449 return 0; 450 450 } 451 451 452 - static inline uint8_t tms9914_read_data_in(gpib_board_t *board, struct tms9914_priv *priv, int *end) 452 + static inline uint8_t tms9914_read_data_in(struct gpib_board *board, struct tms9914_priv *priv, int *end) 453 453 { 454 454 unsigned long flags; 455 455 u8 data; ··· 472 472 case TMS9914_HOLDOFF_NONE: 473 473 break; 474 474 default: 475 - pr_err("%s: bug! bad holdoff mode %i\n", __func__, priv->holdoff_mode); 475 + dev_err(board->gpib_dev, "bug! bad holdoff mode %i\n", priv->holdoff_mode); 476 476 break; 477 477 } 478 478 spin_unlock_irqrestore(&board->spinlock, flags); ··· 480 480 return data; 481 481 } 482 482 483 - static int pio_read(gpib_board_t *board, struct tms9914_priv *priv, uint8_t *buffer, 483 + static int pio_read(struct gpib_board *board, struct tms9914_priv *priv, uint8_t *buffer, 484 484 size_t length, int *end, size_t *bytes_read) 485 485 { 486 486 ssize_t retval = 0; ··· 501 501 return retval; 502 502 } 503 503 504 - int tms9914_read(gpib_board_t *board, struct tms9914_priv *priv, uint8_t *buffer, 504 + int tms9914_read(struct gpib_board *board, struct tms9914_priv *priv, uint8_t *buffer, 505 505 size_t length, int *end, size_t *bytes_read) 506 506 { 507 507 ssize_t retval = 0; ··· 541 541 } 542 542 EXPORT_SYMBOL(tms9914_read); 543 543 544 - static int pio_write_wait(gpib_board_t *board, struct tms9914_priv *priv) 544 + static int pio_write_wait(struct gpib_board *board, struct tms9914_priv *priv) 545 545 { 546 546 // wait until next byte is ready to be sent 547 547 if (wait_event_interruptible(board->wait, 548 548 test_bit(WRITE_READY_BN, &priv->state) || 549 549 test_bit(BUS_ERROR_BN, &priv->state) || 550 550 test_bit(DEV_CLEAR_BN, &priv->state) || 551 - test_bit(TIMO_NUM, &board->status))) { 552 - dev_dbg(board->gpib_dev, "gpib write interrupted!\n"); 551 + test_bit(TIMO_NUM, &board->status))) 553 552 return -ERESTARTSYS; 554 - } 553 + 555 554 if (test_bit(TIMO_NUM, &board->status)) 556 555 return -ETIMEDOUT; 557 556 if (test_bit(BUS_ERROR_BN, &priv->state)) ··· 561 562 return 0; 562 563 } 563 564 564 - static int pio_write(gpib_board_t *board, struct tms9914_priv *priv, uint8_t *buffer, 565 + static int pio_write(struct gpib_board *board, struct tms9914_priv *priv, uint8_t *buffer, 565 566 size_t length, size_t *bytes_written) 566 567 { 567 568 ssize_t retval = 0; ··· 585 586 return length; 586 587 } 587 588 588 - int tms9914_write(gpib_board_t *board, struct tms9914_priv *priv, uint8_t *buffer, size_t length, 589 + int tms9914_write(struct gpib_board *board, struct tms9914_priv *priv, uint8_t *buffer, size_t length, 589 590 int send_eoi, size_t *bytes_written) 590 591 { 591 592 ssize_t retval = 0; ··· 620 621 } 621 622 EXPORT_SYMBOL(tms9914_write); 622 623 623 - static void check_my_address_state(gpib_board_t *board, struct tms9914_priv *priv, int cmd_byte) 624 + static void check_my_address_state(struct gpib_board *board, struct tms9914_priv *priv, int cmd_byte) 624 625 { 625 626 if (cmd_byte == MLA(board->pad)) { 626 627 priv->primary_listen_addressed = 1; ··· 655 656 } 656 657 } 657 658 658 - int tms9914_command(gpib_board_t *board, struct tms9914_priv *priv, uint8_t *buffer, 659 + int tms9914_command(struct gpib_board *board, struct tms9914_priv *priv, uint8_t *buffer, 659 660 size_t length, size_t *bytes_written) 660 661 { 661 662 int retval = 0; ··· 666 667 if (wait_event_interruptible(board->wait, 667 668 test_bit(COMMAND_READY_BN, 668 669 &priv->state) || 669 - test_bit(TIMO_NUM, &board->status))) { 670 - pr_debug("gpib command wait interrupted\n"); 670 + test_bit(TIMO_NUM, &board->status))) 671 671 break; 672 - } 673 672 if (test_bit(TIMO_NUM, &board->status)) 674 673 break; 675 674 ··· 692 695 } 693 696 EXPORT_SYMBOL(tms9914_command); 694 697 695 - irqreturn_t tms9914_interrupt(gpib_board_t *board, struct tms9914_priv *priv) 698 + irqreturn_t tms9914_interrupt(struct gpib_board *board, struct tms9914_priv *priv) 696 699 { 697 700 int status0, status1; 698 701 ··· 703 706 } 704 707 EXPORT_SYMBOL(tms9914_interrupt); 705 708 706 - irqreturn_t tms9914_interrupt_have_status(gpib_board_t *board, struct tms9914_priv *priv, 709 + irqreturn_t tms9914_interrupt_have_status(struct gpib_board *board, struct tms9914_priv *priv, 707 710 int status0, int status1) 708 711 { 709 712 // record reception of END ··· 758 761 write_byte(priv, AUX_INVAL, AUXCR); 759 762 } 760 763 } else { 761 - // printk("tms9914: unrecognized gpib command pass thru 0x%x\n", 762 - // command_byte); 763 764 // clear dac holdoff 764 765 write_byte(priv, AUX_INVAL, AUXCR); 765 766 } ··· 794 799 // check for being addressed with secondary addressing 795 800 if (status1 & HR_APT) { 796 801 if (board->sad < 0) 797 - pr_err("tms9914: bug, APT interrupt without secondary addressing?\n"); 802 + dev_err(board->gpib_dev, "bug, APT interrupt without secondary addressing?\n"); 798 803 if ((read_byte(priv, CPTR) & gpib_command_mask) == MSA(board->sad)) 799 804 write_byte(priv, AUX_VAL, AUXCR); 800 805 else ··· 802 807 } 803 808 804 809 if ((status0 & priv->imr0_bits) || (status1 & priv->imr1_bits)) { 805 - // dev_dbg(board->gpib_dev, "isr0 0x%x, imr0 0x%x, isr1 0x%x, imr1 0x%x\n", 806 - // status0, priv->imr0_bits, status1, priv->imr1_bits); 810 + dev_dbg(board->gpib_dev, "isr0 0x%x, imr0 0x%x, isr1 0x%x, imr1 0x%x\n", 811 + status0, priv->imr0_bits, status1, priv->imr1_bits); 807 812 update_status_nolock(board, priv); 808 813 wake_up_interruptible(&board->wait); 809 814 } ··· 837 842 } 838 843 EXPORT_SYMBOL_GPL(tms9914_board_reset); 839 844 840 - void tms9914_online(gpib_board_t *board, struct tms9914_priv *priv) 845 + void tms9914_online(struct gpib_board *board, struct tms9914_priv *priv) 841 846 { 842 847 /* set GPIB address */ 843 848 tms9914_primary_address(board, priv, board->pad);
-1
drivers/staging/gpib/tnt4882/Makefile
··· 1 - ccflags-$(CONFIG_GPIB_PCMCIA) := -DGPIB_PCMCIA 2 1 obj-$(CONFIG_GPIB_NI_PCI_ISA) += tnt4882.o 3 2 4 3 tnt4882-objs := tnt4882_gpib.o mite.o
-17
drivers/staging/gpib/tnt4882/mite.c
··· 88 88 pr_err("mite: failed to remap mite io memory address.\n"); 89 89 return -ENOMEM; 90 90 } 91 - pr_info("mite: 0x%08lx mapped to %p\n", mite->mite_phys_addr, mite->mite_io_addr); 92 91 addr = pci_resource_start(mite->pcidev, 1); 93 92 mite->daq_phys_addr = addr; 94 93 mite->daq_io_addr = ioremap(mite->daq_phys_addr, pci_resource_len(mite->pcidev, 1)); ··· 95 96 pr_err("mite: failed to remap daq io memory address.\n"); 96 97 return -ENOMEM; 97 98 } 98 - pr_info("mite: daq: 0x%08lx mapped to %p\n", mite->daq_phys_addr, mite->daq_io_addr); 99 99 writel(mite->daq_phys_addr | WENAB, mite->mite_io_addr + MITE_IODWBSR); 100 100 mite->used = 1; 101 101 return 0; ··· 130 132 mite->mite_phys_addr = 0; 131 133 } 132 134 mite->used = 0; 133 - } 134 - 135 - void mite_list_devices(void) 136 - { 137 - struct mite_struct *mite, *next; 138 - 139 - pr_info("Available NI PCI device IDs:"); 140 - if (mite_devices) 141 - for (mite = mite_devices; mite; mite = next) { 142 - next = mite->next; 143 - pr_info(" 0x%04x", mite_device_id(mite)); 144 - if (mite->used) 145 - pr_info("(used)"); 146 - } 147 - pr_info("\n"); 148 135 }
+787 -903
drivers/staging/gpib/tnt4882/tnt4882_gpib.c
··· 5 5 * copyright : (C) 2001, 2002 by Frank Mori Hess 6 6 ***************************************************************************/ 7 7 8 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 9 + #define dev_fmt pr_fmt 10 + #define DRV_NAME KBUILD_MODNAME 11 + 8 12 #include <linux/ioport.h> 9 13 #include <linux/sched.h> 10 14 #include <linux/module.h> ··· 51 47 unsigned short auxg_bits; // bits written to auxiliary register G 52 48 }; 53 49 54 - // interface functions 55 - static int tnt4882_read(gpib_board_t *board, uint8_t *buffer, size_t length, 56 - int *end, size_t *bytes_read); 57 - static int tnt4882_accel_read(gpib_board_t *board, uint8_t *buffer, size_t length, 58 - int *end, size_t *bytes_read); 59 - static int tnt4882_write(gpib_board_t *board, uint8_t *buffer, size_t length, 60 - int send_eoi, size_t *bytes_written); 61 - static int tnt4882_accel_write(gpib_board_t *board, uint8_t *buffer, size_t length, 62 - int send_eoi, size_t *bytes_written); 63 - static int tnt4882_command(gpib_board_t *board, uint8_t *buffer, size_t length, 64 - size_t *bytes_written); 65 - static int tnt4882_command_unaccel(gpib_board_t *board, uint8_t *buffer, 66 - size_t length, size_t *bytes_written); 67 - static int tnt4882_take_control(gpib_board_t *board, int synchronous); 68 - static int tnt4882_go_to_standby(gpib_board_t *board); 69 - static void tnt4882_request_system_control(gpib_board_t *board, int request_control); 70 - static void tnt4882_interface_clear(gpib_board_t *board, int assert); 71 - static void tnt4882_remote_enable(gpib_board_t *board, int enable); 72 - static int tnt4882_enable_eos(gpib_board_t *board, uint8_t eos_byte, int 73 - compare_8_bits); 74 - static void tnt4882_disable_eos(gpib_board_t *board); 75 - static unsigned int tnt4882_update_status(gpib_board_t *board, unsigned int clear_mask); 76 - static int tnt4882_primary_address(gpib_board_t *board, unsigned int address); 77 - static int tnt4882_secondary_address(gpib_board_t *board, unsigned int address, 78 - int enable); 79 - static int tnt4882_parallel_poll(gpib_board_t *board, uint8_t *result); 80 - static void tnt4882_parallel_poll_configure(gpib_board_t *board, uint8_t config); 81 - static void tnt4882_parallel_poll_response(gpib_board_t *board, int ist); 82 - static void tnt4882_serial_poll_response(gpib_board_t *board, uint8_t status); 83 - static uint8_t tnt4882_serial_poll_status(gpib_board_t *board); 84 - static int tnt4882_line_status(const gpib_board_t *board); 85 - static unsigned int tnt4882_t1_delay(gpib_board_t *board, unsigned int nano_sec); 86 - static void tnt4882_return_to_local(gpib_board_t *board); 87 - 88 - // interrupt service routines 89 - static irqreturn_t tnt4882_internal_interrupt(gpib_board_t *board); 90 - static irqreturn_t tnt4882_interrupt(int irq, void *arg); 91 - 92 - // utility functions 93 - static int tnt4882_allocate_private(gpib_board_t *board); 94 - static void tnt4882_free_private(gpib_board_t *board); 95 - static void tnt4882_init(struct tnt4882_priv *tnt_priv, const gpib_board_t *board); 96 - static void tnt4882_board_reset(struct tnt4882_priv *tnt_priv, gpib_board_t *board); 50 + static irqreturn_t tnt4882_internal_interrupt(struct gpib_board *board); 97 51 98 52 // register offset for nec7210 compatible registers 99 53 static const int atgpib_reg_offset = 2; ··· 101 139 retval = 0; 102 140 break; 103 141 default: 104 - pr_err("tnt4882: bug! unsupported ni_chipset\n"); 105 142 retval = 0; 106 143 break; 107 144 } ··· 135 174 case NEC7210: 136 175 break; 137 176 default: 138 - pr_err("tnt4882: bug! unsupported ni_chipset\n"); 139 177 break; 140 178 } 141 179 break; ··· 148 188 MODULE_LICENSE("GPL"); 149 189 MODULE_DESCRIPTION("GPIB driver for National Instruments boards using tnt4882 or compatible chips"); 150 190 151 - int tnt4882_line_status(const gpib_board_t *board) 191 + static int tnt4882_line_status(const struct gpib_board *board) 152 192 { 153 - int status = ValidALL; 193 + int status = VALID_ALL; 154 194 int bcsr_bits; 155 195 struct tnt4882_priv *tnt_priv; 156 196 ··· 159 199 bcsr_bits = tnt_readb(tnt_priv, BSR); 160 200 161 201 if (bcsr_bits & BCSR_REN_BIT) 162 - status |= BusREN; 202 + status |= BUS_REN; 163 203 if (bcsr_bits & BCSR_IFC_BIT) 164 - status |= BusIFC; 204 + status |= BUS_IFC; 165 205 if (bcsr_bits & BCSR_SRQ_BIT) 166 - status |= BusSRQ; 206 + status |= BUS_SRQ; 167 207 if (bcsr_bits & BCSR_EOI_BIT) 168 - status |= BusEOI; 208 + status |= BUS_EOI; 169 209 if (bcsr_bits & BCSR_NRFD_BIT) 170 - status |= BusNRFD; 210 + status |= BUS_NRFD; 171 211 if (bcsr_bits & BCSR_NDAC_BIT) 172 - status |= BusNDAC; 212 + status |= BUS_NDAC; 173 213 if (bcsr_bits & BCSR_DAV_BIT) 174 - status |= BusDAV; 214 + status |= BUS_DAV; 175 215 if (bcsr_bits & BCSR_ATN_BIT) 176 - status |= BusATN; 216 + status |= BUS_ATN; 177 217 178 218 return status; 179 219 } 180 220 181 - unsigned int tnt4882_t1_delay(gpib_board_t *board, unsigned int nano_sec) 221 + static int tnt4882_t1_delay(struct gpib_board *board, unsigned int nano_sec) 182 222 { 183 223 struct tnt4882_priv *tnt_priv = board->private_data; 184 224 struct nec7210_priv *nec_priv = &tnt_priv->nec7210_priv; ··· 251 291 return count; 252 292 } 253 293 254 - static void tnt4882_release_holdoff(gpib_board_t *board, struct tnt4882_priv *tnt_priv) 294 + static void tnt4882_release_holdoff(struct gpib_board *board, struct tnt4882_priv *tnt_priv) 255 295 { 256 296 struct nec7210_priv *nec_priv = &tnt_priv->nec7210_priv; 257 297 unsigned short sasr_bits; ··· 274 314 } 275 315 } 276 316 277 - int tnt4882_accel_read(gpib_board_t *board, uint8_t *buffer, size_t length, int *end, 278 - size_t *bytes_read) 317 + static int tnt4882_accel_read(struct gpib_board *board, uint8_t *buffer, size_t length, int *end, 318 + size_t *bytes_read) 279 319 { 280 320 size_t count = 0; 281 321 ssize_t retval = 0; ··· 328 368 test_bit(DEV_CLEAR_BN, &nec_priv->state) || 329 369 test_bit(ADR_CHANGE_BN, &nec_priv->state) || 330 370 test_bit(TIMO_NUM, &board->status))) { 331 - pr_err("tnt4882: read interrupted\n"); 332 371 retval = -ERESTARTSYS; 333 372 break; 334 373 } 335 374 if (test_bit(TIMO_NUM, &board->status)) { 336 - //pr_info("tnt4882: minor %i read timed out\n", board->minor); 337 375 retval = -ETIMEDOUT; 338 376 break; 339 377 } 340 378 if (test_bit(DEV_CLEAR_BN, &nec_priv->state)) { 341 - pr_err("tnt4882: device clear interrupted read\n"); 342 379 retval = -EINTR; 343 380 break; 344 381 } 345 382 if (test_bit(ADR_CHANGE_BN, &nec_priv->state)) { 346 - pr_err("tnt4882: address change interrupted read\n"); 347 383 retval = -EINTR; 348 384 break; 349 385 } ··· 366 410 test_bit(DEV_CLEAR_BN, &nec_priv->state) || 367 411 test_bit(ADR_CHANGE_BN, &nec_priv->state) || 368 412 test_bit(TIMO_NUM, &board->status))) { 369 - pr_err("tnt4882: read interrupted\n"); 370 413 retval = -ERESTARTSYS; 371 414 } 372 415 if (test_bit(TIMO_NUM, &board->status)) 373 - //pr_info("tnt4882: read timed out\n"); 374 416 retval = -ETIMEDOUT; 375 - if (test_bit(DEV_CLEAR_BN, &nec_priv->state)) { 376 - pr_err("tnt4882: device clear interrupted read\n"); 417 + if (test_bit(DEV_CLEAR_BN, &nec_priv->state)) 377 418 retval = -EINTR; 378 - } 379 - if (test_bit(ADR_CHANGE_BN, &nec_priv->state)) { 380 - pr_err("tnt4882: address change interrupted read\n"); 419 + if (test_bit(ADR_CHANGE_BN, &nec_priv->state)) 381 420 retval = -EINTR; 382 - } 383 421 count += drain_fifo_words(tnt_priv, &buffer[count], length - count); 384 422 if (fifo_byte_available(tnt_priv) && count < length) 385 423 buffer[count++] = tnt_readb(tnt_priv, FIFOB); ··· 426 476 return -count; 427 477 }; 428 478 429 - static int write_wait(gpib_board_t *board, struct tnt4882_priv *tnt_priv, 479 + static int write_wait(struct gpib_board *board, struct tnt4882_priv *tnt_priv, 430 480 int wait_for_done, int send_commands) 431 481 { 432 482 struct nec7210_priv *nec_priv = &tnt_priv->nec7210_priv; ··· 436 486 fifo_xfer_done(tnt_priv) || 437 487 test_bit(BUS_ERROR_BN, &nec_priv->state) || 438 488 test_bit(DEV_CLEAR_BN, &nec_priv->state) || 439 - test_bit(TIMO_NUM, &board->status))) { 440 - dev_dbg(board->gpib_dev, "gpib write interrupted\n"); 489 + test_bit(TIMO_NUM, &board->status))) 441 490 return -ERESTARTSYS; 442 - } 443 - if (test_bit(TIMO_NUM, &board->status)) { 444 - pr_info("tnt4882: write timed out\n"); 491 + 492 + if (test_bit(TIMO_NUM, &board->status)) 445 493 return -ETIMEDOUT; 446 - } 447 - if (test_and_clear_bit(BUS_ERROR_BN, &nec_priv->state)) { 448 - pr_err("tnt4882: write bus error\n"); 494 + if (test_and_clear_bit(BUS_ERROR_BN, &nec_priv->state)) 449 495 return (send_commands) ? -ENOTCONN : -ECOMM; 450 - } 451 - if (test_bit(DEV_CLEAR_BN, &nec_priv->state)) { 452 - pr_err("tnt4882: device clear interrupted write\n"); 496 + if (test_bit(DEV_CLEAR_BN, &nec_priv->state)) 453 497 return -EINTR; 454 - } 455 498 return 0; 456 499 } 457 500 458 - static int generic_write(gpib_board_t *board, uint8_t *buffer, size_t length, 501 + static int generic_write(struct gpib_board *board, uint8_t *buffer, size_t length, 459 502 int send_eoi, int send_commands, size_t *bytes_written) 460 503 { 461 504 size_t count = 0; ··· 539 596 return retval; 540 597 } 541 598 542 - int tnt4882_accel_write(gpib_board_t *board, uint8_t *buffer, size_t length, int send_eoi, 543 - size_t *bytes_written) 599 + static int tnt4882_accel_write(struct gpib_board *board, uint8_t *buffer, size_t length, int send_eoi, 600 + size_t *bytes_written) 544 601 { 545 602 return generic_write(board, buffer, length, send_eoi, 0, bytes_written); 546 603 } 547 604 548 - int tnt4882_command(gpib_board_t *board, uint8_t *buffer, size_t length, size_t *bytes_written) 605 + static int tnt4882_command(struct gpib_board *board, uint8_t *buffer, size_t length, 606 + size_t *bytes_written) 549 607 { 550 608 return generic_write(board, buffer, length, 0, 1, bytes_written); 551 609 } 552 610 553 - irqreturn_t tnt4882_internal_interrupt(gpib_board_t *board) 611 + static irqreturn_t tnt4882_internal_interrupt(struct gpib_board *board) 554 612 { 555 613 struct tnt4882_priv *priv = board->private_data; 556 614 int isr0_bits, isr3_bits, imr3_bits; ··· 577 633 if (isr3_bits & HR_DONE) 578 634 priv->imr3_bits &= ~HR_DONE; 579 635 if (isr3_bits & (HR_INTR | HR_TLCI)) { 580 - dev_dbg(board->gpib_dev, "tnt4882: minor %i isr0 0x%x imr0 0x%x isr3 0x%x imr3 0x%x\n", 636 + dev_dbg(board->gpib_dev, "minor %i isr0 0x%x imr0 0x%x isr3 0x%x imr3 0x%x\n", 581 637 board->minor, isr0_bits, priv->imr0_bits, isr3_bits, imr3_bits); 582 638 tnt_writeb(priv, priv->imr3_bits, IMR3); 583 639 wake_up_interruptible(&board->wait); ··· 586 642 return IRQ_HANDLED; 587 643 } 588 644 589 - irqreturn_t tnt4882_interrupt(int irq, void *arg) 645 + static irqreturn_t tnt4882_interrupt(int irq, void *arg) 590 646 { 591 647 return tnt4882_internal_interrupt(arg); 592 648 } 593 649 594 - static int ni_tnt_isa_attach(gpib_board_t *board, const gpib_board_config_t *config); 595 - static int ni_nat4882_isa_attach(gpib_board_t *board, const gpib_board_config_t *config); 596 - static int ni_nec_isa_attach(gpib_board_t *board, const gpib_board_config_t *config); 597 - static int ni_pci_attach(gpib_board_t *board, const gpib_board_config_t *config); 598 - 599 - static void ni_isa_detach(gpib_board_t *board); 600 - static void ni_pci_detach(gpib_board_t *board); 601 - 602 - #ifdef GPIB_PCMCIA 603 - static int ni_pcmcia_attach(gpib_board_t *board, const gpib_board_config_t *config); 604 - static void ni_pcmcia_detach(gpib_board_t *board); 605 - static int init_ni_gpib_cs(void); 606 - static void __exit exit_ni_gpib_cs(void); 607 - #endif 608 - 609 650 // wrappers for interface functions 610 - int tnt4882_read(gpib_board_t *board, uint8_t *buffer, size_t length, int *end, size_t *bytes_read) 651 + static int tnt4882_read(struct gpib_board *board, uint8_t *buffer, size_t length, int *end, 652 + size_t *bytes_read) 611 653 { 612 654 struct tnt4882_priv *priv = board->private_data; 613 655 struct nec7210_priv *nec_priv = &priv->nec7210_priv; ··· 612 682 return retval; 613 683 } 614 684 615 - int tnt4882_write(gpib_board_t *board, uint8_t *buffer, size_t length, int send_eoi, 616 - size_t *bytes_written) 685 + static int tnt4882_write(struct gpib_board *board, uint8_t *buffer, size_t length, int send_eoi, 686 + size_t *bytes_written) 617 687 { 618 688 struct tnt4882_priv *priv = board->private_data; 619 689 620 690 return nec7210_write(board, &priv->nec7210_priv, buffer, length, send_eoi, bytes_written); 621 691 } 622 692 623 - int tnt4882_command_unaccel(gpib_board_t *board, uint8_t *buffer, 624 - size_t length, size_t *bytes_written) 693 + static int tnt4882_command_unaccel(struct gpib_board *board, uint8_t *buffer, 694 + size_t length, size_t *bytes_written) 625 695 { 626 696 struct tnt4882_priv *priv = board->private_data; 627 697 628 698 return nec7210_command(board, &priv->nec7210_priv, buffer, length, bytes_written); 629 699 } 630 700 631 - int tnt4882_take_control(gpib_board_t *board, int synchronous) 701 + static int tnt4882_take_control(struct gpib_board *board, int synchronous) 632 702 { 633 703 struct tnt4882_priv *priv = board->private_data; 634 704 635 705 return nec7210_take_control(board, &priv->nec7210_priv, synchronous); 636 706 } 637 707 638 - int tnt4882_go_to_standby(gpib_board_t *board) 708 + static int tnt4882_go_to_standby(struct gpib_board *board) 639 709 { 640 710 struct tnt4882_priv *priv = board->private_data; 641 711 642 712 return nec7210_go_to_standby(board, &priv->nec7210_priv); 643 713 } 644 714 645 - void tnt4882_request_system_control(gpib_board_t *board, int request_control) 715 + static void tnt4882_request_system_control(struct gpib_board *board, int request_control) 646 716 { 647 717 struct tnt4882_priv *priv = board->private_data; 648 718 ··· 657 727 } 658 728 } 659 729 660 - void tnt4882_interface_clear(gpib_board_t *board, int assert) 730 + static void tnt4882_interface_clear(struct gpib_board *board, int assert) 661 731 { 662 732 struct tnt4882_priv *priv = board->private_data; 663 733 664 734 nec7210_interface_clear(board, &priv->nec7210_priv, assert); 665 735 } 666 736 667 - void tnt4882_remote_enable(gpib_board_t *board, int enable) 737 + static void tnt4882_remote_enable(struct gpib_board *board, int enable) 668 738 { 669 739 struct tnt4882_priv *priv = board->private_data; 670 740 671 741 nec7210_remote_enable(board, &priv->nec7210_priv, enable); 672 742 } 673 743 674 - int tnt4882_enable_eos(gpib_board_t *board, uint8_t eos_byte, int compare_8_bits) 744 + static int tnt4882_enable_eos(struct gpib_board *board, uint8_t eos_byte, int compare_8_bits) 675 745 { 676 746 struct tnt4882_priv *priv = board->private_data; 677 747 678 748 return nec7210_enable_eos(board, &priv->nec7210_priv, eos_byte, compare_8_bits); 679 749 } 680 750 681 - void tnt4882_disable_eos(gpib_board_t *board) 751 + static void tnt4882_disable_eos(struct gpib_board *board) 682 752 { 683 753 struct tnt4882_priv *priv = board->private_data; 684 754 685 755 nec7210_disable_eos(board, &priv->nec7210_priv); 686 756 } 687 757 688 - unsigned int tnt4882_update_status(gpib_board_t *board, unsigned int clear_mask) 758 + static unsigned int tnt4882_update_status(struct gpib_board *board, unsigned int clear_mask) 689 759 { 690 760 unsigned long flags; 691 761 u8 line_status; 692 - unsigned int retval; 693 762 struct tnt4882_priv *priv = board->private_data; 694 763 695 764 spin_lock_irqsave(&board->spinlock, flags); 696 765 board->status &= ~clear_mask; 697 - retval = nec7210_update_status_nolock(board, &priv->nec7210_priv); 766 + nec7210_update_status_nolock(board, &priv->nec7210_priv); 698 767 /* set / clear SRQ state since it is not cleared by interrupt */ 699 768 line_status = tnt_readb(priv, BSR); 700 769 if (line_status & BCSR_SRQ_BIT) ··· 704 775 return board->status; 705 776 } 706 777 707 - int tnt4882_primary_address(gpib_board_t *board, unsigned int address) 778 + static int tnt4882_primary_address(struct gpib_board *board, unsigned int address) 708 779 { 709 780 struct tnt4882_priv *priv = board->private_data; 710 781 711 782 return nec7210_primary_address(board, &priv->nec7210_priv, address); 712 783 } 713 784 714 - int tnt4882_secondary_address(gpib_board_t *board, unsigned int address, int enable) 785 + static int tnt4882_secondary_address(struct gpib_board *board, unsigned int address, int enable) 715 786 { 716 787 struct tnt4882_priv *priv = board->private_data; 717 788 718 789 return nec7210_secondary_address(board, &priv->nec7210_priv, address, enable); 719 790 } 720 791 721 - int tnt4882_parallel_poll(gpib_board_t *board, uint8_t *result) 722 - 792 + static int tnt4882_parallel_poll(struct gpib_board *board, uint8_t *result) 723 793 { 724 794 struct tnt4882_priv *tnt_priv = board->private_data; 725 795 ··· 735 807 } 736 808 } 737 809 738 - void tnt4882_parallel_poll_configure(gpib_board_t *board, uint8_t config) 810 + static void tnt4882_parallel_poll_configure(struct gpib_board *board, uint8_t config) 739 811 { 740 812 struct tnt4882_priv *priv = board->private_data; 741 813 ··· 753 825 } 754 826 } 755 827 756 - void tnt4882_parallel_poll_response(gpib_board_t *board, int ist) 828 + static void tnt4882_parallel_poll_response(struct gpib_board *board, int ist) 757 829 { 758 830 struct tnt4882_priv *priv = board->private_data; 759 831 ··· 763 835 /* this is just used by the old nec7210 isa interfaces, the newer 764 836 * boards use tnt4882_serial_poll_response2 765 837 */ 766 - void tnt4882_serial_poll_response(gpib_board_t *board, uint8_t status) 838 + static void tnt4882_serial_poll_response(struct gpib_board *board, uint8_t status) 767 839 { 768 840 struct tnt4882_priv *priv = board->private_data; 769 841 770 842 nec7210_serial_poll_response(board, &priv->nec7210_priv, status); 771 843 } 772 844 773 - static void tnt4882_serial_poll_response2(gpib_board_t *board, uint8_t status, 845 + static void tnt4882_serial_poll_response2(struct gpib_board *board, uint8_t status, 774 846 int new_reason_for_service) 775 847 { 776 848 struct tnt4882_priv *priv = board->private_data; ··· 804 876 spin_unlock_irqrestore(&board->spinlock, flags); 805 877 } 806 878 807 - uint8_t tnt4882_serial_poll_status(gpib_board_t *board) 879 + static uint8_t tnt4882_serial_poll_status(struct gpib_board *board) 808 880 { 809 881 struct tnt4882_priv *priv = board->private_data; 810 882 811 883 return nec7210_serial_poll_status(board, &priv->nec7210_priv); 812 884 } 813 885 814 - void tnt4882_return_to_local(gpib_board_t *board) 886 + static void tnt4882_return_to_local(struct gpib_board *board) 815 887 { 816 888 struct tnt4882_priv *priv = board->private_data; 817 889 818 890 nec7210_return_to_local(board, &priv->nec7210_priv); 891 + } 892 + 893 + static void tnt4882_board_reset(struct tnt4882_priv *tnt_priv, struct gpib_board *board) 894 + { 895 + struct nec7210_priv *nec_priv = &tnt_priv->nec7210_priv; 896 + 897 + tnt_priv->imr0_bits = 0; 898 + tnt_writeb(tnt_priv, tnt_priv->imr0_bits, IMR0); 899 + tnt_priv->imr3_bits = 0; 900 + tnt_writeb(tnt_priv, tnt_priv->imr3_bits, IMR3); 901 + tnt_readb(tnt_priv, IMR0); 902 + tnt_readb(tnt_priv, IMR3); 903 + nec7210_board_reset(nec_priv, board); 904 + } 905 + 906 + static int tnt4882_allocate_private(struct gpib_board *board) 907 + { 908 + struct tnt4882_priv *tnt_priv; 909 + 910 + board->private_data = kmalloc(sizeof(struct tnt4882_priv), GFP_KERNEL); 911 + if (!board->private_data) 912 + return -1; 913 + tnt_priv = board->private_data; 914 + memset(tnt_priv, 0, sizeof(struct tnt4882_priv)); 915 + init_nec7210_private(&tnt_priv->nec7210_priv); 916 + return 0; 917 + } 918 + 919 + static void tnt4882_free_private(struct gpib_board *board) 920 + { 921 + kfree(board->private_data); 922 + board->private_data = NULL; 923 + } 924 + 925 + static void tnt4882_init(struct tnt4882_priv *tnt_priv, const struct gpib_board *board) 926 + { 927 + struct nec7210_priv *nec_priv = &tnt_priv->nec7210_priv; 928 + 929 + /* Turbo488 software reset */ 930 + tnt_writeb(tnt_priv, SOFT_RESET, CMDR); 931 + udelay(1); 932 + 933 + // turn off one-chip mode 934 + tnt_writeb(tnt_priv, NODMA, HSSEL); 935 + tnt_writeb(tnt_priv, 0, ACCWR); 936 + // make sure we are in 7210 mode 937 + tnt_writeb(tnt_priv, AUX_7210, AUXCR); 938 + udelay(1); 939 + // registers might be swapped, so write it to the swapped address too 940 + tnt_writeb(tnt_priv, AUX_7210, SWAPPED_AUXCR); 941 + udelay(1); 942 + // turn on one-chip mode 943 + if (nec_priv->type == TNT4882 || nec_priv->type == TNT5004) 944 + tnt_writeb(tnt_priv, NODMA | TNT_ONE_CHIP_BIT, HSSEL); 945 + else 946 + tnt_writeb(tnt_priv, NODMA, HSSEL); 947 + 948 + nec7210_board_reset(nec_priv, board); 949 + // read-clear isr0 950 + tnt_readb(tnt_priv, ISR0); 951 + 952 + // enable passing of nat4882 interrupts 953 + tnt_priv->imr3_bits = HR_TLCI; 954 + tnt_writeb(tnt_priv, tnt_priv->imr3_bits, IMR3); 955 + 956 + // enable interrupt 957 + tnt_writeb(tnt_priv, 0x1, INTRT); 958 + 959 + // force immediate holdoff 960 + write_byte(&tnt_priv->nec7210_priv, AUX_HLDI, AUXMR); 961 + 962 + set_bit(RFD_HOLDOFF_BN, &nec_priv->state); 963 + 964 + tnt_priv->auxg_bits = AUXRG | NTNL_BIT; 965 + write_byte(&tnt_priv->nec7210_priv, tnt_priv->auxg_bits, AUXMR); 966 + 967 + nec7210_board_online(nec_priv, board); 968 + // enable interface clear interrupt for event queue 969 + tnt_priv->imr0_bits = TNT_IMR0_ALWAYS_BITS | TNT_ATNI_BIT | TNT_IFCIE_BIT; 970 + tnt_writeb(tnt_priv, tnt_priv->imr0_bits, IMR0); 971 + } 972 + 973 + static int ni_pci_attach(struct gpib_board *board, const gpib_board_config_t *config) 974 + { 975 + struct tnt4882_priv *tnt_priv; 976 + struct nec7210_priv *nec_priv; 977 + int isr_flags = IRQF_SHARED; 978 + int retval; 979 + struct mite_struct *mite; 980 + 981 + board->status = 0; 982 + 983 + if (tnt4882_allocate_private(board)) 984 + return -ENOMEM; 985 + tnt_priv = board->private_data; 986 + nec_priv = &tnt_priv->nec7210_priv; 987 + nec_priv->type = TNT4882; 988 + nec_priv->read_byte = nec7210_locking_iomem_read_byte; 989 + nec_priv->write_byte = nec7210_locking_iomem_write_byte; 990 + nec_priv->offset = atgpib_reg_offset; 991 + 992 + if (!mite_devices) 993 + return -ENODEV; 994 + 995 + for (mite = mite_devices; mite; mite = mite->next) { 996 + short found_board; 997 + 998 + if (mite->used) 999 + continue; 1000 + if (config->pci_bus >= 0 && config->pci_bus != mite->pcidev->bus->number) 1001 + continue; 1002 + if (config->pci_slot >= 0 && config->pci_slot != PCI_SLOT(mite->pcidev->devfn)) 1003 + continue; 1004 + switch (mite_device_id(mite)) { 1005 + case PCI_DEVICE_ID_NI_GPIB: 1006 + case PCI_DEVICE_ID_NI_GPIB_PLUS: 1007 + case PCI_DEVICE_ID_NI_GPIB_PLUS2: 1008 + case PCI_DEVICE_ID_NI_PXIGPIB: 1009 + case PCI_DEVICE_ID_NI_PMCGPIB: 1010 + case PCI_DEVICE_ID_NI_PCIEGPIB: 1011 + case PCI_DEVICE_ID_NI_PCIE2GPIB: 1012 + // support for Measurement Computing PCI-488 1013 + case PCI_DEVICE_ID_MC_PCI488: 1014 + case PCI_DEVICE_ID_CEC_NI_GPIB: 1015 + found_board = 1; 1016 + break; 1017 + default: 1018 + found_board = 0; 1019 + break; 1020 + } 1021 + if (found_board) 1022 + break; 1023 + } 1024 + if (!mite) 1025 + return -ENODEV; 1026 + 1027 + tnt_priv->mite = mite; 1028 + retval = mite_setup(tnt_priv->mite); 1029 + if (retval < 0) 1030 + return retval; 1031 + 1032 + nec_priv->mmiobase = tnt_priv->mite->daq_io_addr; 1033 + 1034 + // get irq 1035 + retval = request_irq(mite_irq(tnt_priv->mite), tnt4882_interrupt, isr_flags, "ni-pci-gpib", 1036 + board); 1037 + if (retval) { 1038 + dev_err(board->gpib_dev, "failed to obtain pci irq %d\n", mite_irq(tnt_priv->mite)); 1039 + return retval; 1040 + } 1041 + tnt_priv->irq = mite_irq(tnt_priv->mite); 1042 + 1043 + // TNT5004 detection 1044 + switch (tnt_readb(tnt_priv, CSR) & 0xf0) { 1045 + case 0x30: 1046 + nec_priv->type = TNT4882; 1047 + break; 1048 + case 0x40: 1049 + nec_priv->type = TNT5004; 1050 + break; 1051 + } 1052 + tnt4882_init(tnt_priv, board); 1053 + 1054 + return 0; 1055 + } 1056 + 1057 + static void ni_pci_detach(struct gpib_board *board) 1058 + { 1059 + struct tnt4882_priv *tnt_priv = board->private_data; 1060 + struct nec7210_priv *nec_priv; 1061 + 1062 + if (tnt_priv) { 1063 + nec_priv = &tnt_priv->nec7210_priv; 1064 + 1065 + if (nec_priv->mmiobase) 1066 + tnt4882_board_reset(tnt_priv, board); 1067 + if (tnt_priv->irq) 1068 + free_irq(tnt_priv->irq, board); 1069 + if (tnt_priv->mite) 1070 + mite_unsetup(tnt_priv->mite); 1071 + } 1072 + tnt4882_free_private(board); 1073 + } 1074 + 1075 + static int ni_isapnp_find(struct pnp_dev **dev) 1076 + { 1077 + *dev = pnp_find_dev(NULL, ISAPNP_VENDOR_ID_NI, 1078 + ISAPNP_FUNCTION(ISAPNP_ID_NI_ATGPIB_TNT), NULL); 1079 + if (!*dev || !(*dev)->card) 1080 + return -ENODEV; 1081 + if (pnp_device_attach(*dev) < 0) 1082 + return -EBUSY; 1083 + if (pnp_activate_dev(*dev) < 0) { 1084 + pnp_device_detach(*dev); 1085 + return -EAGAIN; 1086 + } 1087 + if (!pnp_port_valid(*dev, 0) || !pnp_irq_valid(*dev, 0)) { 1088 + pnp_device_detach(*dev); 1089 + return -EINVAL; 1090 + } 1091 + return 0; 1092 + } 1093 + 1094 + static int ni_isa_attach_common(struct gpib_board *board, const gpib_board_config_t *config, 1095 + enum nec7210_chipset chipset) 1096 + { 1097 + struct tnt4882_priv *tnt_priv; 1098 + struct nec7210_priv *nec_priv; 1099 + int isr_flags = 0; 1100 + u32 iobase; 1101 + int irq; 1102 + int retval; 1103 + 1104 + board->status = 0; 1105 + 1106 + if (tnt4882_allocate_private(board)) 1107 + return -ENOMEM; 1108 + tnt_priv = board->private_data; 1109 + nec_priv = &tnt_priv->nec7210_priv; 1110 + nec_priv->type = chipset; 1111 + nec_priv->read_byte = nec7210_locking_ioport_read_byte; 1112 + nec_priv->write_byte = nec7210_locking_ioport_write_byte; 1113 + nec_priv->offset = atgpib_reg_offset; 1114 + 1115 + // look for plug-n-play board 1116 + if (config->ibbase == 0) { 1117 + struct pnp_dev *dev; 1118 + 1119 + retval = ni_isapnp_find(&dev); 1120 + if (retval < 0) 1121 + return retval; 1122 + tnt_priv->pnp_dev = dev; 1123 + iobase = pnp_port_start(dev, 0); 1124 + irq = pnp_irq(dev, 0); 1125 + } else { 1126 + iobase = config->ibbase; 1127 + irq = config->ibirq; 1128 + } 1129 + // allocate ioports 1130 + if (!request_region(iobase, atgpib_iosize, "atgpib")) 1131 + return -EBUSY; 1132 + 1133 + nec_priv->mmiobase = ioport_map(iobase, atgpib_iosize); 1134 + if (!nec_priv->mmiobase) 1135 + return -EBUSY; 1136 + 1137 + // get irq 1138 + retval = request_irq(irq, tnt4882_interrupt, isr_flags, "atgpib", board); 1139 + if (retval) { 1140 + dev_err(board->gpib_dev, "failed to request ISA irq %d\n", irq); 1141 + return retval; 1142 + } 1143 + tnt_priv->irq = irq; 1144 + 1145 + tnt4882_init(tnt_priv, board); 1146 + 1147 + return 0; 1148 + } 1149 + 1150 + static int ni_tnt_isa_attach(struct gpib_board *board, const gpib_board_config_t *config) 1151 + { 1152 + return ni_isa_attach_common(board, config, TNT4882); 1153 + } 1154 + 1155 + static int ni_nat4882_isa_attach(struct gpib_board *board, const gpib_board_config_t *config) 1156 + { 1157 + return ni_isa_attach_common(board, config, NAT4882); 1158 + } 1159 + 1160 + static int ni_nec_isa_attach(struct gpib_board *board, const gpib_board_config_t *config) 1161 + { 1162 + return ni_isa_attach_common(board, config, NEC7210); 1163 + } 1164 + 1165 + static void ni_isa_detach(struct gpib_board *board) 1166 + { 1167 + struct tnt4882_priv *tnt_priv = board->private_data; 1168 + struct nec7210_priv *nec_priv; 1169 + 1170 + if (tnt_priv) { 1171 + nec_priv = &tnt_priv->nec7210_priv; 1172 + if (nec_priv->iobase) 1173 + tnt4882_board_reset(tnt_priv, board); 1174 + if (tnt_priv->irq) 1175 + free_irq(tnt_priv->irq, board); 1176 + if (nec_priv->mmiobase) 1177 + ioport_unmap(nec_priv->mmiobase); 1178 + if (nec_priv->iobase) 1179 + release_region(nec_priv->iobase, atgpib_iosize); 1180 + if (tnt_priv->pnp_dev) 1181 + pnp_device_detach(tnt_priv->pnp_dev); 1182 + } 1183 + tnt4882_free_private(board); 1184 + } 1185 + 1186 + static int tnt4882_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) 1187 + { 1188 + return 0; 819 1189 } 820 1190 821 1191 static gpib_interface_t ni_pci_interface = { ··· 1340 1114 .return_to_local = tnt4882_return_to_local, 1341 1115 }; 1342 1116 1343 - #ifdef GPIB_PCMCIA 1117 + static const struct pci_device_id tnt4882_pci_table[] = { 1118 + {PCI_DEVICE(PCI_VENDOR_ID_NATINST, PCI_DEVICE_ID_NI_GPIB)}, 1119 + {PCI_DEVICE(PCI_VENDOR_ID_NATINST, PCI_DEVICE_ID_NI_GPIB_PLUS)}, 1120 + {PCI_DEVICE(PCI_VENDOR_ID_NATINST, PCI_DEVICE_ID_NI_GPIB_PLUS2)}, 1121 + {PCI_DEVICE(PCI_VENDOR_ID_NATINST, PCI_DEVICE_ID_NI_PXIGPIB)}, 1122 + {PCI_DEVICE(PCI_VENDOR_ID_NATINST, PCI_DEVICE_ID_NI_PMCGPIB)}, 1123 + {PCI_DEVICE(PCI_VENDOR_ID_NATINST, PCI_DEVICE_ID_NI_PCIEGPIB)}, 1124 + {PCI_DEVICE(PCI_VENDOR_ID_NATINST, PCI_DEVICE_ID_NI_PCIE2GPIB)}, 1125 + // support for Measurement Computing PCI-488 1126 + {PCI_DEVICE(PCI_VENDOR_ID_NATINST, PCI_DEVICE_ID_MC_PCI488)}, 1127 + {PCI_DEVICE(PCI_VENDOR_ID_NATINST, PCI_DEVICE_ID_CEC_NI_GPIB)}, 1128 + { 0 } 1129 + }; 1130 + MODULE_DEVICE_TABLE(pci, tnt4882_pci_table); 1131 + 1132 + static struct pci_driver tnt4882_pci_driver = { 1133 + .name = DRV_NAME, 1134 + .id_table = tnt4882_pci_table, 1135 + .probe = &tnt4882_pci_probe 1136 + }; 1137 + 1138 + #if 0 1139 + /* unused, will be needed when the driver is turned into a pnp_driver */ 1140 + static const struct pnp_device_id tnt4882_pnp_table[] = { 1141 + {.id = "NICC601"}, 1142 + {.id = ""} 1143 + }; 1144 + MODULE_DEVICE_TABLE(pnp, tnt4882_pnp_table); 1145 + #endif 1146 + 1147 + #ifdef CONFIG_GPIB_PCMCIA 1148 + static gpib_interface_t ni_pcmcia_interface; 1149 + static gpib_interface_t ni_pcmcia_accel_interface; 1150 + static int __init init_ni_gpib_cs(void); 1151 + static void __exit exit_ni_gpib_cs(void); 1152 + #endif 1153 + 1154 + static int __init tnt4882_init_module(void) 1155 + { 1156 + int result; 1157 + 1158 + result = pci_register_driver(&tnt4882_pci_driver); 1159 + if (result) { 1160 + pr_err("pci_register_driver failed: error = %d\n", result); 1161 + return result; 1162 + } 1163 + 1164 + result = gpib_register_driver(&ni_isa_interface, THIS_MODULE); 1165 + if (result) { 1166 + pr_err("gpib_register_driver failed: error = %d\n", result); 1167 + goto err_isa; 1168 + } 1169 + 1170 + result = gpib_register_driver(&ni_isa_accel_interface, THIS_MODULE); 1171 + if (result) { 1172 + pr_err("gpib_register_driver failed: error = %d\n", result); 1173 + goto err_isa_accel; 1174 + } 1175 + 1176 + result = gpib_register_driver(&ni_nat4882_isa_interface, THIS_MODULE); 1177 + if (result) { 1178 + pr_err("gpib_register_driver failed: error = %d\n", result); 1179 + goto err_nat4882_isa; 1180 + } 1181 + 1182 + result = gpib_register_driver(&ni_nat4882_isa_accel_interface, THIS_MODULE); 1183 + if (result) { 1184 + pr_err("gpib_register_driver failed: error = %d\n", result); 1185 + goto err_nat4882_isa_accel; 1186 + } 1187 + 1188 + result = gpib_register_driver(&ni_nec_isa_interface, THIS_MODULE); 1189 + if (result) { 1190 + pr_err("gpib_register_driver failed: error = %d\n", result); 1191 + goto err_nec_isa; 1192 + } 1193 + 1194 + result = gpib_register_driver(&ni_nec_isa_accel_interface, THIS_MODULE); 1195 + if (result) { 1196 + pr_err("gpib_register_driver failed: error = %d\n", result); 1197 + goto err_nec_isa_accel; 1198 + } 1199 + 1200 + result = gpib_register_driver(&ni_pci_interface, THIS_MODULE); 1201 + if (result) { 1202 + pr_err("gpib_register_driver failed: error = %d\n", result); 1203 + goto err_pci; 1204 + } 1205 + 1206 + result = gpib_register_driver(&ni_pci_accel_interface, THIS_MODULE); 1207 + if (result) { 1208 + pr_err("gpib_register_driver failed: error = %d\n", result); 1209 + goto err_pci_accel; 1210 + } 1211 + 1212 + #ifdef CONFIG_GPIB_PCMCIA 1213 + result = gpib_register_driver(&ni_pcmcia_interface, THIS_MODULE); 1214 + if (result) { 1215 + pr_err("gpib_register_driver failed: error = %d\n", result); 1216 + goto err_pcmcia; 1217 + } 1218 + 1219 + result = gpib_register_driver(&ni_pcmcia_accel_interface, THIS_MODULE); 1220 + if (result) { 1221 + pr_err("gpib_register_driver failed: error = %d\n", result); 1222 + goto err_pcmcia_accel; 1223 + } 1224 + 1225 + result = init_ni_gpib_cs(); 1226 + if (result) { 1227 + pr_err("pcmcia_register_driver failed: error = %d\n", result); 1228 + goto err_pcmcia_driver; 1229 + } 1230 + #endif 1231 + 1232 + mite_init(); 1233 + 1234 + return 0; 1235 + 1236 + #ifdef CONFIG_GPIB_PCMCIA 1237 + err_pcmcia_driver: 1238 + gpib_unregister_driver(&ni_pcmcia_accel_interface); 1239 + err_pcmcia_accel: 1240 + gpib_unregister_driver(&ni_pcmcia_interface); 1241 + err_pcmcia: 1242 + #endif 1243 + gpib_unregister_driver(&ni_pci_accel_interface); 1244 + err_pci_accel: 1245 + gpib_unregister_driver(&ni_pci_interface); 1246 + err_pci: 1247 + gpib_unregister_driver(&ni_nec_isa_accel_interface); 1248 + err_nec_isa_accel: 1249 + gpib_unregister_driver(&ni_nec_isa_interface); 1250 + err_nec_isa: 1251 + gpib_unregister_driver(&ni_nat4882_isa_accel_interface); 1252 + err_nat4882_isa_accel: 1253 + gpib_unregister_driver(&ni_nat4882_isa_interface); 1254 + err_nat4882_isa: 1255 + gpib_unregister_driver(&ni_isa_accel_interface); 1256 + err_isa_accel: 1257 + gpib_unregister_driver(&ni_isa_interface); 1258 + err_isa: 1259 + pci_unregister_driver(&tnt4882_pci_driver); 1260 + 1261 + return result; 1262 + } 1263 + 1264 + static void __exit tnt4882_exit_module(void) 1265 + { 1266 + gpib_unregister_driver(&ni_isa_interface); 1267 + gpib_unregister_driver(&ni_isa_accel_interface); 1268 + gpib_unregister_driver(&ni_nat4882_isa_interface); 1269 + gpib_unregister_driver(&ni_nat4882_isa_accel_interface); 1270 + gpib_unregister_driver(&ni_nec_isa_interface); 1271 + gpib_unregister_driver(&ni_nec_isa_accel_interface); 1272 + gpib_unregister_driver(&ni_pci_interface); 1273 + gpib_unregister_driver(&ni_pci_accel_interface); 1274 + #ifdef CONFIG_GPIB_PCMCIA 1275 + gpib_unregister_driver(&ni_pcmcia_interface); 1276 + gpib_unregister_driver(&ni_pcmcia_accel_interface); 1277 + exit_ni_gpib_cs(); 1278 + #endif 1279 + 1280 + mite_cleanup(); 1281 + 1282 + pci_unregister_driver(&tnt4882_pci_driver); 1283 + } 1284 + 1285 + #ifdef CONFIG_GPIB_PCMCIA 1286 + 1287 + #include <linux/kernel.h> 1288 + #include <linux/moduleparam.h> 1289 + #include <linux/ptrace.h> 1290 + #include <linux/timer.h> 1291 + #include <linux/ioport.h> 1292 + #include <linux/io.h> 1293 + 1294 + #include <pcmcia/cistpl.h> 1295 + #include <pcmcia/cisreg.h> 1296 + #include <pcmcia/ds.h> 1297 + 1298 + static int ni_gpib_config(struct pcmcia_device *link); 1299 + static void ni_gpib_release(struct pcmcia_device *link); 1300 + static void ni_pcmcia_detach(struct gpib_board *board); 1301 + 1302 + /* 1303 + * A linked list of "instances" of the dummy device. Each actual 1304 + * PCMCIA card corresponds to one device instance, and is described 1305 + * by one dev_link_t structure (defined in ds.h). 1306 + * 1307 + * You may not want to use a linked list for this -- for example, the 1308 + * memory card driver uses an array of dev_link_t pointers, where minor 1309 + * device numbers are used to derive the corresponding array index. 1310 + * 1311 + * I think this dev_list is obsolete but the pointer is needed to keep 1312 + * the module instance for the ni_pcmcia_attach function. 1313 + */ 1314 + 1315 + static struct pcmcia_device *curr_dev; 1316 + 1317 + struct local_info_t { 1318 + struct pcmcia_device *p_dev; 1319 + struct gpib_board *dev; 1320 + int stop; 1321 + struct bus_operations *bus; 1322 + }; 1323 + 1324 + /* 1325 + * ni_gpib_probe() creates an "instance" of the driver, allocating 1326 + * local data structures for one device. The device is registered 1327 + * with Card Services. 1328 + */ 1329 + 1330 + static int ni_gpib_probe(struct pcmcia_device *link) 1331 + { 1332 + struct local_info_t *info; 1333 + //struct struct gpib_board *dev; 1334 + 1335 + /* Allocate space for private device-specific data */ 1336 + info = kzalloc(sizeof(*info), GFP_KERNEL); 1337 + if (!info) 1338 + return -ENOMEM; 1339 + 1340 + info->p_dev = link; 1341 + link->priv = info; 1342 + 1343 + /* 1344 + * General socket configuration defaults can go here. In this 1345 + * client, we assume very little, and rely on the CIS for almost 1346 + * everything. In most clients, many details (i.e., number, sizes, 1347 + * and attributes of IO windows) are fixed by the nature of the 1348 + * device, and can be hard-wired here. 1349 + */ 1350 + link->config_flags = CONF_ENABLE_IRQ | CONF_AUTO_SET_IO; 1351 + 1352 + /* Register with Card Services */ 1353 + curr_dev = link; 1354 + return ni_gpib_config(link); 1355 + } 1356 + 1357 + /* 1358 + * This deletes a driver "instance". The device is de-registered 1359 + * with Card Services. If it has been released, all local data 1360 + * structures are freed. Otherwise, the structures will be freed 1361 + * when the device is released. 1362 + */ 1363 + static void ni_gpib_remove(struct pcmcia_device *link) 1364 + { 1365 + struct local_info_t *info = link->priv; 1366 + //struct struct gpib_board *dev = info->dev; 1367 + 1368 + if (info->dev) 1369 + ni_pcmcia_detach(info->dev); 1370 + ni_gpib_release(link); 1371 + 1372 + //free_netdev(dev); 1373 + kfree(info); 1374 + } 1375 + 1376 + static int ni_gpib_config_iteration(struct pcmcia_device *link, void *priv_data) 1377 + { 1378 + int retval; 1379 + 1380 + retval = pcmcia_request_io(link); 1381 + if (retval != 0) 1382 + return retval; 1383 + 1384 + return 0; 1385 + } 1386 + 1387 + /* 1388 + * ni_gpib_config() is scheduled to run after a CARD_INSERTION event 1389 + * is received, to configure the PCMCIA socket, and to make the 1390 + * device available to the system. 1391 + */ 1392 + static int ni_gpib_config(struct pcmcia_device *link) 1393 + { 1394 + //struct local_info_t *info = link->priv; 1395 + //struct gpib_board *dev = info->dev; 1396 + int last_ret; 1397 + 1398 + last_ret = pcmcia_loop_config(link, &ni_gpib_config_iteration, NULL); 1399 + if (last_ret) { 1400 + dev_warn(&link->dev, "no configuration found\n"); 1401 + ni_gpib_release(link); 1402 + return last_ret; 1403 + } 1404 + 1405 + last_ret = pcmcia_enable_device(link); 1406 + if (last_ret) { 1407 + ni_gpib_release(link); 1408 + return last_ret; 1409 + } 1410 + return 0; 1411 + } /* ni_gpib_config */ 1412 + 1413 + /* 1414 + * After a card is removed, ni_gpib_release() will unregister the 1415 + * device, and release the PCMCIA configuration. If the device is 1416 + * still open, this will be postponed until it is closed. 1417 + */ 1418 + static void ni_gpib_release(struct pcmcia_device *link) 1419 + { 1420 + pcmcia_disable_device(link); 1421 + } /* ni_gpib_release */ 1422 + 1423 + static int ni_gpib_suspend(struct pcmcia_device *link) 1424 + { 1425 + //struct local_info_t *info = link->priv; 1426 + //struct struct gpib_board *dev = info->dev; 1427 + 1428 + if (link->open) 1429 + dev_warn(&link->dev, "Device still open\n"); 1430 + //netif_device_detach(dev); 1431 + 1432 + return 0; 1433 + } 1434 + 1435 + static int ni_gpib_resume(struct pcmcia_device *link) 1436 + { 1437 + //struct local_info_t *info = link->priv; 1438 + //struct struct gpib_board *dev = info->dev; 1439 + 1440 + /*if (link->open) { 1441 + * ni_gpib_probe(dev); / really? 1442 + * //netif_device_attach(dev); 1443 + *} 1444 + */ 1445 + return ni_gpib_config(link); 1446 + } 1447 + 1448 + static struct pcmcia_device_id ni_pcmcia_ids[] = { 1449 + PCMCIA_DEVICE_MANF_CARD(0x010b, 0x4882), 1450 + PCMCIA_DEVICE_MANF_CARD(0x010b, 0x0c71), // NI PCMCIA-GPIB+ 1451 + PCMCIA_DEVICE_NULL 1452 + }; 1453 + 1454 + MODULE_DEVICE_TABLE(pcmcia, ni_pcmcia_ids); 1455 + 1456 + static struct pcmcia_driver ni_gpib_cs_driver = { 1457 + .name = "ni_gpib_cs", 1458 + .owner = THIS_MODULE, 1459 + .drv = { .name = "ni_gpib_cs", }, 1460 + .id_table = ni_pcmcia_ids, 1461 + .probe = ni_gpib_probe, 1462 + .remove = ni_gpib_remove, 1463 + .suspend = ni_gpib_suspend, 1464 + .resume = ni_gpib_resume, 1465 + }; 1466 + 1467 + static int __init init_ni_gpib_cs(void) 1468 + { 1469 + return pcmcia_register_driver(&ni_gpib_cs_driver); 1470 + } 1471 + 1472 + static void __exit exit_ni_gpib_cs(void) 1473 + { 1474 + pcmcia_unregister_driver(&ni_gpib_cs_driver); 1475 + } 1476 + 1477 + static const int pcmcia_gpib_iosize = 32; 1478 + 1479 + static int ni_pcmcia_attach(struct gpib_board *board, const gpib_board_config_t *config) 1480 + { 1481 + struct local_info_t *info; 1482 + struct tnt4882_priv *tnt_priv; 1483 + struct nec7210_priv *nec_priv; 1484 + int isr_flags = IRQF_SHARED; 1485 + int retval; 1486 + 1487 + if (!curr_dev) 1488 + return -ENODEV; 1489 + 1490 + info = curr_dev->priv; 1491 + info->dev = board; 1492 + 1493 + board->status = 0; 1494 + 1495 + if (tnt4882_allocate_private(board)) 1496 + return -ENOMEM; 1497 + 1498 + tnt_priv = board->private_data; 1499 + nec_priv = &tnt_priv->nec7210_priv; 1500 + nec_priv->type = TNT4882; 1501 + nec_priv->read_byte = nec7210_locking_ioport_read_byte; 1502 + nec_priv->write_byte = nec7210_locking_ioport_write_byte; 1503 + nec_priv->offset = atgpib_reg_offset; 1504 + 1505 + if (!request_region(curr_dev->resource[0]->start, resource_size(curr_dev->resource[0]), 1506 + DRV_NAME)) 1507 + return -ENOMEM; 1508 + 1509 + nec_priv->mmiobase = ioport_map(curr_dev->resource[0]->start, 1510 + resource_size(curr_dev->resource[0])); 1511 + if (!nec_priv->mmiobase) 1512 + return -ENOMEM; 1513 + 1514 + // get irq 1515 + retval = request_irq(curr_dev->irq, tnt4882_interrupt, isr_flags, DRV_NAME, board); 1516 + if (retval) { 1517 + dev_err(board->gpib_dev, "failed to obtain PCMCIA irq %d\n", curr_dev->irq); 1518 + return retval; 1519 + } 1520 + tnt_priv->irq = curr_dev->irq; 1521 + 1522 + tnt4882_init(tnt_priv, board); 1523 + 1524 + return 0; 1525 + } 1526 + 1527 + static void ni_pcmcia_detach(struct gpib_board *board) 1528 + { 1529 + struct tnt4882_priv *tnt_priv = board->private_data; 1530 + struct nec7210_priv *nec_priv; 1531 + 1532 + if (tnt_priv) { 1533 + nec_priv = &tnt_priv->nec7210_priv; 1534 + if (tnt_priv->irq) 1535 + free_irq(tnt_priv->irq, board); 1536 + if (nec_priv->mmiobase) 1537 + ioport_unmap(nec_priv->mmiobase); 1538 + if (nec_priv->iobase) { 1539 + tnt4882_board_reset(tnt_priv, board); 1540 + release_region(nec_priv->iobase, pcmcia_gpib_iosize); 1541 + } 1542 + } 1543 + tnt4882_free_private(board); 1544 + } 1545 + 1344 1546 static gpib_interface_t ni_pcmcia_interface = { 1345 1547 .name = "ni_pcmcia", 1346 1548 .attach = ni_pcmcia_attach, ··· 1824 1170 .t1_delay = tnt4882_t1_delay, 1825 1171 .return_to_local = tnt4882_return_to_local, 1826 1172 }; 1827 - #endif 1828 1173 1829 - void tnt4882_board_reset(struct tnt4882_priv *tnt_priv, gpib_board_t *board) 1830 - { 1831 - struct nec7210_priv *nec_priv = &tnt_priv->nec7210_priv; 1832 - 1833 - tnt_priv->imr0_bits = 0; 1834 - tnt_writeb(tnt_priv, tnt_priv->imr0_bits, IMR0); 1835 - tnt_priv->imr3_bits = 0; 1836 - tnt_writeb(tnt_priv, tnt_priv->imr3_bits, IMR3); 1837 - tnt_readb(tnt_priv, IMR0); 1838 - tnt_readb(tnt_priv, IMR3); 1839 - nec7210_board_reset(nec_priv, board); 1840 - } 1841 - 1842 - int tnt4882_allocate_private(gpib_board_t *board) 1843 - { 1844 - struct tnt4882_priv *tnt_priv; 1845 - 1846 - board->private_data = kmalloc(sizeof(struct tnt4882_priv), GFP_KERNEL); 1847 - if (!board->private_data) 1848 - return -1; 1849 - tnt_priv = board->private_data; 1850 - memset(tnt_priv, 0, sizeof(struct tnt4882_priv)); 1851 - init_nec7210_private(&tnt_priv->nec7210_priv); 1852 - return 0; 1853 - } 1854 - 1855 - void tnt4882_free_private(gpib_board_t *board) 1856 - { 1857 - kfree(board->private_data); 1858 - board->private_data = NULL; 1859 - } 1860 - 1861 - void tnt4882_init(struct tnt4882_priv *tnt_priv, const gpib_board_t *board) 1862 - { 1863 - struct nec7210_priv *nec_priv = &tnt_priv->nec7210_priv; 1864 - 1865 - /* Turbo488 software reset */ 1866 - tnt_writeb(tnt_priv, SOFT_RESET, CMDR); 1867 - udelay(1); 1868 - 1869 - // turn off one-chip mode 1870 - tnt_writeb(tnt_priv, NODMA, HSSEL); 1871 - tnt_writeb(tnt_priv, 0, ACCWR); 1872 - // make sure we are in 7210 mode 1873 - tnt_writeb(tnt_priv, AUX_7210, AUXCR); 1874 - udelay(1); 1875 - // registers might be swapped, so write it to the swapped address too 1876 - tnt_writeb(tnt_priv, AUX_7210, SWAPPED_AUXCR); 1877 - udelay(1); 1878 - // turn on one-chip mode 1879 - if (nec_priv->type == TNT4882 || nec_priv->type == TNT5004) 1880 - tnt_writeb(tnt_priv, NODMA | TNT_ONE_CHIP_BIT, HSSEL); 1881 - else 1882 - tnt_writeb(tnt_priv, NODMA, HSSEL); 1883 - 1884 - nec7210_board_reset(nec_priv, board); 1885 - // read-clear isr0 1886 - tnt_readb(tnt_priv, ISR0); 1887 - 1888 - // enable passing of nat4882 interrupts 1889 - tnt_priv->imr3_bits = HR_TLCI; 1890 - tnt_writeb(tnt_priv, tnt_priv->imr3_bits, IMR3); 1891 - 1892 - // enable interrupt 1893 - tnt_writeb(tnt_priv, 0x1, INTRT); 1894 - 1895 - // force immediate holdoff 1896 - write_byte(&tnt_priv->nec7210_priv, AUX_HLDI, AUXMR); 1897 - 1898 - set_bit(RFD_HOLDOFF_BN, &nec_priv->state); 1899 - 1900 - tnt_priv->auxg_bits = AUXRG | NTNL_BIT; 1901 - write_byte(&tnt_priv->nec7210_priv, tnt_priv->auxg_bits, AUXMR); 1902 - 1903 - nec7210_board_online(nec_priv, board); 1904 - // enable interface clear interrupt for event queue 1905 - tnt_priv->imr0_bits = TNT_IMR0_ALWAYS_BITS | TNT_ATNI_BIT | TNT_IFCIE_BIT; 1906 - tnt_writeb(tnt_priv, tnt_priv->imr0_bits, IMR0); 1907 - } 1908 - 1909 - int ni_pci_attach(gpib_board_t *board, const gpib_board_config_t *config) 1910 - { 1911 - struct tnt4882_priv *tnt_priv; 1912 - struct nec7210_priv *nec_priv; 1913 - int isr_flags = IRQF_SHARED; 1914 - int retval; 1915 - struct mite_struct *mite; 1916 - 1917 - board->status = 0; 1918 - 1919 - if (tnt4882_allocate_private(board)) 1920 - return -ENOMEM; 1921 - tnt_priv = board->private_data; 1922 - nec_priv = &tnt_priv->nec7210_priv; 1923 - nec_priv->type = TNT4882; 1924 - nec_priv->read_byte = nec7210_locking_iomem_read_byte; 1925 - nec_priv->write_byte = nec7210_locking_iomem_write_byte; 1926 - nec_priv->offset = atgpib_reg_offset; 1927 - 1928 - if (!mite_devices) { 1929 - pr_err("no National Instruments PCI boards found\n"); 1930 - return -1; 1931 - } 1932 - 1933 - for (mite = mite_devices; mite; mite = mite->next) { 1934 - short found_board; 1935 - 1936 - if (mite->used) 1937 - continue; 1938 - if (config->pci_bus >= 0 && config->pci_bus != mite->pcidev->bus->number) 1939 - continue; 1940 - if (config->pci_slot >= 0 && config->pci_slot != PCI_SLOT(mite->pcidev->devfn)) 1941 - continue; 1942 - switch (mite_device_id(mite)) { 1943 - case PCI_DEVICE_ID_NI_GPIB: 1944 - case PCI_DEVICE_ID_NI_GPIB_PLUS: 1945 - case PCI_DEVICE_ID_NI_GPIB_PLUS2: 1946 - case PCI_DEVICE_ID_NI_PXIGPIB: 1947 - case PCI_DEVICE_ID_NI_PMCGPIB: 1948 - case PCI_DEVICE_ID_NI_PCIEGPIB: 1949 - case PCI_DEVICE_ID_NI_PCIE2GPIB: 1950 - // support for Measurement Computing PCI-488 1951 - case PCI_DEVICE_ID_MC_PCI488: 1952 - case PCI_DEVICE_ID_CEC_NI_GPIB: 1953 - found_board = 1; 1954 - break; 1955 - default: 1956 - found_board = 0; 1957 - break; 1958 - } 1959 - if (found_board) 1960 - break; 1961 - } 1962 - if (!mite) { 1963 - pr_err("no NI PCI-GPIB boards found\n"); 1964 - return -1; 1965 - } 1966 - tnt_priv->mite = mite; 1967 - retval = mite_setup(tnt_priv->mite); 1968 - if (retval < 0) { 1969 - pr_err("tnt4882: error setting up mite.\n"); 1970 - return retval; 1971 - } 1972 - 1973 - nec_priv->mmiobase = tnt_priv->mite->daq_io_addr; 1974 - 1975 - // get irq 1976 - if (request_irq(mite_irq(tnt_priv->mite), tnt4882_interrupt, isr_flags, 1977 - "ni-pci-gpib", board)) { 1978 - pr_err("gpib: can't request IRQ %d\n", mite_irq(tnt_priv->mite)); 1979 - return -1; 1980 - } 1981 - tnt_priv->irq = mite_irq(tnt_priv->mite); 1982 - pr_info("tnt4882: irq %i\n", tnt_priv->irq); 1983 - 1984 - // TNT5004 detection 1985 - switch (tnt_readb(tnt_priv, CSR) & 0xf0) { 1986 - case 0x30: 1987 - nec_priv->type = TNT4882; 1988 - pr_info("tnt4882: TNT4882 chipset detected\n"); 1989 - break; 1990 - case 0x40: 1991 - nec_priv->type = TNT5004; 1992 - pr_info("tnt4882: TNT5004 chipset detected\n"); 1993 - break; 1994 - } 1995 - tnt4882_init(tnt_priv, board); 1996 - 1997 - return 0; 1998 - } 1999 - 2000 - void ni_pci_detach(gpib_board_t *board) 2001 - { 2002 - struct tnt4882_priv *tnt_priv = board->private_data; 2003 - struct nec7210_priv *nec_priv; 2004 - 2005 - if (tnt_priv) { 2006 - nec_priv = &tnt_priv->nec7210_priv; 2007 - 2008 - if (nec_priv->mmiobase) 2009 - tnt4882_board_reset(tnt_priv, board); 2010 - if (tnt_priv->irq) 2011 - free_irq(tnt_priv->irq, board); 2012 - if (tnt_priv->mite) 2013 - mite_unsetup(tnt_priv->mite); 2014 - } 2015 - tnt4882_free_private(board); 2016 - } 2017 - 2018 - static int ni_isapnp_find(struct pnp_dev **dev) 2019 - { 2020 - *dev = pnp_find_dev(NULL, ISAPNP_VENDOR_ID_NI, 2021 - ISAPNP_FUNCTION(ISAPNP_ID_NI_ATGPIB_TNT), NULL); 2022 - if (!*dev || !(*dev)->card) { 2023 - pr_err("tnt4882: failed to find isapnp board\n"); 2024 - return -ENODEV; 2025 - } 2026 - if (pnp_device_attach(*dev) < 0) { 2027 - pr_err("tnt4882: atgpib/tnt board already active, skipping\n"); 2028 - return -EBUSY; 2029 - } 2030 - if (pnp_activate_dev(*dev) < 0) { 2031 - pnp_device_detach(*dev); 2032 - pr_err("tnt4882: failed to activate() atgpib/tnt, aborting\n"); 2033 - return -EAGAIN; 2034 - } 2035 - if (!pnp_port_valid(*dev, 0) || !pnp_irq_valid(*dev, 0)) { 2036 - pnp_device_detach(*dev); 2037 - pr_err("tnt4882: invalid port or irq for atgpib/tnt, aborting\n"); 2038 - return -ENOMEM; 2039 - } 2040 - return 0; 2041 - } 2042 - 2043 - static int ni_isa_attach_common(gpib_board_t *board, const gpib_board_config_t *config, 2044 - enum nec7210_chipset chipset) 2045 - { 2046 - struct tnt4882_priv *tnt_priv; 2047 - struct nec7210_priv *nec_priv; 2048 - int isr_flags = 0; 2049 - u32 iobase; 2050 - int irq; 2051 - 2052 - board->status = 0; 2053 - 2054 - if (tnt4882_allocate_private(board)) 2055 - return -ENOMEM; 2056 - tnt_priv = board->private_data; 2057 - nec_priv = &tnt_priv->nec7210_priv; 2058 - nec_priv->type = chipset; 2059 - nec_priv->read_byte = nec7210_locking_ioport_read_byte; 2060 - nec_priv->write_byte = nec7210_locking_ioport_write_byte; 2061 - nec_priv->offset = atgpib_reg_offset; 2062 - 2063 - // look for plug-n-play board 2064 - if (config->ibbase == 0) { 2065 - struct pnp_dev *dev; 2066 - int retval; 2067 - 2068 - retval = ni_isapnp_find(&dev); 2069 - if (retval < 0) 2070 - return retval; 2071 - tnt_priv->pnp_dev = dev; 2072 - iobase = pnp_port_start(dev, 0); 2073 - irq = pnp_irq(dev, 0); 2074 - } else { 2075 - iobase = config->ibbase; 2076 - irq = config->ibirq; 2077 - } 2078 - // allocate ioports 2079 - if (!request_region(iobase, atgpib_iosize, "atgpib")) { 2080 - pr_err("tnt4882: failed to allocate ioports\n"); 2081 - return -1; 2082 - } 2083 - nec_priv->mmiobase = ioport_map(iobase, atgpib_iosize); 2084 - if (!nec_priv->mmiobase) 2085 - return -1; 2086 - 2087 - // get irq 2088 - if (request_irq(irq, tnt4882_interrupt, isr_flags, "atgpib", board)) { 2089 - pr_err("gpib: can't request IRQ %d\n", irq); 2090 - return -1; 2091 - } 2092 - tnt_priv->irq = irq; 2093 - 2094 - tnt4882_init(tnt_priv, board); 2095 - 2096 - return 0; 2097 - } 2098 - 2099 - int ni_tnt_isa_attach(gpib_board_t *board, const gpib_board_config_t *config) 2100 - { 2101 - return ni_isa_attach_common(board, config, TNT4882); 2102 - } 2103 - 2104 - int ni_nat4882_isa_attach(gpib_board_t *board, const gpib_board_config_t *config) 2105 - { 2106 - return ni_isa_attach_common(board, config, NAT4882); 2107 - } 2108 - 2109 - int ni_nec_isa_attach(gpib_board_t *board, const gpib_board_config_t *config) 2110 - { 2111 - return ni_isa_attach_common(board, config, NEC7210); 2112 - } 2113 - 2114 - void ni_isa_detach(gpib_board_t *board) 2115 - { 2116 - struct tnt4882_priv *tnt_priv = board->private_data; 2117 - struct nec7210_priv *nec_priv; 2118 - 2119 - if (tnt_priv) { 2120 - nec_priv = &tnt_priv->nec7210_priv; 2121 - if (nec_priv->iobase) 2122 - tnt4882_board_reset(tnt_priv, board); 2123 - if (tnt_priv->irq) 2124 - free_irq(tnt_priv->irq, board); 2125 - if (nec_priv->mmiobase) 2126 - ioport_unmap(nec_priv->mmiobase); 2127 - if (nec_priv->iobase) 2128 - release_region(nec_priv->iobase, atgpib_iosize); 2129 - if (tnt_priv->pnp_dev) 2130 - pnp_device_detach(tnt_priv->pnp_dev); 2131 - } 2132 - tnt4882_free_private(board); 2133 - } 2134 - 2135 - static int tnt4882_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) 2136 - { 2137 - return 0; 2138 - } 2139 - 2140 - static const struct pci_device_id tnt4882_pci_table[] = { 2141 - {PCI_DEVICE(PCI_VENDOR_ID_NATINST, PCI_DEVICE_ID_NI_GPIB)}, 2142 - {PCI_DEVICE(PCI_VENDOR_ID_NATINST, PCI_DEVICE_ID_NI_GPIB_PLUS)}, 2143 - {PCI_DEVICE(PCI_VENDOR_ID_NATINST, PCI_DEVICE_ID_NI_GPIB_PLUS2)}, 2144 - {PCI_DEVICE(PCI_VENDOR_ID_NATINST, PCI_DEVICE_ID_NI_PXIGPIB)}, 2145 - {PCI_DEVICE(PCI_VENDOR_ID_NATINST, PCI_DEVICE_ID_NI_PMCGPIB)}, 2146 - {PCI_DEVICE(PCI_VENDOR_ID_NATINST, PCI_DEVICE_ID_NI_PCIEGPIB)}, 2147 - {PCI_DEVICE(PCI_VENDOR_ID_NATINST, PCI_DEVICE_ID_NI_PCIE2GPIB)}, 2148 - // support for Measurement Computing PCI-488 2149 - {PCI_DEVICE(PCI_VENDOR_ID_NATINST, PCI_DEVICE_ID_MC_PCI488)}, 2150 - {PCI_DEVICE(PCI_VENDOR_ID_NATINST, PCI_DEVICE_ID_CEC_NI_GPIB)}, 2151 - { 0 } 2152 - }; 2153 - MODULE_DEVICE_TABLE(pci, tnt4882_pci_table); 2154 - 2155 - static struct pci_driver tnt4882_pci_driver = { 2156 - .name = "tnt4882", 2157 - .id_table = tnt4882_pci_table, 2158 - .probe = &tnt4882_pci_probe 2159 - }; 2160 - 2161 - static const struct pnp_device_id tnt4882_pnp_table[] = { 2162 - {.id = "NICC601"}, 2163 - {.id = ""} 2164 - }; 2165 - MODULE_DEVICE_TABLE(pnp, tnt4882_pnp_table); 2166 - 2167 - static int __init tnt4882_init_module(void) 2168 - { 2169 - int result; 2170 - 2171 - result = pci_register_driver(&tnt4882_pci_driver); 2172 - if (result) { 2173 - pr_err("tnt4882_gpib: pci_register_driver failed: error = %d\n", result); 2174 - return result; 2175 - } 2176 - 2177 - result = gpib_register_driver(&ni_isa_interface, THIS_MODULE); 2178 - if (result) { 2179 - pr_err("tnt4882_gpib: gpib_register_driver failed: error = %d\n", result); 2180 - goto err_isa; 2181 - } 2182 - 2183 - result = gpib_register_driver(&ni_isa_accel_interface, THIS_MODULE); 2184 - if (result) { 2185 - pr_err("tnt4882_gpib: gpib_register_driver failed: error = %d\n", result); 2186 - goto err_isa_accel; 2187 - } 2188 - 2189 - result = gpib_register_driver(&ni_nat4882_isa_interface, THIS_MODULE); 2190 - if (result) { 2191 - pr_err("tnt4882_gpib: gpib_register_driver failed: error = %d\n", result); 2192 - goto err_nat4882_isa; 2193 - } 2194 - 2195 - result = gpib_register_driver(&ni_nat4882_isa_accel_interface, THIS_MODULE); 2196 - if (result) { 2197 - pr_err("tnt4882_gpib: gpib_register_driver failed: error = %d\n", result); 2198 - goto err_nat4882_isa_accel; 2199 - } 2200 - 2201 - result = gpib_register_driver(&ni_nec_isa_interface, THIS_MODULE); 2202 - if (result) { 2203 - pr_err("tnt4882_gpib: gpib_register_driver failed: error = %d\n", result); 2204 - goto err_nec_isa; 2205 - } 2206 - 2207 - result = gpib_register_driver(&ni_nec_isa_accel_interface, THIS_MODULE); 2208 - if (result) { 2209 - pr_err("tnt4882_gpib: gpib_register_driver failed: error = %d\n", result); 2210 - goto err_nec_isa_accel; 2211 - } 2212 - 2213 - result = gpib_register_driver(&ni_pci_interface, THIS_MODULE); 2214 - if (result) { 2215 - pr_err("tnt4882_gpib: gpib_register_driver failed: error = %d\n", result); 2216 - goto err_pci; 2217 - } 2218 - 2219 - result = gpib_register_driver(&ni_pci_accel_interface, THIS_MODULE); 2220 - if (result) { 2221 - pr_err("tnt4882_gpib: gpib_register_driver failed: error = %d\n", result); 2222 - goto err_pci_accel; 2223 - } 2224 - 2225 - #ifdef GPIB_PCMCIA 2226 - result = gpib_register_driver(&ni_pcmcia_interface, THIS_MODULE); 2227 - if (result) { 2228 - pr_err("tnt4882_gpib: gpib_register_driver failed: error = %d\n", result); 2229 - goto err_pcmcia; 2230 - } 2231 - 2232 - result = gpib_register_driver(&ni_pcmcia_accel_interface, THIS_MODULE); 2233 - if (result) { 2234 - pr_err("tnt4882_gpib: gpib_register_driver failed: error = %d\n", result); 2235 - goto err_pcmcia_accel; 2236 - } 2237 - 2238 - result = init_ni_gpib_cs(); 2239 - if (result) { 2240 - pr_err("tnt4882_gpib: pcmcia_register_driver failed: error = %d\n", result); 2241 - goto err_pcmcia_driver; 2242 - } 2243 - #endif 2244 - 2245 - mite_init(); 2246 - mite_list_devices(); 2247 - 2248 - return 0; 2249 - 2250 - #ifdef GPIB_PCMCIA 2251 - err_pcmcia_driver: 2252 - gpib_unregister_driver(&ni_pcmcia_accel_interface); 2253 - err_pcmcia_accel: 2254 - gpib_unregister_driver(&ni_pcmcia_interface); 2255 - err_pcmcia: 2256 - #endif 2257 - gpib_unregister_driver(&ni_pci_accel_interface); 2258 - err_pci_accel: 2259 - gpib_unregister_driver(&ni_pci_interface); 2260 - err_pci: 2261 - gpib_unregister_driver(&ni_nec_isa_accel_interface); 2262 - err_nec_isa_accel: 2263 - gpib_unregister_driver(&ni_nec_isa_interface); 2264 - err_nec_isa: 2265 - gpib_unregister_driver(&ni_nat4882_isa_accel_interface); 2266 - err_nat4882_isa_accel: 2267 - gpib_unregister_driver(&ni_nat4882_isa_interface); 2268 - err_nat4882_isa: 2269 - gpib_unregister_driver(&ni_isa_accel_interface); 2270 - err_isa_accel: 2271 - gpib_unregister_driver(&ni_isa_interface); 2272 - err_isa: 2273 - pci_unregister_driver(&tnt4882_pci_driver); 2274 - 2275 - return result; 2276 - } 2277 - 2278 - static void __exit tnt4882_exit_module(void) 2279 - { 2280 - gpib_unregister_driver(&ni_isa_interface); 2281 - gpib_unregister_driver(&ni_isa_accel_interface); 2282 - gpib_unregister_driver(&ni_nat4882_isa_interface); 2283 - gpib_unregister_driver(&ni_nat4882_isa_accel_interface); 2284 - gpib_unregister_driver(&ni_nec_isa_interface); 2285 - gpib_unregister_driver(&ni_nec_isa_accel_interface); 2286 - gpib_unregister_driver(&ni_pci_interface); 2287 - gpib_unregister_driver(&ni_pci_accel_interface); 2288 - #ifdef GPIB_PCMCIA 2289 - gpib_unregister_driver(&ni_pcmcia_interface); 2290 - gpib_unregister_driver(&ni_pcmcia_accel_interface); 2291 - exit_ni_gpib_cs(); 2292 - #endif 2293 - 2294 - mite_cleanup(); 2295 - 2296 - pci_unregister_driver(&tnt4882_pci_driver); 2297 - } 2298 - 2299 - #ifdef GPIB_PCMCIA 2300 - 2301 - #include <linux/kernel.h> 2302 - #include <linux/moduleparam.h> 2303 - #include <linux/ptrace.h> 2304 - #include <linux/timer.h> 2305 - #include <linux/ioport.h> 2306 - #include <linux/io.h> 2307 - 2308 - #include <pcmcia/cistpl.h> 2309 - #include <pcmcia/cisreg.h> 2310 - #include <pcmcia/ds.h> 2311 - 2312 - /* 2313 - * All the PCMCIA modules use PCMCIA_DEBUG to control debugging. If 2314 - * you do not define PCMCIA_DEBUG at all, all the debug code will be 2315 - * left out. If you compile with PCMCIA_DEBUG=0, the debug code will 2316 - * be present but disabled -- but it can then be enabled for specific 2317 - * modules at load time with a 'pc_debug=#' option to insmod. 2318 - */ 2319 - #define PCMCIA_DEBUG 1 2320 - #ifdef PCMCIA_DEBUG 2321 - static int pc_debug = PCMCIA_DEBUG; 2322 - module_param(pc_debug, int, 0); 2323 - #define DEBUG(n, args...) \ 2324 - do {if (pc_debug > (n)) \ 2325 - pr_debug(args); } \ 2326 - while (0) 2327 - #else 2328 - #define DEBUG(args...) 2329 - #endif 2330 - 2331 - static int ni_gpib_config(struct pcmcia_device *link); 2332 - static void ni_gpib_release(struct pcmcia_device *link); 2333 - static int ni_pcmcia_attach(gpib_board_t *board, const gpib_board_config_t *config); 2334 - static void ni_pcmcia_detach(gpib_board_t *board); 2335 - 2336 - /* 2337 - * A linked list of "instances" of the dummy device. Each actual 2338 - * PCMCIA card corresponds to one device instance, and is described 2339 - * by one dev_link_t structure (defined in ds.h). 2340 - * 2341 - * You may not want to use a linked list for this -- for example, the 2342 - * memory card driver uses an array of dev_link_t pointers, where minor 2343 - * device numbers are used to derive the corresponding array index. 2344 - * 2345 - * I think this dev_list is obsolete but the pointer is needed to keep 2346 - * the module instance for the ni_pcmcia_attach function. 2347 - */ 2348 - 2349 - static struct pcmcia_device *curr_dev; 2350 - 2351 - struct local_info_t { 2352 - struct pcmcia_device *p_dev; 2353 - gpib_board_t *dev; 2354 - int stop; 2355 - struct bus_operations *bus; 2356 - }; 2357 - 2358 - /* 2359 - * ni_gpib_probe() creates an "instance" of the driver, allocating 2360 - * local data structures for one device. The device is registered 2361 - * with Card Services. 2362 - */ 2363 - 2364 - static int ni_gpib_probe(struct pcmcia_device *link) 2365 - { 2366 - struct local_info_t *info; 2367 - //struct gpib_board_t *dev; 2368 - 2369 - DEBUG(0, "%s(0x%p)\n", __func__, link); 2370 - 2371 - /* Allocate space for private device-specific data */ 2372 - info = kzalloc(sizeof(*info), GFP_KERNEL); 2373 - if (!info) 2374 - return -ENOMEM; 2375 - 2376 - info->p_dev = link; 2377 - link->priv = info; 2378 - 2379 - /* 2380 - * General socket configuration defaults can go here. In this 2381 - * client, we assume very little, and rely on the CIS for almost 2382 - * everything. In most clients, many details (i.e., number, sizes, 2383 - * and attributes of IO windows) are fixed by the nature of the 2384 - * device, and can be hard-wired here. 2385 - */ 2386 - link->config_flags = CONF_ENABLE_IRQ | CONF_AUTO_SET_IO; 2387 - 2388 - /* Register with Card Services */ 2389 - curr_dev = link; 2390 - return ni_gpib_config(link); 2391 - } 2392 - 2393 - /* 2394 - * This deletes a driver "instance". The device is de-registered 2395 - * with Card Services. If it has been released, all local data 2396 - * structures are freed. Otherwise, the structures will be freed 2397 - * when the device is released. 2398 - */ 2399 - static void ni_gpib_remove(struct pcmcia_device *link) 2400 - { 2401 - struct local_info_t *info = link->priv; 2402 - //struct gpib_board_t *dev = info->dev; 2403 - 2404 - DEBUG(0, "%s(%p)\n", __func__, link); 2405 - 2406 - if (info->dev) 2407 - ni_pcmcia_detach(info->dev); 2408 - ni_gpib_release(link); 2409 - 2410 - //free_netdev(dev); 2411 - kfree(info); 2412 - } 2413 - 2414 - static int ni_gpib_config_iteration(struct pcmcia_device *link, void *priv_data) 2415 - { 2416 - int retval; 2417 - 2418 - retval = pcmcia_request_io(link); 2419 - if (retval != 0) 2420 - return retval; 2421 - 2422 - return 0; 2423 - } 2424 - 2425 - /* 2426 - * ni_gpib_config() is scheduled to run after a CARD_INSERTION event 2427 - * is received, to configure the PCMCIA socket, and to make the 2428 - * device available to the system. 2429 - */ 2430 - static int ni_gpib_config(struct pcmcia_device *link) 2431 - { 2432 - //struct local_info_t *info = link->priv; 2433 - //gpib_board_t *dev = info->dev; 2434 - int last_ret; 2435 - 2436 - DEBUG(0, "%s(0x%p)\n", __func__, link); 2437 - 2438 - last_ret = pcmcia_loop_config(link, &ni_gpib_config_iteration, NULL); 2439 - if (last_ret) { 2440 - dev_warn(&link->dev, "no configuration found\n"); 2441 - ni_gpib_release(link); 2442 - return last_ret; 2443 - } 2444 - 2445 - last_ret = pcmcia_enable_device(link); 2446 - if (last_ret) { 2447 - ni_gpib_release(link); 2448 - return last_ret; 2449 - } 2450 - return 0; 2451 - } /* ni_gpib_config */ 2452 - 2453 - /* 2454 - * After a card is removed, ni_gpib_release() will unregister the 2455 - * device, and release the PCMCIA configuration. If the device is 2456 - * still open, this will be postponed until it is closed. 2457 - */ 2458 - static void ni_gpib_release(struct pcmcia_device *link) 2459 - { 2460 - DEBUG(0, "%s(0x%p)\n", __func__, link); 2461 - pcmcia_disable_device(link); 2462 - } /* ni_gpib_release */ 2463 - 2464 - static int ni_gpib_suspend(struct pcmcia_device *link) 2465 - { 2466 - //struct local_info_t *info = link->priv; 2467 - //struct gpib_board_t *dev = info->dev; 2468 - DEBUG(0, "%s(0x%p)\n", __func__, link); 2469 - 2470 - if (link->open) 2471 - pr_err("Device still open ???\n"); 2472 - //netif_device_detach(dev); 2473 - 2474 - return 0; 2475 - } 2476 - 2477 - static int ni_gpib_resume(struct pcmcia_device *link) 2478 - { 2479 - //struct local_info_t *info = link->priv; 2480 - //struct gpib_board_t *dev = info->dev; 2481 - DEBUG(0, "%s(0x%p)\n", __func__, link); 2482 - 2483 - /*if (link->open) { 2484 - * ni_gpib_probe(dev); / really? 2485 - * printk("Gpib resumed ???\n"); 2486 - * //netif_device_attach(dev); 2487 - *} 2488 - */ 2489 - return ni_gpib_config(link); 2490 - } 2491 - 2492 - static struct pcmcia_device_id ni_pcmcia_ids[] = { 2493 - PCMCIA_DEVICE_MANF_CARD(0x010b, 0x4882), 2494 - PCMCIA_DEVICE_MANF_CARD(0x010b, 0x0c71), // NI PCMCIA-GPIB+ 2495 - PCMCIA_DEVICE_NULL 2496 - }; 2497 - 2498 - MODULE_DEVICE_TABLE(pcmcia, ni_pcmcia_ids); 2499 - 2500 - static struct pcmcia_driver ni_gpib_cs_driver = { 2501 - .name = "ni_gpib_cs", 2502 - .owner = THIS_MODULE, 2503 - .drv = { .name = "ni_gpib_cs", }, 2504 - .id_table = ni_pcmcia_ids, 2505 - .probe = ni_gpib_probe, 2506 - .remove = ni_gpib_remove, 2507 - .suspend = ni_gpib_suspend, 2508 - .resume = ni_gpib_resume, 2509 - }; 2510 - 2511 - int __init init_ni_gpib_cs(void) 2512 - { 2513 - return pcmcia_register_driver(&ni_gpib_cs_driver); 2514 - } 2515 - 2516 - void __exit exit_ni_gpib_cs(void) 2517 - { 2518 - DEBUG(0, "ni_gpib_cs: unloading\n"); 2519 - pcmcia_unregister_driver(&ni_gpib_cs_driver); 2520 - } 2521 - 2522 - static const int pcmcia_gpib_iosize = 32; 2523 - 2524 - int ni_pcmcia_attach(gpib_board_t *board, const gpib_board_config_t *config) 2525 - { 2526 - struct local_info_t *info; 2527 - struct tnt4882_priv *tnt_priv; 2528 - struct nec7210_priv *nec_priv; 2529 - int isr_flags = IRQF_SHARED; 2530 - 2531 - DEBUG(0, "%s(0x%p)\n", __func__, board); 2532 - 2533 - if (!curr_dev) { 2534 - pr_err("gpib: no NI PCMCIA board found\n"); 2535 - return -1; 2536 - } 2537 - 2538 - info = curr_dev->priv; 2539 - info->dev = board; 2540 - 2541 - board->status = 0; 2542 - 2543 - if (tnt4882_allocate_private(board)) 2544 - return -ENOMEM; 2545 - tnt_priv = board->private_data; 2546 - nec_priv = &tnt_priv->nec7210_priv; 2547 - nec_priv->type = TNT4882; 2548 - nec_priv->read_byte = nec7210_locking_ioport_read_byte; 2549 - nec_priv->write_byte = nec7210_locking_ioport_write_byte; 2550 - nec_priv->offset = atgpib_reg_offset; 2551 - 2552 - DEBUG(0, "ioport1 window attributes: 0x%lx\n", curr_dev->resource[0]->flags); 2553 - if (!request_region(curr_dev->resource[0]->start, resource_size(curr_dev->resource[0]), 2554 - "tnt4882")) { 2555 - pr_err("gpib: ioports starting at 0x%lx are already in use\n", 2556 - (unsigned long)curr_dev->resource[0]->start); 2557 - return -EIO; 2558 - } 2559 - 2560 - nec_priv->mmiobase = ioport_map(curr_dev->resource[0]->start, 2561 - resource_size(curr_dev->resource[0])); 2562 - if (!nec_priv->mmiobase) 2563 - return -1; 2564 - 2565 - // get irq 2566 - if (request_irq(curr_dev->irq, tnt4882_interrupt, isr_flags, "tnt4882", board)) { 2567 - pr_err("gpib: can't request IRQ %d\n", curr_dev->irq); 2568 - return -1; 2569 - } 2570 - tnt_priv->irq = curr_dev->irq; 2571 - 2572 - tnt4882_init(tnt_priv, board); 2573 - 2574 - return 0; 2575 - } 2576 - 2577 - void ni_pcmcia_detach(gpib_board_t *board) 2578 - { 2579 - struct tnt4882_priv *tnt_priv = board->private_data; 2580 - struct nec7210_priv *nec_priv; 2581 - 2582 - DEBUG(0, "%s(0x%p)\n", __func__, board); 2583 - 2584 - if (tnt_priv) { 2585 - nec_priv = &tnt_priv->nec7210_priv; 2586 - if (tnt_priv->irq) 2587 - free_irq(tnt_priv->irq, board); 2588 - if (nec_priv->mmiobase) 2589 - ioport_unmap(nec_priv->mmiobase); 2590 - if (nec_priv->iobase) { 2591 - tnt4882_board_reset(tnt_priv, board); 2592 - release_region(nec_priv->iobase, pcmcia_gpib_iosize); 2593 - } 2594 - } 2595 - tnt4882_free_private(board); 2596 - } 2597 - 2598 - #endif // GPIB_PCMCIA 1174 + #endif // CONFIG_GPIB_PCMCIA 2599 1175 2600 1176 module_init(tnt4882_init_module); 2601 1177 module_exit(tnt4882_exit_module);
+9 -20
drivers/staging/gpib/uapi/gpib_user.h
··· 106 106 107 107 /* GPIB Bus Control Lines bit vector */ 108 108 enum bus_control_line { 109 - ValidDAV = 0x01, 110 - ValidNDAC = 0x02, 111 - ValidNRFD = 0x04, 112 - ValidIFC = 0x08, 113 - ValidREN = 0x10, 114 - ValidSRQ = 0x20, 115 - ValidATN = 0x40, 116 - ValidEOI = 0x80, 117 - ValidALL = 0xff, 118 - BusDAV = 0x0100, /* DAV line status bit */ 119 - BusNDAC = 0x0200, /* NDAC line status bit */ 120 - BusNRFD = 0x0400, /* NRFD line status bit */ 121 - BusIFC = 0x0800, /* IFC line status bit */ 122 - BusREN = 0x1000, /* REN line status bit */ 123 - BusSRQ = 0x2000, /* SRQ line status bit */ 124 - BusATN = 0x4000, /* ATN line status bit */ 125 - BusEOI = 0x8000 /* EOI line status bit */ 126 - }; 127 - 128 - enum old_bus_control_line { 109 + VALID_DAV = 0x01, 110 + VALID_NDAC = 0x02, 111 + VALID_NRFD = 0x04, 112 + VALID_IFC = 0x08, 113 + VALID_REN = 0x10, 114 + VALID_SRQ = 0x20, 115 + VALID_ATN = 0x40, 116 + VALID_EOI = 0x80, 117 + VALID_ALL = 0xff, 129 118 BUS_DAV = 0x0100, /* DAV line status bit */ 130 119 BUS_NDAC = 0x0200, /* NDAC line status bit */ 131 120 BUS_NRFD = 0x0400, /* NRFD line status bit */
+1
drivers/staging/rtl8723bs/Kconfig
··· 4 4 depends on WLAN && MMC && CFG80211 5 5 depends on m 6 6 select CRYPTO 7 + select CRYPTO_LIB_AES 7 8 select CRYPTO_LIB_ARC4 8 9 help 9 10 This option enables support for RTL8723BS SDIO drivers, such as
+48 -48
drivers/staging/rtl8723bs/core/rtw_ap.c
··· 324 324 { 325 325 unsigned char sta_band = 0, shortGIrate = false; 326 326 unsigned int tx_ra_bitmap = 0; 327 - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); 327 + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; 328 328 struct wlan_bssid_ex 329 329 *pcur_network = (struct wlan_bssid_ex *)&pmlmepriv->cur_network.network; 330 330 ··· 372 372 unsigned char network_type; 373 373 int supportRateNum = 0; 374 374 unsigned int tx_ra_bitmap = 0; 375 - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); 376 - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); 377 - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); 375 + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; 376 + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; 377 + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; 378 378 struct wlan_bssid_ex 379 379 *pcur_network = (struct wlan_bssid_ex *)&pmlmepriv->cur_network.network; 380 380 struct sta_info *psta = rtw_get_bcmc_stainfo(padapter); ··· 451 451 452 452 void update_sta_info_apmode(struct adapter *padapter, struct sta_info *psta) 453 453 { 454 - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); 454 + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; 455 455 struct security_priv *psecuritypriv = &padapter->securitypriv; 456 - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); 456 + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; 457 457 struct ht_priv *phtpriv_ap = &pmlmepriv->htpriv; 458 458 struct ht_priv *phtpriv_sta = &psta->htpriv; 459 459 u8 cur_ldpc_cap = 0, cur_stbc_cap = 0, cur_beamform_cap = 0; ··· 563 563 564 564 static void update_ap_info(struct adapter *padapter, struct sta_info *psta) 565 565 { 566 - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); 566 + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; 567 567 struct wlan_bssid_ex 568 568 *pnetwork = (struct wlan_bssid_ex *)&pmlmepriv->cur_network.network; 569 - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); 569 + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; 570 570 struct ht_priv *phtpriv_ap = &pmlmepriv->htpriv; 571 571 572 572 psta->wireless_mode = pmlmeext->cur_wireless_mode; ··· 609 609 unsigned char max_AMPDU_len; 610 610 unsigned char min_MPDU_spacing; 611 611 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; 612 - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); 612 + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; 613 613 614 614 /* handle A-MPDU parameter field 615 615 * ··· 645 645 u32 acparm; 646 646 int ie_len; 647 647 struct registry_priv *pregpriv = &padapter->registrypriv; 648 - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); 649 - struct security_priv *psecuritypriv = &(padapter->securitypriv); 648 + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; 649 + struct security_priv *psecuritypriv = &padapter->securitypriv; 650 650 struct wlan_bssid_ex 651 651 *pnetwork = (struct wlan_bssid_ex *)&pmlmepriv->cur_network.network; 652 - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); 653 - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); 654 - struct wlan_bssid_ex *pnetwork_mlmeext = &(pmlmeinfo->network); 652 + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; 653 + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; 654 + struct wlan_bssid_ex *pnetwork_mlmeext = &pmlmeinfo->network; 655 655 struct HT_info_element *pht_info = NULL; 656 656 u8 cbw40_enable = 0; 657 657 ··· 823 823 u8 WMM_PARA_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x01, 0x01}; 824 824 struct registry_priv *pregistrypriv = &padapter->registrypriv; 825 825 struct security_priv *psecuritypriv = &padapter->securitypriv; 826 - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); 826 + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; 827 827 struct wlan_bssid_ex 828 828 *pbss_network = (struct wlan_bssid_ex *)&pmlmepriv->cur_network.network; 829 829 u8 *ie = pbss_network->ies; ··· 845 845 846 846 pbss_network->rssi = 0; 847 847 848 - memcpy(pbss_network->mac_address, myid(&(padapter->eeprompriv)), ETH_ALEN); 848 + memcpy(pbss_network->mac_address, myid(&padapter->eeprompriv), ETH_ALEN); 849 849 850 850 /* beacon interval */ 851 851 p = rtw_get_beacon_interval_from_ie(ie);/* ie + 8; 8: TimeStamp, 2: Beacon Interval 2:Capability */ ··· 1186 1186 if ((NUM_ACL - 1) < pacl_list->num) 1187 1187 return (-1); 1188 1188 1189 - spin_lock_bh(&(pacl_node_q->lock)); 1189 + spin_lock_bh(&pacl_node_q->lock); 1190 1190 1191 1191 phead = get_list_head(pacl_node_q); 1192 1192 list_for_each(plist, phead) { ··· 1200 1200 } 1201 1201 } 1202 1202 1203 - spin_unlock_bh(&(pacl_node_q->lock)); 1203 + spin_unlock_bh(&pacl_node_q->lock); 1204 1204 1205 1205 if (added) 1206 1206 return ret; 1207 1207 1208 - spin_lock_bh(&(pacl_node_q->lock)); 1208 + spin_lock_bh(&pacl_node_q->lock); 1209 1209 1210 1210 for (i = 0; i < NUM_ACL; i++) { 1211 1211 paclnode = &pacl_list->aclnode[i]; ··· 1225 1225 } 1226 1226 } 1227 1227 1228 - spin_unlock_bh(&(pacl_node_q->lock)); 1228 + spin_unlock_bh(&pacl_node_q->lock); 1229 1229 1230 1230 return ret; 1231 1231 } ··· 1238 1238 struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; 1239 1239 struct __queue *pacl_node_q = &pacl_list->acl_node_q; 1240 1240 1241 - spin_lock_bh(&(pacl_node_q->lock)); 1241 + spin_lock_bh(&pacl_node_q->lock); 1242 1242 1243 1243 phead = get_list_head(pacl_node_q); 1244 1244 list_for_each_safe(plist, tmp, phead) { ··· 1258 1258 } 1259 1259 } 1260 1260 1261 - spin_unlock_bh(&(pacl_node_q->lock)); 1261 + spin_unlock_bh(&pacl_node_q->lock); 1262 1262 1263 1263 } 1264 1264 ··· 1308 1308 u8 keylen; 1309 1309 struct cmd_obj *pcmd; 1310 1310 struct setkey_parm *psetkeyparm; 1311 - struct cmd_priv *pcmdpriv = &(padapter->cmdpriv); 1311 + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; 1312 1312 int res = _SUCCESS; 1313 1313 1314 1314 pcmd = rtw_zmalloc(sizeof(struct cmd_obj)); ··· 1345 1345 keylen = 16; 1346 1346 } 1347 1347 1348 - memcpy(&(psetkeyparm->key[0]), key, keylen); 1348 + memcpy(&psetkeyparm->key[0], key, keylen); 1349 1349 1350 1350 pcmd->cmdcode = _SetKey_CMD_; 1351 1351 pcmd->parmbuf = (u8 *)psetkeyparm; ··· 1397 1397 1398 1398 static void update_bcn_erpinfo_ie(struct adapter *padapter) 1399 1399 { 1400 - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); 1401 - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); 1402 - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); 1403 - struct wlan_bssid_ex *pnetwork = &(pmlmeinfo->network); 1400 + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; 1401 + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; 1402 + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; 1403 + struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; 1404 1404 unsigned char *p, *ie = pnetwork->ies; 1405 1405 u32 len = 0; 1406 1406 ··· 1461 1461 u8 *pbackup_remainder_ie = NULL; 1462 1462 1463 1463 uint wps_ielen = 0, wps_offset, remainder_ielen; 1464 - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); 1465 - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); 1466 - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); 1467 - struct wlan_bssid_ex *pnetwork = &(pmlmeinfo->network); 1464 + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; 1465 + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; 1466 + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; 1467 + struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; 1468 1468 unsigned char *ie = pnetwork->ies; 1469 1469 u32 ielen = pnetwork->ie_length; 1470 1470 ··· 1537 1537 if (!padapter) 1538 1538 return; 1539 1539 1540 - pmlmepriv = &(padapter->mlmepriv); 1541 - pmlmeext = &(padapter->mlmeextpriv); 1540 + pmlmepriv = &padapter->mlmepriv; 1541 + pmlmeext = &padapter->mlmeextpriv; 1542 1542 /* pmlmeinfo = &(pmlmeext->mlmext_info); */ 1543 1543 1544 1544 if (!pmlmeext->bstart_bss) ··· 1619 1619 { 1620 1620 u16 cur_op_mode, new_op_mode; 1621 1621 int op_mode_changes = 0; 1622 - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); 1622 + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; 1623 1623 struct ht_priv *phtpriv_ap = &pmlmepriv->htpriv; 1624 1624 1625 1625 if (pmlmepriv->htpriv.ht_option) ··· 1703 1703 void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta) 1704 1704 { 1705 1705 u8 beacon_updated = false; 1706 - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); 1707 - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); 1706 + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; 1707 + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; 1708 1708 1709 1709 if (!(psta->flags & WLAN_STA_SHORT_PREAMBLE)) { 1710 1710 if (!psta->no_short_preamble_set) { ··· 1823 1823 u8 bss_cap_update_on_sta_leave(struct adapter *padapter, struct sta_info *psta) 1824 1824 { 1825 1825 u8 beacon_updated = false; 1826 - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); 1827 - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); 1826 + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; 1827 + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; 1828 1828 1829 1829 if (!psta) 1830 1830 return beacon_updated; ··· 1932 1932 struct sta_info *psta = NULL; 1933 1933 struct sta_priv *pstapriv = &padapter->stapriv; 1934 1934 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; 1935 - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); 1935 + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; 1936 1936 u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; 1937 1937 1938 1938 if ((pmlmeinfo->state & 0x03) != WIFI_FW_AP_STATE) ··· 1962 1962 void sta_info_update(struct adapter *padapter, struct sta_info *psta) 1963 1963 { 1964 1964 int flags = psta->flags; 1965 - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); 1965 + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; 1966 1966 1967 1967 /* update wmm cap. */ 1968 1968 if (WLAN_STA_WME & flags) ··· 1991 1991 void ap_sta_info_defer_update(struct adapter *padapter, struct sta_info *psta) 1992 1992 { 1993 1993 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; 1994 - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); 1994 + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; 1995 1995 1996 1996 if (psta->state & _FW_LINKED) { 1997 1997 pmlmeinfo->FW_sta_info[psta->mac_id].psta = psta; ··· 2006 2006 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; 2007 2007 struct sta_priv *pstapriv = &padapter->stapriv; 2008 2008 struct sta_info *psta; 2009 - struct security_priv *psecuritypriv = &(padapter->securitypriv); 2009 + struct security_priv *psecuritypriv = &padapter->securitypriv; 2010 2010 struct list_head *phead, *plist; 2011 2011 u8 chk_alive_num = 0; 2012 2012 char chk_alive_list[NUM_STA]; ··· 2072 2072 void start_ap_mode(struct adapter *padapter) 2073 2073 { 2074 2074 int i; 2075 - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); 2075 + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; 2076 2076 struct sta_priv *pstapriv = &padapter->stapriv; 2077 2077 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; 2078 2078 struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; ··· 2109 2109 pmlmepriv->p2p_probe_resp_ie = NULL; 2110 2110 2111 2111 /* for ACL */ 2112 - INIT_LIST_HEAD(&(pacl_list->acl_node_q.queue)); 2112 + INIT_LIST_HEAD(&pacl_list->acl_node_q.queue); 2113 2113 pacl_list->num = 0; 2114 2114 pacl_list->mode = 0; 2115 2115 for (i = 0; i < NUM_ACL; i++) { ··· 2124 2124 struct rtw_wlan_acl_node *paclnode; 2125 2125 struct sta_info *psta = NULL; 2126 2126 struct sta_priv *pstapriv = &padapter->stapriv; 2127 - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); 2127 + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; 2128 2128 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; 2129 2129 struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; 2130 2130 struct __queue *pacl_node_q = &pacl_list->acl_node_q; ··· 2142 2142 padapter->securitypriv.ndisencryptstatus = Ndis802_11WEPDisabled; 2143 2143 2144 2144 /* for ACL */ 2145 - spin_lock_bh(&(pacl_node_q->lock)); 2145 + spin_lock_bh(&pacl_node_q->lock); 2146 2146 phead = get_list_head(pacl_node_q); 2147 2147 list_for_each_safe(plist, tmp, phead) { 2148 2148 paclnode = list_entry(plist, struct rtw_wlan_acl_node, list); ··· 2155 2155 pacl_list->num--; 2156 2156 } 2157 2157 } 2158 - spin_unlock_bh(&(pacl_node_q->lock)); 2158 + spin_unlock_bh(&pacl_node_q->lock); 2159 2159 2160 2160 rtw_sta_flush(padapter); 2161 2161
+3
drivers/staging/rtl8723bs/hal/hal_com.c
··· 884 884 0xfc, 0x0, 885 885 }; 886 886 887 + #define REG_RF_BB_GAIN_OFFSET 0x7f 888 + //#define RF_GAIN_OFFSET_MASK 0xfffff 889 + 887 890 void rtw_bb_rf_gain_offset(struct adapter *padapter) 888 891 { 889 892 u8 value = padapter->eeprompriv.EEPROMRFGainOffset;
-27
drivers/staging/rtl8723bs/include/osdep_intf.h
··· 8 8 #ifndef __OSDEP_INTF_H_ 9 9 #define __OSDEP_INTF_H_ 10 10 11 - 12 - struct intf_priv { 13 - 14 - u8 *intf_dev; 15 - u32 max_iosz; /* USB2.0: 128, USB1.1: 64, SDIO:64 */ 16 - u32 max_xmitsz; /* USB2.0: unlimited, SDIO:512 */ 17 - u32 max_recvsz; /* USB2.0: unlimited, SDIO:512 */ 18 - 19 - volatile u8 *io_rwmem; 20 - volatile u8 *allocated_io_rwmem; 21 - u32 io_wsz; /* unit: 4bytes */ 22 - u32 io_rsz;/* unit: 4bytes */ 23 - u8 intf_status; 24 - 25 - void (*_bus_io)(u8 *priv); 26 - 27 - /* 28 - Under Sync. IRP (SDIO/USB) 29 - A protection mechanism is necessary for the io_rwmem(read/write protocol) 30 - 31 - Under Async. IRP (SDIO/USB) 32 - The protection mechanism is through the pending queue. 33 - */ 34 - 35 - struct mutex ioctl_mutex; 36 - }; 37 - 38 11 struct dvobj_priv *devobj_init(void); 39 12 void devobj_deinit(struct dvobj_priv *pdvobj); 40 13
-1
drivers/staging/rtl8723bs/include/rtl8723b_hal.h
··· 15 15 #include "rtl8723b_recv.h" 16 16 #include "rtl8723b_xmit.h" 17 17 #include "rtl8723b_cmd.h" 18 - #include "rtw_mp.h" 19 18 #include "hal_pwr_seq.h" 20 19 #include "Hal8192CPhyReg.h" 21 20 #include "hal_phy_cfg.h"
-92
drivers/staging/rtl8723bs/include/rtw_io.h
··· 8 8 #ifndef _RTW_IO_H_ 9 9 #define _RTW_IO_H_ 10 10 11 - /* 12 - For prompt mode accessing, caller shall free io_req 13 - Otherwise, io_handler will free io_req 14 - */ 15 - 16 - /* below is for the intf_option bit definition... */ 17 - 18 - struct intf_priv; 19 11 struct intf_hdl; 20 - struct io_queue; 21 12 22 13 struct _io_ops { 23 14 u8 (*_read8)(struct intf_hdl *pintfhdl, u32 addr); ··· 27 36 void (*_read_mem)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem); 28 37 void (*_write_mem)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem); 29 38 30 - void (*_sync_irp_protocol_rw)(struct io_queue *pio_q); 31 - 32 39 u32 (*_read_interrupt)(struct intf_hdl *pintfhdl, u32 addr); 33 40 34 41 u32 (*_read_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem); ··· 36 47 37 48 void (*_read_port_cancel)(struct intf_hdl *pintfhdl); 38 49 void (*_write_port_cancel)(struct intf_hdl *pintfhdl); 39 - }; 40 - 41 - struct io_req { 42 - struct list_head list; 43 - u32 addr; 44 - volatile u32 val; 45 - u32 command; 46 - u32 status; 47 - u8 *pbuf; 48 - 49 - void (*_async_io_callback)(struct adapter *padater, struct io_req *pio_req, u8 *cnxt); 50 - u8 *cnxt; 51 50 }; 52 51 53 52 struct intf_hdl { ··· 51 74 int rtw_inc_and_chk_continual_io_error(struct dvobj_priv *dvobj); 52 75 void rtw_reset_continual_io_error(struct dvobj_priv *dvobj); 53 76 54 - /* 55 - Below is the data structure used by _io_handler 56 - 57 - */ 58 - 59 - struct io_queue { 60 - spinlock_t lock; 61 - struct list_head free_ioreqs; 62 - struct list_head pending; /* The io_req list that will be served in the single protocol read/write. */ 63 - struct list_head processing; 64 - u8 *free_ioreqs_buf; /* 4-byte aligned */ 65 - u8 *pallocated_free_ioreqs_buf; 66 - struct intf_hdl intf; 67 - }; 68 - 69 77 struct io_priv { 70 78 71 79 struct adapter *padapter; ··· 58 96 struct intf_hdl intf; 59 97 60 98 }; 61 - 62 - extern uint ioreq_flush(struct adapter *adapter, struct io_queue *ioqueue); 63 - extern void sync_ioreq_enqueue(struct io_req *preq, struct io_queue *ioqueue); 64 - extern uint sync_ioreq_flush(struct adapter *adapter, struct io_queue *ioqueue); 65 - 66 - 67 - extern uint free_ioreq(struct io_req *preq, struct io_queue *pio_queue); 68 - extern struct io_req *alloc_ioreq(struct io_queue *pio_q); 69 - 70 - extern uint register_intf_hdl(u8 *dev, struct intf_hdl *pintfhdl); 71 - extern void unregister_intf_hdl(struct intf_hdl *pintfhdl); 72 - 73 - extern void _rtw_attrib_read(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem); 74 - extern void _rtw_attrib_write(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem); 75 99 76 100 extern u8 rtw_read8(struct adapter *adapter, u32 addr); 77 101 extern u16 rtw_read16(struct adapter *adapter, u32 addr); ··· 69 121 70 122 extern u32 rtw_write_port(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem); 71 123 72 - extern void rtw_write_scsi(struct adapter *adapter, u32 cnt, u8 *pmem); 73 - 74 - /* ioreq */ 75 - extern void ioreq_read8(struct adapter *adapter, u32 addr, u8 *pval); 76 - extern void ioreq_read16(struct adapter *adapter, u32 addr, u16 *pval); 77 - extern void ioreq_read32(struct adapter *adapter, u32 addr, u32 *pval); 78 - extern void ioreq_write8(struct adapter *adapter, u32 addr, u8 val); 79 - extern void ioreq_write16(struct adapter *adapter, u32 addr, u16 val); 80 - extern void ioreq_write32(struct adapter *adapter, u32 addr, u32 val); 81 - 82 - 83 - extern uint async_read8(struct adapter *adapter, u32 addr, u8 *pbuff, 84 - void (*_async_io_callback)(struct adapter *padater, struct io_req *pio_req, u8 *cnxt), u8 *cnxt); 85 - extern uint async_read16(struct adapter *adapter, u32 addr, u8 *pbuff, 86 - void (*_async_io_callback)(struct adapter *padater, struct io_req *pio_req, u8 *cnxt), u8 *cnxt); 87 - extern uint async_read32(struct adapter *adapter, u32 addr, u8 *pbuff, 88 - void (*_async_io_callback)(struct adapter *padater, struct io_req *pio_req, u8 *cnxt), u8 *cnxt); 89 - 90 - extern void async_read_mem(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem); 91 - extern void async_read_port(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem); 92 - 93 - extern void async_write8(struct adapter *adapter, u32 addr, u8 val, 94 - void (*_async_io_callback)(struct adapter *padater, struct io_req *pio_req, u8 *cnxt), u8 *cnxt); 95 - extern void async_write16(struct adapter *adapter, u32 addr, u16 val, 96 - void (*_async_io_callback)(struct adapter *padater, struct io_req *pio_req, u8 *cnxt), u8 *cnxt); 97 - extern void async_write32(struct adapter *adapter, u32 addr, u32 val, 98 - void (*_async_io_callback)(struct adapter *padater, struct io_req *pio_req, u8 *cnxt), u8 *cnxt); 99 - 100 - extern void async_write_mem(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem); 101 - extern void async_write_port(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem); 102 - 103 - 104 124 int rtw_init_io_priv(struct adapter *padapter, void (*set_intf_ops)(struct adapter *padapter, struct _io_ops *pops)); 105 - 106 - 107 - extern uint alloc_io_queue(struct adapter *adapter); 108 - extern void free_io_queue(struct adapter *adapter); 109 - extern void async_bus_io(struct io_queue *pio_q); 110 - extern void bus_sync_io(struct io_queue *pio_q); 111 - extern u32 _ioreq2rwmem(struct io_queue *pio_q); 112 - extern void dev_power_down(struct adapter *Adapter, u8 bpwrup); 113 125 114 126 #endif /* _RTL8711_IO_H_ */
-341
drivers/staging/rtl8723bs/include/rtw_mp.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - /****************************************************************************** 3 - * 4 - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. 5 - * 6 - ******************************************************************************/ 7 - #ifndef _RTW_MP_H_ 8 - #define _RTW_MP_H_ 9 - 10 - #define MAX_MP_XMITBUF_SZ 2048 11 - 12 - struct mp_xmit_frame { 13 - struct list_head list; 14 - 15 - struct pkt_attrib attrib; 16 - 17 - struct sk_buff *pkt; 18 - 19 - int frame_tag; 20 - 21 - struct adapter *padapter; 22 - 23 - uint mem[(MAX_MP_XMITBUF_SZ >> 2)]; 24 - }; 25 - 26 - struct mp_wiparam { 27 - u32 bcompleted; 28 - u32 act_type; 29 - u32 io_offset; 30 - u32 io_value; 31 - }; 32 - 33 - struct mp_tx { 34 - u8 stop; 35 - u32 count, sended; 36 - u8 payload; 37 - struct pkt_attrib attrib; 38 - /* struct tx_desc desc; */ 39 - /* u8 resvdtx[7]; */ 40 - u8 desc[TXDESC_SIZE]; 41 - u8 *pallocated_buf; 42 - u8 *buf; 43 - u32 buf_size, write_size; 44 - void *PktTxThread; 45 - }; 46 - 47 - #define MP_MAX_LINES 1000 48 - #define MP_MAX_LINES_BYTES 256 49 - 50 - typedef void (*MPT_WORK_ITEM_HANDLER)(void *Adapter); 51 - struct mpt_context { 52 - /* Indicate if we have started Mass Production Test. */ 53 - bool bMassProdTest; 54 - 55 - /* Indicate if the driver is unloading or unloaded. */ 56 - bool bMptDrvUnload; 57 - 58 - struct timer_list MPh2c_timeout_timer; 59 - /* Event used to sync H2c for BT control */ 60 - 61 - bool MptH2cRspEvent; 62 - bool MptBtC2hEvent; 63 - bool bMPh2c_timeout; 64 - 65 - /* 8190 PCI does not support NDIS_WORK_ITEM. */ 66 - /* Work Item for Mass Production Test. */ 67 - /* NDIS_WORK_ITEM MptWorkItem; */ 68 - /* RT_WORK_ITEM MptWorkItem; */ 69 - /* Event used to sync the case unloading driver and MptWorkItem is still in progress. */ 70 - /* NDIS_EVENT MptWorkItemEvent; */ 71 - /* To protect the following variables. */ 72 - /* NDIS_SPIN_LOCK MptWorkItemSpinLock; */ 73 - /* Indicate a MptWorkItem is scheduled and not yet finished. */ 74 - bool bMptWorkItemInProgress; 75 - /* An instance which implements function and context of MptWorkItem. */ 76 - MPT_WORK_ITEM_HANDLER CurrMptAct; 77 - 78 - /* 1 =Start, 0 =Stop from UI. */ 79 - u32 MptTestStart; 80 - /* _TEST_MODE, defined in MPT_Req2.h */ 81 - u32 MptTestItem; 82 - /* Variable needed in each implementation of CurrMptAct. */ 83 - u32 MptActType; /* Type of action performed in CurrMptAct. */ 84 - /* The Offset of IO operation is depend of MptActType. */ 85 - u32 MptIoOffset; 86 - /* The Value of IO operation is depend of MptActType. */ 87 - u32 MptIoValue; 88 - /* The RfPath of IO operation is depend of MptActType. */ 89 - u32 MptRfPath; 90 - 91 - enum wireless_mode MptWirelessModeToSw; /* Wireless mode to switch. */ 92 - u8 MptChannelToSw; /* Channel to switch. */ 93 - u8 MptInitGainToSet; /* Initial gain to set. */ 94 - u32 MptBandWidth; /* bandwidth to switch. */ 95 - u32 MptRateIndex; /* rate index. */ 96 - /* Register value kept for Single Carrier Tx test. */ 97 - u8 btMpCckTxPower; 98 - /* Register value kept for Single Carrier Tx test. */ 99 - u8 btMpOfdmTxPower; 100 - /* For MP Tx Power index */ 101 - u8 TxPwrLevel[2]; /* rf-A, rf-B */ 102 - u32 RegTxPwrLimit; 103 - /* Content of RCR Register for Mass Production Test. */ 104 - u32 MptRCR; 105 - /* true if we only receive packets with specific pattern. */ 106 - bool bMptFilterPattern; 107 - /* Rx OK count, statistics used in Mass Production Test. */ 108 - u32 MptRxOkCnt; 109 - /* Rx CRC32 error count, statistics used in Mass Production Test. */ 110 - u32 MptRxCrcErrCnt; 111 - 112 - bool bCckContTx; /* true if we are in CCK Continuous Tx test. */ 113 - bool bOfdmContTx; /* true if we are in OFDM Continuous Tx test. */ 114 - bool bStartContTx; /* true if we have start Continuous Tx test. */ 115 - /* true if we are in Single Carrier Tx test. */ 116 - bool bSingleCarrier; 117 - /* true if we are in Carrier Suppression Tx Test. */ 118 - bool bCarrierSuppression; 119 - /* true if we are in Single Tone Tx test. */ 120 - bool bSingleTone; 121 - 122 - /* ACK counter asked by K.Y.. */ 123 - bool bMptEnableAckCounter; 124 - u32 MptAckCounter; 125 - 126 - /* SD3 Willis For 8192S to save 1T/2T RF table for ACUT Only fro ACUT delete later ~~~! */ 127 - /* s8 BufOfLines[2][MAX_LINES_HWCONFIG_TXT][MAX_BYTES_LINE_HWCONFIG_TXT]; */ 128 - /* s8 BufOfLines[2][MP_MAX_LINES][MP_MAX_LINES_BYTES]; */ 129 - /* s32 RfReadLine[2]; */ 130 - 131 - u8 APK_bound[2]; /* for APK path A/path B */ 132 - bool bMptIndexEven; 133 - 134 - u8 backup0xc50; 135 - u8 backup0xc58; 136 - u8 backup0xc30; 137 - u8 backup0x52_RF_A; 138 - u8 backup0x52_RF_B; 139 - 140 - u32 backup0x58_RF_A; 141 - u32 backup0x58_RF_B; 142 - 143 - u8 h2cReqNum; 144 - u8 c2hBuf[32]; 145 - 146 - u8 btInBuf[100]; 147 - u32 mptOutLen; 148 - u8 mptOutBuf[100]; 149 - 150 - }; 151 - /* endif */ 152 - 153 - /* define RTPRIV_IOCTL_MP (SIOCIWFIRSTPRIV + 0x17) */ 154 - enum { 155 - WRITE_REG = 1, 156 - READ_REG, 157 - WRITE_RF, 158 - READ_RF, 159 - MP_START, 160 - MP_STOP, 161 - MP_RATE, 162 - MP_CHANNEL, 163 - MP_BANDWIDTH, 164 - MP_TXPOWER, 165 - MP_ANT_TX, 166 - MP_ANT_RX, 167 - MP_CTX, 168 - MP_QUERY, 169 - MP_ARX, 170 - MP_PSD, 171 - MP_PWRTRK, 172 - MP_THER, 173 - MP_IOCTL, 174 - EFUSE_GET, 175 - EFUSE_SET, 176 - MP_RESET_STATS, 177 - MP_DUMP, 178 - MP_PHYPARA, 179 - MP_SetRFPathSwh, 180 - MP_QueryDrvStats, 181 - MP_SetBT, 182 - CTA_TEST, 183 - MP_DISABLE_BT_COEXIST, 184 - MP_PwrCtlDM, 185 - MP_NULL, 186 - MP_GET_TXPOWER_INX, 187 - }; 188 - 189 - struct mp_priv { 190 - struct adapter *papdater; 191 - 192 - /* Testing Flag */ 193 - u32 mode;/* 0 for normal type packet, 1 for loopback packet (16bytes TXCMD) */ 194 - 195 - u32 prev_fw_state; 196 - 197 - /* OID cmd handler */ 198 - struct mp_wiparam workparam; 199 - /* u8 act_in_progress; */ 200 - 201 - /* Tx Section */ 202 - u8 TID; 203 - u32 tx_pktcount; 204 - u32 pktInterval; 205 - struct mp_tx tx; 206 - 207 - /* Rx Section */ 208 - u32 rx_bssidpktcount; 209 - u32 rx_pktcount; 210 - u32 rx_pktcount_filter_out; 211 - u32 rx_crcerrpktcount; 212 - u32 rx_pktloss; 213 - bool rx_bindicatePkt; 214 - struct recv_stat rxstat; 215 - 216 - /* RF/BB relative */ 217 - u8 channel; 218 - u8 bandwidth; 219 - u8 prime_channel_offset; 220 - u8 txpoweridx; 221 - u8 txpoweridx_b; 222 - u8 rateidx; 223 - u32 preamble; 224 - /* u8 modem; */ 225 - u32 CrystalCap; 226 - /* u32 curr_crystalcap; */ 227 - 228 - u16 antenna_tx; 229 - u16 antenna_rx; 230 - /* u8 curr_rfpath; */ 231 - 232 - u8 check_mp_pkt; 233 - 234 - u8 bSetTxPower; 235 - /* uint ForcedDataRate; */ 236 - u8 mp_dm; 237 - u8 mac_filter[ETH_ALEN]; 238 - u8 bmac_filter; 239 - 240 - struct wlan_network mp_network; 241 - NDIS_802_11_MAC_ADDRESS network_macaddr; 242 - 243 - u8 *pallocated_mp_xmitframe_buf; 244 - u8 *pmp_xmtframe_buf; 245 - struct __queue free_mp_xmitqueue; 246 - u32 free_mp_xmitframe_cnt; 247 - bool bSetRxBssid; 248 - bool bTxBufCkFail; 249 - 250 - struct mpt_context MptCtx; 251 - 252 - u8 *TXradomBuffer; 253 - }; 254 - 255 - /* Hardware Registers */ 256 - extern u8 mpdatarate[NumRates]; 257 - 258 - #define MAX_TX_PWR_INDEX_N_MODE 64 /* 0x3F */ 259 - 260 - #define REG_RF_BB_GAIN_OFFSET 0x7f 261 - #define RF_GAIN_OFFSET_MASK 0xfffff 262 - 263 - /* */ 264 - /* struct mp_xmit_frame *alloc_mp_xmitframe(struct mp_priv *pmp_priv); */ 265 - /* int free_mp_xmitframe(struct xmit_priv *pxmitpriv, struct mp_xmit_frame *pmp_xmitframe); */ 266 - 267 - s32 init_mp_priv(struct adapter *padapter); 268 - void free_mp_priv(struct mp_priv *pmp_priv); 269 - s32 MPT_InitializeAdapter(struct adapter *padapter, u8 Channel); 270 - void MPT_DeInitAdapter(struct adapter *padapter); 271 - s32 mp_start_test(struct adapter *padapter); 272 - void mp_stop_test(struct adapter *padapter); 273 - 274 - u32 _read_rfreg(struct adapter *padapter, u8 rfpath, u32 addr, u32 bitmask); 275 - void _write_rfreg(struct adapter *padapter, u8 rfpath, u32 addr, u32 bitmask, u32 val); 276 - 277 - u32 read_macreg(struct adapter *padapter, u32 addr, u32 sz); 278 - void write_macreg(struct adapter *padapter, u32 addr, u32 val, u32 sz); 279 - 280 - void SetChannel(struct adapter *padapter); 281 - void SetBandwidth(struct adapter *padapter); 282 - int SetTxPower(struct adapter *padapter); 283 - void SetAntennaPathPower(struct adapter *padapter); 284 - void SetDataRate(struct adapter *padapter); 285 - 286 - void SetAntenna(struct adapter *padapter); 287 - 288 - s32 SetThermalMeter(struct adapter *padapter, u8 target_ther); 289 - void GetThermalMeter(struct adapter *padapter, u8 *value); 290 - 291 - void SetContinuousTx(struct adapter *padapter, u8 bStart); 292 - void SetSingleCarrierTx(struct adapter *padapter, u8 bStart); 293 - void SetSingleToneTx(struct adapter *padapter, u8 bStart); 294 - void SetCarrierSuppressionTx(struct adapter *padapter, u8 bStart); 295 - void PhySetTxPowerLevel(struct adapter *padapter); 296 - 297 - void fill_txdesc_for_mp(struct adapter *padapter, u8 *ptxdesc); 298 - void SetPacketTx(struct adapter *padapter); 299 - void SetPacketRx(struct adapter *padapter, u8 bStartRx); 300 - 301 - void ResetPhyRxPktCount(struct adapter *padapter); 302 - u32 GetPhyRxPktReceived(struct adapter *padapter); 303 - u32 GetPhyRxPktCRC32Error(struct adapter *padapter); 304 - 305 - s32 SetPowerTracking(struct adapter *padapter, u8 enable); 306 - void GetPowerTracking(struct adapter *padapter, u8 *enable); 307 - 308 - u32 mp_query_psd(struct adapter *padapter, u8 *data); 309 - 310 - void Hal_SetAntenna(struct adapter *padapter); 311 - void Hal_SetBandwidth(struct adapter *padapter); 312 - 313 - void Hal_SetTxPower(struct adapter *padapter); 314 - void Hal_SetCarrierSuppressionTx(struct adapter *padapter, u8 bStart); 315 - void Hal_SetSingleToneTx(struct adapter *padapter, u8 bStart); 316 - void Hal_SetSingleCarrierTx(struct adapter *padapter, u8 bStart); 317 - void Hal_SetContinuousTx(struct adapter *padapter, u8 bStart); 318 - 319 - void Hal_SetDataRate(struct adapter *padapter); 320 - void Hal_SetChannel(struct adapter *padapter); 321 - void Hal_SetAntennaPathPower(struct adapter *padapter); 322 - s32 Hal_SetThermalMeter(struct adapter *padapter, u8 target_ther); 323 - s32 Hal_SetPowerTracking(struct adapter *padapter, u8 enable); 324 - void Hal_GetPowerTracking(struct adapter *padapter, u8 *enable); 325 - void Hal_GetThermalMeter(struct adapter *padapter, u8 *value); 326 - void Hal_mpt_SwitchRfSetting(struct adapter *padapter); 327 - void Hal_MPT_CCKTxPowerAdjust(struct adapter *Adapter, bool bInCH14); 328 - void Hal_MPT_CCKTxPowerAdjustbyIndex(struct adapter *padapter, bool beven); 329 - void Hal_SetCCKTxPower(struct adapter *padapter, u8 *TxPower); 330 - void Hal_SetOFDMTxPower(struct adapter *padapter, u8 *TxPower); 331 - void Hal_TriggerRFThermalMeter(struct adapter *padapter); 332 - u8 Hal_ReadRFThermalMeter(struct adapter *padapter); 333 - void Hal_SetCCKContinuousTx(struct adapter *padapter, u8 bStart); 334 - void Hal_SetOFDMContinuousTx(struct adapter *padapter, u8 bStart); 335 - void Hal_ProSetCrystalCap(struct adapter *padapter, u32 CrystalCapVal); 336 - void MP_PHY_SetRFPathSwitch(struct adapter *padapter, bool bMain); 337 - u32 mpt_ProQueryCalTxPower(struct adapter *padapter, u8 RfPath); 338 - void MPT_PwrCtlDM(struct adapter *padapter, u32 bstart); 339 - u8 MptToMgntRate(u32 MptRateIdx); 340 - 341 - #endif /* _RTW_MP_H_ */
-2
drivers/staging/rtl8723bs/os_dep/os_intfs.c
··· 724 724 725 725 rtw_free_mlme_priv(&padapter->mlmepriv); 726 726 727 - /* free_io_queue(padapter); */ 728 - 729 727 _rtw_free_xmit_priv(&padapter->xmitpriv); 730 728 731 729 _rtw_free_sta_priv(&padapter->stapriv); /* will free bcmc_stainfo here */
+1 -1
drivers/staging/sm750fb/ddk750_chip.c
··· 228 228 reg = peek32(VGA_CONFIGURATION); 229 229 reg |= (VGA_CONFIGURATION_PLL | VGA_CONFIGURATION_MODE); 230 230 poke32(VGA_CONFIGURATION, reg); 231 + #ifdef CONFIG_X86 231 232 } else { 232 - #if defined(__i386__) || defined(__x86_64__) 233 233 /* set graphic mode via IO method */ 234 234 outb_p(0x88, 0x3d4); 235 235 outb_p(0x06, 0x3d5);
-2
drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
··· 658 658 .buf_queue = buffer_queue, 659 659 .start_streaming = start_streaming, 660 660 .stop_streaming = stop_streaming, 661 - .wait_prepare = vb2_ops_wait_prepare, 662 - .wait_finish = vb2_ops_wait_finish, 663 661 }; 664 662 665 663 /* ------------------------------------------------------------------
+61 -68
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
··· 97 97 * tracked separately with the state. 98 98 */ 99 99 int peer_use_count; 100 - 101 - /* 102 - * Flag to indicate that the first vchiq connect has made it through. 103 - * This means that both sides should be fully ready, and we should 104 - * be able to suspend after this point. 105 - */ 106 - int first_connect; 107 100 }; 108 101 109 102 static int ··· 264 271 return -ENXIO; 265 272 } 266 273 267 - dev_dbg(&pdev->dev, "arm: vchiq_init - done (slots %pK, phys %pad)\n", 274 + dev_dbg(&pdev->dev, "arm: vchiq_init - done (slots %p, phys %pad)\n", 268 275 vchiq_slot_zero, &slot_phys); 269 276 270 277 mutex_init(&drv_mgmt->connected_mutex); ··· 273 280 return 0; 274 281 } 275 282 276 - int 277 - vchiq_platform_init_state(struct vchiq_state *state) 278 - { 279 - struct vchiq_arm_state *platform_state; 280 - 281 - platform_state = devm_kzalloc(state->dev, sizeof(*platform_state), GFP_KERNEL); 282 - if (!platform_state) 283 - return -ENOMEM; 284 - 285 - rwlock_init(&platform_state->susp_res_lock); 286 - 287 - init_completion(&platform_state->ka_evt); 288 - atomic_set(&platform_state->ka_use_count, 0); 289 - atomic_set(&platform_state->ka_use_ack_count, 0); 290 - atomic_set(&platform_state->ka_release_count, 0); 291 - 292 - platform_state->state = state; 293 - 294 - state->platform_state = (struct opaque_platform_state *)platform_state; 295 - 296 - return 0; 297 - } 298 - 299 283 static struct vchiq_arm_state *vchiq_platform_get_arm_state(struct vchiq_state *state) 300 284 { 301 285 return (struct vchiq_arm_state *)state->platform_state; 286 + } 287 + 288 + static void 289 + vchiq_platform_uninit(struct vchiq_drv_mgmt *mgmt) 290 + { 291 + struct vchiq_arm_state *arm_state; 292 + 293 + kthread_stop(mgmt->state.sync_thread); 294 + kthread_stop(mgmt->state.recycle_thread); 295 + kthread_stop(mgmt->state.slot_handler_thread); 296 + 297 + arm_state = vchiq_platform_get_arm_state(&mgmt->state); 298 + if (!IS_ERR_OR_NULL(arm_state->ka_thread)) 299 + kthread_stop(arm_state->ka_thread); 302 300 } 303 301 304 302 void vchiq_dump_platform_state(struct seq_file *f) ··· 352 368 &instance->bulk_waiter_list, list) { 353 369 list_del(&waiter->list); 354 370 dev_dbg(instance->state->dev, 355 - "arm: bulk_waiter - cleaned up %pK for pid %d\n", 371 + "arm: bulk_waiter - cleaned up %p for pid %d\n", 356 372 waiter, waiter->pid); 357 373 kfree(waiter); 358 374 } ··· 606 622 mutex_lock(&instance->bulk_waiter_list_mutex); 607 623 list_add(&waiter->list, &instance->bulk_waiter_list); 608 624 mutex_unlock(&instance->bulk_waiter_list_mutex); 609 - dev_dbg(instance->state->dev, "arm: saved bulk_waiter %pK for pid %d\n", 625 + dev_dbg(instance->state->dev, "arm: saved bulk_waiter %p for pid %d\n", 610 626 waiter, current->pid); 611 627 } 612 628 ··· 982 998 } 983 999 984 1000 int 1001 + vchiq_platform_init_state(struct vchiq_state *state) 1002 + { 1003 + struct vchiq_arm_state *platform_state; 1004 + char threadname[16]; 1005 + 1006 + platform_state = devm_kzalloc(state->dev, sizeof(*platform_state), GFP_KERNEL); 1007 + if (!platform_state) 1008 + return -ENOMEM; 1009 + 1010 + snprintf(threadname, sizeof(threadname), "vchiq-keep/%d", 1011 + state->id); 1012 + platform_state->ka_thread = kthread_create(&vchiq_keepalive_thread_func, 1013 + (void *)state, threadname); 1014 + if (IS_ERR(platform_state->ka_thread)) { 1015 + dev_err(state->dev, "couldn't create thread %s\n", threadname); 1016 + return PTR_ERR(platform_state->ka_thread); 1017 + } 1018 + 1019 + rwlock_init(&platform_state->susp_res_lock); 1020 + 1021 + init_completion(&platform_state->ka_evt); 1022 + atomic_set(&platform_state->ka_use_count, 0); 1023 + atomic_set(&platform_state->ka_use_ack_count, 0); 1024 + atomic_set(&platform_state->ka_release_count, 0); 1025 + 1026 + platform_state->state = state; 1027 + 1028 + state->platform_state = (struct opaque_platform_state *)platform_state; 1029 + 1030 + return 0; 1031 + } 1032 + 1033 + int 985 1034 vchiq_use_internal(struct vchiq_state *state, struct vchiq_service *service, 986 1035 enum USE_TYPE_E use_type) 987 1036 { ··· 1329 1312 return ret; 1330 1313 } 1331 1314 1315 + void vchiq_platform_connected(struct vchiq_state *state) 1316 + { 1317 + struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state); 1318 + 1319 + wake_up_process(arm_state->ka_thread); 1320 + } 1321 + 1332 1322 void vchiq_platform_conn_state_changed(struct vchiq_state *state, 1333 1323 enum vchiq_connstate oldstate, 1334 1324 enum vchiq_connstate newstate) 1335 1325 { 1336 - struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state); 1337 - char threadname[16]; 1338 - 1339 1326 dev_dbg(state->dev, "suspend: %d: %s->%s\n", 1340 1327 state->id, get_conn_state_name(oldstate), get_conn_state_name(newstate)); 1341 - if (state->conn_state != VCHIQ_CONNSTATE_CONNECTED) 1342 - return; 1343 - 1344 - write_lock_bh(&arm_state->susp_res_lock); 1345 - if (arm_state->first_connect) { 1346 - write_unlock_bh(&arm_state->susp_res_lock); 1347 - return; 1348 - } 1349 - 1350 - arm_state->first_connect = 1; 1351 - write_unlock_bh(&arm_state->susp_res_lock); 1352 - snprintf(threadname, sizeof(threadname), "vchiq-keep/%d", 1353 - state->id); 1354 - arm_state->ka_thread = kthread_create(&vchiq_keepalive_thread_func, 1355 - (void *)state, 1356 - threadname); 1357 - if (IS_ERR(arm_state->ka_thread)) { 1358 - dev_err(state->dev, "suspend: Couldn't create thread %s\n", 1359 - threadname); 1360 - } else { 1361 - wake_up_process(arm_state->ka_thread); 1362 - } 1363 1328 } 1364 1329 1365 1330 static const struct of_device_id vchiq_of_match[] = { ··· 1385 1386 return ret; 1386 1387 } 1387 1388 1388 - vchiq_debugfs_init(&mgmt->state); 1389 - 1390 1389 dev_dbg(&pdev->dev, "arm: platform initialised - version %d (min %d)\n", 1391 1390 VCHIQ_VERSION, VCHIQ_VERSION_MIN); 1392 1391 ··· 1395 1398 ret = vchiq_register_chrdev(&pdev->dev); 1396 1399 if (ret) { 1397 1400 dev_err(&pdev->dev, "arm: Failed to initialize vchiq cdev\n"); 1401 + vchiq_platform_uninit(mgmt); 1398 1402 return ret; 1399 1403 } 1404 + 1405 + vchiq_debugfs_init(&mgmt->state); 1400 1406 1401 1407 bcm2835_audio = vchiq_device_register(&pdev->dev, "bcm2835-audio"); 1402 1408 bcm2835_camera = vchiq_device_register(&pdev->dev, "bcm2835-camera"); ··· 1410 1410 static void vchiq_remove(struct platform_device *pdev) 1411 1411 { 1412 1412 struct vchiq_drv_mgmt *mgmt = dev_get_drvdata(&pdev->dev); 1413 - struct vchiq_arm_state *arm_state; 1414 1413 1415 1414 vchiq_device_unregister(bcm2835_audio); 1416 1415 vchiq_device_unregister(bcm2835_camera); 1417 1416 vchiq_debugfs_deinit(); 1418 1417 vchiq_deregister_chrdev(); 1419 - 1420 - kthread_stop(mgmt->state.sync_thread); 1421 - kthread_stop(mgmt->state.recycle_thread); 1422 - kthread_stop(mgmt->state.slot_handler_thread); 1423 - 1424 - arm_state = vchiq_platform_get_arm_state(&mgmt->state); 1425 - kthread_stop(arm_state->ka_thread); 1418 + vchiq_platform_uninit(mgmt); 1426 1419 } 1427 1420 1428 1421 static struct platform_driver vchiq_driver = {
+33 -32
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
··· 470 470 cb_userdata = bulk->cb_userdata; 471 471 } 472 472 473 - dev_dbg(service->state->dev, "core: %d: callback:%d (%s, %pK, %pK %pK)\n", 473 + dev_dbg(service->state->dev, "core: %d: callback:%d (%s, %p, %p %p)\n", 474 474 service->state->id, service->localport, reason_names[reason], 475 475 header, cb_data, cb_userdata); 476 476 status = service->base.callback(service->instance, reason, header, service->handle, ··· 778 778 complete(&quota->quota_event); 779 779 } else if (count == 0) { 780 780 dev_err(state->dev, 781 - "core: service %d message_use_count=%d (header %pK, msgid %x, header->msgid %x, header->size %x)\n", 781 + "core: service %d message_use_count=%d (header %p, msgid %x, header->msgid %x, header->size %x)\n", 782 782 port, quota->message_use_count, header, msgid, 783 783 header->msgid, header->size); 784 784 WARN(1, "invalid message use count\n"); ··· 799 799 * it has dropped below its quota 800 800 */ 801 801 complete(&quota->quota_event); 802 - dev_dbg(state->dev, "core: %d: pfq:%d %x@%pK - slot_use->%d\n", 802 + dev_dbg(state->dev, "core: %d: pfq:%d %x@%p - slot_use->%d\n", 803 803 state->id, port, header->size, header, count - 1); 804 804 } else { 805 805 dev_err(state->dev, 806 - "core: service %d slot_use_count=%d (header %pK, msgid %x, header->msgid %x, header->size %x)\n", 806 + "core: service %d slot_use_count=%d (header %p, msgid %x, header->msgid %x, header->size %x)\n", 807 807 port, count, header, msgid, header->msgid, header->size); 808 808 WARN(1, "bad slot use count\n"); 809 809 } ··· 845 845 */ 846 846 rmb(); 847 847 848 - dev_dbg(state->dev, "core: %d: pfq %d=%pK %x %x\n", 848 + dev_dbg(state->dev, "core: %d: pfq %d=%p %x %x\n", 849 849 state->id, slot_index, data, local->slot_queue_recycle, 850 850 slot_queue_available); 851 851 ··· 868 868 pos += calc_stride(header->size); 869 869 if (pos > VCHIQ_SLOT_SIZE) { 870 870 dev_err(state->dev, 871 - "core: pfq - pos %x: header %pK, msgid %x, header->msgid %x, header->size %x\n", 871 + "core: pfq - pos %x: header %p, msgid %x, header->msgid %x, header->size %x\n", 872 872 pos, header, msgid, header->msgid, header->size); 873 873 WARN(1, "invalid slot position\n"); 874 874 } ··· 1060 1060 int tx_end_index; 1061 1061 int slot_use_count; 1062 1062 1063 - dev_dbg(state->dev, "core: %d: qm %s@%pK,%zx (%d->%d)\n", 1063 + dev_dbg(state->dev, "core: %d: qm %s@%p,%zx (%d->%d)\n", 1064 1064 state->id, msg_type_str(VCHIQ_MSG_TYPE(msgid)), header, size, 1065 1065 VCHIQ_MSG_SRCPORT(msgid), VCHIQ_MSG_DSTPORT(msgid)); 1066 1066 ··· 1117 1117 VCHIQ_SERVICE_STATS_INC(service, ctrl_tx_count); 1118 1118 VCHIQ_SERVICE_STATS_ADD(service, ctrl_tx_bytes, size); 1119 1119 } else { 1120 - dev_dbg(state->dev, "core: %d: qm %s@%pK,%zx (%d->%d)\n", 1120 + dev_dbg(state->dev, "core: %d: qm %s@%p,%zx (%d->%d)\n", 1121 1121 state->id, msg_type_str(VCHIQ_MSG_TYPE(msgid)), header, size, 1122 1122 VCHIQ_MSG_SRCPORT(msgid), VCHIQ_MSG_DSTPORT(msgid)); 1123 1123 if (size != 0) { ··· 1204 1204 state->id, oldmsgid); 1205 1205 } 1206 1206 1207 - dev_dbg(state->dev, "sync: %d: qms %s@%pK,%x (%d->%d)\n", 1207 + dev_dbg(state->dev, "sync: %d: qms %s@%p,%x (%d->%d)\n", 1208 1208 state->id, msg_type_str(VCHIQ_MSG_TYPE(msgid)), header, size, 1209 1209 VCHIQ_MSG_SRCPORT(msgid), VCHIQ_MSG_DSTPORT(msgid)); 1210 1210 ··· 1539 1539 pagelist = dma_alloc_coherent(instance->state->dev, pagelist_size, &dma_addr, 1540 1540 GFP_KERNEL); 1541 1541 1542 - dev_dbg(instance->state->dev, "arm: %pK\n", pagelist); 1542 + dev_dbg(instance->state->dev, "arm: %p\n", pagelist); 1543 1543 1544 1544 if (!pagelist) 1545 1545 return NULL; ··· 1692 1692 unsigned int num_pages = pagelistinfo->num_pages; 1693 1693 unsigned int cache_line_size; 1694 1694 1695 - dev_dbg(instance->state->dev, "arm: %pK, %d\n", pagelistinfo->pagelist, actual); 1695 + dev_dbg(instance->state->dev, "arm: %p, %d\n", pagelistinfo->pagelist, actual); 1696 1696 1697 1697 drv_mgmt = dev_get_drvdata(instance->state->dev); 1698 1698 ··· 1849 1849 1850 1850 payload = (struct vchiq_open_payload *)header->data; 1851 1851 fourcc = payload->fourcc; 1852 - dev_dbg(state->dev, "core: %d: prs OPEN@%pK (%d->'%p4cc')\n", 1852 + dev_dbg(state->dev, "core: %d: prs OPEN@%p (%d->'%p4cc')\n", 1853 1853 state->id, header, localport, &fourcc); 1854 1854 1855 1855 service = get_listening_service(state, fourcc); ··· 1976 1976 service = get_connected_service(state, remoteport); 1977 1977 if (service) 1978 1978 dev_warn(state->dev, 1979 - "core: %d: prs %s@%pK (%d->%d) - found connected service %d\n", 1979 + "core: %d: prs %s@%p (%d->%d) - found connected service %d\n", 1980 1980 state->id, msg_type_str(type), header, 1981 1981 remoteport, localport, service->localport); 1982 1982 } 1983 1983 1984 1984 if (!service) { 1985 1985 dev_err(state->dev, 1986 - "core: %d: prs %s@%pK (%d->%d) - invalid/closed service %d\n", 1986 + "core: %d: prs %s@%p (%d->%d) - invalid/closed service %d\n", 1987 1987 state->id, msg_type_str(type), header, remoteport, 1988 1988 localport, localport); 1989 1989 goto skip_message; ··· 2003 2003 2004 2004 if (((unsigned long)header & VCHIQ_SLOT_MASK) + 2005 2005 calc_stride(size) > VCHIQ_SLOT_SIZE) { 2006 - dev_err(state->dev, "core: header %pK (msgid %x) - size %x too big for slot\n", 2006 + dev_err(state->dev, "core: header %p (msgid %x) - size %x too big for slot\n", 2007 2007 header, (unsigned int)msgid, (unsigned int)size); 2008 2008 WARN(1, "oversized for slot\n"); 2009 2009 } ··· 2022 2022 service->peer_version = payload->version; 2023 2023 } 2024 2024 dev_dbg(state->dev, 2025 - "core: %d: prs OPENACK@%pK,%x (%d->%d) v:%d\n", 2025 + "core: %d: prs OPENACK@%p,%x (%d->%d) v:%d\n", 2026 2026 state->id, header, size, remoteport, localport, 2027 2027 service->peer_version); 2028 2028 if (service->srvstate == VCHIQ_SRVSTATE_OPENING) { ··· 2037 2037 case VCHIQ_MSG_CLOSE: 2038 2038 WARN_ON(size); /* There should be no data */ 2039 2039 2040 - dev_dbg(state->dev, "core: %d: prs CLOSE@%pK (%d->%d)\n", 2040 + dev_dbg(state->dev, "core: %d: prs CLOSE@%p (%d->%d)\n", 2041 2041 state->id, header, remoteport, localport); 2042 2042 2043 2043 mark_service_closing_internal(service, 1); ··· 2049 2049 &service->base.fourcc, service->localport, service->remoteport); 2050 2050 break; 2051 2051 case VCHIQ_MSG_DATA: 2052 - dev_dbg(state->dev, "core: %d: prs DATA@%pK,%x (%d->%d)\n", 2052 + dev_dbg(state->dev, "core: %d: prs DATA@%p,%x (%d->%d)\n", 2053 2053 state->id, header, size, remoteport, localport); 2054 2054 2055 2055 if ((service->remoteport == remoteport) && ··· 2069 2069 } 2070 2070 break; 2071 2071 case VCHIQ_MSG_CONNECT: 2072 - dev_dbg(state->dev, "core: %d: prs CONNECT@%pK\n", 2072 + dev_dbg(state->dev, "core: %d: prs CONNECT@%p\n", 2073 2073 state->id, header); 2074 2074 state->version_common = ((struct vchiq_slot_zero *) 2075 2075 state->slot_data)->version; ··· 2102 2102 if ((int)(queue->remote_insert - 2103 2103 queue->local_insert) >= 0) { 2104 2104 dev_err(state->dev, 2105 - "core: %d: prs %s@%pK (%d->%d) unexpected (ri=%d,li=%d)\n", 2105 + "core: %d: prs %s@%p (%d->%d) unexpected (ri=%d,li=%d)\n", 2106 2106 state->id, msg_type_str(type), header, remoteport, 2107 2107 localport, queue->remote_insert, queue->local_insert); 2108 2108 mutex_unlock(&service->bulk_mutex); ··· 2120 2120 bulk->actual = *(int *)header->data; 2121 2121 queue->remote_insert++; 2122 2122 2123 - dev_dbg(state->dev, "core: %d: prs %s@%pK (%d->%d) %x@%pad\n", 2123 + dev_dbg(state->dev, "core: %d: prs %s@%p (%d->%d) %x@%pad\n", 2124 2124 state->id, msg_type_str(type), header, remoteport, 2125 2125 localport, bulk->actual, &bulk->dma_addr); 2126 2126 ··· 2140 2140 } 2141 2141 break; 2142 2142 case VCHIQ_MSG_PADDING: 2143 - dev_dbg(state->dev, "core: %d: prs PADDING@%pK,%x\n", 2143 + dev_dbg(state->dev, "core: %d: prs PADDING@%p,%x\n", 2144 2144 state->id, header, size); 2145 2145 break; 2146 2146 case VCHIQ_MSG_PAUSE: 2147 2147 /* If initiated, signal the application thread */ 2148 - dev_dbg(state->dev, "core: %d: prs PAUSE@%pK,%x\n", 2148 + dev_dbg(state->dev, "core: %d: prs PAUSE@%p,%x\n", 2149 2149 state->id, header, size); 2150 2150 if (state->conn_state == VCHIQ_CONNSTATE_PAUSED) { 2151 2151 dev_err(state->dev, "core: %d: PAUSE received in state PAUSED\n", ··· 2162 2162 vchiq_set_conn_state(state, VCHIQ_CONNSTATE_PAUSED); 2163 2163 break; 2164 2164 case VCHIQ_MSG_RESUME: 2165 - dev_dbg(state->dev, "core: %d: prs RESUME@%pK,%x\n", 2165 + dev_dbg(state->dev, "core: %d: prs RESUME@%p,%x\n", 2166 2166 state->id, header, size); 2167 2167 /* Release the slot mutex */ 2168 2168 mutex_unlock(&state->slot_mutex); ··· 2179 2179 break; 2180 2180 2181 2181 default: 2182 - dev_err(state->dev, "core: %d: prs invalid msgid %x@%pK,%x\n", 2182 + dev_err(state->dev, "core: %d: prs invalid msgid %x@%p,%x\n", 2183 2183 state->id, msgid, header, size); 2184 2184 WARN(1, "invalid message\n"); 2185 2185 break; ··· 2400 2400 2401 2401 if (!service) { 2402 2402 dev_err(state->dev, 2403 - "sync: %d: sf %s@%pK (%d->%d) - invalid/closed service %d\n", 2403 + "sync: %d: sf %s@%p (%d->%d) - invalid/closed service %d\n", 2404 2404 state->id, msg_type_str(type), header, remoteport, 2405 2405 localport, localport); 2406 2406 release_message_sync(state, header); ··· 2422 2422 header->data; 2423 2423 service->peer_version = payload->version; 2424 2424 } 2425 - dev_err(state->dev, "sync: %d: sf OPENACK@%pK,%x (%d->%d) v:%d\n", 2425 + dev_err(state->dev, "sync: %d: sf OPENACK@%p,%x (%d->%d) v:%d\n", 2426 2426 state->id, header, size, remoteport, localport, 2427 2427 service->peer_version); 2428 2428 if (service->srvstate == VCHIQ_SRVSTATE_OPENING) { ··· 2435 2435 break; 2436 2436 2437 2437 case VCHIQ_MSG_DATA: 2438 - dev_dbg(state->dev, "sync: %d: sf DATA@%pK,%x (%d->%d)\n", 2438 + dev_dbg(state->dev, "sync: %d: sf DATA@%p,%x (%d->%d)\n", 2439 2439 state->id, header, size, remoteport, localport); 2440 2440 2441 2441 if ((service->remoteport == remoteport) && ··· 2449 2449 break; 2450 2450 2451 2451 default: 2452 - dev_err(state->dev, "sync: error: %d: sf unexpected msgid %x@%pK,%x\n", 2452 + dev_err(state->dev, "sync: error: %d: sf unexpected msgid %x@%p,%x\n", 2453 2453 state->id, msgid, header, size); 2454 2454 release_message_sync(state, header); 2455 2455 break; ··· 2926 2926 int port = VCHIQ_MSG_DSTPORT(msgid); 2927 2927 2928 2928 if ((port == service->localport) && (msgid & VCHIQ_MSGID_CLAIMED)) { 2929 - dev_dbg(state->dev, "core: fsi - hdr %pK\n", header); 2929 + dev_dbg(state->dev, "core: fsi - hdr %p\n", header); 2930 2930 release_slot(state, slot_info, header, NULL); 2931 2931 } 2932 2932 pos += calc_stride(header->size); 2933 2933 if (pos > VCHIQ_SLOT_SIZE) { 2934 2934 dev_err(state->dev, 2935 - "core: fsi - pos %x: header %pK, msgid %x, header->msgid %x, header->size %x\n", 2935 + "core: fsi - pos %x: header %p, msgid %x, header->msgid %x, header->size %x\n", 2936 2936 pos, header, msgid, header->msgid, header->size); 2937 2937 WARN(1, "invalid slot position\n"); 2938 2938 } ··· 3091 3091 */ 3092 3092 wmb(); 3093 3093 3094 - dev_dbg(state->dev, "core: %d: bt (%d->%d) %cx %x@%pad %pK\n", 3094 + dev_dbg(state->dev, "core: %d: bt (%d->%d) %cx %x@%pad %p\n", 3095 3095 state->id, service->localport, service->remoteport, 3096 3096 dir_char, bulk->size, &bulk->dma_addr, bulk->cb_data); 3097 3097 ··· 3343 3343 return -EAGAIN; 3344 3344 3345 3345 vchiq_set_conn_state(state, VCHIQ_CONNSTATE_CONNECTED); 3346 + vchiq_platform_connected(state); 3346 3347 complete(&state->connect); 3347 3348 } 3348 3349
+2
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h
··· 575 575 576 576 int vchiq_send_remote_use_active(struct vchiq_state *state); 577 577 578 + void vchiq_platform_connected(struct vchiq_state *state); 579 + 578 580 void vchiq_platform_conn_state_changed(struct vchiq_state *state, 579 581 enum vchiq_connstate oldstate, 580 582 enum vchiq_connstate newstate);
+7 -7
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c
··· 270 270 } 271 271 } else { 272 272 dev_err(service->state->dev, 273 - "arm: header %pK: bufsize %x < size %x\n", 273 + "arm: header %p: bufsize %x < size %x\n", 274 274 header, args->bufsize, header->size); 275 275 WARN(1, "invalid size\n"); 276 276 ret = -EMSGSIZE; ··· 328 328 ret = -ESRCH; 329 329 goto out; 330 330 } 331 - dev_dbg(service->state->dev, "arm: found bulk_waiter %pK for pid %d\n", 331 + dev_dbg(service->state->dev, "arm: found bulk_waiter %p for pid %d\n", 332 332 waiter, current->pid); 333 333 334 334 status = vchiq_bulk_xfer_waiting(instance, args->handle, ··· 366 366 mutex_lock(&instance->bulk_waiter_list_mutex); 367 367 list_add(&waiter->list, &instance->bulk_waiter_list); 368 368 mutex_unlock(&instance->bulk_waiter_list_mutex); 369 - dev_dbg(service->state->dev, "arm: saved bulk_waiter %pK for pid %d\n", 369 + dev_dbg(service->state->dev, "arm: saved bulk_waiter %p for pid %d\n", 370 370 waiter, current->pid); 371 371 372 372 ret = put_user(mode_waiting, mode); ··· 512 512 /* This must be a VCHIQ-style service */ 513 513 if (args->msgbufsize < msglen) { 514 514 dev_err(service->state->dev, 515 - "arm: header %pK: msgbufsize %x < msglen %x\n", 515 + "arm: header %p: msgbufsize %x < msglen %x\n", 516 516 header, args->msgbufsize, msglen); 517 517 WARN(1, "invalid message size\n"); 518 518 if (ret == 0) ··· 588 588 long ret = 0; 589 589 int i, rc; 590 590 591 - dev_dbg(instance->state->dev, "arm: instance %pK, cmd %s, arg %lx\n", instance, 591 + dev_dbg(instance->state->dev, "arm: instance %p, cmd %s, arg %lx\n", instance, 592 592 ((_IOC_TYPE(cmd) == VCHIQ_IOC_MAGIC) && (_IOC_NR(cmd) <= VCHIQ_IOC_MAX)) ? 593 593 ioctl_names[_IOC_NR(cmd)] : "<invalid>", arg); 594 594 ··· 874 874 875 875 if (!status && (ret < 0) && (ret != -EINTR) && (ret != -EWOULDBLOCK)) { 876 876 dev_dbg(instance->state->dev, 877 - "arm: ioctl instance %pK, cmd %s -> status %d, %ld\n", 877 + "arm: ioctl instance %p, cmd %s -> status %d, %ld\n", 878 878 instance, (_IOC_NR(cmd) <= VCHIQ_IOC_MAX) ? 879 879 ioctl_names[_IOC_NR(cmd)] : "<invalid>", status, ret); 880 880 } else { 881 881 dev_dbg(instance->state->dev, 882 - "arm: ioctl instance %pK, cmd %s -> status %d\n, %ld\n", 882 + "arm: ioctl instance %p, cmd %s -> status %d\n, %ld\n", 883 883 instance, (_IOC_NR(cmd) <= VCHIQ_IOC_MAX) ? 884 884 ioctl_names[_IOC_NR(cmd)] : "<invalid>", status, ret); 885 885 }