ser_gigaset: return -ENOMEM on error instead of success
[pandora-kernel.git] / drivers / isdn / gigaset / ser-gigaset.c
index 1d44d47..92846da 100644 (file)
@@ -371,19 +371,23 @@ static void gigaset_freecshw(struct cardstate *cs)
        tasklet_kill(&cs->write_tasklet);
        if (!cs->hw.ser)
                return;
-       dev_set_drvdata(&cs->hw.ser->dev.dev, NULL);
        platform_device_unregister(&cs->hw.ser->dev);
-       kfree(cs->hw.ser);
-       cs->hw.ser = NULL;
 }
 
 static void gigaset_device_release(struct device *dev)
 {
        struct platform_device *pdev = to_platform_device(dev);
+       struct cardstate *cs = dev_get_drvdata(dev);
 
        /* adapted from platform_device_release() in drivers/base/platform.c */
        kfree(dev->platform_data);
        kfree(pdev->resource);
+
+       if (!cs)
+               return;
+       dev_set_drvdata(dev, NULL);
+       kfree(cs->hw.ser);
+       cs->hw.ser = NULL;
 }
 
 /*
@@ -674,7 +678,7 @@ gigaset_tty_ioctl(struct tty_struct *tty, struct file *file,
  *     cflags  buffer containing error flags for received characters (ignored)
  *     count   number of received characters
  */
-static unsigned int
+static void
 gigaset_tty_receive(struct tty_struct *tty, const unsigned char *buf,
                    char *cflags, int count)
 {
@@ -683,12 +687,12 @@ gigaset_tty_receive(struct tty_struct *tty, const unsigned char *buf,
        struct inbuf_t *inbuf;
 
        if (!cs)
-               return -ENODEV;
+               return;
        inbuf = cs->inbuf;
        if (!inbuf) {
                dev_err(cs->dev, "%s: no inbuf\n", __func__);
                cs_put(cs);
-               return -EINVAL;
+               return;
        }
 
        tail = inbuf->tail;
@@ -725,8 +729,6 @@ gigaset_tty_receive(struct tty_struct *tty, const unsigned char *buf,
        gig_dbg(DEBUG_INTR, "%s-->BH", __func__);
        gigaset_schedule_event(cs);
        cs_put(cs);
-
-       return count;
 }
 
 /*
@@ -777,8 +779,10 @@ static int __init ser_gigaset_init(void)
        driver = gigaset_initdriver(GIGASET_MINOR, GIGASET_MINORS,
                                          GIGASET_MODULENAME, GIGASET_DEVNAME,
                                          &ops, THIS_MODULE);
-       if (!driver)
+       if (!driver) {
+               rc = -ENOMEM;
                goto error;
+       }
 
        rc = tty_register_ldisc(N_GIGASET_M101, &gigaset_ldisc);
        if (rc != 0) {