pc2_gpib.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685
  1. // SPDX-License-Identifier: GPL-2.0
  2. /***************************************************************************
  3. * copyright : (C) 2001, 2002 by Frank Mori Hess
  4. ***************************************************************************/
  5. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  6. #define dev_fmt pr_fmt
  7. #include <linux/ioport.h>
  8. #include <linux/sched.h>
  9. #include <linux/module.h>
  10. #include <linux/slab.h>
  11. #include <linux/bitops.h>
  12. #include <asm/dma.h>
  13. #include <linux/dma-mapping.h>
  14. #include <linux/string.h>
  15. #include <linux/init.h>
  16. #include "nec7210.h"
  17. #include "gpibP.h"
  18. // struct which defines private_data for pc2 driver
  19. struct pc2_priv {
  20. struct nec7210_priv nec7210_priv;
  21. unsigned int irq;
  22. // io address that clears interrupt for pc2a (0x2f0 + irq)
  23. unsigned int clear_intr_addr;
  24. };
  25. // pc2 uses 8 consecutive io addresses
  26. static const int pc2_iosize = 8;
  27. static const int pc2a_iosize = 8;
  28. static const int pc2_2a_iosize = 16;
  29. // offset between io addresses of successive nec7210 registers
  30. static const int pc2a_reg_offset = 0x400;
  31. static const int pc2_reg_offset = 1;
  32. // interrupt service routine
  33. static irqreturn_t pc2_interrupt(int irq, void *arg);
  34. static irqreturn_t pc2a_interrupt(int irq, void *arg);
  35. // pc2 specific registers and bits
  36. // interrupt clear register address
  37. static const int pc2a_clear_intr_iobase = 0x2f0;
  38. static inline unsigned int CLEAR_INTR_REG(unsigned int irq)
  39. {
  40. return pc2a_clear_intr_iobase + irq;
  41. }
  42. MODULE_LICENSE("GPL");
  43. MODULE_DESCRIPTION("GPIB driver for PC2/PC2a and compatible devices");
  44. /*
  45. * GPIB interrupt service routines
  46. */
  47. irqreturn_t pc2_interrupt(int irq, void *arg)
  48. {
  49. struct gpib_board *board = arg;
  50. struct pc2_priv *priv = board->private_data;
  51. unsigned long flags;
  52. irqreturn_t retval;
  53. spin_lock_irqsave(&board->spinlock, flags);
  54. retval = nec7210_interrupt(board, &priv->nec7210_priv);
  55. spin_unlock_irqrestore(&board->spinlock, flags);
  56. return retval;
  57. }
  58. irqreturn_t pc2a_interrupt(int irq, void *arg)
  59. {
  60. struct gpib_board *board = arg;
  61. struct pc2_priv *priv = board->private_data;
  62. int status1, status2;
  63. unsigned long flags;
  64. irqreturn_t retval;
  65. spin_lock_irqsave(&board->spinlock, flags);
  66. // read interrupt status (also clears status)
  67. status1 = read_byte(&priv->nec7210_priv, ISR1);
  68. status2 = read_byte(&priv->nec7210_priv, ISR2);
  69. /* clear interrupt circuit */
  70. if (priv->irq)
  71. outb(0xff, CLEAR_INTR_REG(priv->irq));
  72. retval = nec7210_interrupt_have_status(board, &priv->nec7210_priv, status1, status2);
  73. spin_unlock_irqrestore(&board->spinlock, flags);
  74. return retval;
  75. }
  76. // wrappers for interface functions
  77. static int pc2_read(struct gpib_board *board, u8 *buffer, size_t length, int *end,
  78. size_t *bytes_read)
  79. {
  80. struct pc2_priv *priv = board->private_data;
  81. return nec7210_read(board, &priv->nec7210_priv, buffer, length, end, bytes_read);
  82. }
  83. static int pc2_write(struct gpib_board *board, u8 *buffer, size_t length, int send_eoi,
  84. size_t *bytes_written)
  85. {
  86. struct pc2_priv *priv = board->private_data;
  87. return nec7210_write(board, &priv->nec7210_priv, buffer, length, send_eoi, bytes_written);
  88. }
  89. static int pc2_command(struct gpib_board *board, u8 *buffer,
  90. size_t length, size_t *bytes_written)
  91. {
  92. struct pc2_priv *priv = board->private_data;
  93. return nec7210_command(board, &priv->nec7210_priv, buffer, length, bytes_written);
  94. }
  95. static int pc2_take_control(struct gpib_board *board, int synchronous)
  96. {
  97. struct pc2_priv *priv = board->private_data;
  98. return nec7210_take_control(board, &priv->nec7210_priv, synchronous);
  99. }
  100. static int pc2_go_to_standby(struct gpib_board *board)
  101. {
  102. struct pc2_priv *priv = board->private_data;
  103. return nec7210_go_to_standby(board, &priv->nec7210_priv);
  104. }
  105. static int pc2_request_system_control(struct gpib_board *board, int request_control)
  106. {
  107. struct pc2_priv *priv = board->private_data;
  108. return nec7210_request_system_control(board, &priv->nec7210_priv, request_control);
  109. }
  110. static void pc2_interface_clear(struct gpib_board *board, int assert)
  111. {
  112. struct pc2_priv *priv = board->private_data;
  113. nec7210_interface_clear(board, &priv->nec7210_priv, assert);
  114. }
  115. static void pc2_remote_enable(struct gpib_board *board, int enable)
  116. {
  117. struct pc2_priv *priv = board->private_data;
  118. nec7210_remote_enable(board, &priv->nec7210_priv, enable);
  119. }
  120. static int pc2_enable_eos(struct gpib_board *board, u8 eos_byte, int compare_8_bits)
  121. {
  122. struct pc2_priv *priv = board->private_data;
  123. return nec7210_enable_eos(board, &priv->nec7210_priv, eos_byte, compare_8_bits);
  124. }
  125. static void pc2_disable_eos(struct gpib_board *board)
  126. {
  127. struct pc2_priv *priv = board->private_data;
  128. nec7210_disable_eos(board, &priv->nec7210_priv);
  129. }
  130. static unsigned int pc2_update_status(struct gpib_board *board, unsigned int clear_mask)
  131. {
  132. struct pc2_priv *priv = board->private_data;
  133. return nec7210_update_status(board, &priv->nec7210_priv, clear_mask);
  134. }
  135. static int pc2_primary_address(struct gpib_board *board, unsigned int address)
  136. {
  137. struct pc2_priv *priv = board->private_data;
  138. return nec7210_primary_address(board, &priv->nec7210_priv, address);
  139. }
  140. static int pc2_secondary_address(struct gpib_board *board, unsigned int address, int enable)
  141. {
  142. struct pc2_priv *priv = board->private_data;
  143. return nec7210_secondary_address(board, &priv->nec7210_priv, address, enable);
  144. }
  145. static int pc2_parallel_poll(struct gpib_board *board, u8 *result)
  146. {
  147. struct pc2_priv *priv = board->private_data;
  148. return nec7210_parallel_poll(board, &priv->nec7210_priv, result);
  149. }
  150. static void pc2_parallel_poll_configure(struct gpib_board *board, u8 config)
  151. {
  152. struct pc2_priv *priv = board->private_data;
  153. nec7210_parallel_poll_configure(board, &priv->nec7210_priv, config);
  154. }
  155. static void pc2_parallel_poll_response(struct gpib_board *board, int ist)
  156. {
  157. struct pc2_priv *priv = board->private_data;
  158. nec7210_parallel_poll_response(board, &priv->nec7210_priv, ist);
  159. }
  160. static void pc2_serial_poll_response(struct gpib_board *board, u8 status)
  161. {
  162. struct pc2_priv *priv = board->private_data;
  163. nec7210_serial_poll_response(board, &priv->nec7210_priv, status);
  164. }
  165. static u8 pc2_serial_poll_status(struct gpib_board *board)
  166. {
  167. struct pc2_priv *priv = board->private_data;
  168. return nec7210_serial_poll_status(board, &priv->nec7210_priv);
  169. }
  170. static int pc2_t1_delay(struct gpib_board *board, unsigned int nano_sec)
  171. {
  172. struct pc2_priv *priv = board->private_data;
  173. return nec7210_t1_delay(board, &priv->nec7210_priv, nano_sec);
  174. }
  175. static void pc2_return_to_local(struct gpib_board *board)
  176. {
  177. struct pc2_priv *priv = board->private_data;
  178. nec7210_return_to_local(board, &priv->nec7210_priv);
  179. }
  180. static int allocate_private(struct gpib_board *board)
  181. {
  182. struct pc2_priv *priv;
  183. board->private_data = kzalloc_obj(struct pc2_priv);
  184. if (!board->private_data)
  185. return -ENOMEM;
  186. priv = board->private_data;
  187. init_nec7210_private(&priv->nec7210_priv);
  188. return 0;
  189. }
  190. static void free_private(struct gpib_board *board)
  191. {
  192. kfree(board->private_data);
  193. board->private_data = NULL;
  194. }
  195. static int pc2_generic_attach(struct gpib_board *board, const struct gpib_board_config *config,
  196. enum nec7210_chipset chipset)
  197. {
  198. struct pc2_priv *pc2_priv;
  199. struct nec7210_priv *nec_priv;
  200. int retval;
  201. board->status = 0;
  202. retval = allocate_private(board);
  203. if (retval)
  204. return retval;
  205. pc2_priv = board->private_data;
  206. nec_priv = &pc2_priv->nec7210_priv;
  207. nec_priv->read_byte = nec7210_ioport_read_byte;
  208. nec_priv->write_byte = nec7210_ioport_write_byte;
  209. nec_priv->type = chipset;
  210. #ifndef PC2_DMA
  211. /*
  212. * board->dev hasn't been initialized, so forget about DMA until this driver
  213. * is adapted to use isa_register_driver.
  214. */
  215. if (config->ibdma)
  216. // driver needs to be adapted to use isa_register_driver to get a struct device*
  217. dev_err(board->gpib_dev, "DMA disabled for pc2 gpib");
  218. #else
  219. if (config->ibdma) {
  220. nec_priv->dma_buffer_length = 0x1000;
  221. nec_priv->dma_buffer = dma_alloc_coherent(board->dev,
  222. nec_priv->dma_buffer_length, &
  223. nec_priv->dma_buffer_addr, GFP_ATOMIC);
  224. if (!nec_priv->dma_buffer)
  225. return -ENOMEM;
  226. // request isa dma channel
  227. if (request_dma(config->ibdma, "pc2")) {
  228. dev_err(board->gpib_dev, "can't request DMA %d\n", config->ibdma);
  229. return -1;
  230. }
  231. nec_priv->dma_channel = config->ibdma;
  232. }
  233. #endif
  234. return 0;
  235. }
  236. static int pc2_attach(struct gpib_board *board, const struct gpib_board_config *config)
  237. {
  238. int isr_flags = 0;
  239. struct pc2_priv *pc2_priv;
  240. struct nec7210_priv *nec_priv;
  241. int retval;
  242. retval = pc2_generic_attach(board, config, NEC7210);
  243. if (retval)
  244. return retval;
  245. pc2_priv = board->private_data;
  246. nec_priv = &pc2_priv->nec7210_priv;
  247. nec_priv->offset = pc2_reg_offset;
  248. if (!request_region(config->ibbase, pc2_iosize, "pc2")) {
  249. dev_err(board->gpib_dev, "ioports are already in use\n");
  250. return -EBUSY;
  251. }
  252. nec_priv->iobase = config->ibbase;
  253. nec7210_board_reset(nec_priv, board);
  254. // install interrupt handler
  255. if (config->ibirq) {
  256. if (request_irq(config->ibirq, pc2_interrupt, isr_flags, "pc2", board)) {
  257. dev_err(board->gpib_dev, "can't request IRQ %d\n", config->ibirq);
  258. return -EBUSY;
  259. }
  260. }
  261. pc2_priv->irq = config->ibirq;
  262. /* poll so we can detect assertion of ATN */
  263. if (gpib_request_pseudo_irq(board, pc2_interrupt)) {
  264. dev_err(board->gpib_dev, "failed to allocate pseudo_irq\n");
  265. return -1;
  266. }
  267. /* set internal counter register for 8 MHz input clock */
  268. write_byte(nec_priv, ICR | 8, AUXMR);
  269. nec7210_board_online(nec_priv, board);
  270. return 0;
  271. }
  272. static void pc2_detach(struct gpib_board *board)
  273. {
  274. struct pc2_priv *pc2_priv = board->private_data;
  275. struct nec7210_priv *nec_priv;
  276. if (pc2_priv) {
  277. nec_priv = &pc2_priv->nec7210_priv;
  278. #ifdef PC2_DMA
  279. if (nec_priv->dma_channel)
  280. free_dma(nec_priv->dma_channel);
  281. #endif
  282. gpib_free_pseudo_irq(board);
  283. if (pc2_priv->irq)
  284. free_irq(pc2_priv->irq, board);
  285. if (nec_priv->iobase) {
  286. nec7210_board_reset(nec_priv, board);
  287. release_region(nec_priv->iobase, pc2_iosize);
  288. }
  289. if (nec_priv->dma_buffer) {
  290. dma_free_coherent(board->dev, nec_priv->dma_buffer_length,
  291. nec_priv->dma_buffer, nec_priv->dma_buffer_addr);
  292. nec_priv->dma_buffer = NULL;
  293. }
  294. }
  295. free_private(board);
  296. }
  297. static int pc2a_common_attach(struct gpib_board *board, const struct gpib_board_config *config,
  298. unsigned int num_registers, enum nec7210_chipset chipset)
  299. {
  300. unsigned int i, j;
  301. struct pc2_priv *pc2_priv;
  302. struct nec7210_priv *nec_priv;
  303. int retval;
  304. retval = pc2_generic_attach(board, config, chipset);
  305. if (retval)
  306. return retval;
  307. pc2_priv = board->private_data;
  308. nec_priv = &pc2_priv->nec7210_priv;
  309. nec_priv->offset = pc2a_reg_offset;
  310. switch (config->ibbase) {
  311. case 0x02e1:
  312. case 0x22e1:
  313. case 0x42e1:
  314. case 0x62e1:
  315. break;
  316. default:
  317. dev_err(board->gpib_dev, "PCIIa base range invalid, must be one of 0x[0246]2e1, but is 0x%x\n",
  318. config->ibbase);
  319. return -1;
  320. }
  321. if (config->ibirq) {
  322. if (config->ibirq < 2 || config->ibirq > 7) {
  323. dev_err(board->gpib_dev, "illegal interrupt level %i\n",
  324. config->ibirq);
  325. return -1;
  326. }
  327. } else {
  328. dev_err(board->gpib_dev, "interrupt disabled, using polling mode (slow)\n");
  329. }
  330. #ifdef CHECK_IOPORTS
  331. unsigned int err = 0;
  332. for (i = 0; i < num_registers; i++) {
  333. if (check_region(config->ibbase + i * pc2a_reg_offset, 1))
  334. err++;
  335. }
  336. if (config->ibirq && check_region(pc2a_clear_intr_iobase + config->ibirq, 1))
  337. err++;
  338. if (err) {
  339. dev_err(board->gpib_dev, "ioports are already in use");
  340. return -EBUSY;
  341. }
  342. #endif
  343. for (i = 0; i < num_registers; i++) {
  344. if (!request_region(config->ibbase +
  345. i * pc2a_reg_offset, 1, "pc2a")) {
  346. dev_err(board->gpib_dev, "ioports are already in use");
  347. for (j = 0; j < i; j++)
  348. release_region(config->ibbase +
  349. j * pc2a_reg_offset, 1);
  350. return -EBUSY;
  351. }
  352. }
  353. nec_priv->iobase = config->ibbase;
  354. if (config->ibirq) {
  355. if (!request_region(pc2a_clear_intr_iobase + config->ibirq, 1, "pc2a")) {
  356. dev_err(board->gpib_dev, "ioports are already in use");
  357. return -1;
  358. }
  359. pc2_priv->clear_intr_addr = pc2a_clear_intr_iobase + config->ibirq;
  360. if (request_irq(config->ibirq, pc2a_interrupt, 0, "pc2a", board)) {
  361. dev_err(board->gpib_dev, "can't request IRQ %d\n", config->ibirq);
  362. return -EBUSY;
  363. }
  364. }
  365. pc2_priv->irq = config->ibirq;
  366. /* poll so we can detect assertion of ATN */
  367. if (gpib_request_pseudo_irq(board, pc2_interrupt)) {
  368. dev_err(board->gpib_dev, "failed to allocate pseudo_irq\n");
  369. return -1;
  370. }
  371. // make sure interrupt is clear
  372. if (pc2_priv->irq)
  373. outb(0xff, CLEAR_INTR_REG(pc2_priv->irq));
  374. nec7210_board_reset(nec_priv, board);
  375. /* set internal counter register for 8 MHz input clock */
  376. write_byte(nec_priv, ICR | 8, AUXMR);
  377. nec7210_board_online(nec_priv, board);
  378. return 0;
  379. }
  380. static int pc2a_attach(struct gpib_board *board, const struct gpib_board_config *config)
  381. {
  382. return pc2a_common_attach(board, config, pc2a_iosize, NEC7210);
  383. }
  384. static int pc2a_cb7210_attach(struct gpib_board *board, const struct gpib_board_config *config)
  385. {
  386. return pc2a_common_attach(board, config, pc2a_iosize, CB7210);
  387. }
  388. static int pc2_2a_attach(struct gpib_board *board, const struct gpib_board_config *config)
  389. {
  390. return pc2a_common_attach(board, config, pc2_2a_iosize, NAT4882);
  391. }
  392. static void pc2a_common_detach(struct gpib_board *board, unsigned int num_registers)
  393. {
  394. int i;
  395. struct pc2_priv *pc2_priv = board->private_data;
  396. struct nec7210_priv *nec_priv;
  397. if (pc2_priv) {
  398. nec_priv = &pc2_priv->nec7210_priv;
  399. #ifdef PC2_DMA
  400. if (nec_priv->dma_channel)
  401. free_dma(nec_priv->dma_channel);
  402. #endif
  403. gpib_free_pseudo_irq(board);
  404. if (pc2_priv->irq)
  405. free_irq(pc2_priv->irq, board);
  406. if (nec_priv->iobase) {
  407. nec7210_board_reset(nec_priv, board);
  408. for (i = 0; i < num_registers; i++)
  409. release_region(nec_priv->iobase +
  410. i * pc2a_reg_offset, 1);
  411. }
  412. if (pc2_priv->clear_intr_addr)
  413. release_region(pc2_priv->clear_intr_addr, 1);
  414. if (nec_priv->dma_buffer) {
  415. dma_free_coherent(board->dev, nec_priv->dma_buffer_length,
  416. nec_priv->dma_buffer,
  417. nec_priv->dma_buffer_addr);
  418. nec_priv->dma_buffer = NULL;
  419. }
  420. }
  421. free_private(board);
  422. }
  423. static void pc2a_detach(struct gpib_board *board)
  424. {
  425. pc2a_common_detach(board, pc2a_iosize);
  426. }
  427. static void pc2_2a_detach(struct gpib_board *board)
  428. {
  429. pc2a_common_detach(board, pc2_2a_iosize);
  430. }
  431. static struct gpib_interface pc2_interface = {
  432. .name = "pcII",
  433. .attach = pc2_attach,
  434. .detach = pc2_detach,
  435. .read = pc2_read,
  436. .write = pc2_write,
  437. .command = pc2_command,
  438. .take_control = pc2_take_control,
  439. .go_to_standby = pc2_go_to_standby,
  440. .request_system_control = pc2_request_system_control,
  441. .interface_clear = pc2_interface_clear,
  442. .remote_enable = pc2_remote_enable,
  443. .enable_eos = pc2_enable_eos,
  444. .disable_eos = pc2_disable_eos,
  445. .parallel_poll = pc2_parallel_poll,
  446. .parallel_poll_configure = pc2_parallel_poll_configure,
  447. .parallel_poll_response = pc2_parallel_poll_response,
  448. .local_parallel_poll_mode = NULL, // XXX
  449. .line_status = NULL,
  450. .update_status = pc2_update_status,
  451. .primary_address = pc2_primary_address,
  452. .secondary_address = pc2_secondary_address,
  453. .serial_poll_response = pc2_serial_poll_response,
  454. .serial_poll_status = pc2_serial_poll_status,
  455. .t1_delay = pc2_t1_delay,
  456. .return_to_local = pc2_return_to_local,
  457. };
  458. static struct gpib_interface pc2a_interface = {
  459. .name = "pcIIa",
  460. .attach = pc2a_attach,
  461. .detach = pc2a_detach,
  462. .read = pc2_read,
  463. .write = pc2_write,
  464. .command = pc2_command,
  465. .take_control = pc2_take_control,
  466. .go_to_standby = pc2_go_to_standby,
  467. .request_system_control = pc2_request_system_control,
  468. .interface_clear = pc2_interface_clear,
  469. .remote_enable = pc2_remote_enable,
  470. .enable_eos = pc2_enable_eos,
  471. .disable_eos = pc2_disable_eos,
  472. .parallel_poll = pc2_parallel_poll,
  473. .parallel_poll_configure = pc2_parallel_poll_configure,
  474. .parallel_poll_response = pc2_parallel_poll_response,
  475. .local_parallel_poll_mode = NULL, // XXX
  476. .line_status = NULL,
  477. .update_status = pc2_update_status,
  478. .primary_address = pc2_primary_address,
  479. .secondary_address = pc2_secondary_address,
  480. .serial_poll_response = pc2_serial_poll_response,
  481. .serial_poll_status = pc2_serial_poll_status,
  482. .t1_delay = pc2_t1_delay,
  483. .return_to_local = pc2_return_to_local,
  484. };
  485. static struct gpib_interface pc2a_cb7210_interface = {
  486. .name = "pcIIa_cb7210",
  487. .attach = pc2a_cb7210_attach,
  488. .detach = pc2a_detach,
  489. .read = pc2_read,
  490. .write = pc2_write,
  491. .command = pc2_command,
  492. .take_control = pc2_take_control,
  493. .go_to_standby = pc2_go_to_standby,
  494. .request_system_control = pc2_request_system_control,
  495. .interface_clear = pc2_interface_clear,
  496. .remote_enable = pc2_remote_enable,
  497. .enable_eos = pc2_enable_eos,
  498. .disable_eos = pc2_disable_eos,
  499. .parallel_poll = pc2_parallel_poll,
  500. .parallel_poll_configure = pc2_parallel_poll_configure,
  501. .parallel_poll_response = pc2_parallel_poll_response,
  502. .local_parallel_poll_mode = NULL, // XXX
  503. .line_status = NULL, // XXX
  504. .update_status = pc2_update_status,
  505. .primary_address = pc2_primary_address,
  506. .secondary_address = pc2_secondary_address,
  507. .serial_poll_response = pc2_serial_poll_response,
  508. .serial_poll_status = pc2_serial_poll_status,
  509. .t1_delay = pc2_t1_delay,
  510. .return_to_local = pc2_return_to_local,
  511. };
  512. static struct gpib_interface pc2_2a_interface = {
  513. .name = "pcII_IIa",
  514. .attach = pc2_2a_attach,
  515. .detach = pc2_2a_detach,
  516. .read = pc2_read,
  517. .write = pc2_write,
  518. .command = pc2_command,
  519. .take_control = pc2_take_control,
  520. .go_to_standby = pc2_go_to_standby,
  521. .request_system_control = pc2_request_system_control,
  522. .interface_clear = pc2_interface_clear,
  523. .remote_enable = pc2_remote_enable,
  524. .enable_eos = pc2_enable_eos,
  525. .disable_eos = pc2_disable_eos,
  526. .parallel_poll = pc2_parallel_poll,
  527. .parallel_poll_configure = pc2_parallel_poll_configure,
  528. .parallel_poll_response = pc2_parallel_poll_response,
  529. .local_parallel_poll_mode = NULL, // XXX
  530. .line_status = NULL,
  531. .update_status = pc2_update_status,
  532. .primary_address = pc2_primary_address,
  533. .secondary_address = pc2_secondary_address,
  534. .serial_poll_response = pc2_serial_poll_response,
  535. .serial_poll_status = pc2_serial_poll_status,
  536. .t1_delay = pc2_t1_delay,
  537. .return_to_local = pc2_return_to_local,
  538. };
  539. static int __init pc2_init_module(void)
  540. {
  541. int ret;
  542. ret = gpib_register_driver(&pc2_interface, THIS_MODULE);
  543. if (ret) {
  544. pr_err("gpib_register_driver failed: error = %d\n", ret);
  545. return ret;
  546. }
  547. ret = gpib_register_driver(&pc2a_interface, THIS_MODULE);
  548. if (ret) {
  549. pr_err("gpib_register_driver failed: error = %d\n", ret);
  550. goto err_pc2a;
  551. }
  552. ret = gpib_register_driver(&pc2a_cb7210_interface, THIS_MODULE);
  553. if (ret) {
  554. pr_err("gpib_register_driver failed: error = %d\n", ret);
  555. goto err_cb7210;
  556. }
  557. ret = gpib_register_driver(&pc2_2a_interface, THIS_MODULE);
  558. if (ret) {
  559. pr_err("gpib_register_driver failed: error = %d\n", ret);
  560. goto err_pc2_2a;
  561. }
  562. return 0;
  563. err_pc2_2a:
  564. gpib_unregister_driver(&pc2a_cb7210_interface);
  565. err_cb7210:
  566. gpib_unregister_driver(&pc2a_interface);
  567. err_pc2a:
  568. gpib_unregister_driver(&pc2_interface);
  569. return ret;
  570. }
  571. static void __exit pc2_exit_module(void)
  572. {
  573. gpib_unregister_driver(&pc2_interface);
  574. gpib_unregister_driver(&pc2a_interface);
  575. gpib_unregister_driver(&pc2a_cb7210_interface);
  576. gpib_unregister_driver(&pc2_2a_interface);
  577. }
  578. module_init(pc2_init_module);
  579. module_exit(pc2_exit_module);