Skip to contentSkip to conversation

PATCH: rio driver rework continued #2

PATCH Alan Cox 2 participants 3 messages Mar 15, 2006 Char and misc drivers

lore
Share & tools
lore

Alan Cox

author
#0 lore raw

First large chunk of code cleanup. The split between this and #3 and #4 is fairly arbitary and due to the message length limit on the list. These patches continue the process of ripping out macros and typedefs while cleaning up lots of 32bit assumptions. Several inlines for compatibility also get removed and that causes a lot of noise.

drivers/char/rio/rioparam.c +45 -63
diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla-2.6.16-rc6-mm1/drivers/char/rio/rioparam.c linux-2.6.16-rc6-mm1/drivers/char/rio/rioparam.c
@@ -157,20 +157,16 @@
 ** NB. for MPX
 **	tty lock must NOT have been previously acquired.
 */
-int RIOParam(PortP, cmd, Modem, SleepFlag)
-struct Port *PortP;
-int cmd;
-int Modem;
-int SleepFlag;
+int RIOParam(struct Port *PortP, int cmd, int Modem, int SleepFlag)
 {
-	register struct tty_struct *TtyP;
+	struct tty_struct *TtyP;
 	int retval;
-	register struct phb_param *phb_param_ptr;
+	struct phb_param *phb_param_ptr;
 	PKT *PacketP;
 	int res;
-	uchar Cor1 = 0, Cor2 = 0, Cor4 = 0, Cor5 = 0;
-	uchar TxXon = 0, TxXoff = 0, RxXon = 0, RxXoff = 0;
-	uchar LNext = 0, TxBaud = 0, RxBaud = 0;
+	u8 Cor1 = 0, Cor2 = 0, Cor4 = 0, Cor5 = 0;
+	u8 TxXon = 0, TxXoff = 0, RxXon = 0, RxXoff = 0;
+	u8 LNext = 0, TxBaud = 0, RxBaud = 0;
 	int retries = 0xff;
 	unsigned long flags;
 
@@ -226,15 +222,12 @@
 		if (retval == RIO_FAIL) {
 			rio_dprintk(RIO_DEBUG_PARAM, "wait for can_add_transmit broken by signal\n");
 			rio_spin_unlock_irqrestore(&PortP->portSem, flags);
-			pseterr(EINTR);
 			func_exit();
-
-			return RIO_FAIL;
+			return -EINTR;
 		}
 		if (PortP->State & RIO_DELETED) {
 			rio_spin_unlock_irqrestore(&PortP->portSem, flags);
 			func_exit();
-
 			return RIO_SUCCESS;
 		}
 	}
@@ -247,7 +240,7 @@
 	}
 
 	rio_dprintk(RIO_DEBUG_PARAM, "can_add_transmit() returns %x\n", res);
-	rio_dprintk(RIO_DEBUG_PARAM, "Packet is 0x%x\n", (int) PacketP);
+	rio_dprintk(RIO_DEBUG_PARAM, "Packet is 0x%p\n", PacketP);
 
 	phb_param_ptr = (struct phb_param *) PacketP->data;
 
@@ -474,9 +467,6 @@
 		e(115200);	/* e(230400);e(460800); e(921600);  */
 	}
 
-	/* XXX MIssing conversion table. XXX */
-	/*       (TtyP->termios->c_cflag & V_CBAUD); */
-
 	rio_dprintk(RIO_DEBUG_PARAM, "tx baud 0x%x, rx baud 0x%x\n", TxBaud, RxBaud);
 
 
@@ -552,23 +542,23 @@
 	/*
 	 ** Actually write the info into the packet to be sent
 	 */
-	WBYTE(phb_param_ptr->Cmd, cmd);
-	WBYTE(phb_param_ptr->Cor1, Cor1);
-	WBYTE(phb_param_ptr->Cor2, Cor2);
-	WBYTE(phb_param_ptr->Cor4, Cor4);
-	WBYTE(phb_param_ptr->Cor5, Cor5);
-	WBYTE(phb_param_ptr->TxXon, TxXon);
-	WBYTE(phb_param_ptr->RxXon, RxXon);
-	WBYTE(phb_param_ptr->TxXoff, TxXoff);
-	WBYTE(phb_param_ptr->RxXoff, RxXoff);
-	WBYTE(phb_param_ptr->LNext, LNext);
-	WBYTE(phb_param_ptr->TxBaud, TxBaud);
-	WBYTE(phb_param_ptr->RxBaud, RxBaud);
+	writeb(cmd, &phb_param_ptr->Cmd);
+	writeb(Cor1, &phb_param_ptr->Cor1);
+	writeb(Cor2, &phb_param_ptr->Cor2);
+	writeb(Cor4, &phb_param_ptr->Cor4);
+	writeb(Cor5, &phb_param_ptr->Cor5);
+	writeb(TxXon, &phb_param_ptr->TxXon);
+	writeb(RxXon, &phb_param_ptr->RxXon);
+	writeb(TxXoff, &phb_param_ptr->TxXoff);
+	writeb(RxXoff, &phb_param_ptr->RxXoff);
+	writeb(LNext, &phb_param_ptr->LNext);
+	writeb(TxBaud, &phb_param_ptr->TxBaud);
+	writeb(RxBaud, &phb_param_ptr->RxBaud);
 
 	/*
 	 ** Set the length/command field
 	 */
-	WBYTE(PacketP->len, 12 | PKT_CMD_BIT);
+	writeb(12 | PKT_CMD_BIT, &PacketP->len);
 
 	/*
 	 ** The packet is formed - now, whack it off
@@ -597,15 +587,13 @@
 ** We can add another packet to a transmit queue if the packet pointer pointed
 ** to by the TxAdd pointer has PKT_IN_USE clear in its address.
 */
-int can_add_transmit(PktP, PortP)
-PKT **PktP;
-struct Port *PortP;
+int can_add_transmit(PKT **PktP, struct Port *PortP)
 {
-	register PKT *tp;
+	PKT *tp;
 
-	*PktP = tp = (PKT *) RIO_PTR(PortP->Caddr, RWORD(*PortP->TxAdd));
+	*PktP = tp = (PKT *) RIO_PTR(PortP->Caddr, readw(PortP->TxAdd));
 
-	return !((uint) tp & PKT_IN_USE);
+	return !((unsigned long) tp & PKT_IN_USE);
 }
 
 /*
@@ -613,24 +601,21 @@
 ** and then move the TxAdd pointer along one position to point to the next
 ** packet pointer. You must wrap the pointer from the end back to the start.
 */
-void add_transmit(PortP)
-struct Port *PortP;
+void add_transmit(struct Port *PortP)
 {
-	if (RWORD(*PortP->TxAdd) & PKT_IN_USE) {
+	if (readw(PortP->TxAdd) & PKT_IN_USE) {
 		rio_dprintk(RIO_DEBUG_PARAM, "add_transmit: Packet has been stolen!");
 	}
-	WWORD(*(ushort *) PortP->TxAdd, RWORD(*PortP->TxAdd) | PKT_IN_USE);
+	writew(readw(PortP->TxAdd) | PKT_IN_USE, PortP->TxAdd);
 	PortP->TxAdd = (PortP->TxAdd == PortP->TxEnd) ? PortP->TxStart : PortP->TxAdd + 1;
-	WWORD(PortP->PhbP->tx_add, RIO_OFF(PortP->Caddr, PortP->TxAdd));
+	writew(RIO_OFF(PortP->Caddr, PortP->TxAdd), &PortP->PhbP->tx_add);
 }
 
 /****************************************
  * Put a packet onto the end of the
  * free list
  ****************************************/
-void put_free_end(HostP, PktP)
-struct Host *HostP;
-PKT *PktP;
+void put_free_end(struct Host *HostP, PKT *PktP)
 {
 	FREE_LIST *tmp_pointer;
 	ushort old_end, new_end;
@@ -643,21 +628,21 @@
 	*
 	************************************************/
 
-	rio_dprintk(RIO_DEBUG_PFE, "put_free_end(PktP=%x)\n", (int) PktP);
+	rio_dprintk(RIO_DEBUG_PFE, "put_free_end(PktP=%p)\n", PktP);
 
-	if ((old_end = RWORD(HostP->ParmMapP->free_list_end)) != TPNULL) {
+	if ((old_end = readw(&HostP->ParmMapP->free_list_end)) != TPNULL) {
 		new_end = RIO_OFF(HostP->Caddr, PktP);
 		tmp_pointer = (FREE_LIST *) RIO_PTR(HostP->Caddr, old_end);
-		WWORD(tmp_pointer->next, new_end);
-		WWORD(((FREE_LIST *) PktP)->prev, old_end);
-		WWORD(((FREE_LIST *) PktP)->next, TPNULL);
-		WWORD(HostP->ParmMapP->free_list_end, new_end);
+		writew(new_end, &tmp_pointer->next);
+		writew(old_end, &((FREE_LIST *) PktP)->prev);
+		writew(TPNULL, &((FREE_LIST *) PktP)->next);
+		writew(new_end, &HostP->ParmMapP->free_list_end);
 	} else {		/* First packet on the free list this should never happen! */
 		rio_dprintk(RIO_DEBUG_PFE, "put_free_end(): This should never happen\n");
-		WWORD(HostP->ParmMapP->free_list_end, RIO_OFF(HostP->Caddr, PktP));
+		writew(RIO_OFF(HostP->Caddr, PktP), &HostP->ParmMapP->free_list_end);
 		tmp_pointer = (FREE_LIST *) PktP;
-		WWORD(tmp_pointer->prev, TPNULL);
-		WWORD(tmp_pointer->next, TPNULL);
+		writew(TPNULL, &tmp_pointer->prev);
+		writew(TPNULL, &tmp_pointer->next);
 	}
 	rio_dprintk(RIO_DEBUG_CMD, "Before unlock: %p\n", &HostP->HostLock);
 	rio_spin_unlock_irqrestore(&HostP->HostLock, flags);
@@ -669,12 +654,10 @@
 ** relevant packet, [having cleared the PKT_IN_USE bit]. If PKT_IN_USE is clear,
 ** then can_remove_receive() returns 0.
 */
-int can_remove_receive(PktP, PortP)
-PKT **PktP;
-struct Port *PortP;
+int can_remove_receive(PKT **PktP, struct Port *PortP)
 {
-	if (RWORD(*PortP->RxRemove) & PKT_IN_USE) {
-		*PktP = (PKT *) RIO_PTR(PortP->Caddr, RWORD(*PortP->RxRemove) & ~PKT_IN_USE);
+	if (readw(PortP->RxRemove) & PKT_IN_USE) {
+		*PktP = (PKT *) RIO_PTR(PortP->Caddr, readw(PortP->RxRemove) & ~PKT_IN_USE);
 		return 1;
 	}
 	return 0;
@@ -685,10 +668,9 @@
 ** and then bump the pointers. Once the pointers get to the end, they must
 ** be wrapped back to the start.
 */
-void remove_receive(PortP)
-struct Port *PortP;
+void remove_receive(struct Port *PortP)
 {
-	WWORD(*PortP->RxRemove, RWORD(*PortP->RxRemove) & ~PKT_IN_USE);
+	writew(readw(PortP->RxRemove) & ~PKT_IN_USE, PortP->RxRemove);
 	PortP->RxRemove = (PortP->RxRemove == PortP->RxEnd) ? PortP->RxStart : PortP->RxRemove + 1;
-	WWORD(PortP->PhbP->rx_remove, RIO_OFF(PortP->Caddr, PortP->RxRemove));
+	writew(RIO_OFF(PortP->Caddr, PortP->RxRemove), &PortP->PhbP->rx_remove);
 }
drivers/char/rio/rioroute.c +32 -32

177 lines not on this page · raw message

drivers/char/rio/riotable.c +33 -43

189 lines not on this page · raw message

drivers/char/rio/riotty.c +6 -17
diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla-2.6.16-rc6-mm1/drivers/char/rio/riotty.c linux-2.6.16-rc6-mm1/drivers/char/rio/riotty.c
@@ -136,7 +136,7 @@
 
 int riotopen(struct tty_struct *tty, struct file *filp)
 {
-	register uint SysPort;
+	unsigned int SysPort;
 	int Modem;
 	int repeat_this = 250;
 	struct Port *PortP;	/* pointer to the port structure */
@@ -155,7 +155,6 @@
 
 	if (p->RIOFailed) {
 		rio_dprintk(RIO_DEBUG_TTY, "System initialisation failed\n");
-		pseterr(ENXIO);
 		func_exit();
 		return -ENXIO;
 	}
@@ -170,7 +169,6 @@
 	 */
 	if (SysPort >= RIO_PORTS) {	/* out of range ? */
 		rio_dprintk(RIO_DEBUG_TTY, "Illegal port number %d\n", SysPort);
-		pseterr(ENXIO);
 		func_exit();
 		return -ENXIO;
 	}
@@ -187,7 +185,6 @@
 		 */
 		rio_dprintk(RIO_DEBUG_TTY, "port not mapped into system\n");
 		func_exit();
-		pseterr(ENXIO);
 		return -ENXIO;
 	}
 
@@ -209,7 +206,6 @@
 	 */
 	if ((PortP->HostP->Flags & RUN_STATE) != RC_RUNNING) {
 		rio_dprintk(RIO_DEBUG_TTY, "Host not running\n");
-		pseterr(ENXIO);
 		func_exit();
 		return -ENXIO;
 	}
@@ -429,9 +425,6 @@
 
 	rio_dprintk(RIO_DEBUG_TTY, "high level open done\n");
 
-#ifdef STATS
-	PortP->Stat.OpenCnt++;
-#endif
 	/*
 	 ** Count opens for port statistics reporting
 	 */
@@ -466,10 +459,10 @@
 	rio_dprintk(RIO_DEBUG_TTY, "port close SysPort %d\n", PortP->PortNum);
 
 	/* PortP = p->RIOPortp[SysPort]; */
-	rio_dprintk(RIO_DEBUG_TTY, "Port is at address 0x%x\n", (int) PortP);
+	rio_dprintk(RIO_DEBUG_TTY, "Port is at address 0x%p\n", PortP);
 	/* tp = PortP->TtyP; *//* Get tty */
 	tty = PortP->gs.tty;
-	rio_dprintk(RIO_DEBUG_TTY, "TTY is at address 0x%x\n", (int) tty);
+	rio_dprintk(RIO_DEBUG_TTY, "TTY is at address 0x%p\n", tty);
 
 	if (PortP->gs.closing_wait)
 		end_time = jiffies + PortP->gs.closing_wait;
@@ -536,7 +529,6 @@
 
 	if (!deleted)
 		while ((PortP->InUse != NOT_INUSE) && !p->RIOHalted && (PortP->TxBufferIn != PortP->TxBufferOut)) {
-			cprintf("Need to flush the ttyport\n");
 			if (repeat_this-- <= 0) {
 				rv = -EINTR;
 				rio_dprintk(RIO_DEBUG_TTY, "Waiting for not idle closed broken by signal\n");
@@ -615,9 +607,6 @@
 */
 	PortP->Config &= ~(RIO_CTSFLOW | RIO_RTSFLOW);
 
-#ifdef STATS
-	PortP->Stat.CloseCnt++;
-#endif
 	/*
 	 ** Count opens for port statistics reporting
 	 */
@@ -722,15 +711,15 @@
 	/*
 	 ** set the command byte and the argument byte
 	 */
-	WBYTE(PacketP->data[0], command);
+	writeb(command, &PacketP->data[0]);
 
 	if (len == 2)
-		WBYTE(PacketP->data[1], arg);
+		writeb(arg, &PacketP->data[1]);
 
 	/*
 	 ** set the length of the packet and set the command bit.
 	 */
-	WBYTE(PacketP->len, PKT_CMD_BIT | len);
+	writeb(PKT_CMD_BIT | len, &PacketP->len);
 
 	add_transmit(PortP);
 	/*
#1 lore raw
Quoted 9 lines · Alan Cox

First large chunk of code cleanup. The split between this and #3 and #4 is fairly arbitary and due to the message length limit on the list. These patches continue the process of ripping out macros and typedefs while cleaning up lots of 32bit assumptions. Several inlines for compatibility also get removed and that causes a lot of noise.

drivers/char/rio/rioparam.c line 243

Quoted 5 lines
drivers/char/rio/rioparam.c +1 -1
@@ -247,7 +240,7 @@
 	}
 
 	rio_dprintk(RIO_DEBUG_PARAM, "can_add_transmit() returns %x\n", res);
-	rio_dprintk(RIO_DEBUG_PARAM, "Packet is 0x%x\n", (int) PacketP);
+	rio_dprintk(RIO_DEBUG_PARAM, "Packet is 0x%p\n", PacketP);
						^^^^

Just %p.

drivers/char/rio/rioparam.c line 465

Quoted 10 lines
drivers/char/rio/rioparam.c +2 -2
@@ -466,10 +459,10 @@
 	rio_dprintk(RIO_DEBUG_TTY, "port close SysPort %d\n", PortP->PortNum);
 
 	/* PortP = p->RIOPortp[SysPort]; */
-	rio_dprintk(RIO_DEBUG_TTY, "Port is at address 0x%x\n", (int) PortP);
+	rio_dprintk(RIO_DEBUG_TTY, "Port is at address 0x%p\n", PortP);
 	/* tp = PortP->TtyP; *//* Get tty */
 	tty = PortP->gs.tty;
-	rio_dprintk(RIO_DEBUG_TTY, "TTY is at address 0x%x\n", (int) tty);
+	rio_dprintk(RIO_DEBUG_TTY, "TTY is at address 0x%p\n", tty);

Ditto.

author
#2 lore raw
Quoted 6 lines · Alexey Dobriyan

drivers/char/rio/rioparam.c line 243

Quoted 3 lines
drivers/char/rio/rioparam.c +1 -1
 	rio_dprintk(RIO_DEBUG_PARAM, "can_add_transmit() returns %x\n", res);
-	rio_dprintk(RIO_DEBUG_PARAM, "Packet is 0x%x\n", (int) PacketP);
+	rio_dprintk(RIO_DEBUG_PARAM, "Packet is 0x%p\n", PacketP);
						^^^^

Just %p.

Thanks .. good point. Will go whack all those on the head once I've finished this batch of changes to remove even more typedefery