nosy.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691
  1. /*
  2. * nosy - Snoop mode driver for TI PCILynx 1394 controllers
  3. * Copyright (C) 2002-2007 Kristian Høgsberg
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software Foundation,
  17. * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18. */
  19. #include <linux/errno.h>
  20. #include <linux/fs.h>
  21. #include <linux/init.h>
  22. #include <linux/interrupt.h>
  23. #include <linux/io.h>
  24. #include <linux/kernel.h>
  25. #include <linux/miscdevice.h>
  26. #include <linux/module.h>
  27. #include <linux/pci.h>
  28. #include <linux/poll.h>
  29. #include <linux/sched.h> /* required for linux/wait.h */
  30. #include <linux/slab.h>
  31. #include <linux/spinlock.h>
  32. #include <linux/timex.h>
  33. #include <linux/uaccess.h>
  34. #include <linux/wait.h>
  35. #include <asm/atomic.h>
  36. #include <asm/byteorder.h>
  37. #include "nosy.h"
  38. #include "nosy-user.h"
  39. #define TCODE_PHY_PACKET 0x10
  40. #define PCI_DEVICE_ID_TI_PCILYNX 0x8000
  41. #define notify(s, args...) printk(KERN_NOTICE s, ## args)
  42. #define error(s, args...) printk(KERN_ERR s, ## args)
  43. #define debug(s, args...) printk(KERN_DEBUG s, ## args)
  44. static char driver_name[] = KBUILD_MODNAME;
  45. struct pcl_status {
  46. unsigned int transfer_count : 13;
  47. unsigned int reserved0 : 1;
  48. unsigned int ack_type : 1;
  49. unsigned int ack : 4;
  50. unsigned int rcv_speed : 2;
  51. unsigned int rcv_dma_channel : 6;
  52. unsigned int packet_complete : 1;
  53. unsigned int packet_error : 1;
  54. unsigned int master_error : 1;
  55. unsigned int iso_mode : 1;
  56. unsigned int self_id : 1;
  57. };
  58. /* this is the physical layout of a PCL, its size is 128 bytes */
  59. struct pcl {
  60. u32 next;
  61. u32 async_error_next;
  62. u32 user_data;
  63. struct pcl_status pcl_status;
  64. u32 remaining_transfer_count;
  65. u32 next_data_buffer;
  66. struct {
  67. u32 control;
  68. u32 pointer;
  69. } buffer[13] __attribute__ ((packed));
  70. } __attribute__ ((packed));
  71. struct packet {
  72. unsigned int length;
  73. char data[0];
  74. };
  75. struct packet_buffer {
  76. char *data;
  77. size_t capacity;
  78. long total_packet_count, lost_packet_count;
  79. atomic_t size;
  80. struct packet *head, *tail;
  81. wait_queue_head_t wait;
  82. };
  83. struct pcilynx {
  84. struct pci_dev *pci_device;
  85. unsigned char *registers;
  86. struct pcl *rcv_start_pcl, *rcv_pcl;
  87. u32 *rcv_buffer;
  88. dma_addr_t rcv_start_pcl_bus, rcv_pcl_bus, rcv_buffer_bus;
  89. spinlock_t client_list_lock;
  90. struct list_head client_list;
  91. struct miscdevice misc;
  92. };
  93. struct client {
  94. struct pcilynx *lynx;
  95. u32 tcode_mask;
  96. struct packet_buffer buffer;
  97. struct list_head link;
  98. };
  99. #define MAX_MINORS 64
  100. static struct pcilynx *minors[MAX_MINORS];
  101. static int
  102. packet_buffer_init(struct packet_buffer *buffer, size_t capacity)
  103. {
  104. buffer->data = kmalloc(capacity, GFP_KERNEL);
  105. if (buffer->data == NULL)
  106. return -ENOMEM;
  107. buffer->head = (struct packet *) buffer->data;
  108. buffer->tail = (struct packet *) buffer->data;
  109. buffer->capacity = capacity;
  110. buffer->lost_packet_count = 0;
  111. atomic_set(&buffer->size, 0);
  112. init_waitqueue_head(&buffer->wait);
  113. return 0;
  114. }
  115. static void
  116. packet_buffer_destroy(struct packet_buffer *buffer)
  117. {
  118. kfree(buffer->data);
  119. }
  120. static int
  121. packet_buffer_get(struct packet_buffer *buffer, void *data, size_t user_length)
  122. {
  123. size_t length;
  124. char *end;
  125. if (wait_event_interruptible(buffer->wait,
  126. atomic_read(&buffer->size) > 0))
  127. return -ERESTARTSYS;
  128. /* FIXME: Check length <= user_length. */
  129. end = buffer->data + buffer->capacity;
  130. length = buffer->head->length;
  131. if (&buffer->head->data[length] < end) {
  132. if (copy_to_user(data, buffer->head->data, length))
  133. return -EFAULT;
  134. buffer->head = (struct packet *) &buffer->head->data[length];
  135. } else {
  136. size_t split = end - buffer->head->data;
  137. if (copy_to_user(data, buffer->head->data, split))
  138. return -EFAULT;
  139. if (copy_to_user(data + split, buffer->data, length - split))
  140. return -EFAULT;
  141. buffer->head = (struct packet *) &buffer->data[length - split];
  142. }
  143. /*
  144. * Decrease buffer->size as the last thing, since this is what
  145. * keeps the interrupt from overwriting the packet we are
  146. * retrieving from the buffer.
  147. */
  148. atomic_sub(sizeof(struct packet) + length, &buffer->size);
  149. return length;
  150. }
  151. static void
  152. packet_buffer_put(struct packet_buffer *buffer, void *data, size_t length)
  153. {
  154. char *end;
  155. buffer->total_packet_count++;
  156. if (buffer->capacity <
  157. atomic_read(&buffer->size) + sizeof(struct packet) + length) {
  158. buffer->lost_packet_count++;
  159. return;
  160. }
  161. end = buffer->data + buffer->capacity;
  162. buffer->tail->length = length;
  163. if (&buffer->tail->data[length] < end) {
  164. memcpy(buffer->tail->data, data, length);
  165. buffer->tail = (struct packet *) &buffer->tail->data[length];
  166. } else {
  167. size_t split = end - buffer->tail->data;
  168. memcpy(buffer->tail->data, data, split);
  169. memcpy(buffer->data, data + split, length - split);
  170. buffer->tail = (struct packet *) &buffer->data[length - split];
  171. }
  172. /* Finally, adjust buffer size and wake up userspace reader. */
  173. atomic_add(sizeof(struct packet) + length, &buffer->size);
  174. wake_up_interruptible(&buffer->wait);
  175. }
  176. static inline void
  177. reg_write(struct pcilynx *lynx, int offset, u32 data)
  178. {
  179. writel(data, lynx->registers + offset);
  180. }
  181. static inline u32
  182. reg_read(struct pcilynx *lynx, int offset)
  183. {
  184. return readl(lynx->registers + offset);
  185. }
  186. static inline void
  187. reg_set_bits(struct pcilynx *lynx, int offset, u32 mask)
  188. {
  189. reg_write(lynx, offset, (reg_read(lynx, offset) | mask));
  190. }
  191. /*
  192. * Maybe the pcl programs could be set up to just append data instead
  193. * of using a whole packet.
  194. */
  195. static inline void
  196. run_pcl(struct pcilynx *lynx, dma_addr_t pcl_bus,
  197. int dmachan)
  198. {
  199. reg_write(lynx, DMA0_CURRENT_PCL + dmachan * 0x20, pcl_bus);
  200. reg_write(lynx, DMA0_CHAN_CTRL + dmachan * 0x20,
  201. DMA_CHAN_CTRL_ENABLE | DMA_CHAN_CTRL_LINK);
  202. }
  203. static int
  204. set_phy_reg(struct pcilynx *lynx, int addr, int val)
  205. {
  206. if (addr > 15) {
  207. debug("PHY register address %d out of range\n", addr);
  208. return -1;
  209. }
  210. if (val > 0xff) {
  211. debug("PHY register value %d out of range\n", val);
  212. return -1;
  213. }
  214. reg_write(lynx, LINK_PHY, LINK_PHY_WRITE |
  215. LINK_PHY_ADDR(addr) | LINK_PHY_WDATA(val));
  216. return 0;
  217. }
  218. static int
  219. nosy_open(struct inode *inode, struct file *file)
  220. {
  221. int minor = iminor(inode);
  222. struct client *client;
  223. if (minor > MAX_MINORS || minors[minor] == NULL)
  224. return -ENODEV;
  225. client = kmalloc(sizeof *client, GFP_KERNEL);
  226. if (client == NULL)
  227. return -ENOMEM;
  228. client->tcode_mask = ~0;
  229. client->lynx = minors[minor];
  230. INIT_LIST_HEAD(&client->link);
  231. if (packet_buffer_init(&client->buffer, 128 * 1024) < 0) {
  232. kfree(client);
  233. return -ENOMEM;
  234. }
  235. file->private_data = client;
  236. return 0;
  237. }
  238. static int
  239. nosy_release(struct inode *inode, struct file *file)
  240. {
  241. struct client *client = file->private_data;
  242. spin_lock_irq(&client->lynx->client_list_lock);
  243. list_del_init(&client->link);
  244. spin_unlock_irq(&client->lynx->client_list_lock);
  245. packet_buffer_destroy(&client->buffer);
  246. kfree(client);
  247. return 0;
  248. }
  249. static unsigned int
  250. nosy_poll(struct file *file, poll_table *pt)
  251. {
  252. struct client *client = file->private_data;
  253. poll_wait(file, &client->buffer.wait, pt);
  254. if (atomic_read(&client->buffer.size) > 0)
  255. return POLLIN | POLLRDNORM;
  256. else
  257. return 0;
  258. }
  259. static ssize_t
  260. nosy_read(struct file *file, char *buffer, size_t count, loff_t *offset)
  261. {
  262. struct client *client = file->private_data;
  263. return packet_buffer_get(&client->buffer, buffer, count);
  264. }
  265. static long
  266. nosy_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
  267. {
  268. struct client *client = file->private_data;
  269. spinlock_t *client_list_lock = &client->lynx->client_list_lock;
  270. struct nosy_stats stats;
  271. switch (cmd) {
  272. case NOSY_IOC_GET_STATS:
  273. spin_lock_irq(client_list_lock);
  274. stats.total_packet_count = client->buffer.total_packet_count;
  275. stats.lost_packet_count = client->buffer.lost_packet_count;
  276. spin_unlock_irq(client_list_lock);
  277. if (copy_to_user((void *) arg, &stats, sizeof stats))
  278. return -EFAULT;
  279. else
  280. return 0;
  281. case NOSY_IOC_START:
  282. spin_lock_irq(client_list_lock);
  283. list_add_tail(&client->link, &client->lynx->client_list);
  284. spin_unlock_irq(client_list_lock);
  285. return 0;
  286. case NOSY_IOC_STOP:
  287. spin_lock_irq(client_list_lock);
  288. list_del_init(&client->link);
  289. spin_unlock_irq(client_list_lock);
  290. return 0;
  291. case NOSY_IOC_FILTER:
  292. spin_lock_irq(client_list_lock);
  293. client->tcode_mask = arg;
  294. spin_unlock_irq(client_list_lock);
  295. return 0;
  296. default:
  297. return -EINVAL;
  298. /* Flush buffer, configure filter. */
  299. }
  300. }
  301. static const struct file_operations nosy_ops = {
  302. .owner = THIS_MODULE,
  303. .read = nosy_read,
  304. .unlocked_ioctl = nosy_ioctl,
  305. .poll = nosy_poll,
  306. .open = nosy_open,
  307. .release = nosy_release,
  308. };
  309. #define PHY_PACKET_SIZE 12 /* 1 payload, 1 inverse, 1 ack = 3 quadlets */
  310. struct link_packet {
  311. unsigned int priority : 4;
  312. unsigned int tcode : 4;
  313. unsigned int rt : 2;
  314. unsigned int tlabel : 6;
  315. unsigned int destination : 16;
  316. };
  317. static void
  318. packet_irq_handler(struct pcilynx *lynx)
  319. {
  320. struct client *client;
  321. u32 tcode_mask;
  322. size_t length;
  323. struct link_packet *packet;
  324. struct timeval tv;
  325. /* FIXME: Also report rcv_speed. */
  326. length = lynx->rcv_pcl->pcl_status.transfer_count;
  327. packet = (struct link_packet *) &lynx->rcv_buffer[1];
  328. do_gettimeofday(&tv);
  329. lynx->rcv_buffer[0] = tv.tv_usec;
  330. if (length == PHY_PACKET_SIZE)
  331. tcode_mask = 1 << TCODE_PHY_PACKET;
  332. else
  333. tcode_mask = 1 << packet->tcode;
  334. spin_lock(&lynx->client_list_lock);
  335. list_for_each_entry(client, &lynx->client_list, link)
  336. if (client->tcode_mask & tcode_mask)
  337. packet_buffer_put(&client->buffer,
  338. lynx->rcv_buffer, length + 4);
  339. spin_unlock(&lynx->client_list_lock);
  340. }
  341. static void
  342. bus_reset_irq_handler(struct pcilynx *lynx)
  343. {
  344. struct client *client;
  345. struct timeval tv;
  346. do_gettimeofday(&tv);
  347. spin_lock(&lynx->client_list_lock);
  348. list_for_each_entry(client, &lynx->client_list, link)
  349. packet_buffer_put(&client->buffer, &tv.tv_usec, 4);
  350. spin_unlock(&lynx->client_list_lock);
  351. }
  352. static irqreturn_t
  353. irq_handler(int irq, void *device)
  354. {
  355. struct pcilynx *lynx = device;
  356. u32 pci_int_status;
  357. pci_int_status = reg_read(lynx, PCI_INT_STATUS);
  358. if (pci_int_status == ~0)
  359. /* Card was ejected. */
  360. return IRQ_NONE;
  361. if ((pci_int_status & PCI_INT_INT_PEND) == 0)
  362. /* Not our interrupt, bail out quickly. */
  363. return IRQ_NONE;
  364. if ((pci_int_status & PCI_INT_P1394_INT) != 0) {
  365. u32 link_int_status;
  366. link_int_status = reg_read(lynx, LINK_INT_STATUS);
  367. reg_write(lynx, LINK_INT_STATUS, link_int_status);
  368. if ((link_int_status & LINK_INT_PHY_BUSRESET) > 0)
  369. bus_reset_irq_handler(lynx);
  370. }
  371. /* Clear the PCI_INT_STATUS register only after clearing the
  372. * LINK_INT_STATUS register; otherwise the PCI_INT_P1394 will
  373. * be set again immediately. */
  374. reg_write(lynx, PCI_INT_STATUS, pci_int_status);
  375. if ((pci_int_status & PCI_INT_DMA0_HLT) > 0) {
  376. packet_irq_handler(lynx);
  377. run_pcl(lynx, lynx->rcv_start_pcl_bus, 0);
  378. }
  379. return IRQ_HANDLED;
  380. }
  381. static void
  382. remove_card(struct pci_dev *dev)
  383. {
  384. struct pcilynx *lynx;
  385. lynx = pci_get_drvdata(dev);
  386. if (!lynx)
  387. return;
  388. pci_set_drvdata(dev, NULL);
  389. reg_write(lynx, PCI_INT_ENABLE, 0);
  390. free_irq(lynx->pci_device->irq, lynx);
  391. pci_free_consistent(lynx->pci_device, sizeof(struct pcl),
  392. lynx->rcv_start_pcl, lynx->rcv_start_pcl_bus);
  393. pci_free_consistent(lynx->pci_device, sizeof(struct pcl),
  394. lynx->rcv_pcl, lynx->rcv_pcl_bus);
  395. pci_free_consistent(lynx->pci_device, PAGE_SIZE,
  396. lynx->rcv_buffer, lynx->rcv_buffer_bus);
  397. iounmap(lynx->registers);
  398. pci_disable_device(dev);
  399. minors[lynx->misc.minor] = NULL;
  400. misc_deregister(&lynx->misc);
  401. kfree(lynx);
  402. }
  403. #define RCV_BUFFER_SIZE (16 * 1024)
  404. static int __devinit
  405. add_card(struct pci_dev *dev, const struct pci_device_id *unused)
  406. {
  407. struct pcilynx *lynx;
  408. u32 p, end;
  409. int ret, i;
  410. if (pci_set_dma_mask(dev, 0xffffffff)) {
  411. error("DMA address limits not supported "
  412. "for PCILynx hardware\n");
  413. return -ENXIO;
  414. }
  415. if (pci_enable_device(dev)) {
  416. error("Failed to enable PCILynx hardware\n");
  417. return -ENXIO;
  418. }
  419. pci_set_master(dev);
  420. lynx = kzalloc(sizeof *lynx, GFP_KERNEL);
  421. if (lynx == NULL) {
  422. error("Failed to allocate control structure memory\n");
  423. ret = -ENOMEM;
  424. goto fail_disable;
  425. }
  426. lynx->pci_device = dev;
  427. pci_set_drvdata(dev, lynx);
  428. spin_lock_init(&lynx->client_list_lock);
  429. INIT_LIST_HEAD(&lynx->client_list);
  430. lynx->registers = ioremap_nocache(pci_resource_start(dev, 0),
  431. PCILYNX_MAX_REGISTER);
  432. lynx->rcv_start_pcl = pci_alloc_consistent(lynx->pci_device,
  433. sizeof(struct pcl), &lynx->rcv_start_pcl_bus);
  434. lynx->rcv_pcl = pci_alloc_consistent(lynx->pci_device,
  435. sizeof(struct pcl), &lynx->rcv_pcl_bus);
  436. lynx->rcv_buffer = pci_alloc_consistent(lynx->pci_device,
  437. RCV_BUFFER_SIZE, &lynx->rcv_buffer_bus);
  438. if (lynx->rcv_start_pcl == NULL ||
  439. lynx->rcv_pcl == NULL ||
  440. lynx->rcv_buffer == NULL) {
  441. error("Failed to allocate receive buffer\n");
  442. ret = -ENOMEM;
  443. goto fail_deallocate;
  444. }
  445. lynx->rcv_start_pcl->next = lynx->rcv_pcl_bus;
  446. lynx->rcv_pcl->next = PCL_NEXT_INVALID;
  447. lynx->rcv_pcl->async_error_next = PCL_NEXT_INVALID;
  448. lynx->rcv_pcl->buffer[0].control =
  449. PCL_CMD_RCV | PCL_BIGENDIAN | 2044;
  450. lynx->rcv_pcl->buffer[0].pointer = lynx->rcv_buffer_bus + 4;
  451. p = lynx->rcv_buffer_bus + 2048;
  452. end = lynx->rcv_buffer_bus + RCV_BUFFER_SIZE;
  453. for (i = 1; p < end; i++, p += 2048) {
  454. lynx->rcv_pcl->buffer[i].control =
  455. PCL_CMD_RCV | PCL_BIGENDIAN | 2048;
  456. lynx->rcv_pcl->buffer[i].pointer = p;
  457. }
  458. lynx->rcv_pcl->buffer[i - 1].control |= PCL_LAST_BUFF;
  459. reg_set_bits(lynx, MISC_CONTROL, MISC_CONTROL_SWRESET);
  460. /* Fix buggy cards with autoboot pin not tied low: */
  461. reg_write(lynx, DMA0_CHAN_CTRL, 0);
  462. reg_write(lynx, DMA_GLOBAL_REGISTER, 0x00 << 24);
  463. #if 0
  464. /* now, looking for PHY register set */
  465. if ((get_phy_reg(lynx, 2) & 0xe0) == 0xe0) {
  466. lynx->phyic.reg_1394a = 1;
  467. PRINT(KERN_INFO, lynx->id,
  468. "found 1394a conform PHY (using extended register set)");
  469. lynx->phyic.vendor = get_phy_vendorid(lynx);
  470. lynx->phyic.product = get_phy_productid(lynx);
  471. } else {
  472. lynx->phyic.reg_1394a = 0;
  473. PRINT(KERN_INFO, lynx->id, "found old 1394 PHY");
  474. }
  475. #endif
  476. /* Setup the general receive FIFO max size. */
  477. reg_write(lynx, FIFO_SIZES, 255);
  478. reg_set_bits(lynx, PCI_INT_ENABLE, PCI_INT_DMA_ALL);
  479. reg_write(lynx, LINK_INT_ENABLE,
  480. LINK_INT_PHY_TIME_OUT | LINK_INT_PHY_REG_RCVD |
  481. LINK_INT_PHY_BUSRESET | LINK_INT_IT_STUCK |
  482. LINK_INT_AT_STUCK | LINK_INT_SNTRJ |
  483. LINK_INT_TC_ERR | LINK_INT_GRF_OVER_FLOW |
  484. LINK_INT_ITF_UNDER_FLOW | LINK_INT_ATF_UNDER_FLOW);
  485. /* Disable the L flag in self ID packets. */
  486. set_phy_reg(lynx, 4, 0);
  487. /* Put this baby into snoop mode */
  488. reg_set_bits(lynx, LINK_CONTROL, LINK_CONTROL_SNOOP_ENABLE);
  489. run_pcl(lynx, lynx->rcv_start_pcl_bus, 0);
  490. if (request_irq(dev->irq, irq_handler, IRQF_SHARED,
  491. driver_name, lynx)) {
  492. error("Failed to allocate shared interrupt %d\n", dev->irq);
  493. ret = -EIO;
  494. goto fail_deallocate;
  495. }
  496. lynx->misc.parent = &dev->dev;
  497. lynx->misc.minor = MISC_DYNAMIC_MINOR;
  498. lynx->misc.name = "nosy";
  499. lynx->misc.fops = &nosy_ops;
  500. ret = misc_register(&lynx->misc);
  501. if (ret) {
  502. error("Failed to register misc char device\n");
  503. goto fail_free_irq;
  504. }
  505. minors[lynx->misc.minor] = lynx;
  506. notify("Initialized PCILynx IEEE1394 card, irq=%d\n", dev->irq);
  507. return 0;
  508. fail_free_irq:
  509. reg_write(lynx, PCI_INT_ENABLE, 0);
  510. free_irq(lynx->pci_device->irq, lynx);
  511. fail_deallocate:
  512. if (lynx->rcv_start_pcl)
  513. pci_free_consistent(lynx->pci_device, sizeof(struct pcl),
  514. lynx->rcv_start_pcl, lynx->rcv_start_pcl_bus);
  515. if (lynx->rcv_pcl)
  516. pci_free_consistent(lynx->pci_device, sizeof(struct pcl),
  517. lynx->rcv_pcl, lynx->rcv_pcl_bus);
  518. if (lynx->rcv_buffer)
  519. pci_free_consistent(lynx->pci_device, PAGE_SIZE,
  520. lynx->rcv_buffer, lynx->rcv_buffer_bus);
  521. iounmap(lynx->registers);
  522. kfree(lynx);
  523. fail_disable:
  524. pci_disable_device(dev);
  525. return ret;
  526. }
  527. static struct pci_device_id pci_table[] __devinitdata = {
  528. {
  529. .vendor = PCI_VENDOR_ID_TI,
  530. .device = PCI_DEVICE_ID_TI_PCILYNX,
  531. .subvendor = PCI_ANY_ID,
  532. .subdevice = PCI_ANY_ID,
  533. },
  534. { } /* Terminating entry */
  535. };
  536. static struct pci_driver lynx_pci_driver = {
  537. .name = driver_name,
  538. .id_table = pci_table,
  539. .probe = add_card,
  540. .remove = remove_card,
  541. };
  542. MODULE_AUTHOR("Kristian Hoegsberg");
  543. MODULE_DESCRIPTION("Snoop mode driver for TI pcilynx 1394 controllers");
  544. MODULE_LICENSE("GPL");
  545. MODULE_DEVICE_TABLE(pci, pci_table);
  546. static int __init nosy_init(void)
  547. {
  548. return pci_register_driver(&lynx_pci_driver);
  549. }
  550. static void __exit nosy_cleanup(void)
  551. {
  552. pci_unregister_driver(&lynx_pci_driver);
  553. notify("Unloaded %s.\n", driver_name);
  554. }
  555. module_init(nosy_init);
  556. module_exit(nosy_cleanup);