common.c 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232
  1. /*
  2. * Stuff used by all variants of the driver
  3. *
  4. * Copyright (c) 2001 by Stefan Eilers,
  5. * Hansjoerg Lipp <hjlipp@web.de>,
  6. * Tilman Schmidt <tilman@imap.cc>.
  7. *
  8. * =====================================================================
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License as
  11. * published by the Free Software Foundation; either version 2 of
  12. * the License, or (at your option) any later version.
  13. * =====================================================================
  14. */
  15. #include "gigaset.h"
  16. #include <linux/ctype.h>
  17. #include <linux/module.h>
  18. #include <linux/moduleparam.h>
  19. /* Version Information */
  20. #define DRIVER_AUTHOR "Hansjoerg Lipp <hjlipp@web.de>, Tilman Schmidt <tilman@imap.cc>, Stefan Eilers"
  21. #define DRIVER_DESC "Driver for Gigaset 307x"
  22. /* Module parameters */
  23. int gigaset_debuglevel = DEBUG_DEFAULT;
  24. EXPORT_SYMBOL_GPL(gigaset_debuglevel);
  25. module_param_named(debug, gigaset_debuglevel, int, S_IRUGO|S_IWUSR);
  26. MODULE_PARM_DESC(debug, "debug level");
  27. /* driver state flags */
  28. #define VALID_MINOR 0x01
  29. #define VALID_ID 0x02
  30. #define ASSIGNED 0x04
  31. /* bitwise byte inversion table */
  32. __u8 gigaset_invtab[256] = {
  33. 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
  34. 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
  35. 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
  36. 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
  37. 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
  38. 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
  39. 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
  40. 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
  41. 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
  42. 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
  43. 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
  44. 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
  45. 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
  46. 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
  47. 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
  48. 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
  49. 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
  50. 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
  51. 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
  52. 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
  53. 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
  54. 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
  55. 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
  56. 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
  57. 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
  58. 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
  59. 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
  60. 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
  61. 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
  62. 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
  63. 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
  64. 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff
  65. };
  66. EXPORT_SYMBOL_GPL(gigaset_invtab);
  67. void gigaset_dbg_buffer(enum debuglevel level, const unsigned char *msg,
  68. size_t len, const unsigned char *buf)
  69. {
  70. unsigned char outbuf[80];
  71. unsigned char c;
  72. size_t space = sizeof outbuf - 1;
  73. unsigned char *out = outbuf;
  74. size_t numin = len;
  75. while (numin--) {
  76. c = *buf++;
  77. if (c == '~' || c == '^' || c == '\\') {
  78. if (!space--)
  79. break;
  80. *out++ = '\\';
  81. }
  82. if (c & 0x80) {
  83. if (!space--)
  84. break;
  85. *out++ = '~';
  86. c ^= 0x80;
  87. }
  88. if (c < 0x20 || c == 0x7f) {
  89. if (!space--)
  90. break;
  91. *out++ = '^';
  92. c ^= 0x40;
  93. }
  94. if (!space--)
  95. break;
  96. *out++ = c;
  97. }
  98. *out = 0;
  99. gig_dbg(level, "%s (%u bytes): %s", msg, (unsigned) len, outbuf);
  100. }
  101. EXPORT_SYMBOL_GPL(gigaset_dbg_buffer);
  102. static int setflags(struct cardstate *cs, unsigned flags, unsigned delay)
  103. {
  104. int r;
  105. r = cs->ops->set_modem_ctrl(cs, cs->control_state, flags);
  106. cs->control_state = flags;
  107. if (r < 0)
  108. return r;
  109. if (delay) {
  110. set_current_state(TASK_INTERRUPTIBLE);
  111. schedule_timeout(delay * HZ / 1000);
  112. }
  113. return 0;
  114. }
  115. int gigaset_enterconfigmode(struct cardstate *cs)
  116. {
  117. int i, r;
  118. if (!atomic_read(&cs->connected)) {
  119. err("not connected!");
  120. return -1;
  121. }
  122. cs->control_state = TIOCM_RTS; //FIXME
  123. r = setflags(cs, TIOCM_DTR, 200);
  124. if (r < 0)
  125. goto error;
  126. r = setflags(cs, 0, 200);
  127. if (r < 0)
  128. goto error;
  129. for (i = 0; i < 5; ++i) {
  130. r = setflags(cs, TIOCM_RTS, 100);
  131. if (r < 0)
  132. goto error;
  133. r = setflags(cs, 0, 100);
  134. if (r < 0)
  135. goto error;
  136. }
  137. r = setflags(cs, TIOCM_RTS|TIOCM_DTR, 800);
  138. if (r < 0)
  139. goto error;
  140. return 0;
  141. error:
  142. dev_err(cs->dev, "error %d on setuartbits\n", -r);
  143. cs->control_state = TIOCM_RTS|TIOCM_DTR; // FIXME is this a good value?
  144. cs->ops->set_modem_ctrl(cs, 0, TIOCM_RTS|TIOCM_DTR);
  145. return -1; //r
  146. }
  147. static int test_timeout(struct at_state_t *at_state)
  148. {
  149. if (!at_state->timer_expires)
  150. return 0;
  151. if (--at_state->timer_expires) {
  152. gig_dbg(DEBUG_MCMD, "decreased timer of %p to %lu",
  153. at_state, at_state->timer_expires);
  154. return 0;
  155. }
  156. if (!gigaset_add_event(at_state->cs, at_state, EV_TIMEOUT, NULL,
  157. atomic_read(&at_state->timer_index), NULL)) {
  158. //FIXME what should we do?
  159. }
  160. return 1;
  161. }
  162. static void timer_tick(unsigned long data)
  163. {
  164. struct cardstate *cs = (struct cardstate *) data;
  165. unsigned long flags;
  166. unsigned channel;
  167. struct at_state_t *at_state;
  168. int timeout = 0;
  169. spin_lock_irqsave(&cs->lock, flags);
  170. for (channel = 0; channel < cs->channels; ++channel)
  171. if (test_timeout(&cs->bcs[channel].at_state))
  172. timeout = 1;
  173. if (test_timeout(&cs->at_state))
  174. timeout = 1;
  175. list_for_each_entry(at_state, &cs->temp_at_states, list)
  176. if (test_timeout(at_state))
  177. timeout = 1;
  178. if (atomic_read(&cs->running)) {
  179. mod_timer(&cs->timer, jiffies + msecs_to_jiffies(GIG_TICK));
  180. if (timeout) {
  181. gig_dbg(DEBUG_CMD, "scheduling timeout");
  182. tasklet_schedule(&cs->event_tasklet);
  183. }
  184. }
  185. spin_unlock_irqrestore(&cs->lock, flags);
  186. }
  187. int gigaset_get_channel(struct bc_state *bcs)
  188. {
  189. unsigned long flags;
  190. spin_lock_irqsave(&bcs->cs->lock, flags);
  191. if (bcs->use_count) {
  192. gig_dbg(DEBUG_ANY, "could not allocate channel %d",
  193. bcs->channel);
  194. spin_unlock_irqrestore(&bcs->cs->lock, flags);
  195. return 0;
  196. }
  197. ++bcs->use_count;
  198. bcs->busy = 1;
  199. gig_dbg(DEBUG_ANY, "allocated channel %d", bcs->channel);
  200. spin_unlock_irqrestore(&bcs->cs->lock, flags);
  201. return 1;
  202. }
  203. void gigaset_free_channel(struct bc_state *bcs)
  204. {
  205. unsigned long flags;
  206. spin_lock_irqsave(&bcs->cs->lock, flags);
  207. if (!bcs->busy) {
  208. gig_dbg(DEBUG_ANY, "could not free channel %d", bcs->channel);
  209. spin_unlock_irqrestore(&bcs->cs->lock, flags);
  210. return;
  211. }
  212. --bcs->use_count;
  213. bcs->busy = 0;
  214. gig_dbg(DEBUG_ANY, "freed channel %d", bcs->channel);
  215. spin_unlock_irqrestore(&bcs->cs->lock, flags);
  216. }
  217. int gigaset_get_channels(struct cardstate *cs)
  218. {
  219. unsigned long flags;
  220. int i;
  221. spin_lock_irqsave(&cs->lock, flags);
  222. for (i = 0; i < cs->channels; ++i)
  223. if (cs->bcs[i].use_count) {
  224. spin_unlock_irqrestore(&cs->lock, flags);
  225. gig_dbg(DEBUG_ANY, "could not allocate all channels");
  226. return 0;
  227. }
  228. for (i = 0; i < cs->channels; ++i)
  229. ++cs->bcs[i].use_count;
  230. spin_unlock_irqrestore(&cs->lock, flags);
  231. gig_dbg(DEBUG_ANY, "allocated all channels");
  232. return 1;
  233. }
  234. void gigaset_free_channels(struct cardstate *cs)
  235. {
  236. unsigned long flags;
  237. int i;
  238. gig_dbg(DEBUG_ANY, "unblocking all channels");
  239. spin_lock_irqsave(&cs->lock, flags);
  240. for (i = 0; i < cs->channels; ++i)
  241. --cs->bcs[i].use_count;
  242. spin_unlock_irqrestore(&cs->lock, flags);
  243. }
  244. void gigaset_block_channels(struct cardstate *cs)
  245. {
  246. unsigned long flags;
  247. int i;
  248. gig_dbg(DEBUG_ANY, "blocking all channels");
  249. spin_lock_irqsave(&cs->lock, flags);
  250. for (i = 0; i < cs->channels; ++i)
  251. ++cs->bcs[i].use_count;
  252. spin_unlock_irqrestore(&cs->lock, flags);
  253. }
  254. static void clear_events(struct cardstate *cs)
  255. {
  256. struct event_t *ev;
  257. unsigned head, tail;
  258. /* no locking needed (no reader/writer allowed) */
  259. head = atomic_read(&cs->ev_head);
  260. tail = atomic_read(&cs->ev_tail);
  261. while (tail != head) {
  262. ev = cs->events + head;
  263. kfree(ev->ptr);
  264. head = (head + 1) % MAX_EVENTS;
  265. }
  266. atomic_set(&cs->ev_head, tail);
  267. }
  268. struct event_t *gigaset_add_event(struct cardstate *cs,
  269. struct at_state_t *at_state, int type,
  270. void *ptr, int parameter, void *arg)
  271. {
  272. unsigned long flags;
  273. unsigned next, tail;
  274. struct event_t *event = NULL;
  275. spin_lock_irqsave(&cs->ev_lock, flags);
  276. tail = atomic_read(&cs->ev_tail);
  277. next = (tail + 1) % MAX_EVENTS;
  278. if (unlikely(next == atomic_read(&cs->ev_head)))
  279. err("event queue full");
  280. else {
  281. event = cs->events + tail;
  282. event->type = type;
  283. event->at_state = at_state;
  284. event->cid = -1;
  285. event->ptr = ptr;
  286. event->arg = arg;
  287. event->parameter = parameter;
  288. atomic_set(&cs->ev_tail, next);
  289. }
  290. spin_unlock_irqrestore(&cs->ev_lock, flags);
  291. return event;
  292. }
  293. EXPORT_SYMBOL_GPL(gigaset_add_event);
  294. static void free_strings(struct at_state_t *at_state)
  295. {
  296. int i;
  297. for (i = 0; i < STR_NUM; ++i) {
  298. kfree(at_state->str_var[i]);
  299. at_state->str_var[i] = NULL;
  300. }
  301. }
  302. static void clear_at_state(struct at_state_t *at_state)
  303. {
  304. free_strings(at_state);
  305. }
  306. static void dealloc_at_states(struct cardstate *cs)
  307. {
  308. struct at_state_t *cur, *next;
  309. list_for_each_entry_safe(cur, next, &cs->temp_at_states, list) {
  310. list_del(&cur->list);
  311. free_strings(cur);
  312. kfree(cur);
  313. }
  314. }
  315. static void gigaset_freebcs(struct bc_state *bcs)
  316. {
  317. int i;
  318. gig_dbg(DEBUG_INIT, "freeing bcs[%d]->hw", bcs->channel);
  319. if (!bcs->cs->ops->freebcshw(bcs)) {
  320. gig_dbg(DEBUG_INIT, "failed");
  321. }
  322. gig_dbg(DEBUG_INIT, "clearing bcs[%d]->at_state", bcs->channel);
  323. clear_at_state(&bcs->at_state);
  324. gig_dbg(DEBUG_INIT, "freeing bcs[%d]->skb", bcs->channel);
  325. if (bcs->skb)
  326. dev_kfree_skb(bcs->skb);
  327. for (i = 0; i < AT_NUM; ++i) {
  328. kfree(bcs->commands[i]);
  329. bcs->commands[i] = NULL;
  330. }
  331. }
  332. static struct cardstate *alloc_cs(struct gigaset_driver *drv)
  333. {
  334. unsigned long flags;
  335. unsigned i;
  336. static struct cardstate *ret = NULL;
  337. spin_lock_irqsave(&drv->lock, flags);
  338. for (i = 0; i < drv->minors; ++i) {
  339. if (!(drv->flags[i] & VALID_MINOR)) {
  340. drv->flags[i] = VALID_MINOR;
  341. ret = drv->cs + i;
  342. }
  343. if (ret)
  344. break;
  345. }
  346. spin_unlock_irqrestore(&drv->lock, flags);
  347. return ret;
  348. }
  349. static void free_cs(struct cardstate *cs)
  350. {
  351. unsigned long flags;
  352. struct gigaset_driver *drv = cs->driver;
  353. spin_lock_irqsave(&drv->lock, flags);
  354. drv->flags[cs->minor_index] = 0;
  355. spin_unlock_irqrestore(&drv->lock, flags);
  356. }
  357. static void make_valid(struct cardstate *cs, unsigned mask)
  358. {
  359. unsigned long flags;
  360. struct gigaset_driver *drv = cs->driver;
  361. spin_lock_irqsave(&drv->lock, flags);
  362. drv->flags[cs->minor_index] |= mask;
  363. spin_unlock_irqrestore(&drv->lock, flags);
  364. }
  365. static void make_invalid(struct cardstate *cs, unsigned mask)
  366. {
  367. unsigned long flags;
  368. struct gigaset_driver *drv = cs->driver;
  369. spin_lock_irqsave(&drv->lock, flags);
  370. drv->flags[cs->minor_index] &= ~mask;
  371. spin_unlock_irqrestore(&drv->lock, flags);
  372. }
  373. void gigaset_freecs(struct cardstate *cs)
  374. {
  375. int i;
  376. unsigned long flags;
  377. if (!cs)
  378. return;
  379. mutex_lock(&cs->mutex);
  380. if (!cs->bcs)
  381. goto f_cs;
  382. if (!cs->inbuf)
  383. goto f_bcs;
  384. spin_lock_irqsave(&cs->lock, flags);
  385. atomic_set(&cs->running, 0);
  386. spin_unlock_irqrestore(&cs->lock, flags); /* event handler and timer are
  387. not rescheduled below */
  388. tasklet_kill(&cs->event_tasklet);
  389. del_timer_sync(&cs->timer);
  390. switch (cs->cs_init) {
  391. default:
  392. gigaset_if_free(cs);
  393. gig_dbg(DEBUG_INIT, "clearing hw");
  394. cs->ops->freecshw(cs);
  395. //FIXME cmdbuf
  396. /* fall through */
  397. case 2: /* error in initcshw */
  398. /* Deregister from LL */
  399. make_invalid(cs, VALID_ID);
  400. gig_dbg(DEBUG_INIT, "clearing iif");
  401. gigaset_i4l_cmd(cs, ISDN_STAT_UNLOAD);
  402. /* fall through */
  403. case 1: /* error when regestering to LL */
  404. gig_dbg(DEBUG_INIT, "clearing at_state");
  405. clear_at_state(&cs->at_state);
  406. dealloc_at_states(cs);
  407. /* fall through */
  408. case 0: /* error in one call to initbcs */
  409. for (i = 0; i < cs->channels; ++i) {
  410. gig_dbg(DEBUG_INIT, "clearing bcs[%d]", i);
  411. gigaset_freebcs(cs->bcs + i);
  412. }
  413. clear_events(cs);
  414. gig_dbg(DEBUG_INIT, "freeing inbuf");
  415. kfree(cs->inbuf);
  416. }
  417. f_bcs: gig_dbg(DEBUG_INIT, "freeing bcs[]");
  418. kfree(cs->bcs);
  419. f_cs: gig_dbg(DEBUG_INIT, "freeing cs");
  420. mutex_unlock(&cs->mutex);
  421. free_cs(cs);
  422. }
  423. EXPORT_SYMBOL_GPL(gigaset_freecs);
  424. void gigaset_at_init(struct at_state_t *at_state, struct bc_state *bcs,
  425. struct cardstate *cs, int cid)
  426. {
  427. int i;
  428. INIT_LIST_HEAD(&at_state->list);
  429. at_state->waiting = 0;
  430. at_state->getstring = 0;
  431. at_state->pending_commands = 0;
  432. at_state->timer_expires = 0;
  433. at_state->timer_active = 0;
  434. atomic_set(&at_state->timer_index, 0);
  435. atomic_set(&at_state->seq_index, 0);
  436. at_state->ConState = 0;
  437. for (i = 0; i < STR_NUM; ++i)
  438. at_state->str_var[i] = NULL;
  439. at_state->int_var[VAR_ZDLE] = 0;
  440. at_state->int_var[VAR_ZCTP] = -1;
  441. at_state->int_var[VAR_ZSAU] = ZSAU_NULL;
  442. at_state->cs = cs;
  443. at_state->bcs = bcs;
  444. at_state->cid = cid;
  445. if (!cid)
  446. at_state->replystruct = cs->tabnocid;
  447. else
  448. at_state->replystruct = cs->tabcid;
  449. }
  450. static void gigaset_inbuf_init(struct inbuf_t *inbuf, struct bc_state *bcs,
  451. struct cardstate *cs, int inputstate)
  452. /* inbuf->read must be allocated before! */
  453. {
  454. atomic_set(&inbuf->head, 0);
  455. atomic_set(&inbuf->tail, 0);
  456. inbuf->cs = cs;
  457. inbuf->bcs = bcs; /*base driver: NULL*/
  458. inbuf->rcvbuf = NULL; //FIXME
  459. inbuf->inputstate = inputstate;
  460. }
  461. /* append received bytes to inbuf */
  462. int gigaset_fill_inbuf(struct inbuf_t *inbuf, const unsigned char *src,
  463. unsigned numbytes)
  464. {
  465. unsigned n, head, tail, bytesleft;
  466. gig_dbg(DEBUG_INTR, "received %u bytes", numbytes);
  467. if (!numbytes)
  468. return 0;
  469. bytesleft = numbytes;
  470. tail = atomic_read(&inbuf->tail);
  471. head = atomic_read(&inbuf->head);
  472. gig_dbg(DEBUG_INTR, "buffer state: %u -> %u", head, tail);
  473. while (bytesleft) {
  474. if (head > tail)
  475. n = head - 1 - tail;
  476. else if (head == 0)
  477. n = (RBUFSIZE-1) - tail;
  478. else
  479. n = RBUFSIZE - tail;
  480. if (!n) {
  481. dev_err(inbuf->cs->dev,
  482. "buffer overflow (%u bytes lost)", bytesleft);
  483. break;
  484. }
  485. if (n > bytesleft)
  486. n = bytesleft;
  487. memcpy(inbuf->data + tail, src, n);
  488. bytesleft -= n;
  489. tail = (tail + n) % RBUFSIZE;
  490. src += n;
  491. }
  492. gig_dbg(DEBUG_INTR, "setting tail to %u", tail);
  493. atomic_set(&inbuf->tail, tail);
  494. return numbytes != bytesleft;
  495. }
  496. EXPORT_SYMBOL_GPL(gigaset_fill_inbuf);
  497. /* Initialize the b-channel structure */
  498. static struct bc_state *gigaset_initbcs(struct bc_state *bcs,
  499. struct cardstate *cs, int channel)
  500. {
  501. int i;
  502. bcs->tx_skb = NULL; //FIXME -> hw part
  503. skb_queue_head_init(&bcs->squeue);
  504. bcs->corrupted = 0;
  505. bcs->trans_down = 0;
  506. bcs->trans_up = 0;
  507. gig_dbg(DEBUG_INIT, "setting up bcs[%d]->at_state", channel);
  508. gigaset_at_init(&bcs->at_state, bcs, cs, -1);
  509. bcs->rcvbytes = 0;
  510. #ifdef CONFIG_GIGASET_DEBUG
  511. bcs->emptycount = 0;
  512. #endif
  513. gig_dbg(DEBUG_INIT, "allocating bcs[%d]->skb", channel);
  514. bcs->fcs = PPP_INITFCS;
  515. bcs->inputstate = 0;
  516. if (cs->ignoreframes) {
  517. bcs->inputstate |= INS_skip_frame;
  518. bcs->skb = NULL;
  519. } else if ((bcs->skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL)
  520. skb_reserve(bcs->skb, HW_HDR_LEN);
  521. else {
  522. dev_warn(cs->dev, "could not allocate skb\n");
  523. bcs->inputstate |= INS_skip_frame;
  524. }
  525. bcs->channel = channel;
  526. bcs->cs = cs;
  527. bcs->chstate = 0;
  528. bcs->use_count = 1;
  529. bcs->busy = 0;
  530. bcs->ignore = cs->ignoreframes;
  531. for (i = 0; i < AT_NUM; ++i)
  532. bcs->commands[i] = NULL;
  533. gig_dbg(DEBUG_INIT, " setting up bcs[%d]->hw", channel);
  534. if (cs->ops->initbcshw(bcs))
  535. return bcs;
  536. gig_dbg(DEBUG_INIT, " failed");
  537. gig_dbg(DEBUG_INIT, " freeing bcs[%d]->skb", channel);
  538. if (bcs->skb)
  539. dev_kfree_skb(bcs->skb);
  540. return NULL;
  541. }
  542. /* gigaset_initcs
  543. * Allocate and initialize cardstate structure for Gigaset driver
  544. * Calls hardware dependent gigaset_initcshw() function
  545. * Calls B channel initialization function gigaset_initbcs() for each B channel
  546. * parameters:
  547. * drv hardware driver the device belongs to
  548. * channels number of B channels supported by device
  549. * onechannel !=0: B channel data and AT commands share one
  550. * communication channel
  551. * ==0: B channels have separate communication channels
  552. * ignoreframes number of frames to ignore after setting up B channel
  553. * cidmode !=0: start in CallID mode
  554. * modulename name of driver module (used for I4L registration)
  555. * return value:
  556. * pointer to cardstate structure
  557. */
  558. struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
  559. int onechannel, int ignoreframes,
  560. int cidmode, const char *modulename)
  561. {
  562. struct cardstate *cs = NULL;
  563. int i;
  564. gig_dbg(DEBUG_INIT, "allocating cs");
  565. cs = alloc_cs(drv);
  566. if (!cs)
  567. goto error;
  568. gig_dbg(DEBUG_INIT, "allocating bcs[0..%d]", channels - 1);
  569. cs->bcs = kmalloc(channels * sizeof(struct bc_state), GFP_KERNEL);
  570. if (!cs->bcs)
  571. goto error;
  572. gig_dbg(DEBUG_INIT, "allocating inbuf");
  573. cs->inbuf = kmalloc(sizeof(struct inbuf_t), GFP_KERNEL);
  574. if (!cs->inbuf)
  575. goto error;
  576. cs->cs_init = 0;
  577. cs->channels = channels;
  578. cs->onechannel = onechannel;
  579. cs->ignoreframes = ignoreframes;
  580. INIT_LIST_HEAD(&cs->temp_at_states);
  581. atomic_set(&cs->running, 0);
  582. init_timer(&cs->timer); /* clear next & prev */
  583. spin_lock_init(&cs->ev_lock);
  584. atomic_set(&cs->ev_tail, 0);
  585. atomic_set(&cs->ev_head, 0);
  586. mutex_init(&cs->mutex);
  587. mutex_lock(&cs->mutex);
  588. tasklet_init(&cs->event_tasklet, &gigaset_handle_event,
  589. (unsigned long) cs);
  590. atomic_set(&cs->commands_pending, 0);
  591. cs->cur_at_seq = 0;
  592. cs->gotfwver = -1;
  593. cs->open_count = 0;
  594. cs->dev = NULL;
  595. cs->tty = NULL;
  596. atomic_set(&cs->cidmode, cidmode != 0);
  597. //if(onechannel) { //FIXME
  598. cs->tabnocid = gigaset_tab_nocid_m10x;
  599. cs->tabcid = gigaset_tab_cid_m10x;
  600. //} else {
  601. // cs->tabnocid = gigaset_tab_nocid;
  602. // cs->tabcid = gigaset_tab_cid;
  603. //}
  604. init_waitqueue_head(&cs->waitqueue);
  605. cs->waiting = 0;
  606. atomic_set(&cs->mode, M_UNKNOWN);
  607. atomic_set(&cs->mstate, MS_UNINITIALIZED);
  608. for (i = 0; i < channels; ++i) {
  609. gig_dbg(DEBUG_INIT, "setting up bcs[%d].read", i);
  610. if (!gigaset_initbcs(cs->bcs + i, cs, i))
  611. goto error;
  612. }
  613. ++cs->cs_init;
  614. gig_dbg(DEBUG_INIT, "setting up at_state");
  615. spin_lock_init(&cs->lock);
  616. gigaset_at_init(&cs->at_state, NULL, cs, 0);
  617. cs->dle = 0;
  618. cs->cbytes = 0;
  619. gig_dbg(DEBUG_INIT, "setting up inbuf");
  620. if (onechannel) { //FIXME distinction necessary?
  621. gigaset_inbuf_init(cs->inbuf, cs->bcs, cs, INS_command);
  622. } else
  623. gigaset_inbuf_init(cs->inbuf, NULL, cs, INS_command);
  624. atomic_set(&cs->connected, 0);
  625. gig_dbg(DEBUG_INIT, "setting up cmdbuf");
  626. cs->cmdbuf = cs->lastcmdbuf = NULL;
  627. spin_lock_init(&cs->cmdlock);
  628. cs->curlen = 0;
  629. cs->cmdbytes = 0;
  630. gig_dbg(DEBUG_INIT, "setting up iif");
  631. if (!gigaset_register_to_LL(cs, modulename)) {
  632. err("register_isdn failed");
  633. goto error;
  634. }
  635. make_valid(cs, VALID_ID);
  636. ++cs->cs_init;
  637. gig_dbg(DEBUG_INIT, "setting up hw");
  638. if (!cs->ops->initcshw(cs))
  639. goto error;
  640. ++cs->cs_init;
  641. gigaset_if_init(cs);
  642. atomic_set(&cs->running, 1);
  643. setup_timer(&cs->timer, timer_tick, (unsigned long) cs);
  644. cs->timer.expires = jiffies + msecs_to_jiffies(GIG_TICK);
  645. /* FIXME: can jiffies increase too much until the timer is added?
  646. * Same problem(?) with mod_timer() in timer_tick(). */
  647. add_timer(&cs->timer);
  648. gig_dbg(DEBUG_INIT, "cs initialized");
  649. mutex_unlock(&cs->mutex);
  650. return cs;
  651. error: if (cs)
  652. mutex_unlock(&cs->mutex);
  653. gig_dbg(DEBUG_INIT, "failed");
  654. gigaset_freecs(cs);
  655. return NULL;
  656. }
  657. EXPORT_SYMBOL_GPL(gigaset_initcs);
  658. /* ReInitialize the b-channel structure */
  659. /* e.g. called on hangup, disconnect */
  660. void gigaset_bcs_reinit(struct bc_state *bcs)
  661. {
  662. struct sk_buff *skb;
  663. struct cardstate *cs = bcs->cs;
  664. unsigned long flags;
  665. while ((skb = skb_dequeue(&bcs->squeue)) != NULL)
  666. dev_kfree_skb(skb);
  667. spin_lock_irqsave(&cs->lock, flags);
  668. clear_at_state(&bcs->at_state);
  669. bcs->at_state.ConState = 0;
  670. bcs->at_state.timer_active = 0;
  671. bcs->at_state.timer_expires = 0;
  672. bcs->at_state.cid = -1; /* No CID defined */
  673. spin_unlock_irqrestore(&cs->lock, flags);
  674. bcs->inputstate = 0;
  675. #ifdef CONFIG_GIGASET_DEBUG
  676. bcs->emptycount = 0;
  677. #endif
  678. bcs->fcs = PPP_INITFCS;
  679. bcs->chstate = 0;
  680. bcs->ignore = cs->ignoreframes;
  681. if (bcs->ignore)
  682. bcs->inputstate |= INS_skip_frame;
  683. cs->ops->reinitbcshw(bcs);
  684. }
  685. static void cleanup_cs(struct cardstate *cs)
  686. {
  687. struct cmdbuf_t *cb, *tcb;
  688. int i;
  689. unsigned long flags;
  690. spin_lock_irqsave(&cs->lock, flags);
  691. atomic_set(&cs->mode, M_UNKNOWN);
  692. atomic_set(&cs->mstate, MS_UNINITIALIZED);
  693. clear_at_state(&cs->at_state);
  694. dealloc_at_states(cs);
  695. free_strings(&cs->at_state);
  696. gigaset_at_init(&cs->at_state, NULL, cs, 0);
  697. kfree(cs->inbuf->rcvbuf);
  698. cs->inbuf->rcvbuf = NULL;
  699. cs->inbuf->inputstate = INS_command;
  700. atomic_set(&cs->inbuf->head, 0);
  701. atomic_set(&cs->inbuf->tail, 0);
  702. cb = cs->cmdbuf;
  703. while (cb) {
  704. tcb = cb;
  705. cb = cb->next;
  706. kfree(tcb);
  707. }
  708. cs->cmdbuf = cs->lastcmdbuf = NULL;
  709. cs->curlen = 0;
  710. cs->cmdbytes = 0;
  711. cs->gotfwver = -1;
  712. cs->dle = 0;
  713. cs->cur_at_seq = 0;
  714. atomic_set(&cs->commands_pending, 0);
  715. cs->cbytes = 0;
  716. spin_unlock_irqrestore(&cs->lock, flags);
  717. for (i = 0; i < cs->channels; ++i) {
  718. gigaset_freebcs(cs->bcs + i);
  719. if (!gigaset_initbcs(cs->bcs + i, cs, i))
  720. break; //FIXME error handling
  721. }
  722. if (cs->waiting) {
  723. cs->cmd_result = -ENODEV;
  724. cs->waiting = 0;
  725. wake_up_interruptible(&cs->waitqueue);
  726. }
  727. }
  728. int gigaset_start(struct cardstate *cs)
  729. {
  730. if (mutex_lock_interruptible(&cs->mutex))
  731. return 0;
  732. atomic_set(&cs->connected, 1);
  733. if (atomic_read(&cs->mstate) != MS_LOCKED) {
  734. cs->ops->set_modem_ctrl(cs, 0, TIOCM_DTR|TIOCM_RTS);
  735. cs->ops->baud_rate(cs, B115200);
  736. cs->ops->set_line_ctrl(cs, CS8);
  737. cs->control_state = TIOCM_DTR|TIOCM_RTS;
  738. } else {
  739. //FIXME use some saved values?
  740. }
  741. cs->waiting = 1;
  742. if (!gigaset_add_event(cs, &cs->at_state, EV_START, NULL, 0, NULL)) {
  743. cs->waiting = 0;
  744. //FIXME what should we do?
  745. goto error;
  746. }
  747. gig_dbg(DEBUG_CMD, "scheduling START");
  748. gigaset_schedule_event(cs);
  749. wait_event(cs->waitqueue, !cs->waiting);
  750. /* set up device sysfs */
  751. gigaset_init_dev_sysfs(cs);
  752. mutex_unlock(&cs->mutex);
  753. return 1;
  754. error:
  755. mutex_unlock(&cs->mutex);
  756. return 0;
  757. }
  758. EXPORT_SYMBOL_GPL(gigaset_start);
  759. void gigaset_shutdown(struct cardstate *cs)
  760. {
  761. mutex_lock(&cs->mutex);
  762. cs->waiting = 1;
  763. if (!gigaset_add_event(cs, &cs->at_state, EV_SHUTDOWN, NULL, 0, NULL)) {
  764. //FIXME what should we do?
  765. goto exit;
  766. }
  767. gig_dbg(DEBUG_CMD, "scheduling SHUTDOWN");
  768. gigaset_schedule_event(cs);
  769. if (wait_event_interruptible(cs->waitqueue, !cs->waiting)) {
  770. warn("%s: aborted", __func__);
  771. //FIXME
  772. }
  773. if (atomic_read(&cs->mstate) != MS_LOCKED) {
  774. //FIXME?
  775. //gigaset_baud_rate(cs, B115200);
  776. //gigaset_set_line_ctrl(cs, CS8);
  777. //gigaset_set_modem_ctrl(cs, TIOCM_DTR|TIOCM_RTS, 0);
  778. //cs->control_state = 0;
  779. } else {
  780. //FIXME use some saved values?
  781. }
  782. cleanup_cs(cs);
  783. exit:
  784. mutex_unlock(&cs->mutex);
  785. }
  786. EXPORT_SYMBOL_GPL(gigaset_shutdown);
  787. void gigaset_stop(struct cardstate *cs)
  788. {
  789. mutex_lock(&cs->mutex);
  790. /* clear device sysfs */
  791. gigaset_free_dev_sysfs(cs);
  792. atomic_set(&cs->connected, 0);
  793. cs->waiting = 1;
  794. if (!gigaset_add_event(cs, &cs->at_state, EV_STOP, NULL, 0, NULL)) {
  795. //FIXME what should we do?
  796. goto exit;
  797. }
  798. gig_dbg(DEBUG_CMD, "scheduling STOP");
  799. gigaset_schedule_event(cs);
  800. if (wait_event_interruptible(cs->waitqueue, !cs->waiting)) {
  801. warn("%s: aborted", __func__);
  802. //FIXME
  803. }
  804. /* Tell the LL that the device is not available .. */
  805. gigaset_i4l_cmd(cs, ISDN_STAT_STOP); // FIXME move to event layer?
  806. cleanup_cs(cs);
  807. exit:
  808. mutex_unlock(&cs->mutex);
  809. }
  810. EXPORT_SYMBOL_GPL(gigaset_stop);
  811. static LIST_HEAD(drivers);
  812. static spinlock_t driver_lock = SPIN_LOCK_UNLOCKED;
  813. struct cardstate *gigaset_get_cs_by_id(int id)
  814. {
  815. unsigned long flags;
  816. static struct cardstate *ret = NULL;
  817. static struct cardstate *cs;
  818. struct gigaset_driver *drv;
  819. unsigned i;
  820. spin_lock_irqsave(&driver_lock, flags);
  821. list_for_each_entry(drv, &drivers, list) {
  822. spin_lock(&drv->lock);
  823. for (i = 0; i < drv->minors; ++i) {
  824. if (drv->flags[i] & VALID_ID) {
  825. cs = drv->cs + i;
  826. if (cs->myid == id)
  827. ret = cs;
  828. }
  829. if (ret)
  830. break;
  831. }
  832. spin_unlock(&drv->lock);
  833. if (ret)
  834. break;
  835. }
  836. spin_unlock_irqrestore(&driver_lock, flags);
  837. return ret;
  838. }
  839. void gigaset_debugdrivers(void)
  840. {
  841. unsigned long flags;
  842. static struct cardstate *cs;
  843. struct gigaset_driver *drv;
  844. unsigned i;
  845. spin_lock_irqsave(&driver_lock, flags);
  846. list_for_each_entry(drv, &drivers, list) {
  847. gig_dbg(DEBUG_DRIVER, "driver %p", drv);
  848. spin_lock(&drv->lock);
  849. for (i = 0; i < drv->minors; ++i) {
  850. gig_dbg(DEBUG_DRIVER, " index %u", i);
  851. gig_dbg(DEBUG_DRIVER, " flags 0x%02x",
  852. drv->flags[i]);
  853. cs = drv->cs + i;
  854. gig_dbg(DEBUG_DRIVER, " cardstate %p", cs);
  855. gig_dbg(DEBUG_DRIVER, " minor_index %u",
  856. cs->minor_index);
  857. gig_dbg(DEBUG_DRIVER, " driver %p", cs->driver);
  858. gig_dbg(DEBUG_DRIVER, " i4l id %d", cs->myid);
  859. }
  860. spin_unlock(&drv->lock);
  861. }
  862. spin_unlock_irqrestore(&driver_lock, flags);
  863. }
  864. EXPORT_SYMBOL_GPL(gigaset_debugdrivers);
  865. struct cardstate *gigaset_get_cs_by_tty(struct tty_struct *tty)
  866. {
  867. if (tty->index < 0 || tty->index >= tty->driver->num)
  868. return NULL;
  869. return gigaset_get_cs_by_minor(tty->index + tty->driver->minor_start);
  870. }
  871. struct cardstate *gigaset_get_cs_by_minor(unsigned minor)
  872. {
  873. unsigned long flags;
  874. static struct cardstate *ret = NULL;
  875. struct gigaset_driver *drv;
  876. unsigned index;
  877. spin_lock_irqsave(&driver_lock, flags);
  878. list_for_each_entry(drv, &drivers, list) {
  879. if (minor < drv->minor || minor >= drv->minor + drv->minors)
  880. continue;
  881. index = minor - drv->minor;
  882. spin_lock(&drv->lock);
  883. if (drv->flags[index] & VALID_MINOR)
  884. ret = drv->cs + index;
  885. spin_unlock(&drv->lock);
  886. if (ret)
  887. break;
  888. }
  889. spin_unlock_irqrestore(&driver_lock, flags);
  890. return ret;
  891. }
  892. void gigaset_freedriver(struct gigaset_driver *drv)
  893. {
  894. unsigned long flags;
  895. spin_lock_irqsave(&driver_lock, flags);
  896. list_del(&drv->list);
  897. spin_unlock_irqrestore(&driver_lock, flags);
  898. gigaset_if_freedriver(drv);
  899. module_put(drv->owner);
  900. kfree(drv->cs);
  901. kfree(drv->flags);
  902. kfree(drv);
  903. }
  904. EXPORT_SYMBOL_GPL(gigaset_freedriver);
  905. /* gigaset_initdriver
  906. * Allocate and initialize gigaset_driver structure. Initialize interface.
  907. * parameters:
  908. * minor First minor number
  909. * minors Number of minors this driver can handle
  910. * procname Name of the driver
  911. * devname Name of the device files (prefix without minor number)
  912. * devfsname Devfs name of the device files without %d
  913. * return value:
  914. * Pointer to the gigaset_driver structure on success, NULL on failure.
  915. */
  916. struct gigaset_driver *gigaset_initdriver(unsigned minor, unsigned minors,
  917. const char *procname,
  918. const char *devname,
  919. const char *devfsname,
  920. const struct gigaset_ops *ops,
  921. struct module *owner)
  922. {
  923. struct gigaset_driver *drv;
  924. unsigned long flags;
  925. unsigned i;
  926. drv = kmalloc(sizeof *drv, GFP_KERNEL);
  927. if (!drv)
  928. return NULL;
  929. if (!try_module_get(owner))
  930. return NULL;
  931. drv->cs = NULL;
  932. drv->have_tty = 0;
  933. drv->minor = minor;
  934. drv->minors = minors;
  935. spin_lock_init(&drv->lock);
  936. drv->blocked = 0;
  937. drv->ops = ops;
  938. drv->owner = owner;
  939. INIT_LIST_HEAD(&drv->list);
  940. drv->cs = kmalloc(minors * sizeof *drv->cs, GFP_KERNEL);
  941. if (!drv->cs)
  942. goto out1;
  943. drv->flags = kmalloc(minors * sizeof *drv->flags, GFP_KERNEL);
  944. if (!drv->flags)
  945. goto out2;
  946. for (i = 0; i < minors; ++i) {
  947. drv->flags[i] = 0;
  948. drv->cs[i].driver = drv;
  949. drv->cs[i].ops = drv->ops;
  950. drv->cs[i].minor_index = i;
  951. }
  952. gigaset_if_initdriver(drv, procname, devname, devfsname);
  953. spin_lock_irqsave(&driver_lock, flags);
  954. list_add(&drv->list, &drivers);
  955. spin_unlock_irqrestore(&driver_lock, flags);
  956. return drv;
  957. out2:
  958. kfree(drv->cs);
  959. out1:
  960. kfree(drv);
  961. module_put(owner);
  962. return NULL;
  963. }
  964. EXPORT_SYMBOL_GPL(gigaset_initdriver);
  965. /* For drivers without fixed assignment device<->cardstate (usb) */
  966. struct cardstate *gigaset_getunassignedcs(struct gigaset_driver *drv)
  967. {
  968. unsigned long flags;
  969. struct cardstate *cs = NULL;
  970. unsigned i;
  971. spin_lock_irqsave(&drv->lock, flags);
  972. if (drv->blocked)
  973. goto exit;
  974. for (i = 0; i < drv->minors; ++i) {
  975. if ((drv->flags[i] & VALID_MINOR) &&
  976. !(drv->flags[i] & ASSIGNED)) {
  977. drv->flags[i] |= ASSIGNED;
  978. cs = drv->cs + i;
  979. break;
  980. }
  981. }
  982. exit:
  983. spin_unlock_irqrestore(&drv->lock, flags);
  984. return cs;
  985. }
  986. EXPORT_SYMBOL_GPL(gigaset_getunassignedcs);
  987. void gigaset_unassign(struct cardstate *cs)
  988. {
  989. unsigned long flags;
  990. unsigned *minor_flags;
  991. struct gigaset_driver *drv;
  992. if (!cs)
  993. return;
  994. drv = cs->driver;
  995. spin_lock_irqsave(&drv->lock, flags);
  996. minor_flags = drv->flags + cs->minor_index;
  997. if (*minor_flags & VALID_MINOR)
  998. *minor_flags &= ~ASSIGNED;
  999. spin_unlock_irqrestore(&drv->lock, flags);
  1000. }
  1001. EXPORT_SYMBOL_GPL(gigaset_unassign);
  1002. void gigaset_blockdriver(struct gigaset_driver *drv)
  1003. {
  1004. unsigned long flags;
  1005. spin_lock_irqsave(&drv->lock, flags);
  1006. drv->blocked = 1;
  1007. spin_unlock_irqrestore(&drv->lock, flags);
  1008. }
  1009. EXPORT_SYMBOL_GPL(gigaset_blockdriver);
  1010. static int __init gigaset_init_module(void)
  1011. {
  1012. /* in accordance with the principle of least astonishment,
  1013. * setting the 'debug' parameter to 1 activates a sensible
  1014. * set of default debug levels
  1015. */
  1016. if (gigaset_debuglevel == 1)
  1017. gigaset_debuglevel = DEBUG_DEFAULT;
  1018. info(DRIVER_AUTHOR);
  1019. info(DRIVER_DESC);
  1020. return 0;
  1021. }
  1022. static void __exit gigaset_exit_module(void)
  1023. {
  1024. }
  1025. module_init(gigaset_init_module);
  1026. module_exit(gigaset_exit_module);
  1027. MODULE_AUTHOR(DRIVER_AUTHOR);
  1028. MODULE_DESCRIPTION(DRIVER_DESC);
  1029. MODULE_LICENSE("GPL");