share.c 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360
  1. /*
  2. * Parallel-port resource manager code.
  3. *
  4. * Authors: David Campbell <campbell@tirian.che.curtin.edu.au>
  5. * Tim Waugh <tim@cyberelk.demon.co.uk>
  6. * Jose Renau <renau@acm.org>
  7. * Philip Blundell <philb@gnu.org>
  8. * Andrea Arcangeli
  9. *
  10. * based on work by Grant Guenther <grant@torque.net>
  11. * and Philip Blundell
  12. *
  13. * Any part of this program may be used in documents licensed under
  14. * the GNU Free Documentation License, Version 1.1 or any later version
  15. * published by the Free Software Foundation.
  16. */
  17. #undef PARPORT_DEBUG_SHARING /* undef for production */
  18. #include <linux/module.h>
  19. #include <linux/string.h>
  20. #include <linux/threads.h>
  21. #include <linux/parport.h>
  22. #include <linux/delay.h>
  23. #include <linux/errno.h>
  24. #include <linux/interrupt.h>
  25. #include <linux/ioport.h>
  26. #include <linux/kernel.h>
  27. #include <linux/slab.h>
  28. #include <linux/sched.h>
  29. #include <linux/kmod.h>
  30. #include <linux/device.h>
  31. #include <linux/spinlock.h>
  32. #include <linux/mutex.h>
  33. #include <asm/irq.h>
  34. #undef PARPORT_PARANOID
  35. #define PARPORT_DEFAULT_TIMESLICE (HZ/5)
  36. unsigned long parport_default_timeslice = PARPORT_DEFAULT_TIMESLICE;
  37. int parport_default_spintime = DEFAULT_SPIN_TIME;
  38. static LIST_HEAD(portlist);
  39. static DEFINE_SPINLOCK(parportlist_lock);
  40. /* list of all allocated ports, sorted by ->number */
  41. static LIST_HEAD(all_ports);
  42. static DEFINE_SPINLOCK(full_list_lock);
  43. static LIST_HEAD(drivers);
  44. static DEFINE_MUTEX(registration_lock);
  45. /* What you can do to a port that's gone away.. */
  46. static void dead_write_lines (struct parport *p, unsigned char b){}
  47. static unsigned char dead_read_lines (struct parport *p) { return 0; }
  48. static unsigned char dead_frob_lines (struct parport *p, unsigned char b,
  49. unsigned char c) { return 0; }
  50. static void dead_onearg (struct parport *p){}
  51. static void dead_initstate (struct pardevice *d, struct parport_state *s) { }
  52. static void dead_state (struct parport *p, struct parport_state *s) { }
  53. static size_t dead_write (struct parport *p, const void *b, size_t l, int f)
  54. { return 0; }
  55. static size_t dead_read (struct parport *p, void *b, size_t l, int f)
  56. { return 0; }
  57. static struct parport_operations dead_ops = {
  58. .write_data = dead_write_lines, /* data */
  59. .read_data = dead_read_lines,
  60. .write_control = dead_write_lines, /* control */
  61. .read_control = dead_read_lines,
  62. .frob_control = dead_frob_lines,
  63. .read_status = dead_read_lines, /* status */
  64. .enable_irq = dead_onearg, /* enable_irq */
  65. .disable_irq = dead_onearg, /* disable_irq */
  66. .data_forward = dead_onearg, /* data_forward */
  67. .data_reverse = dead_onearg, /* data_reverse */
  68. .init_state = dead_initstate, /* init_state */
  69. .save_state = dead_state,
  70. .restore_state = dead_state,
  71. .epp_write_data = dead_write, /* epp */
  72. .epp_read_data = dead_read,
  73. .epp_write_addr = dead_write,
  74. .epp_read_addr = dead_read,
  75. .ecp_write_data = dead_write, /* ecp */
  76. .ecp_read_data = dead_read,
  77. .ecp_write_addr = dead_write,
  78. .compat_write_data = dead_write, /* compat */
  79. .nibble_read_data = dead_read, /* nibble */
  80. .byte_read_data = dead_read, /* byte */
  81. .owner = NULL,
  82. };
  83. static struct device_type parport_device_type = {
  84. .name = "parport",
  85. };
  86. static int is_parport(struct device *dev)
  87. {
  88. return dev->type == &parport_device_type;
  89. }
  90. static int parport_probe(struct device *dev)
  91. {
  92. struct parport_driver *drv;
  93. if (is_parport(dev))
  94. return -ENODEV;
  95. drv = to_parport_driver(dev->driver);
  96. if (!drv->probe) {
  97. /* if driver has not defined a custom probe */
  98. struct pardevice *par_dev = to_pardevice(dev);
  99. if (strcmp(par_dev->name, drv->name))
  100. return -ENODEV;
  101. return 0;
  102. }
  103. /* if driver defined its own probe */
  104. return drv->probe(to_pardevice(dev));
  105. }
  106. static struct bus_type parport_bus_type = {
  107. .name = "parport",
  108. .probe = parport_probe,
  109. };
  110. int parport_bus_init(void)
  111. {
  112. return bus_register(&parport_bus_type);
  113. }
  114. void parport_bus_exit(void)
  115. {
  116. bus_unregister(&parport_bus_type);
  117. }
  118. /*
  119. * iterates through all the drivers registered with the bus and sends the port
  120. * details to the match_port callback of the driver, so that the driver can
  121. * know about the new port that just regsitered with the bus and decide if it
  122. * wants to use this new port.
  123. */
  124. static int driver_check(struct device_driver *dev_drv, void *_port)
  125. {
  126. struct parport *port = _port;
  127. struct parport_driver *drv = to_parport_driver(dev_drv);
  128. if (drv->match_port)
  129. drv->match_port(port);
  130. return 0;
  131. }
  132. /* Call attach(port) for each registered driver. */
  133. static void attach_driver_chain(struct parport *port)
  134. {
  135. /* caller has exclusive registration_lock */
  136. struct parport_driver *drv;
  137. list_for_each_entry(drv, &drivers, list)
  138. drv->attach(port);
  139. /*
  140. * call the driver_check function of the drivers registered in
  141. * new device model
  142. */
  143. bus_for_each_drv(&parport_bus_type, NULL, port, driver_check);
  144. }
  145. static int driver_detach(struct device_driver *_drv, void *_port)
  146. {
  147. struct parport *port = _port;
  148. struct parport_driver *drv = to_parport_driver(_drv);
  149. if (drv->detach)
  150. drv->detach(port);
  151. return 0;
  152. }
  153. /* Call detach(port) for each registered driver. */
  154. static void detach_driver_chain(struct parport *port)
  155. {
  156. struct parport_driver *drv;
  157. /* caller has exclusive registration_lock */
  158. list_for_each_entry(drv, &drivers, list)
  159. drv->detach (port);
  160. /*
  161. * call the detach function of the drivers registered in
  162. * new device model
  163. */
  164. bus_for_each_drv(&parport_bus_type, NULL, port, driver_detach);
  165. }
  166. /* Ask kmod for some lowlevel drivers. */
  167. static void get_lowlevel_driver (void)
  168. {
  169. /* There is no actual module called this: you should set
  170. * up an alias for modutils. */
  171. request_module ("parport_lowlevel");
  172. }
  173. /*
  174. * iterates through all the devices connected to the bus and sends the device
  175. * details to the match_port callback of the driver, so that the driver can
  176. * know what are all the ports that are connected to the bus and choose the
  177. * port to which it wants to register its device.
  178. */
  179. static int port_check(struct device *dev, void *dev_drv)
  180. {
  181. struct parport_driver *drv = dev_drv;
  182. /* only send ports, do not send other devices connected to bus */
  183. if (is_parport(dev))
  184. drv->match_port(to_parport_dev(dev));
  185. return 0;
  186. }
  187. /**
  188. * parport_register_driver - register a parallel port device driver
  189. * @drv: structure describing the driver
  190. * @owner: owner module of drv
  191. * @mod_name: module name string
  192. *
  193. * This can be called by a parallel port device driver in order
  194. * to receive notifications about ports being found in the
  195. * system, as well as ports no longer available.
  196. *
  197. * If devmodel is true then the new device model is used
  198. * for registration.
  199. *
  200. * The @drv structure is allocated by the caller and must not be
  201. * deallocated until after calling parport_unregister_driver().
  202. *
  203. * If using the non device model:
  204. * The driver's attach() function may block. The port that
  205. * attach() is given will be valid for the duration of the
  206. * callback, but if the driver wants to take a copy of the
  207. * pointer it must call parport_get_port() to do so. Calling
  208. * parport_register_device() on that port will do this for you.
  209. *
  210. * The driver's detach() function may block. The port that
  211. * detach() is given will be valid for the duration of the
  212. * callback, but if the driver wants to take a copy of the
  213. * pointer it must call parport_get_port() to do so.
  214. *
  215. *
  216. * Returns 0 on success. The non device model will always succeeds.
  217. * but the new device model can fail and will return the error code.
  218. **/
  219. int __parport_register_driver(struct parport_driver *drv, struct module *owner,
  220. const char *mod_name)
  221. {
  222. if (list_empty(&portlist))
  223. get_lowlevel_driver ();
  224. if (drv->devmodel) {
  225. /* using device model */
  226. int ret;
  227. /* initialize common driver fields */
  228. drv->driver.name = drv->name;
  229. drv->driver.bus = &parport_bus_type;
  230. drv->driver.owner = owner;
  231. drv->driver.mod_name = mod_name;
  232. ret = driver_register(&drv->driver);
  233. if (ret)
  234. return ret;
  235. mutex_lock(&registration_lock);
  236. if (drv->match_port)
  237. bus_for_each_dev(&parport_bus_type, NULL, drv,
  238. port_check);
  239. mutex_unlock(&registration_lock);
  240. } else {
  241. struct parport *port;
  242. drv->devmodel = false;
  243. mutex_lock(&registration_lock);
  244. list_for_each_entry(port, &portlist, list)
  245. drv->attach(port);
  246. list_add(&drv->list, &drivers);
  247. mutex_unlock(&registration_lock);
  248. }
  249. return 0;
  250. }
  251. EXPORT_SYMBOL(__parport_register_driver);
  252. static int port_detach(struct device *dev, void *_drv)
  253. {
  254. struct parport_driver *drv = _drv;
  255. if (is_parport(dev) && drv->detach)
  256. drv->detach(to_parport_dev(dev));
  257. return 0;
  258. }
  259. /**
  260. * parport_unregister_driver - deregister a parallel port device driver
  261. * @drv: structure describing the driver that was given to
  262. * parport_register_driver()
  263. *
  264. * This should be called by a parallel port device driver that
  265. * has registered itself using parport_register_driver() when it
  266. * is about to be unloaded.
  267. *
  268. * When it returns, the driver's attach() routine will no longer
  269. * be called, and for each port that attach() was called for, the
  270. * detach() routine will have been called.
  271. *
  272. * All the driver's attach() and detach() calls are guaranteed to have
  273. * finished by the time this function returns.
  274. **/
  275. void parport_unregister_driver (struct parport_driver *drv)
  276. {
  277. struct parport *port;
  278. mutex_lock(&registration_lock);
  279. if (drv->devmodel) {
  280. bus_for_each_dev(&parport_bus_type, NULL, drv, port_detach);
  281. driver_unregister(&drv->driver);
  282. } else {
  283. list_del_init(&drv->list);
  284. list_for_each_entry(port, &portlist, list)
  285. drv->detach(port);
  286. }
  287. mutex_unlock(&registration_lock);
  288. }
  289. static void free_port(struct device *dev)
  290. {
  291. int d;
  292. struct parport *port = to_parport_dev(dev);
  293. spin_lock(&full_list_lock);
  294. list_del(&port->full_list);
  295. spin_unlock(&full_list_lock);
  296. for (d = 0; d < 5; d++) {
  297. kfree(port->probe_info[d].class_name);
  298. kfree(port->probe_info[d].mfr);
  299. kfree(port->probe_info[d].model);
  300. kfree(port->probe_info[d].cmdset);
  301. kfree(port->probe_info[d].description);
  302. }
  303. kfree(port->name);
  304. kfree(port);
  305. }
  306. /**
  307. * parport_get_port - increment a port's reference count
  308. * @port: the port
  309. *
  310. * This ensures that a struct parport pointer remains valid
  311. * until the matching parport_put_port() call.
  312. **/
  313. struct parport *parport_get_port (struct parport *port)
  314. {
  315. struct device *dev = get_device(&port->bus_dev);
  316. return to_parport_dev(dev);
  317. }
  318. void parport_del_port(struct parport *port)
  319. {
  320. device_unregister(&port->bus_dev);
  321. }
  322. EXPORT_SYMBOL(parport_del_port);
  323. /**
  324. * parport_put_port - decrement a port's reference count
  325. * @port: the port
  326. *
  327. * This should be called once for each call to parport_get_port(),
  328. * once the port is no longer needed. When the reference count reaches
  329. * zero (port is no longer used), free_port is called.
  330. **/
  331. void parport_put_port (struct parport *port)
  332. {
  333. put_device(&port->bus_dev);
  334. }
  335. /**
  336. * parport_register_port - register a parallel port
  337. * @base: base I/O address
  338. * @irq: IRQ line
  339. * @dma: DMA channel
  340. * @ops: pointer to the port driver's port operations structure
  341. *
  342. * When a parallel port (lowlevel) driver finds a port that
  343. * should be made available to parallel port device drivers, it
  344. * should call parport_register_port(). The @base, @irq, and
  345. * @dma parameters are for the convenience of port drivers, and
  346. * for ports where they aren't meaningful needn't be set to
  347. * anything special. They can be altered afterwards by adjusting
  348. * the relevant members of the parport structure that is returned
  349. * and represents the port. They should not be tampered with
  350. * after calling parport_announce_port, however.
  351. *
  352. * If there are parallel port device drivers in the system that
  353. * have registered themselves using parport_register_driver(),
  354. * they are not told about the port at this time; that is done by
  355. * parport_announce_port().
  356. *
  357. * The @ops structure is allocated by the caller, and must not be
  358. * deallocated before calling parport_remove_port().
  359. *
  360. * If there is no memory to allocate a new parport structure,
  361. * this function will return %NULL.
  362. **/
  363. struct parport *parport_register_port(unsigned long base, int irq, int dma,
  364. struct parport_operations *ops)
  365. {
  366. struct list_head *l;
  367. struct parport *tmp;
  368. int num;
  369. int device;
  370. char *name;
  371. int ret;
  372. tmp = kzalloc(sizeof(struct parport), GFP_KERNEL);
  373. if (!tmp) {
  374. printk(KERN_WARNING "parport: memory squeeze\n");
  375. return NULL;
  376. }
  377. /* Init our structure */
  378. tmp->base = base;
  379. tmp->irq = irq;
  380. tmp->dma = dma;
  381. tmp->muxport = tmp->daisy = tmp->muxsel = -1;
  382. tmp->modes = 0;
  383. INIT_LIST_HEAD(&tmp->list);
  384. tmp->devices = tmp->cad = NULL;
  385. tmp->flags = 0;
  386. tmp->ops = ops;
  387. tmp->physport = tmp;
  388. memset (tmp->probe_info, 0, 5 * sizeof (struct parport_device_info));
  389. rwlock_init(&tmp->cad_lock);
  390. spin_lock_init(&tmp->waitlist_lock);
  391. spin_lock_init(&tmp->pardevice_lock);
  392. tmp->ieee1284.mode = IEEE1284_MODE_COMPAT;
  393. tmp->ieee1284.phase = IEEE1284_PH_FWD_IDLE;
  394. sema_init(&tmp->ieee1284.irq, 0);
  395. tmp->spintime = parport_default_spintime;
  396. atomic_set (&tmp->ref_count, 1);
  397. INIT_LIST_HEAD(&tmp->full_list);
  398. name = kmalloc(15, GFP_KERNEL);
  399. if (!name) {
  400. printk(KERN_ERR "parport: memory squeeze\n");
  401. kfree(tmp);
  402. return NULL;
  403. }
  404. /* Search for the lowest free parport number. */
  405. spin_lock(&full_list_lock);
  406. for (l = all_ports.next, num = 0; l != &all_ports; l = l->next, num++) {
  407. struct parport *p = list_entry(l, struct parport, full_list);
  408. if (p->number != num)
  409. break;
  410. }
  411. tmp->portnum = tmp->number = num;
  412. list_add_tail(&tmp->full_list, l);
  413. spin_unlock(&full_list_lock);
  414. /*
  415. * Now that the portnum is known finish doing the Init.
  416. */
  417. sprintf(name, "parport%d", tmp->portnum = tmp->number);
  418. tmp->name = name;
  419. tmp->bus_dev.bus = &parport_bus_type;
  420. tmp->bus_dev.release = free_port;
  421. dev_set_name(&tmp->bus_dev, name);
  422. tmp->bus_dev.type = &parport_device_type;
  423. for (device = 0; device < 5; device++)
  424. /* assume the worst */
  425. tmp->probe_info[device].class = PARPORT_CLASS_LEGACY;
  426. tmp->waithead = tmp->waittail = NULL;
  427. ret = device_register(&tmp->bus_dev);
  428. if (ret) {
  429. put_device(&tmp->bus_dev);
  430. return NULL;
  431. }
  432. return tmp;
  433. }
  434. /**
  435. * parport_announce_port - tell device drivers about a parallel port
  436. * @port: parallel port to announce
  437. *
  438. * After a port driver has registered a parallel port with
  439. * parport_register_port, and performed any necessary
  440. * initialisation or adjustments, it should call
  441. * parport_announce_port() in order to notify all device drivers
  442. * that have called parport_register_driver(). Their attach()
  443. * functions will be called, with @port as the parameter.
  444. **/
  445. void parport_announce_port (struct parport *port)
  446. {
  447. int i;
  448. #ifdef CONFIG_PARPORT_1284
  449. /* Analyse the IEEE1284.3 topology of the port. */
  450. parport_daisy_init(port);
  451. #endif
  452. if (!port->dev)
  453. printk(KERN_WARNING "%s: fix this legacy "
  454. "no-device port driver!\n",
  455. port->name);
  456. parport_proc_register(port);
  457. mutex_lock(&registration_lock);
  458. spin_lock_irq(&parportlist_lock);
  459. list_add_tail(&port->list, &portlist);
  460. for (i = 1; i < 3; i++) {
  461. struct parport *slave = port->slaves[i-1];
  462. if (slave)
  463. list_add_tail(&slave->list, &portlist);
  464. }
  465. spin_unlock_irq(&parportlist_lock);
  466. /* Let drivers know that new port(s) has arrived. */
  467. attach_driver_chain (port);
  468. for (i = 1; i < 3; i++) {
  469. struct parport *slave = port->slaves[i-1];
  470. if (slave)
  471. attach_driver_chain(slave);
  472. }
  473. mutex_unlock(&registration_lock);
  474. }
  475. /**
  476. * parport_remove_port - deregister a parallel port
  477. * @port: parallel port to deregister
  478. *
  479. * When a parallel port driver is forcibly unloaded, or a
  480. * parallel port becomes inaccessible, the port driver must call
  481. * this function in order to deal with device drivers that still
  482. * want to use it.
  483. *
  484. * The parport structure associated with the port has its
  485. * operations structure replaced with one containing 'null'
  486. * operations that return errors or just don't do anything.
  487. *
  488. * Any drivers that have registered themselves using
  489. * parport_register_driver() are notified that the port is no
  490. * longer accessible by having their detach() routines called
  491. * with @port as the parameter.
  492. **/
  493. void parport_remove_port(struct parport *port)
  494. {
  495. int i;
  496. mutex_lock(&registration_lock);
  497. /* Spread the word. */
  498. detach_driver_chain (port);
  499. #ifdef CONFIG_PARPORT_1284
  500. /* Forget the IEEE1284.3 topology of the port. */
  501. parport_daisy_fini(port);
  502. for (i = 1; i < 3; i++) {
  503. struct parport *slave = port->slaves[i-1];
  504. if (!slave)
  505. continue;
  506. detach_driver_chain(slave);
  507. parport_daisy_fini(slave);
  508. }
  509. #endif
  510. port->ops = &dead_ops;
  511. spin_lock(&parportlist_lock);
  512. list_del_init(&port->list);
  513. for (i = 1; i < 3; i++) {
  514. struct parport *slave = port->slaves[i-1];
  515. if (slave)
  516. list_del_init(&slave->list);
  517. }
  518. spin_unlock(&parportlist_lock);
  519. mutex_unlock(&registration_lock);
  520. parport_proc_unregister(port);
  521. for (i = 1; i < 3; i++) {
  522. struct parport *slave = port->slaves[i-1];
  523. if (slave)
  524. parport_put_port(slave);
  525. }
  526. }
  527. /**
  528. * parport_register_device - register a device on a parallel port
  529. * @port: port to which the device is attached
  530. * @name: a name to refer to the device
  531. * @pf: preemption callback
  532. * @kf: kick callback (wake-up)
  533. * @irq_func: interrupt handler
  534. * @flags: registration flags
  535. * @handle: data for callback functions
  536. *
  537. * This function, called by parallel port device drivers,
  538. * declares that a device is connected to a port, and tells the
  539. * system all it needs to know.
  540. *
  541. * The @name is allocated by the caller and must not be
  542. * deallocated until the caller calls @parport_unregister_device
  543. * for that device.
  544. *
  545. * The preemption callback function, @pf, is called when this
  546. * device driver has claimed access to the port but another
  547. * device driver wants to use it. It is given @handle as its
  548. * parameter, and should return zero if it is willing for the
  549. * system to release the port to another driver on its behalf.
  550. * If it wants to keep control of the port it should return
  551. * non-zero, and no action will be taken. It is good manners for
  552. * the driver to try to release the port at the earliest
  553. * opportunity after its preemption callback rejects a preemption
  554. * attempt. Note that if a preemption callback is happy for
  555. * preemption to go ahead, there is no need to release the port;
  556. * it is done automatically. This function may not block, as it
  557. * may be called from interrupt context. If the device driver
  558. * does not support preemption, @pf can be %NULL.
  559. *
  560. * The wake-up ("kick") callback function, @kf, is called when
  561. * the port is available to be claimed for exclusive access; that
  562. * is, parport_claim() is guaranteed to succeed when called from
  563. * inside the wake-up callback function. If the driver wants to
  564. * claim the port it should do so; otherwise, it need not take
  565. * any action. This function may not block, as it may be called
  566. * from interrupt context. If the device driver does not want to
  567. * be explicitly invited to claim the port in this way, @kf can
  568. * be %NULL.
  569. *
  570. * The interrupt handler, @irq_func, is called when an interrupt
  571. * arrives from the parallel port. Note that if a device driver
  572. * wants to use interrupts it should use parport_enable_irq(),
  573. * and can also check the irq member of the parport structure
  574. * representing the port.
  575. *
  576. * The parallel port (lowlevel) driver is the one that has called
  577. * request_irq() and whose interrupt handler is called first.
  578. * This handler does whatever needs to be done to the hardware to
  579. * acknowledge the interrupt (for PC-style ports there is nothing
  580. * special to be done). It then tells the IEEE 1284 code about
  581. * the interrupt, which may involve reacting to an IEEE 1284
  582. * event depending on the current IEEE 1284 phase. After this,
  583. * it calls @irq_func. Needless to say, @irq_func will be called
  584. * from interrupt context, and may not block.
  585. *
  586. * The %PARPORT_DEV_EXCL flag is for preventing port sharing, and
  587. * so should only be used when sharing the port with other device
  588. * drivers is impossible and would lead to incorrect behaviour.
  589. * Use it sparingly! Normally, @flags will be zero.
  590. *
  591. * This function returns a pointer to a structure that represents
  592. * the device on the port, or %NULL if there is not enough memory
  593. * to allocate space for that structure.
  594. **/
  595. struct pardevice *
  596. parport_register_device(struct parport *port, const char *name,
  597. int (*pf)(void *), void (*kf)(void *),
  598. void (*irq_func)(void *),
  599. int flags, void *handle)
  600. {
  601. struct pardevice *tmp;
  602. if (port->physport->flags & PARPORT_FLAG_EXCL) {
  603. /* An exclusive device is registered. */
  604. printk (KERN_DEBUG "%s: no more devices allowed\n",
  605. port->name);
  606. return NULL;
  607. }
  608. if (flags & PARPORT_DEV_LURK) {
  609. if (!pf || !kf) {
  610. printk(KERN_INFO "%s: refused to register lurking device (%s) without callbacks\n", port->name, name);
  611. return NULL;
  612. }
  613. }
  614. if (flags & PARPORT_DEV_EXCL) {
  615. if (port->physport->devices) {
  616. /*
  617. * If a device is already registered and this new
  618. * device wants exclusive access, then no need to
  619. * continue as we can not grant exclusive access to
  620. * this device.
  621. */
  622. pr_err("%s: cannot grant exclusive access for device %s\n",
  623. port->name, name);
  624. return NULL;
  625. }
  626. }
  627. /* We up our own module reference count, and that of the port
  628. on which a device is to be registered, to ensure that
  629. neither of us gets unloaded while we sleep in (e.g.)
  630. kmalloc.
  631. */
  632. if (!try_module_get(port->ops->owner)) {
  633. return NULL;
  634. }
  635. parport_get_port (port);
  636. tmp = kmalloc(sizeof(struct pardevice), GFP_KERNEL);
  637. if (tmp == NULL) {
  638. printk(KERN_WARNING "%s: memory squeeze, couldn't register %s.\n", port->name, name);
  639. goto out;
  640. }
  641. tmp->state = kmalloc(sizeof(struct parport_state), GFP_KERNEL);
  642. if (tmp->state == NULL) {
  643. printk(KERN_WARNING "%s: memory squeeze, couldn't register %s.\n", port->name, name);
  644. goto out_free_pardevice;
  645. }
  646. tmp->name = name;
  647. tmp->port = port;
  648. tmp->daisy = -1;
  649. tmp->preempt = pf;
  650. tmp->wakeup = kf;
  651. tmp->private = handle;
  652. tmp->flags = flags;
  653. tmp->irq_func = irq_func;
  654. tmp->waiting = 0;
  655. tmp->timeout = 5 * HZ;
  656. tmp->devmodel = false;
  657. /* Chain this onto the list */
  658. tmp->prev = NULL;
  659. /*
  660. * This function must not run from an irq handler so we don' t need
  661. * to clear irq on the local CPU. -arca
  662. */
  663. spin_lock(&port->physport->pardevice_lock);
  664. if (flags & PARPORT_DEV_EXCL) {
  665. if (port->physport->devices) {
  666. spin_unlock (&port->physport->pardevice_lock);
  667. printk (KERN_DEBUG
  668. "%s: cannot grant exclusive access for "
  669. "device %s\n", port->name, name);
  670. goto out_free_all;
  671. }
  672. port->flags |= PARPORT_FLAG_EXCL;
  673. }
  674. tmp->next = port->physport->devices;
  675. wmb(); /* Make sure that tmp->next is written before it's
  676. added to the list; see comments marked 'no locking
  677. required' */
  678. if (port->physport->devices)
  679. port->physport->devices->prev = tmp;
  680. port->physport->devices = tmp;
  681. spin_unlock(&port->physport->pardevice_lock);
  682. init_waitqueue_head(&tmp->wait_q);
  683. tmp->timeslice = parport_default_timeslice;
  684. tmp->waitnext = tmp->waitprev = NULL;
  685. /*
  686. * This has to be run as last thing since init_state may need other
  687. * pardevice fields. -arca
  688. */
  689. port->ops->init_state(tmp, tmp->state);
  690. if (!test_and_set_bit(PARPORT_DEVPROC_REGISTERED, &port->devflags)) {
  691. port->proc_device = tmp;
  692. parport_device_proc_register(tmp);
  693. }
  694. return tmp;
  695. out_free_all:
  696. kfree(tmp->state);
  697. out_free_pardevice:
  698. kfree(tmp);
  699. out:
  700. parport_put_port (port);
  701. module_put(port->ops->owner);
  702. return NULL;
  703. }
  704. static void free_pardevice(struct device *dev)
  705. {
  706. struct pardevice *par_dev = to_pardevice(dev);
  707. kfree(par_dev->name);
  708. kfree(par_dev);
  709. }
  710. struct pardevice *
  711. parport_register_dev_model(struct parport *port, const char *name,
  712. const struct pardev_cb *par_dev_cb, int id)
  713. {
  714. struct pardevice *par_dev;
  715. int ret;
  716. char *devname;
  717. if (port->physport->flags & PARPORT_FLAG_EXCL) {
  718. /* An exclusive device is registered. */
  719. pr_err("%s: no more devices allowed\n", port->name);
  720. return NULL;
  721. }
  722. if (par_dev_cb->flags & PARPORT_DEV_LURK) {
  723. if (!par_dev_cb->preempt || !par_dev_cb->wakeup) {
  724. pr_info("%s: refused to register lurking device (%s) without callbacks\n",
  725. port->name, name);
  726. return NULL;
  727. }
  728. }
  729. if (par_dev_cb->flags & PARPORT_DEV_EXCL) {
  730. if (port->physport->devices) {
  731. /*
  732. * If a device is already registered and this new
  733. * device wants exclusive access, then no need to
  734. * continue as we can not grant exclusive access to
  735. * this device.
  736. */
  737. pr_err("%s: cannot grant exclusive access for device %s\n",
  738. port->name, name);
  739. return NULL;
  740. }
  741. }
  742. if (!try_module_get(port->ops->owner))
  743. return NULL;
  744. parport_get_port(port);
  745. par_dev = kzalloc(sizeof(*par_dev), GFP_KERNEL);
  746. if (!par_dev)
  747. goto err_put_port;
  748. par_dev->state = kzalloc(sizeof(*par_dev->state), GFP_KERNEL);
  749. if (!par_dev->state)
  750. goto err_put_par_dev;
  751. devname = kstrdup(name, GFP_KERNEL);
  752. if (!devname)
  753. goto err_free_par_dev;
  754. par_dev->name = devname;
  755. par_dev->port = port;
  756. par_dev->daisy = -1;
  757. par_dev->preempt = par_dev_cb->preempt;
  758. par_dev->wakeup = par_dev_cb->wakeup;
  759. par_dev->private = par_dev_cb->private;
  760. par_dev->flags = par_dev_cb->flags;
  761. par_dev->irq_func = par_dev_cb->irq_func;
  762. par_dev->waiting = 0;
  763. par_dev->timeout = 5 * HZ;
  764. par_dev->dev.parent = &port->bus_dev;
  765. par_dev->dev.bus = &parport_bus_type;
  766. ret = dev_set_name(&par_dev->dev, "%s.%d", devname, id);
  767. if (ret)
  768. goto err_free_devname;
  769. par_dev->dev.release = free_pardevice;
  770. par_dev->devmodel = true;
  771. ret = device_register(&par_dev->dev);
  772. if (ret)
  773. goto err_put_dev;
  774. /* Chain this onto the list */
  775. par_dev->prev = NULL;
  776. /*
  777. * This function must not run from an irq handler so we don' t need
  778. * to clear irq on the local CPU. -arca
  779. */
  780. spin_lock(&port->physport->pardevice_lock);
  781. if (par_dev_cb->flags & PARPORT_DEV_EXCL) {
  782. if (port->physport->devices) {
  783. spin_unlock(&port->physport->pardevice_lock);
  784. pr_debug("%s: cannot grant exclusive access for device %s\n",
  785. port->name, name);
  786. goto err_put_dev;
  787. }
  788. port->flags |= PARPORT_FLAG_EXCL;
  789. }
  790. par_dev->next = port->physport->devices;
  791. wmb(); /*
  792. * Make sure that tmp->next is written before it's
  793. * added to the list; see comments marked 'no locking
  794. * required'
  795. */
  796. if (port->physport->devices)
  797. port->physport->devices->prev = par_dev;
  798. port->physport->devices = par_dev;
  799. spin_unlock(&port->physport->pardevice_lock);
  800. init_waitqueue_head(&par_dev->wait_q);
  801. par_dev->timeslice = parport_default_timeslice;
  802. par_dev->waitnext = NULL;
  803. par_dev->waitprev = NULL;
  804. /*
  805. * This has to be run as last thing since init_state may need other
  806. * pardevice fields. -arca
  807. */
  808. port->ops->init_state(par_dev, par_dev->state);
  809. port->proc_device = par_dev;
  810. parport_device_proc_register(par_dev);
  811. return par_dev;
  812. err_put_dev:
  813. put_device(&par_dev->dev);
  814. err_free_devname:
  815. kfree(devname);
  816. err_free_par_dev:
  817. kfree(par_dev->state);
  818. err_put_par_dev:
  819. if (!par_dev->devmodel)
  820. kfree(par_dev);
  821. err_put_port:
  822. parport_put_port(port);
  823. module_put(port->ops->owner);
  824. return NULL;
  825. }
  826. EXPORT_SYMBOL(parport_register_dev_model);
  827. /**
  828. * parport_unregister_device - deregister a device on a parallel port
  829. * @dev: pointer to structure representing device
  830. *
  831. * This undoes the effect of parport_register_device().
  832. **/
  833. void parport_unregister_device(struct pardevice *dev)
  834. {
  835. struct parport *port;
  836. #ifdef PARPORT_PARANOID
  837. if (dev == NULL) {
  838. printk(KERN_ERR "parport_unregister_device: passed NULL\n");
  839. return;
  840. }
  841. #endif
  842. port = dev->port->physport;
  843. if (port->proc_device == dev) {
  844. port->proc_device = NULL;
  845. clear_bit(PARPORT_DEVPROC_REGISTERED, &port->devflags);
  846. parport_device_proc_unregister(dev);
  847. }
  848. if (port->cad == dev) {
  849. printk(KERN_DEBUG "%s: %s forgot to release port\n",
  850. port->name, dev->name);
  851. parport_release (dev);
  852. }
  853. spin_lock(&port->pardevice_lock);
  854. if (dev->next)
  855. dev->next->prev = dev->prev;
  856. if (dev->prev)
  857. dev->prev->next = dev->next;
  858. else
  859. port->devices = dev->next;
  860. if (dev->flags & PARPORT_DEV_EXCL)
  861. port->flags &= ~PARPORT_FLAG_EXCL;
  862. spin_unlock(&port->pardevice_lock);
  863. /* Make sure we haven't left any pointers around in the wait
  864. * list. */
  865. spin_lock_irq(&port->waitlist_lock);
  866. if (dev->waitprev || dev->waitnext || port->waithead == dev) {
  867. if (dev->waitprev)
  868. dev->waitprev->waitnext = dev->waitnext;
  869. else
  870. port->waithead = dev->waitnext;
  871. if (dev->waitnext)
  872. dev->waitnext->waitprev = dev->waitprev;
  873. else
  874. port->waittail = dev->waitprev;
  875. }
  876. spin_unlock_irq(&port->waitlist_lock);
  877. kfree(dev->state);
  878. if (dev->devmodel)
  879. device_unregister(&dev->dev);
  880. else
  881. kfree(dev);
  882. module_put(port->ops->owner);
  883. parport_put_port (port);
  884. }
  885. /**
  886. * parport_find_number - find a parallel port by number
  887. * @number: parallel port number
  888. *
  889. * This returns the parallel port with the specified number, or
  890. * %NULL if there is none.
  891. *
  892. * There is an implicit parport_get_port() done already; to throw
  893. * away the reference to the port that parport_find_number()
  894. * gives you, use parport_put_port().
  895. */
  896. struct parport *parport_find_number (int number)
  897. {
  898. struct parport *port, *result = NULL;
  899. if (list_empty(&portlist))
  900. get_lowlevel_driver ();
  901. spin_lock (&parportlist_lock);
  902. list_for_each_entry(port, &portlist, list) {
  903. if (port->number == number) {
  904. result = parport_get_port (port);
  905. break;
  906. }
  907. }
  908. spin_unlock (&parportlist_lock);
  909. return result;
  910. }
  911. /**
  912. * parport_find_base - find a parallel port by base address
  913. * @base: base I/O address
  914. *
  915. * This returns the parallel port with the specified base
  916. * address, or %NULL if there is none.
  917. *
  918. * There is an implicit parport_get_port() done already; to throw
  919. * away the reference to the port that parport_find_base()
  920. * gives you, use parport_put_port().
  921. */
  922. struct parport *parport_find_base (unsigned long base)
  923. {
  924. struct parport *port, *result = NULL;
  925. if (list_empty(&portlist))
  926. get_lowlevel_driver ();
  927. spin_lock (&parportlist_lock);
  928. list_for_each_entry(port, &portlist, list) {
  929. if (port->base == base) {
  930. result = parport_get_port (port);
  931. break;
  932. }
  933. }
  934. spin_unlock (&parportlist_lock);
  935. return result;
  936. }
  937. /**
  938. * parport_claim - claim access to a parallel port device
  939. * @dev: pointer to structure representing a device on the port
  940. *
  941. * This function will not block and so can be used from interrupt
  942. * context. If parport_claim() succeeds in claiming access to
  943. * the port it returns zero and the port is available to use. It
  944. * may fail (returning non-zero) if the port is in use by another
  945. * driver and that driver is not willing to relinquish control of
  946. * the port.
  947. **/
  948. int parport_claim(struct pardevice *dev)
  949. {
  950. struct pardevice *oldcad;
  951. struct parport *port = dev->port->physport;
  952. unsigned long flags;
  953. if (port->cad == dev) {
  954. printk(KERN_INFO "%s: %s already owner\n",
  955. dev->port->name,dev->name);
  956. return 0;
  957. }
  958. /* Preempt any current device */
  959. write_lock_irqsave (&port->cad_lock, flags);
  960. if ((oldcad = port->cad) != NULL) {
  961. if (oldcad->preempt) {
  962. if (oldcad->preempt(oldcad->private))
  963. goto blocked;
  964. port->ops->save_state(port, dev->state);
  965. } else
  966. goto blocked;
  967. if (port->cad != oldcad) {
  968. /* I think we'll actually deadlock rather than
  969. get here, but just in case.. */
  970. printk(KERN_WARNING
  971. "%s: %s released port when preempted!\n",
  972. port->name, oldcad->name);
  973. if (port->cad)
  974. goto blocked;
  975. }
  976. }
  977. /* Can't fail from now on, so mark ourselves as no longer waiting. */
  978. if (dev->waiting & 1) {
  979. dev->waiting = 0;
  980. /* Take ourselves out of the wait list again. */
  981. spin_lock_irq (&port->waitlist_lock);
  982. if (dev->waitprev)
  983. dev->waitprev->waitnext = dev->waitnext;
  984. else
  985. port->waithead = dev->waitnext;
  986. if (dev->waitnext)
  987. dev->waitnext->waitprev = dev->waitprev;
  988. else
  989. port->waittail = dev->waitprev;
  990. spin_unlock_irq (&port->waitlist_lock);
  991. dev->waitprev = dev->waitnext = NULL;
  992. }
  993. /* Now we do the change of devices */
  994. port->cad = dev;
  995. #ifdef CONFIG_PARPORT_1284
  996. /* If it's a mux port, select it. */
  997. if (dev->port->muxport >= 0) {
  998. /* FIXME */
  999. port->muxsel = dev->port->muxport;
  1000. }
  1001. /* If it's a daisy chain device, select it. */
  1002. if (dev->daisy >= 0) {
  1003. /* This could be lazier. */
  1004. if (!parport_daisy_select (port, dev->daisy,
  1005. IEEE1284_MODE_COMPAT))
  1006. port->daisy = dev->daisy;
  1007. }
  1008. #endif /* IEEE1284.3 support */
  1009. /* Restore control registers */
  1010. port->ops->restore_state(port, dev->state);
  1011. write_unlock_irqrestore(&port->cad_lock, flags);
  1012. dev->time = jiffies;
  1013. return 0;
  1014. blocked:
  1015. /* If this is the first time we tried to claim the port, register an
  1016. interest. This is only allowed for devices sleeping in
  1017. parport_claim_or_block(), or those with a wakeup function. */
  1018. /* The cad_lock is still held for writing here */
  1019. if (dev->waiting & 2 || dev->wakeup) {
  1020. spin_lock (&port->waitlist_lock);
  1021. if (test_and_set_bit(0, &dev->waiting) == 0) {
  1022. /* First add ourselves to the end of the wait list. */
  1023. dev->waitnext = NULL;
  1024. dev->waitprev = port->waittail;
  1025. if (port->waittail) {
  1026. port->waittail->waitnext = dev;
  1027. port->waittail = dev;
  1028. } else
  1029. port->waithead = port->waittail = dev;
  1030. }
  1031. spin_unlock (&port->waitlist_lock);
  1032. }
  1033. write_unlock_irqrestore (&port->cad_lock, flags);
  1034. return -EAGAIN;
  1035. }
  1036. /**
  1037. * parport_claim_or_block - claim access to a parallel port device
  1038. * @dev: pointer to structure representing a device on the port
  1039. *
  1040. * This behaves like parport_claim(), but will block if necessary
  1041. * to wait for the port to be free. A return value of 1
  1042. * indicates that it slept; 0 means that it succeeded without
  1043. * needing to sleep. A negative error code indicates failure.
  1044. **/
  1045. int parport_claim_or_block(struct pardevice *dev)
  1046. {
  1047. int r;
  1048. /* Signal to parport_claim() that we can wait even without a
  1049. wakeup function. */
  1050. dev->waiting = 2;
  1051. /* Try to claim the port. If this fails, we need to sleep. */
  1052. r = parport_claim(dev);
  1053. if (r == -EAGAIN) {
  1054. #ifdef PARPORT_DEBUG_SHARING
  1055. printk(KERN_DEBUG "%s: parport_claim() returned -EAGAIN\n", dev->name);
  1056. #endif
  1057. /*
  1058. * FIXME!!! Use the proper locking for dev->waiting,
  1059. * and make this use the "wait_event_interruptible()"
  1060. * interfaces. The cli/sti that used to be here
  1061. * did nothing.
  1062. *
  1063. * See also parport_release()
  1064. */
  1065. /* If dev->waiting is clear now, an interrupt
  1066. gave us the port and we would deadlock if we slept. */
  1067. if (dev->waiting) {
  1068. wait_event_interruptible(dev->wait_q,
  1069. !dev->waiting);
  1070. if (signal_pending (current)) {
  1071. return -EINTR;
  1072. }
  1073. r = 1;
  1074. } else {
  1075. r = 0;
  1076. #ifdef PARPORT_DEBUG_SHARING
  1077. printk(KERN_DEBUG "%s: didn't sleep in parport_claim_or_block()\n",
  1078. dev->name);
  1079. #endif
  1080. }
  1081. #ifdef PARPORT_DEBUG_SHARING
  1082. if (dev->port->physport->cad != dev)
  1083. printk(KERN_DEBUG "%s: exiting parport_claim_or_block "
  1084. "but %s owns port!\n", dev->name,
  1085. dev->port->physport->cad ?
  1086. dev->port->physport->cad->name:"nobody");
  1087. #endif
  1088. }
  1089. dev->waiting = 0;
  1090. return r;
  1091. }
  1092. /**
  1093. * parport_release - give up access to a parallel port device
  1094. * @dev: pointer to structure representing parallel port device
  1095. *
  1096. * This function cannot fail, but it should not be called without
  1097. * the port claimed. Similarly, if the port is already claimed
  1098. * you should not try claiming it again.
  1099. **/
  1100. void parport_release(struct pardevice *dev)
  1101. {
  1102. struct parport *port = dev->port->physport;
  1103. struct pardevice *pd;
  1104. unsigned long flags;
  1105. /* Make sure that dev is the current device */
  1106. write_lock_irqsave(&port->cad_lock, flags);
  1107. if (port->cad != dev) {
  1108. write_unlock_irqrestore (&port->cad_lock, flags);
  1109. printk(KERN_WARNING "%s: %s tried to release parport "
  1110. "when not owner\n", port->name, dev->name);
  1111. return;
  1112. }
  1113. #ifdef CONFIG_PARPORT_1284
  1114. /* If this is on a mux port, deselect it. */
  1115. if (dev->port->muxport >= 0) {
  1116. /* FIXME */
  1117. port->muxsel = -1;
  1118. }
  1119. /* If this is a daisy device, deselect it. */
  1120. if (dev->daisy >= 0) {
  1121. parport_daisy_deselect_all (port);
  1122. port->daisy = -1;
  1123. }
  1124. #endif
  1125. port->cad = NULL;
  1126. write_unlock_irqrestore(&port->cad_lock, flags);
  1127. /* Save control registers */
  1128. port->ops->save_state(port, dev->state);
  1129. /* If anybody is waiting, find out who's been there longest and
  1130. then wake them up. (Note: no locking required) */
  1131. /* !!! LOCKING IS NEEDED HERE */
  1132. for (pd = port->waithead; pd; pd = pd->waitnext) {
  1133. if (pd->waiting & 2) { /* sleeping in claim_or_block */
  1134. parport_claim(pd);
  1135. if (waitqueue_active(&pd->wait_q))
  1136. wake_up_interruptible(&pd->wait_q);
  1137. return;
  1138. } else if (pd->wakeup) {
  1139. pd->wakeup(pd->private);
  1140. if (dev->port->cad) /* racy but no matter */
  1141. return;
  1142. } else {
  1143. printk(KERN_ERR "%s: don't know how to wake %s\n", port->name, pd->name);
  1144. }
  1145. }
  1146. /* Nobody was waiting, so walk the list to see if anyone is
  1147. interested in being woken up. (Note: no locking required) */
  1148. /* !!! LOCKING IS NEEDED HERE */
  1149. for (pd = port->devices; (port->cad == NULL) && pd; pd = pd->next) {
  1150. if (pd->wakeup && pd != dev)
  1151. pd->wakeup(pd->private);
  1152. }
  1153. }
  1154. irqreturn_t parport_irq_handler(int irq, void *dev_id)
  1155. {
  1156. struct parport *port = dev_id;
  1157. parport_generic_irq(port);
  1158. return IRQ_HANDLED;
  1159. }
  1160. /* Exported symbols for modules. */
  1161. EXPORT_SYMBOL(parport_claim);
  1162. EXPORT_SYMBOL(parport_claim_or_block);
  1163. EXPORT_SYMBOL(parport_release);
  1164. EXPORT_SYMBOL(parport_register_port);
  1165. EXPORT_SYMBOL(parport_announce_port);
  1166. EXPORT_SYMBOL(parport_remove_port);
  1167. EXPORT_SYMBOL(parport_unregister_driver);
  1168. EXPORT_SYMBOL(parport_register_device);
  1169. EXPORT_SYMBOL(parport_unregister_device);
  1170. EXPORT_SYMBOL(parport_get_port);
  1171. EXPORT_SYMBOL(parport_put_port);
  1172. EXPORT_SYMBOL(parport_find_number);
  1173. EXPORT_SYMBOL(parport_find_base);
  1174. EXPORT_SYMBOL(parport_irq_handler);
  1175. MODULE_LICENSE("GPL");