diff options
Diffstat (limited to 'drivers/ipack')
-rw-r--r-- | drivers/ipack/carriers/tpci200.c | 3 | ||||
-rw-r--r-- | drivers/ipack/devices/ipoctal.c | 69 | ||||
-rw-r--r-- | drivers/ipack/devices/ipoctal.h | 2 | ||||
-rw-r--r-- | drivers/ipack/ipack.c | 4 |
4 files changed, 50 insertions, 28 deletions
diff --git a/drivers/ipack/carriers/tpci200.c b/drivers/ipack/carriers/tpci200.c index de5e32151a1e..9b23843dcad4 100644 --- a/drivers/ipack/carriers/tpci200.c +++ b/drivers/ipack/carriers/tpci200.c @@ -572,7 +572,8 @@ static int tpci200_pci_probe(struct pci_dev *pdev, /* Register the carrier in the industry pack bus driver */ tpci200->info->ipack_bus = ipack_bus_register(&pdev->dev, TPCI200_NB_SLOT, - &tpci200_bus_ops); + &tpci200_bus_ops, + THIS_MODULE); if (!tpci200->info->ipack_bus) { dev_err(&pdev->dev, "error registering the carrier on ipack driver\n"); diff --git a/drivers/ipack/devices/ipoctal.c b/drivers/ipack/devices/ipoctal.c index e41bef048c23..035d5449227e 100644 --- a/drivers/ipack/devices/ipoctal.c +++ b/drivers/ipack/devices/ipoctal.c @@ -55,6 +55,22 @@ struct ipoctal { u8 __iomem *int_space; }; +static inline struct ipoctal *chan_to_ipoctal(struct ipoctal_channel *chan, + unsigned int index) +{ + return container_of(chan, struct ipoctal, channel[index]); +} + +static void ipoctal_reset_channel(struct ipoctal_channel *channel) +{ + iowrite8(CR_DISABLE_RX | CR_DISABLE_TX, &channel->regs->w.cr); + channel->rx_enable = 0; + iowrite8(CR_CMD_RESET_RX, &channel->regs->w.cr); + iowrite8(CR_CMD_RESET_TX, &channel->regs->w.cr); + iowrite8(CR_CMD_RESET_ERR_STATUS, &channel->regs->w.cr); + iowrite8(CR_CMD_RESET_MR, &channel->regs->w.cr); +} + static int ipoctal_port_activate(struct tty_port *port, struct tty_struct *tty) { struct ipoctal_channel *channel; @@ -72,12 +88,20 @@ static int ipoctal_port_activate(struct tty_port *port, struct tty_struct *tty) static int ipoctal_open(struct tty_struct *tty, struct file *file) { - struct ipoctal_channel *channel; + struct ipoctal_channel *channel = dev_get_drvdata(tty->dev); + struct ipoctal *ipoctal = chan_to_ipoctal(channel, tty->index); + int err; - channel = dev_get_drvdata(tty->dev); tty->driver_data = channel; - return tty_port_open(&channel->tty_port, tty, file); + if (!ipack_get_carrier(ipoctal->dev)) + return -EBUSY; + + err = tty_port_open(&channel->tty_port, tty, file); + if (err) + ipack_put_carrier(ipoctal->dev); + + return err; } static void ipoctal_reset_stats(struct ipoctal_stats *stats) @@ -151,7 +175,6 @@ static void ipoctal_irq_rx(struct ipoctal_channel *channel, u8 sr) flag = TTY_FRAME; } if (sr & SR_RECEIVED_BREAK) { - iowrite8(CR_CMD_RESET_BREAK_CHANGE, &channel->regs->w.cr); channel->stats.rcv_break++; flag = TTY_BREAK; } @@ -196,6 +219,9 @@ static void ipoctal_irq_channel(struct ipoctal_channel *channel) isr = ioread8(&channel->block_regs->r.isr); sr = ioread8(&channel->regs->r.sr); + if (isr & (IMR_DELTA_BREAK_A | IMR_DELTA_BREAK_B)) + iowrite8(CR_CMD_RESET_BREAK_CHANGE, &channel->regs->w.cr); + if ((sr & SR_TX_EMPTY) && (channel->nb_bytes == 0)) { iowrite8(CR_DISABLE_TX, &channel->regs->w.cr); /* In case of RS-485, change from TX to RX when finishing TX. @@ -304,10 +330,7 @@ static int ipoctal_inst_slot(struct ipoctal *ipoctal, unsigned int bus_nr, channel->isr_rx_rdy_mask = ISR_RxRDY_FFULL_A; } - iowrite8(CR_DISABLE_RX | CR_DISABLE_TX, &channel->regs->w.cr); - channel->rx_enable = 0; - iowrite8(CR_CMD_RESET_RX, &channel->regs->w.cr); - iowrite8(CR_CMD_RESET_TX, &channel->regs->w.cr); + ipoctal_reset_channel(channel); iowrite8(MR1_CHRL_8_BITS | MR1_ERROR_CHAR | MR1_RxINT_RxRDY, &channel->regs->w.mr); /* mr1 */ iowrite8(0, &channel->regs->w.mr); /* mr2 */ @@ -467,11 +490,7 @@ static void ipoctal_set_termios(struct tty_struct *tty, cflag = tty->termios.c_cflag; /* Disable and reset everything before change the setup */ - iowrite8(CR_DISABLE_RX | CR_DISABLE_TX, &channel->regs->w.cr); - iowrite8(CR_CMD_RESET_RX, &channel->regs->w.cr); - iowrite8(CR_CMD_RESET_TX, &channel->regs->w.cr); - iowrite8(CR_CMD_RESET_ERR_STATUS, &channel->regs->w.cr); - iowrite8(CR_CMD_RESET_MR, &channel->regs->w.cr); + ipoctal_reset_channel(channel); /* Set Bits per chars */ switch (cflag & CSIZE) { @@ -609,12 +628,7 @@ static void ipoctal_hangup(struct tty_struct *tty) tty_port_hangup(&channel->tty_port); - iowrite8(CR_DISABLE_RX | CR_DISABLE_TX, &channel->regs->w.cr); - channel->rx_enable = 0; - iowrite8(CR_CMD_RESET_RX, &channel->regs->w.cr); - iowrite8(CR_CMD_RESET_TX, &channel->regs->w.cr); - iowrite8(CR_CMD_RESET_ERR_STATUS, &channel->regs->w.cr); - iowrite8(CR_CMD_RESET_MR, &channel->regs->w.cr); + ipoctal_reset_channel(channel); clear_bit(ASYNCB_INITIALIZED, &channel->tty_port.flags); wake_up_interruptible(&channel->tty_port.open_wait); @@ -627,15 +641,19 @@ static void ipoctal_shutdown(struct tty_struct *tty) if (channel == NULL) return; - iowrite8(CR_DISABLE_RX | CR_DISABLE_TX, &channel->regs->w.cr); - channel->rx_enable = 0; - iowrite8(CR_CMD_RESET_RX, &channel->regs->w.cr); - iowrite8(CR_CMD_RESET_TX, &channel->regs->w.cr); - iowrite8(CR_CMD_RESET_ERR_STATUS, &channel->regs->w.cr); - iowrite8(CR_CMD_RESET_MR, &channel->regs->w.cr); + ipoctal_reset_channel(channel); clear_bit(ASYNCB_INITIALIZED, &channel->tty_port.flags); } +static void ipoctal_cleanup(struct tty_struct *tty) +{ + struct ipoctal_channel *channel = tty->driver_data; + struct ipoctal *ipoctal = chan_to_ipoctal(channel, tty->index); + + /* release the carrier driver */ + ipack_put_carrier(ipoctal->dev); +} + static const struct tty_operations ipoctal_fops = { .ioctl = NULL, .open = ipoctal_open, @@ -647,6 +665,7 @@ static const struct tty_operations ipoctal_fops = { .get_icount = ipoctal_get_icount, .hangup = ipoctal_hangup, .shutdown = ipoctal_shutdown, + .cleanup = ipoctal_cleanup, }; static int ipoctal_probe(struct ipack_device *dev) diff --git a/drivers/ipack/devices/ipoctal.h b/drivers/ipack/devices/ipoctal.h index 28f1c4233154..7fede0eb6a0c 100644 --- a/drivers/ipack/devices/ipoctal.h +++ b/drivers/ipack/devices/ipoctal.h @@ -12,7 +12,7 @@ * Software Foundation; version 2 of the License. */ -#ifndef _IPOCTAL_H +#ifndef _IPOCTAL_H_ #define _IPOCTAL_H_ #define NR_CHANNELS 8 diff --git a/drivers/ipack/ipack.c b/drivers/ipack/ipack.c index d0016ba469ed..c0e7b624ce54 100644 --- a/drivers/ipack/ipack.c +++ b/drivers/ipack/ipack.c @@ -206,7 +206,8 @@ static struct bus_type ipack_bus_type = { }; struct ipack_bus_device *ipack_bus_register(struct device *parent, int slots, - const struct ipack_bus_ops *ops) + const struct ipack_bus_ops *ops, + struct module *owner) { int bus_nr; struct ipack_bus_device *bus; @@ -225,6 +226,7 @@ struct ipack_bus_device *ipack_bus_register(struct device *parent, int slots, bus->parent = parent; bus->slots = slots; bus->ops = ops; + bus->owner = owner; return bus; } EXPORT_SYMBOL_GPL(ipack_bus_register); |