Staging: ipack/devices/ipoctal: Get rid of ipoctal_list.
Use tty_dev->dev's drdata to associate struct ipocal_channel to the respective tty_struct. Signed-off-by: Jens Taprogge <jens.taprogge@taprogge.org> Signed-off-by: Samuel Iglesias Gonsalvez <siglesias@igalia.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
3f3a592798
commit
9c1d784afc
1 changed files with 3 additions and 36 deletions
|
@ -49,7 +49,6 @@ struct ipoctal_channel {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ipoctal {
|
struct ipoctal {
|
||||||
struct list_head list;
|
|
||||||
struct ipack_device *dev;
|
struct ipack_device *dev;
|
||||||
unsigned int board_id;
|
unsigned int board_id;
|
||||||
struct ipoctal_channel channel[NR_CHANNELS];
|
struct ipoctal_channel channel[NR_CHANNELS];
|
||||||
|
@ -57,34 +56,11 @@ struct ipoctal {
|
||||||
struct tty_driver *tty_drv;
|
struct tty_driver *tty_drv;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Linked list to save the registered devices */
|
|
||||||
static LIST_HEAD(ipoctal_list);
|
|
||||||
|
|
||||||
static struct ipoctal *ipoctal_find_board(struct tty_struct *tty)
|
|
||||||
{
|
|
||||||
struct ipoctal *p;
|
|
||||||
|
|
||||||
list_for_each_entry(p, &ipoctal_list, list) {
|
|
||||||
if (tty->driver->major == p->tty_drv->major)
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int ipoctal_port_activate(struct tty_port *port, struct tty_struct *tty)
|
static int ipoctal_port_activate(struct tty_port *port, struct tty_struct *tty)
|
||||||
{
|
{
|
||||||
struct ipoctal *ipoctal;
|
|
||||||
struct ipoctal_channel *channel;
|
struct ipoctal_channel *channel;
|
||||||
|
|
||||||
ipoctal = ipoctal_find_board(tty);
|
channel = dev_get_drvdata(tty->dev);
|
||||||
|
|
||||||
if (ipoctal == NULL) {
|
|
||||||
dev_err(tty->dev, "Device not found. Major %d\n",
|
|
||||||
tty->driver->major);
|
|
||||||
return -ENODEV;
|
|
||||||
}
|
|
||||||
channel = &ipoctal->channel[tty->index];
|
|
||||||
|
|
||||||
iowrite8(CR_ENABLE_RX, &channel->regs->w.cr);
|
iowrite8(CR_ENABLE_RX, &channel->regs->w.cr);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -93,17 +69,9 @@ static int ipoctal_port_activate(struct tty_port *port, struct tty_struct *tty)
|
||||||
static int ipoctal_open(struct tty_struct *tty, struct file *file)
|
static int ipoctal_open(struct tty_struct *tty, struct file *file)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
struct ipoctal *ipoctal;
|
|
||||||
struct ipoctal_channel *channel;
|
struct ipoctal_channel *channel;
|
||||||
|
|
||||||
ipoctal = ipoctal_find_board(tty);
|
channel = dev_get_drvdata(tty->dev);
|
||||||
|
|
||||||
if (ipoctal == NULL) {
|
|
||||||
dev_err(tty->dev, "Device not found. Major %d\n",
|
|
||||||
tty->driver->major);
|
|
||||||
return -ENODEV;
|
|
||||||
}
|
|
||||||
channel = &ipoctal->channel[tty->index];
|
|
||||||
|
|
||||||
if (atomic_read(&channel->open))
|
if (atomic_read(&channel->open))
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
|
@ -457,6 +425,7 @@ static int ipoctal_inst_slot(struct ipoctal *ipoctal, unsigned int bus_nr,
|
||||||
dev_err(&ipoctal->dev->dev, "Failed to register tty device.\n");
|
dev_err(&ipoctal->dev->dev, "Failed to register tty device.\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
dev_set_drvdata(tty_dev, channel);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Enable again the RX. TX will be enabled when
|
* Enable again the RX. TX will be enabled when
|
||||||
|
@ -732,7 +701,6 @@ static int ipoctal_probe(struct ipack_device *dev)
|
||||||
goto out_uninst;
|
goto out_uninst;
|
||||||
|
|
||||||
dev_set_drvdata(&dev->dev, ipoctal);
|
dev_set_drvdata(&dev->dev, ipoctal);
|
||||||
list_add_tail(&ipoctal->list, &ipoctal_list);
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
out_uninst:
|
out_uninst:
|
||||||
|
@ -754,7 +722,6 @@ static void __ipoctal_remove(struct ipoctal *ipoctal)
|
||||||
|
|
||||||
tty_unregister_driver(ipoctal->tty_drv);
|
tty_unregister_driver(ipoctal->tty_drv);
|
||||||
put_tty_driver(ipoctal->tty_drv);
|
put_tty_driver(ipoctal->tty_drv);
|
||||||
list_del(&ipoctal->list);
|
|
||||||
kfree(ipoctal);
|
kfree(ipoctal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue