aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/gigaset/ser-gigaset.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/isdn/gigaset/ser-gigaset.c')
-rw-r--r--drivers/isdn/gigaset/ser-gigaset.c58
1 files changed, 37 insertions, 21 deletions
diff --git a/drivers/isdn/gigaset/ser-gigaset.c b/drivers/isdn/gigaset/ser-gigaset.c
index 3071a52467ed..e96c0586886c 100644
--- a/drivers/isdn/gigaset/ser-gigaset.c
+++ b/drivers/isdn/gigaset/ser-gigaset.c
@@ -11,11 +11,9 @@
11 */ 11 */
12 12
13#include "gigaset.h" 13#include "gigaset.h"
14
15#include <linux/module.h> 14#include <linux/module.h>
16#include <linux/moduleparam.h> 15#include <linux/moduleparam.h>
17#include <linux/platform_device.h> 16#include <linux/platform_device.h>
18#include <linux/tty.h>
19#include <linux/completion.h> 17#include <linux/completion.h>
20 18
21/* Version Information */ 19/* Version Information */
@@ -164,9 +162,15 @@ static void gigaset_modem_fill(unsigned long data)
164{ 162{
165 struct cardstate *cs = (struct cardstate *) data; 163 struct cardstate *cs = (struct cardstate *) data;
166 struct bc_state *bcs; 164 struct bc_state *bcs;
165 struct sk_buff *nextskb;
167 int sent = 0; 166 int sent = 0;
168 167
169 if (!cs || !(bcs = cs->bcs)) { 168 if (!cs) {
169 gig_dbg(DEBUG_OUTPUT, "%s: no cardstate", __func__);
170 return;
171 }
172 bcs = cs->bcs;
173 if (!bcs) {
170 gig_dbg(DEBUG_OUTPUT, "%s: no cardstate", __func__); 174 gig_dbg(DEBUG_OUTPUT, "%s: no cardstate", __func__);
171 return; 175 return;
172 } 176 }
@@ -179,9 +183,11 @@ static void gigaset_modem_fill(unsigned long data)
179 return; 183 return;
180 184
181 /* no command to send; get skb */ 185 /* no command to send; get skb */
182 if (!(bcs->tx_skb = skb_dequeue(&bcs->squeue))) 186 nextskb = skb_dequeue(&bcs->squeue);
187 if (!nextskb)
183 /* no skb either, nothing to do */ 188 /* no skb either, nothing to do */
184 return; 189 return;
190 bcs->tx_skb = nextskb;
185 191
186 gig_dbg(DEBUG_INTR, "Dequeued skb (Adr: %lx)", 192 gig_dbg(DEBUG_INTR, "Dequeued skb (Adr: %lx)",
187 (unsigned long) bcs->tx_skb); 193 (unsigned long) bcs->tx_skb);
@@ -236,19 +242,20 @@ static void flush_send_queue(struct cardstate *cs)
236 * number of bytes queued, or error code < 0 242 * number of bytes queued, or error code < 0
237 */ 243 */
238static int gigaset_write_cmd(struct cardstate *cs, const unsigned char *buf, 244static int gigaset_write_cmd(struct cardstate *cs, const unsigned char *buf,
239 int len, struct tasklet_struct *wake_tasklet) 245 int len, struct tasklet_struct *wake_tasklet)
240{ 246{
241 struct cmdbuf_t *cb; 247 struct cmdbuf_t *cb;
242 unsigned long flags; 248 unsigned long flags;
243 249
244 gigaset_dbg_buffer(cs->mstate != MS_LOCKED ? 250 gigaset_dbg_buffer(cs->mstate != MS_LOCKED ?
245 DEBUG_TRANSCMD : DEBUG_LOCKCMD, 251 DEBUG_TRANSCMD : DEBUG_LOCKCMD,
246 "CMD Transmit", len, buf); 252 "CMD Transmit", len, buf);
247 253
248 if (len <= 0) 254 if (len <= 0)
249 return 0; 255 return 0;
250 256
251 if (!(cb = kmalloc(sizeof(struct cmdbuf_t) + len, GFP_ATOMIC))) { 257 cb = kmalloc(sizeof(struct cmdbuf_t) + len, GFP_ATOMIC);
258 if (!cb) {
252 dev_err(cs->dev, "%s: out of memory!\n", __func__); 259 dev_err(cs->dev, "%s: out of memory!\n", __func__);
253 return -ENOMEM; 260 return -ENOMEM;
254 } 261 }
@@ -392,7 +399,6 @@ static void gigaset_device_release(struct device *dev)
392 struct platform_device *pdev = to_platform_device(dev); 399 struct platform_device *pdev = to_platform_device(dev);
393 400
394 /* adapted from platform_device_release() in drivers/base/platform.c */ 401 /* adapted from platform_device_release() in drivers/base/platform.c */
395 //FIXME is this actually necessary?
396 kfree(dev->platform_data); 402 kfree(dev->platform_data);
397 kfree(pdev->resource); 403 kfree(pdev->resource);
398} 404}
@@ -404,16 +410,20 @@ static void gigaset_device_release(struct device *dev)
404static int gigaset_initcshw(struct cardstate *cs) 410static int gigaset_initcshw(struct cardstate *cs)
405{ 411{
406 int rc; 412 int rc;
413 struct ser_cardstate *scs;
407 414
408 if (!(cs->hw.ser = kzalloc(sizeof(struct ser_cardstate), GFP_KERNEL))) { 415 scs = kzalloc(sizeof(struct ser_cardstate), GFP_KERNEL);
416 if (!scs) {
409 pr_err("out of memory\n"); 417 pr_err("out of memory\n");
410 return 0; 418 return 0;
411 } 419 }
420 cs->hw.ser = scs;
412 421
413 cs->hw.ser->dev.name = GIGASET_MODULENAME; 422 cs->hw.ser->dev.name = GIGASET_MODULENAME;
414 cs->hw.ser->dev.id = cs->minor_index; 423 cs->hw.ser->dev.id = cs->minor_index;
415 cs->hw.ser->dev.dev.release = gigaset_device_release; 424 cs->hw.ser->dev.dev.release = gigaset_device_release;
416 if ((rc = platform_device_register(&cs->hw.ser->dev)) != 0) { 425 rc = platform_device_register(&cs->hw.ser->dev);
426 if (rc != 0) {
417 pr_err("error %d registering platform device\n", rc); 427 pr_err("error %d registering platform device\n", rc);
418 kfree(cs->hw.ser); 428 kfree(cs->hw.ser);
419 cs->hw.ser = NULL; 429 cs->hw.ser = NULL;
@@ -422,7 +432,7 @@ static int gigaset_initcshw(struct cardstate *cs)
422 dev_set_drvdata(&cs->hw.ser->dev.dev, cs); 432 dev_set_drvdata(&cs->hw.ser->dev.dev, cs);
423 433
424 tasklet_init(&cs->write_tasklet, 434 tasklet_init(&cs->write_tasklet,
425 &gigaset_modem_fill, (unsigned long) cs); 435 gigaset_modem_fill, (unsigned long) cs);
426 return 1; 436 return 1;
427} 437}
428 438
@@ -434,7 +444,8 @@ static int gigaset_initcshw(struct cardstate *cs)
434 * Called by "gigaset_start" and "gigaset_enterconfigmode" in common.c 444 * Called by "gigaset_start" and "gigaset_enterconfigmode" in common.c
435 * and by "if_lock" and "if_termios" in interface.c 445 * and by "if_lock" and "if_termios" in interface.c
436 */ 446 */
437static int gigaset_set_modem_ctrl(struct cardstate *cs, unsigned old_state, unsigned new_state) 447static int gigaset_set_modem_ctrl(struct cardstate *cs, unsigned old_state,
448 unsigned new_state)
438{ 449{
439 struct tty_struct *tty = cs->hw.ser->tty; 450 struct tty_struct *tty = cs->hw.ser->tty;
440 unsigned int set, clear; 451 unsigned int set, clear;
@@ -520,8 +531,8 @@ gigaset_tty_open(struct tty_struct *tty)
520 } 531 }
521 532
522 /* allocate memory for our device state and intialize it */ 533 /* allocate memory for our device state and intialize it */
523 if (!(cs = gigaset_initcs(driver, 1, 1, 0, cidmode, 534 cs = gigaset_initcs(driver, 1, 1, 0, cidmode, GIGASET_MODULENAME);
524 GIGASET_MODULENAME))) 535 if (!cs)
525 goto error; 536 goto error;
526 537
527 cs->dev = &cs->hw.ser->dev.dev; 538 cs->dev = &cs->hw.ser->dev.dev;
@@ -690,7 +701,8 @@ gigaset_tty_receive(struct tty_struct *tty, const unsigned char *buf,
690 701
691 if (!cs) 702 if (!cs)
692 return; 703 return;
693 if (!(inbuf = cs->inbuf)) { 704 inbuf = cs->inbuf;
705 if (!inbuf) {
694 dev_err(cs->dev, "%s: no inbuf\n", __func__); 706 dev_err(cs->dev, "%s: no inbuf\n", __func__);
695 cs_put(cs); 707 cs_put(cs);
696 return; 708 return;
@@ -770,18 +782,21 @@ static int __init ser_gigaset_init(void)
770 int rc; 782 int rc;
771 783
772 gig_dbg(DEBUG_INIT, "%s", __func__); 784 gig_dbg(DEBUG_INIT, "%s", __func__);
773 if ((rc = platform_driver_register(&device_driver)) != 0) { 785 rc = platform_driver_register(&device_driver);
786 if (rc != 0) {
774 pr_err("error %d registering platform driver\n", rc); 787 pr_err("error %d registering platform driver\n", rc);
775 return rc; 788 return rc;
776 } 789 }
777 790
778 /* allocate memory for our driver state and intialize it */ 791 /* allocate memory for our driver state and intialize it */
779 if (!(driver = gigaset_initdriver(GIGASET_MINOR, GIGASET_MINORS, 792 driver = gigaset_initdriver(GIGASET_MINOR, GIGASET_MINORS,
780 GIGASET_MODULENAME, GIGASET_DEVNAME, 793 GIGASET_MODULENAME, GIGASET_DEVNAME,
781 &ops, THIS_MODULE))) 794 &ops, THIS_MODULE);
795 if (!driver)
782 goto error; 796 goto error;
783 797
784 if ((rc = tty_register_ldisc(N_GIGASET_M101, &gigaset_ldisc)) != 0) { 798 rc = tty_register_ldisc(N_GIGASET_M101, &gigaset_ldisc);
799 if (rc != 0) {
785 pr_err("error %d registering line discipline\n", rc); 800 pr_err("error %d registering line discipline\n", rc);
786 goto error; 801 goto error;
787 } 802 }
@@ -808,7 +823,8 @@ static void __exit ser_gigaset_exit(void)
808 driver = NULL; 823 driver = NULL;
809 } 824 }
810 825
811 if ((rc = tty_unregister_ldisc(N_GIGASET_M101)) != 0) 826 rc = tty_unregister_ldisc(N_GIGASET_M101);
827 if (rc != 0)
812 pr_err("error %d unregistering line discipline\n", rc); 828 pr_err("error %d unregistering line discipline\n", rc);
813 829
814 platform_driver_unregister(&device_driver); 830 platform_driver_unregister(&device_driver);