Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 78f22bc2 authored by Federico Vaga's avatar Federico Vaga Committed by Greg Kroah-Hartman
Browse files

ipoctal: reset function istead of duplicate code

parent e0b04f2e
Loading
Loading
Loading
Loading
+14 −21
Original line number Original line Diff line number Diff line
@@ -55,6 +55,16 @@ struct ipoctal {
	u8 __iomem			*int_space;
	u8 __iomem			*int_space;
};
};


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)
static int ipoctal_port_activate(struct tty_port *port, struct tty_struct *tty)
{
{
	struct ipoctal_channel *channel;
	struct ipoctal_channel *channel;
@@ -304,10 +314,7 @@ static int ipoctal_inst_slot(struct ipoctal *ipoctal, unsigned int bus_nr,
			channel->isr_rx_rdy_mask = ISR_RxRDY_FFULL_A;
			channel->isr_rx_rdy_mask = ISR_RxRDY_FFULL_A;
		}
		}


		iowrite8(CR_DISABLE_RX | CR_DISABLE_TX, &channel->regs->w.cr);
		ipoctal_reset_channel(channel);
		channel->rx_enable = 0;
		iowrite8(CR_CMD_RESET_RX, &channel->regs->w.cr);
		iowrite8(CR_CMD_RESET_TX, &channel->regs->w.cr);
		iowrite8(MR1_CHRL_8_BITS | MR1_ERROR_CHAR | MR1_RxINT_RxRDY,
		iowrite8(MR1_CHRL_8_BITS | MR1_ERROR_CHAR | MR1_RxINT_RxRDY,
			 &channel->regs->w.mr); /* mr1 */
			 &channel->regs->w.mr); /* mr1 */
		iowrite8(0, &channel->regs->w.mr); /* mr2 */
		iowrite8(0, &channel->regs->w.mr); /* mr2 */
@@ -467,11 +474,7 @@ static void ipoctal_set_termios(struct tty_struct *tty,
	cflag = tty->termios.c_cflag;
	cflag = tty->termios.c_cflag;


	/* Disable and reset everything before change the setup */
	/* Disable and reset everything before change the setup */
	iowrite8(CR_DISABLE_RX | CR_DISABLE_TX, &channel->regs->w.cr);
	ipoctal_reset_channel(channel);
	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);


	/* Set Bits per chars */
	/* Set Bits per chars */
	switch (cflag & CSIZE) {
	switch (cflag & CSIZE) {
@@ -609,12 +612,7 @@ static void ipoctal_hangup(struct tty_struct *tty)


	tty_port_hangup(&channel->tty_port);
	tty_port_hangup(&channel->tty_port);


	iowrite8(CR_DISABLE_RX | CR_DISABLE_TX, &channel->regs->w.cr);
	ipoctal_reset_channel(channel);
	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);


	clear_bit(ASYNCB_INITIALIZED, &channel->tty_port.flags);
	clear_bit(ASYNCB_INITIALIZED, &channel->tty_port.flags);
	wake_up_interruptible(&channel->tty_port.open_wait);
	wake_up_interruptible(&channel->tty_port.open_wait);
@@ -627,12 +625,7 @@ static void ipoctal_shutdown(struct tty_struct *tty)
	if (channel == NULL)
	if (channel == NULL)
		return;
		return;


	iowrite8(CR_DISABLE_RX | CR_DISABLE_TX, &channel->regs->w.cr);
	ipoctal_reset_channel(channel);
	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);
	clear_bit(ASYNCB_INITIALIZED, &channel->tty_port.flags);
	clear_bit(ASYNCB_INITIALIZED, &channel->tty_port.flags);
}
}