common.c 29 KB

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