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;
/* 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;
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);
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
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;
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;
if (res)
goto out_uninst;
+ dev_set_drvdata(&dev->dev, ipoctal);
list_add_tail(&ipoctal->list, &ipoctal_list);
return 0;
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) = {