Staging: ipack/devices/ipoctal: Use KBUILD_MODNAME instead of hardcoded string.
[pandora-kernel.git] / drivers / staging / ipack / devices / ipoctal.c
index e0be660..a0c1e76 100644 (file)
@@ -263,7 +263,7 @@ static void ipoctal_irq_channel(struct ipoctal_channel *channel)
        tty_kref_put(tty);
 }
 
-static int ipoctal_irq_handler(void *arg)
+static irqreturn_t ipoctal_irq_handler(void *arg)
 {
        unsigned int i;
        struct ipoctal *ipoctal = (struct ipoctal *) arg;
@@ -411,8 +411,8 @@ static int ipoctal_inst_slot(struct ipoctal *ipoctal, unsigned int bus_nr,
 
        /* Fill struct tty_driver with ipoctal data */
        tty->owner = THIS_MODULE;
-       tty->driver_name = "ipoctal";
-       sprintf(name, "ipoctal.%d.%d.", bus_nr, slot);
+       tty->driver_name = KBUILD_MODNAME;
+       sprintf(name, KBUILD_MODNAME ".%d.%d.", bus_nr, slot);
        tty->name = name;
        tty->major = 0;
 
@@ -437,6 +437,8 @@ static int ipoctal_inst_slot(struct ipoctal *ipoctal, unsigned int bus_nr,
        ipoctal->tty_drv = tty;
 
        for (i = 0; i < NR_CHANNELS; i++) {
+               struct device *tty_dev;
+
                channel = &ipoctal->channel[i];
                tty_port_init(&channel->tty_port);
                tty_port_alloc_xmit_buf(&channel->tty_port);
@@ -450,7 +452,11 @@ static int ipoctal_inst_slot(struct ipoctal *ipoctal, unsigned int bus_nr,
                channel->pointer_read = 0;
                channel->pointer_write = 0;
                channel->nb_bytes = 0;
-               tty_register_device(tty, i, NULL);
+               tty_dev = tty_register_device(tty, i, NULL);
+               if (IS_ERR(tty_dev)) {
+                       dev_err(&ipoctal->dev->dev, "Failed to register tty device.\n");
+                       continue;
+               }
 
                /*
                 * Enable again the RX. TX will be enabled when
@@ -493,9 +499,11 @@ static inline int ipoctal_copy_write_buffer(struct ipoctal_channel *channel,
        return i;
 }
 
-static int ipoctal_write(struct ipoctal_channel *channel,
-                        const unsigned char *buf, int count)
+static int ipoctal_write_tty(struct tty_struct *tty,
+                            const unsigned char *buf, int count)
 {
+       struct ipoctal_channel *channel = tty->driver_data;
+
        channel->nb_bytes = 0;
        channel->count_wr = 0;
 
@@ -519,14 +527,6 @@ static int ipoctal_write(struct ipoctal_channel *channel,
        return channel->count_wr;
 }
 
-static int ipoctal_write_tty(struct tty_struct *tty,
-                            const unsigned char *buf, int count)
-{
-       struct ipoctal_channel *channel = tty->driver_data;
-
-       return ipoctal_write(channel, buf, count);
-}
-
 static int ipoctal_write_room(struct tty_struct *tty)
 {
        struct ipoctal_channel *channel = tty->driver_data;
@@ -731,6 +731,7 @@ static int ipoctal_probe(struct ipack_device *dev)
        if (res)
                goto out_uninst;
 
+       dev_set_drvdata(&dev->dev, ipoctal);
        list_add_tail(&ipoctal->list, &ipoctal_list);
        return 0;
 
@@ -757,14 +758,9 @@ static void __ipoctal_remove(struct ipoctal *ipoctal)
        kfree(ipoctal);
 }
 
-static void ipoctal_remove(struct ipack_device *device)
+static void ipoctal_remove(struct ipack_device *idev)
 {
-       struct ipoctal *ipoctal, *next;
-
-       list_for_each_entry_safe(ipoctal, next, &ipoctal_list, list) {
-               if (ipoctal->dev == device)
-                       __ipoctal_remove(ipoctal);
-       }
+       __ipoctal_remove(dev_get_drvdata(&idev->dev));
 }
 
 static DEFINE_IPACK_DEVICE_TABLE(ipoctal_ids) = {