Skip to contentSkip to conversation

Merging Skylark's IOC3 patch

DISCUSSION Martin Michlmayr 3 participants 12 messages Feb 19, 2006

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

Ralf,

Can you please review and/or merge Skylark's IOC3 patch from ftp://ftp.linux-mips.org/pub/linux/mips/people/skylark/linux-mips-2.6.14-ioc3-r26.patch.bz2

#1 lore raw
Quoted 5 lines · Martin Michlmayr

Can you please review and/or merge Skylark's IOC3 patch from ftp://ftp.linux-mips.org/pub/linux/mips/people/skylark/linux-mips-2.6.14-ioc3-r26.patch.bz2

From my basic understanding I believe that this patch needs to be split up and submitted to different sub-system maintainers.

From: Stanislaw Skowronek <[email protected]>

[PATCH 1/6] [MIPS] Improved IOC3 driver

An an improved driver for the IOC3 bridge, used in SGI Origin and Octane.

---

 Kconfig      |    8
 pci/Makefile |    2
 pci/ioc3.c   |  801 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 811 insertions(+)
arch/mips/Kconfig +8 -0
index 4ca93ff..3c5cc08 100644
@@ -1663,6 +1663,14 @@ config PCI_DOMAINS
 
 source "drivers/pci/Kconfig"
 
+config SGI_IOC3
+	bool "SGI IOC3 Master Driver"
+	depends on PCI
+	help
+	  If you have a Silicon Graphics Origin or Octane, say Y.
+	  This driver provides base for IOC3 feature drivers, such as
+	  Ethernet, keyboard, mouse, serial ports, LEDs and RTC.
+
 #
 # ISA support is now enabled via select.  Too many systems still have the one
 # or other ISA chip on the board that users don't know about so don't expect
arch/mips/pci/Makefile +2 -0
index 16205b5..8e0456b 100644
@@ -57,3 +57,5 @@ obj-$(CONFIG_TOSHIBA_RBTX4927)	+= fixup-
 obj-$(CONFIG_TOSHIBA_RBTX4938)	+= fixup-tx4938.o ops-tx4938.o
 obj-$(CONFIG_VICTOR_MPC30X)	+= fixup-mpc30x.o
 obj-$(CONFIG_ZAO_CAPCELLA)	+= fixup-capcella.o
+
+obj-$(CONFIG_SGI_IOC3) += ioc3.o
arch/mips/pci/ioc3.c new file +801 -0

801 lines not on this page · raw message

Signature · 2 lines
Martin Michlmayr
http://www.cyrius.com/
#3 lore raw
In reply to Martin Michlmayr
Quoted 5 lines · Martin Michlmayr

Can you please review and/or merge Skylark's IOC3 patch from ftp://ftp.linux-mips.org/pub/linux/mips/people/skylark/linux-mips-2.6.14-ioc3-r26.patch.bz2

From my basic understanding I believe that this patch needs to be split up and submitted to different sub-system maintainers.

(Dmitry, this is only a RFC for now since the main support patch for IOC3 has not been merged yet.)

From: Stanislaw Skowronek <[email protected]>

[PATCH 2/5] serio: SGI IOC3 PS/2 controller driver

Add a PS/2 driver based on the SGI IOC3. This is useful for SGI Octane machines (IP27).

---

 Kconfig   |    7 ++
 Makefile  |    1 
 ioc3kbd.c |  172 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 180 insertions(+)
drivers/input/serio/Kconfig +7 -0
index 98acf17..7dedec0 100644
@@ -18,6 +18,13 @@ config SERIO
 
 if SERIO
 
+config SERIO_SGI_IOC3
+	tristate "SGI IOC3 keyboard controller"
+	default y
+	depends on SGI_IOC3
+	---help---
+	  If you have an Octane and you want to use its keyboard, select this.
+
 config SERIO_I8042
 	tristate "i8042 PC Keyboard controller" if EMBEDDED || !X86
 	default y
drivers/input/serio/Makefile +1 -0
index 4155197..14cb41b 100644
@@ -18,5 +18,6 @@ obj-$(CONFIG_HP_SDC)		+= hp_sdc.o
 obj-$(CONFIG_HIL_MLC)		+= hp_sdc_mlc.o hil_mlc.o
 obj-$(CONFIG_SERIO_PCIPS2)	+= pcips2.o
 obj-$(CONFIG_SERIO_MACEPS2)	+= maceps2.o
+obj-$(CONFIG_SERIO_SGI_IOC3)	+= ioc3kbd.o
 obj-$(CONFIG_SERIO_LIBPS2)	+= libps2.o
 obj-$(CONFIG_SERIO_RAW)		+= serio_raw.o
drivers/input/serio/ioc3kbd.c new file +172 -0

172 lines not on this page · raw message

Signature · 2 lines
Martin Michlmayr
http://www.cyrius.com/
#5 lore raw
In reply to Martin Michlmayr
Quoted 5 lines · Martin Michlmayr

Can you please review and/or merge Skylark's IOC3 patch from ftp://ftp.linux-mips.org/pub/linux/mips/people/skylark/linux-mips-2.6.14-ioc3-r26.patch.bz2

From my basic understanding I believe that this patch needs to be split up and submitted to different sub-system maintainers.

([email protected], this is only a RFC for now since the main support patch for IOC3 has not been merged yet.)

From: Stanislaw Skowronek <[email protected]>

[PATCH 3/5] net: Convert the SGI IOC3 Ethernet driver to use IOC3 meta driver

Convert the SGI IOC3 Ethernet driver to use the IOC3 meta driver.

---

 Kconfig    |    2 
 ioc3-eth.c |  458 +++++++------------------------------------------------------
 2 files changed, 55 insertions(+), 405 deletions(-)
drivers/net/Kconfig +1 -1
index 94ad74c..66c340d 100644
@@ -462,7 +462,7 @@ config MIPS_AU1X00_ENET
 
 config SGI_IOC3_ETH
 	bool "SGI IOC3 Ethernet"
-	depends on NET_ETHERNET && PCI && SGI_IP27
+	depends on NET_ETHERNET && SGI_IOC3
 	select CRC32
 	select MII
 	help
drivers/net/ioc3-eth.c +54 -404

624 lines not on this page · raw message

Signature · 2 lines
Martin Michlmayr
http://www.cyrius.com/
#6 lore raw
In reply to Martin Michlmayr
Quoted 5 lines · Martin Michlmayr

Can you please review and/or merge Skylark's IOC3 patch from ftp://ftp.linux-mips.org/pub/linux/mips/people/skylark/linux-mips-2.6.14-ioc3-r26.patch.bz2

From my basic understanding I believe that this patch needs to be split up and submitted to different sub-system maintainers.

(Russell, this is only a RFC for now since the main support patch for IOC3 has not been merged yet. But please do comment)

From: Stanislaw Skowronek <[email protected]>

[PATCH 4/6] serial: UART support for SGI IOC3 bridge

Add UART support for the SGI IOC3 bridge, used in Origin and Octane machines.

---

 drivers/serial/8250.c        |   17 ++++-
 drivers/serial/Kconfig       |    7 ++
 drivers/serial/Makefile      |    1 
 drivers/serial/ioc3uart.c    |  135 +++++++++++++++++++++++++++++++++++++++++++
 drivers/serial/serial_core.c |   12 ++-
 include/linux/serial.h       |    1 
 include/linux/serial_core.h  |    1 
 7 files changed, 169 insertions(+), 5 deletions(-)
drivers/serial/8250.c +15 -2
@@ -310,6 +310,9 @@ static unsigned int serial_in(struct uar
 	case UPIO_MEM:
 		return readb(up->port.membase + offset);
 
+	case UPIO_IOC3:
+		return readb(up->port.membase + (offset^3));
+
 	case UPIO_MEM32:
 		return readl(up->port.membase + offset);
 
@@ -338,6 +341,10 @@ serial_out(struct uart_8250_port *up, in
 		writeb(value, up->port.membase + offset);
 		break;
 
+	case UPIO_IOC3:
+		writeb(value, up->port.membase + (offset^3));
+		break;
+
 	case UPIO_MEM32:
 		writel(value, up->port.membase + offset);
 		break;
@@ -1906,6 +1913,8 @@ static int serial8250_request_std_resour
 	int ret = 0;
 
 	switch (up->port.iotype) {
+	case UPIO_IOC3:
+		break;
 	case UPIO_MEM:
 		if (!up->port.mapbase)
 			break;
@@ -1938,6 +1947,8 @@ static void serial8250_release_std_resou
 	unsigned int size = 8 << up->port.regshift;
 
 	switch (up->port.iotype) {
+	case UPIO_IOC3:
+		break;
 	case UPIO_MEM:
 		if (!up->port.mapbase)
 			break;
@@ -2300,8 +2311,10 @@ int __init serial8250_start_console(stru
 
 	add_preferred_console("ttyS", line, options);
 	printk("Adding console on ttyS%d at %s 0x%lx (options '%s')\n",
-		line, port->iotype == UPIO_MEM ? "MMIO" : "I/O port",
-		port->iotype == UPIO_MEM ? (unsigned long) port->mapbase :
+		line, port->iotype == UPIO_MEM ? "MMIO" : 
+		port->iotype == UPIO_IOC3 ? "IOC3" : "I/O port",
+		(port->iotype == UPIO_MEM || port->iotype == UPIO_IOC3) ?
+		    (unsigned long) port->mapbase :
 		    (unsigned long) port->iobase, options);
 	if (!(serial8250_console.flags & CON_ENABLED)) {
 		serial8250_console.flags &= ~CON_PRINTBUFFER;
drivers/serial/Kconfig +7 -0
index baa8417..0f1102f 100644
@@ -225,6 +225,13 @@ config SERIAL_8250_AU1X00
 	  to this option.  The driver can handle 1 or 2 serial ports.
 	  If unsure, say N.
 
+config SGI_IOC3_UART
+	bool "SGI IOC3 UART support"
+	depends on SGI_IOC3 && SERIAL_8250
+	help
+	  Enable this if you have a SGI Origin or Octane machine. This module
+	  provides serial port support for IOC3 chips on those systems.
+
 comment "Non-8250 serial port support"
 
 config SERIAL_AMBA_PL010
drivers/serial/Makefile +1 -0
index 738f0a0..5ea2e3e 100644
@@ -55,6 +55,7 @@ obj-$(CONFIG_ETRAX_SERIAL) += crisv10.o
 obj-$(CONFIG_SERIAL_JSM) += jsm/
 obj-$(CONFIG_SERIAL_TXX9) += serial_txx9.o
 obj-$(CONFIG_SERIAL_VR41XX) += vr41xx_siu.o
+obj-$(CONFIG_SGI_IOC3_UART) += ioc3uart.o
 obj-$(CONFIG_SERIAL_SGI_IOC4) += ioc4_serial.o
 obj-$(CONFIG_SERIAL_SGI_IOC3) += ioc3_serial.o
 obj-$(CONFIG_SERIAL_AT91) += at91_serial.o
drivers/serial/serial_core.c +9 -3
index 95fb493..40db05c 100644
@@ -1636,9 +1636,10 @@ static int uart_line_info(char *buf, str
 
 	ret = sprintf(buf, "%d: uart:%s %s%08lX irq:%d",
 			port->line, uart_type(port),
-			port->iotype == UPIO_MEM ? "mmio:0x" : "port:",
-			port->iotype == UPIO_MEM ? port->mapbase :
-						(unsigned long) port->iobase,
+			port->iotype == UPIO_MEM ? "mmio:0x" :
+			  port->iotype == UPIO_IOC3 ? "ioc3:0x" : "port:",
+			(port->iotype == UPIO_MEM || port->iotype == UPIO_IOC3) ?
+			  port->mapbase : (unsigned long) port->iobase,
 			port->irq);
 
 	if (port->type == PORT_UNKNOWN) {
@@ -1981,6 +1982,10 @@ uart_report_port(struct uart_driver *drv
 		snprintf(address, sizeof(address),
 			 "MMIO 0x%lx", port->mapbase);
 		break;
+	case UPIO_IOC3:
+		snprintf(address, sizeof(address), "IOC3 0x%lx",
+			 port->mapbase);
+		break;
 	default:
 		strlcpy(address, "*unknown*", sizeof(address));
 		break;
@@ -2311,6 +2316,7 @@ int uart_match_port(struct uart_port *po
 		return (port1->iobase == port2->iobase) &&
 		       (port1->hub6   == port2->hub6);
 	case UPIO_MEM:
+	case UPIO_IOC3:
 		return (port1->mapbase == port2->mapbase);
 	}
 	return 0;
include/linux/serial.h +1 -0
index c69c6b9..a3ee515 100644
@@ -82,6 +82,7 @@ struct serial_struct {
 #define SERIAL_IO_PORT	0
 #define SERIAL_IO_HUB6	1
 #define SERIAL_IO_MEM	2
+#define SERIAL_IO_IOC3	3
 
 struct serial_uart_config {
 	char	*name;
include/linux/serial_core.h +1 -0
index 4041122..9441c90 100644
@@ -221,6 +221,7 @@ struct uart_port {
 #define UPIO_MEM		(2)
 #define UPIO_MEM32		(3)
 #define UPIO_AU			(4)			/* Au1x00 type IO */
+#define UPIO_IOC3		(5)
 
 	unsigned int		read_status_mask;	/* driver specific */
 	unsigned int		ignore_status_mask;	/* driver specific */
drivers/serial/ioc3uart.c new file +135 -0

135 lines not on this page · raw message

Signature · 2 lines
Martin Michlmayr
http://www.cyrius.com/
#8 lore raw
In reply to Martin Michlmayr

Ralf, please apply.

From: Stanislaw Skowronek <[email protected]>

[PATCH 5/6] [MIPS] Make 8-bit devices on PCI work on IP27

Fix the definition of __swizzle_addr_b and make 8-bit PCI devices work on IP27.

---

 mangle-port.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/asm-mips/mach-ip27/mangle-port.h +1 -1
index f76c448..83e12e3 100644
@@ -8,7 +8,7 @@
 #ifndef __ASM_MACH_IP27_MANGLE_PORT_H
 #define __ASM_MACH_IP27_MANGLE_PORT_H
 
-#define __swizzle_addr_b(port)	(port)
+#define __swizzle_addr_b(port)	((port) ^ 3)
 #define __swizzle_addr_w(port)	((port) ^ 2)
 #define __swizzle_addr_l(port)	(port)
 #define __swizzle_addr_q(port)	(port)
Signature · 2 lines
Martin Michlmayr
http://www.cyrius.com/
#11 lore raw
In reply to Martin Michlmayr

To be applied after the IOC3 UART driver has been accepted.

From: Stanislaw Skowronek <[email protected]>

[PATCH 6/6] [MIPS] Switch IP27 to the new IOC3 UART driver

---

 ip27-console.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/sgi-ip27/ip27-console.c +1 -1
index 3e1ac29..a973610 100644
@@ -64,7 +64,7 @@ static void inline ioc3_console_probe(vo
 	up.irq		= 0;
 	up.uartclk	= IOC3_CLK;
 	up.regshift	= 0;
-	up.iotype	= UPIO_MEM;
+	up.iotype	= UPIO_IOC3;
 	up.flags	= IOC3_FLAGS;
 	up.line		= 0;
 
Signature · 2 lines
Martin Michlmayr
http://www.cyrius.com/
#9 lore raw
In reply to Martin Michlmayr
Quoted 1 line · Martin Michlmayr

Ralf, please apply.

or maybe not.

21:59 < Skylark> The 6/6 isn't exactly right
22:00 < Skylark> It should be a part of the 5/6, really (making it 5/5) 22:00 < Skylark> And dependent on 4/6

Signature · 2 lines
Martin Michlmayr
http://www.cyrius.com/
#7 lore raw
In reply to Martin Michlmayr
Quoted 13 lines · Martin Michlmayr
drivers/serial/8250.c +3 -0
@@ -310,6 +310,9 @@ static unsigned int serial_in(struct uar
 	case UPIO_MEM:
 		return readb(up->port.membase + offset);
 
+	case UPIO_IOC3:
+		return readb(up->port.membase + (offset^3));
+
 	case UPIO_MEM32:
 		return readl(up->port.membase + offset);
 

drivers/serial/8250.c serial_out(struct uart_8250_port *up, in · line 350

Quoted 10 lines
drivers/serial/8250.c +4 -0
@@ -338,6 +341,10 @@ serial_out(struct uart_8250_port *up, in
 		writeb(value, up->port.membase + offset);
 		break;
 
+	case UPIO_IOC3:
+		writeb(value, up->port.membase + (offset^3));
+		break;
+
 	case UPIO_MEM32:
 		writel(value, up->port.membase + offset);
 		break;

Hmm, this starts to open up the question of whether having an array of register pointers becomes cheaper.

drivers/serial/8250.c int __init serial8250_start_console(stru · line 2318

Quoted 11 lines
drivers/serial/8250.c +4 -2
@@ -2300,8 +2311,10 @@ int __init serial8250_start_console(stru
 
 	add_preferred_console("ttyS", line, options);
 	printk("Adding console on ttyS%d at %s 0x%lx (options '%s')\n",
-		line, port->iotype == UPIO_MEM ? "MMIO" : "I/O port",
-		port->iotype == UPIO_MEM ? (unsigned long) port->mapbase :
+		line, port->iotype == UPIO_MEM ? "MMIO" : 
+		port->iotype == UPIO_IOC3 ? "IOC3" : "I/O port",
+		(port->iotype == UPIO_MEM || port->iotype == UPIO_IOC3) ?
+		    (unsigned long) port->mapbase :
 		    (unsigned long) port->iobase, options);

Maybe the "iotype" should index an array?

Quoted 17 lines
include/linux/serial.h +1 -0
index c69c6b9..a3ee515 100644
@@ -82,6 +82,7 @@ struct serial_struct {
 #define SERIAL_IO_PORT	0
 #define SERIAL_IO_HUB6	1
 #define SERIAL_IO_MEM	2
+#define SERIAL_IO_IOC3	3
 
 struct serial_uart_config {
 	char	*name;
include/linux/serial_core.h +0 -0
index 4041122..9441c90 100644

include/linux/serial_core.h struct uart_port { · line 224

Quoted 4 lines
include/linux/serial_core.h +1 -0
@@ -221,6 +221,7 @@ struct uart_port {
 #define UPIO_MEM		(2)
 #define UPIO_MEM32		(3)
 #define UPIO_AU			(4)			/* Au1x00 type IO */
+#define UPIO_IOC3		(5)

Comparing SERIAL_IO_* and UPIO_*, I have to say no here. Always ensure that they end up with the same number. SERIAL_IO_* is the current userland version of UPIO_*. At some point in the future (once the pipedream of having _all_ serial drivers updated becomes reality) this can be sorted out sanely.

include/linux/serial_core.h struct uart_port { · line 227

Quoted 3 lines
include/linux/serial_core.h +3 -0
+	port.membase = (unsigned char *) &idd->vma->sregs.uarta;
+	port.mapbase = ((unsigned long) port.membase) & 0xFFFFFFFFFF;
+	d->line_a = serial8250_register_port(&port);

mapbase is supposed to be the physical address, whereas membase is what is used to access the register, and should be something compatible with MMIO accessors. Is the cast really required here?

Are you tagging MMIO stuff with __iomem ?

Apart from that, I don't have any further comments at present.

Signature · 3 lines
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 Serial core
#10 lore raw
In reply to Martin Michlmayr
Quoted 3 lines · Martin Michlmayr

21:59 < Skylark> The 6/6 isn't exactly right
22:00 < Skylark> It should be a part of the 5/6, really (making it 5/5) 22:00 < Skylark> And dependent on 4/6

Updated patch, merged 5/6 and 6/6 into 5/5.

From: Stanislaw Skowronek <[email protected]>

[PATCH 5/5] [MIPS] Switch IP27 to the new IOC3 UART driver

Switch IP27 to the new IOC3 UART driver. Also now that IOC3 swapping has been moved to where it belongs, namely into the serial layer, make IP27 swizzle the 8-bit accesses in the correct way.

---

 arch/mips/sgi-ip27/ip27-console.c        |    2 +-
 include/asm-mips/mach-ip27/mangle-port.h |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
include/asm-mips/mach-ip27/mangle-port.h +1 -1
index f76c448..83e12e3 100644
@@ -8,7 +8,7 @@
 #ifndef __ASM_MACH_IP27_MANGLE_PORT_H
 #define __ASM_MACH_IP27_MANGLE_PORT_H
 
-#define __swizzle_addr_b(port)	(port)
+#define __swizzle_addr_b(port)	((port) ^ 3)
 #define __swizzle_addr_w(port)	((port) ^ 2)
 #define __swizzle_addr_l(port)	(port)
 #define __swizzle_addr_q(port)	(port)
arch/mips/sgi-ip27/ip27-console.c +1 -1
index 3e1ac29..a973610 100644
@@ -64,7 +64,7 @@ static void inline ioc3_console_probe(vo
 	up.irq		= 0;
 	up.uartclk	= IOC3_CLK;
 	up.regshift	= 0;
-	up.iotype	= UPIO_MEM;
+	up.iotype	= UPIO_IOC3;
 	up.flags	= IOC3_FLAGS;
 	up.line		= 0;
 
Signature · 2 lines
Martin Michlmayr
http://www.cyrius.com/
#4 lore raw
In reply to Martin Michlmayr
Quoted 10 lines · Martin Michlmayr
Quoted 5 lines · Martin Michlmayr

Can you please review and/or merge Skylark's IOC3 patch from ftp://ftp.linux-mips.org/pub/linux/mips/people/skylark/linux-mips-2.6.14-ioc3-r26.patch.bz2

From my basic understanding I believe that this patch needs to be split up and submitted to different sub-system maintainers.

(Dmitry, this is only a RFC for now since the main support patch for IOC3 has not been merged yet.)

OK... I have some comments, mostly cosmetic.

drivers/input/serio/ioc3kbd.c line 31

Quoted 5 lines
drivers/input/serio/ioc3kbd.c new file +5 -0
+
+struct ioc3kbd_data {
+	struct ioc3_driver_data *idd;
+	struct serio *kbd,*aux;
+};

Space after comma please.

drivers/input/serio/ioc3kbd.c line 35

Quoted 4 lines
drivers/input/serio/ioc3kbd.c new file +4 -0
+
+static int ioc3kbd_write(struct serio *dev, unsigned char val)
+{
+	struct ioc3kbd_data *d = (struct ioc3kbd_data *)(dev->port_data);

Unneeded parens...

drivers/input/serio/ioc3kbd.c line 37

Quoted 2 lines
drivers/input/serio/ioc3kbd.c new file +2 -0
+	unsigned mask;
+	unsigned long timeout=0;

Missing spaces around operators...

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+	mask = (dev==d->aux) ? KM_CSR_M_WRT_PEND : KM_CSR_K_WRT_PEND;

Missing spaces around operators...

drivers/input/serio/ioc3kbd.c line 40

Quoted 1 line
drivers/input/serio/ioc3kbd.c new file +1 -0
+	while((d->idd->vma->km_csr & mask) && (timeout<1000)) {

Missing a space after operator and unneeded parens again.

drivers/input/serio/ioc3kbd.c line 50

Quoted 6 lines
drivers/input/serio/ioc3kbd.c new file +6 -0
+	if(dev==d->aux)
+		d->idd->vma->m_wd=((unsigned)val)&0x000000ff;
+	else
+		d->idd->vma->k_wd=((unsigned)val)&0x000000ff;
+
+	if(timeout>=1000)

Missing spaces around operators...

drivers/input/serio/ioc3kbd.c line 87

Quoted 9 lines
drivers/input/serio/ioc3kbd.c new file +9 -0
+
+static int ioc3kbd_open(struct serio *dev)
+{
+	return 0;
+}
+
+static void ioc3kbd_close(struct serio *dev)
+{
+}

You don't need to implement dummy functions, serio core can live without these.

drivers/input/serio/ioc3kbd.c line 95

Quoted 8 lines
drivers/input/serio/ioc3kbd.c new file +8 -0
+
+static struct ioc3kbd_data * __init ioc3kbd_allocate_port(int idx, struct ioc3_driver_data *idd)
+{
+	struct serio *sk, *sa;
+	struct ioc3kbd_data *d;
+
+	sk = kmalloc(sizeof(struct serio), GFP_KERNEL);
+	sa = kmalloc(sizeof(struct serio), GFP_KERNEL);

kzalloc()? You fill them with 0 later anyway.

Quoted 15 lines
drivers/input/serio/ioc3kbd.c new file +15 -0
+	d = kmalloc(sizeof(struct ioc3kbd_data), GFP_KERNEL);
+	if (sk && sa && d) {
+		memset(sk, 0, sizeof(struct serio));
+		sk->id.type = SERIO_8042;
+		sk->write = ioc3kbd_write;
+		sk->open = ioc3kbd_open;
+		sk->close = ioc3kbd_close;
+		snprintf(sk->name, sizeof(sk->name), "IOC3 keyboard %d", idx);
+		snprintf(sk->phys, sizeof(sk->phys), "ioc3/serio%dkbd", idx);
+		sk->port_data = d;
+		sk->dev.parent = &(idd->pdev->dev);
+		memset(sa, 0, sizeof(struct serio));
+		sa->id.type = SERIO_8042;
+		sa->write = ioc3kbd_write;
+		sa->open = ioc3kbd_open;

drivers/input/serio/ioc3kbd.c line 120

Quoted 10 lines
drivers/input/serio/ioc3kbd.c new file +10 -0
+		sa->close = ioc3kbd_close;
+		snprintf(sa->name, sizeof(sa->name), "IOC3 auxiliary %d", idx);
+		snprintf(sa->phys, sizeof(sa->phys), "ioc3/serio%daux", idx);
+		sa->port_data = d;
+		sa->dev.parent = &(idd->pdev->dev);
+		d->idd = idd;
+		d->kbd = sk;
+		d->aux = sa;
+		return d;
+	}

Need to free() allocated stuff here in case it was not the first allocation that failed.

drivers/input/serio/ioc3kbd.c line 124

Quoted 4 lines
drivers/input/serio/ioc3kbd.c new file +4 -0
+	return NULL;
+}
+
+static int ioc3kbd_probe(struct ioc3_submodule *is, struct ioc3_driver_data *idd)

__devinit perhaps?

drivers/input/serio/ioc3kbd.c line 128

Quoted 4 lines
drivers/input/serio/ioc3kbd.c new file +4 -0
+{
+	struct ioc3kbd_data *d;
+	if(idd->class != IOC3_CLASS_BASE_IP30 && idd->class != IOC3_CLASS_CADDUO)
+		return 1;

Usually failure indicator is negative. Serio core does not really care but people expect to see either -ENODEV or at least -1.

Quoted 7 lines
drivers/input/serio/ioc3kbd.c new file +7 -0
+	d = ioc3kbd_allocate_port(idd->id, idd);
+	idd->data[is->id] = d;
+	if(!d)
+		return 1;
+	ioc3_enable(is, idd);
+	serio_register_port(d->kbd);
+	serio_register_port(d->aux);

drivers/input/serio/ioc3kbd.c line 145

Quoted 10 lines
drivers/input/serio/ioc3kbd.c new file +10 -0
+	return 0;
+}
+
+static int ioc3kbd_remove(struct ioc3_submodule *is, struct ioc3_driver_data *idd)
+{
+	struct ioc3kbd_data *d = (struct ioc3kbd_data *)(idd->data[is->id]);
+	serio_unregister_port(d->kbd);
+	serio_unregister_port(d->aux);
+	kfree(d->kbd);
+	kfree(d->aux);

Double free - serio core frees serio structure once the last reference is dropped. You are freeing already freed memory here.

Quoted 7 lines
drivers/input/serio/ioc3kbd.c new file +7 -0
+	kfree(d);
+	idd->data[is->id] = NULL;
+	return 0;
+}
+
+static struct ioc3_submodule ioc3kbd_submodule = {
+	.name = "serio",

drivers/input/serio/ioc3kbd.c line 162

Quoted 10 lines
drivers/input/serio/ioc3kbd.c new file +10 -0
+	.probe = ioc3kbd_probe,
+	.remove = ioc3kbd_remove,
+	.irq_mask = SIO_IR_KBD_INT,
+	.intr = ioc3kbd_intr,
+	.owner = THIS_MODULE,
+};
+
+static int __init ioc3kbd_init(void)
+{
+	ioc3_register_submodule(&ioc3kbd_submodule);

Can this ioc3_... function fail?

Signature · 1 line
Dmitry