Skip to contentSkip to conversation

goldfish: virtual input event driver

PATCH In review Alan Cox 2 participants 4 messages Jan 23, 2013 – Jan 24, 2013

Subsystems (3)
lore
Share & tools
lore

Alan Cox

author
#0 lore raw

PATCH 1/1 goldfish: virtual input event driver

From: Brian Swetland <[email protected]>

This device is a direct pipe from "hardware" to the input event subsystem, allowing us to avoid having to route "keypad" style events through an AT keyboard driver (gross!)

As with the other submissions this driver is cross architecture.

[Tided up to work on x86]
[Ported to 3.4]
[Cleaned up for 3.7 and submission]

---

 drivers/input/keyboard/Kconfig           |   10 ++
 drivers/input/keyboard/Makefile          |    1 
 drivers/input/keyboard/goldfish_events.c |  186 ++++++++++++++++++++++++++++++
 drivers/tty/goldfish.c                   |   19 +--
 4 files changed, 204 insertions(+), 12 deletions(-)
 create mode 100644 drivers/input/keyboard/goldfish_events.c
drivers/input/keyboard/Kconfig +10 -0
index 008f96a..07f7bb2 100644
@@ -482,6 +482,16 @@ config KEYBOARD_SAMSUNG
 	  To compile this driver as a module, choose M here: the
 	  module will be called samsung-keypad.
 
+config KEYBOARD_GOLDFISH_EVENTS
+	depends on GOLDFISH
+	tristate "Generic Input Event device for Goldfish"
+	help
+	  Say Y here to get an input event device for the Goldfish virtual
+	  device emulator.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called goldfish-events.
+
 if TTY
 
 config KEYBOARD_STOWAWAY
drivers/input/keyboard/Makefile +1 -0
index 44e7600..49b1645 100644
@@ -13,6 +13,7 @@ obj-$(CONFIG_KEYBOARD_ATKBD)		+= atkbd.o
 obj-$(CONFIG_KEYBOARD_BFIN)		+= bf54x-keys.o
 obj-$(CONFIG_KEYBOARD_DAVINCI)		+= davinci_keyscan.o
 obj-$(CONFIG_KEYBOARD_EP93XX)		+= ep93xx_keypad.o
+obj-$(CONFIG_KEYBOARD_GOLDFISH_EVENTS)	+= goldfish_events.o
 obj-$(CONFIG_KEYBOARD_GPIO)		+= gpio_keys.o
 obj-$(CONFIG_KEYBOARD_GPIO_POLLED)	+= gpio_keys_polled.o
 obj-$(CONFIG_KEYBOARD_TCA6416)		+= tca6416-keypad.o
drivers/input/keyboard/goldfish_events.c new file +186 -0

186 lines not on this page · raw message

drivers/tty/goldfish.c +7 -12
index e2ccb6d..f17d2e4 100644
@@ -72,23 +72,18 @@ static irqreturn_t goldfish_tty_interrupt(int irq, void *dev_id)
 	unsigned long irq_flags;
 	unsigned char *buf;
 	u32 count;
-	struct tty_struct *tty;
 
 	count = readl(base + GOLDFISH_TTY_BYTES_READY);
 	if(count == 0)
 		return IRQ_NONE;
 
-	tty = tty_port_tty_get(&qtty->port);
-	if (tty) {
-		count = tty_prepare_flip_string(tty, &buf, count);
-		spin_lock_irqsave(&qtty->lock, irq_flags);
-		writel((u32)buf, base + GOLDFISH_TTY_DATA_PTR);
-		writel(count, base + GOLDFISH_TTY_DATA_LEN);
-		writel(GOLDFISH_TTY_CMD_READ_BUFFER, base + GOLDFISH_TTY_CMD);
-		spin_unlock_irqrestore(&qtty->lock, irq_flags);
-		tty_schedule_flip(tty);
-		tty_kref_put(tty);
-	}
+	count = tty_prepare_flip_string(&qtty->port, &buf, count);
+	spin_lock_irqsave(&qtty->lock, irq_flags);
+	writel((u32)buf, base + GOLDFISH_TTY_DATA_PTR);
+	writel(count, base + GOLDFISH_TTY_DATA_LEN);
+	writel(GOLDFISH_TTY_CMD_READ_BUFFER, base + GOLDFISH_TTY_CMD);
+	spin_unlock_irqrestore(&qtty->lock, irq_flags);
+	tty_schedule_flip(&qtty->port);
 	return IRQ_HANDLED;
 }
 
maintainer
#1 lore raw

Hi Alan,

Quoted 8 lines · Alan Cox

From: Brian Swetland <[email protected]>

This device is a direct pipe from "hardware" to the input event subsystem, allowing us to avoid having to route "keypad" style events through an AT keyboard driver (gross!)

As with the other submissions this driver is cross architecture.

Quoted 11 lines
[Tided up to work on x86]
[Ported to 3.4]
[Cleaned up for 3.7 and submission]

I do not have drivers/tty/goldfish.c so I dropped that change... I also had a few more cleanups, the result is below.

I know you stepping away for a while so unless I hear from you in a day or so I will apply the patch as is.

Thanks!

Signature · 30 lines
Dmitry

Input: goldfish - virtual input event driver

From: Brian Swetland <[email protected]>

This device is a direct pipe from "hardware" to the input event subsystem,
allowing us to avoid having to route "keypad" style events through an
AT keyboard driver (gross!).

As with the other submissions this driver is cross architecture.

Signed-off-by: Mike A. Chan <[email protected]>
[Tided up to work on x86]
Signed-off-by: Sheng Yang <[email protected]>
Signed-off-by: Yunhong Jiang <[email protected]>
Signed-off-by: Xiaohui Xin <[email protected]>
Signed-off-by: Jun Nakajima <[email protected]>
Signed-off-by: Bruce Beare <[email protected]>
[Ported to 3.4]
Signed-off-by: Tom Keel <[email protected]>
[Cleaned up for 3.7 and submission]
Signed-off-by: Alan Cox <[email protected]>
Signed-off-by: Dmitry Torokhov <[email protected]>
---
 drivers/input/keyboard/Kconfig           |   10 ++
 drivers/input/keyboard/Makefile          |    1 
 drivers/input/keyboard/goldfish_events.c |  194 ++++++++++++++++++++++++++++++
 3 files changed, 205 insertions(+)
 create mode 100644 drivers/input/keyboard/goldfish_events.c
drivers/input/keyboard/Kconfig +10 -0
index 7adfe68..0e72c87 100644
@@ -488,6 +488,16 @@ config KEYBOARD_SAMSUNG
 	  To compile this driver as a module, choose M here: the
 	  module will be called samsung-keypad.
 
+config KEYBOARD_GOLDFISH_EVENTS
+	depends on GOLDFISH
+	tristate "Generic Input Event device for Goldfish"
+	help
+	  Say Y here to get an input event device for the Goldfish virtual
+	  device emulator.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called goldfish-events.
+
 config KEYBOARD_STOWAWAY
 	tristate "Stowaway keyboard"
 	select SERIO
drivers/input/keyboard/Makefile +1 -0
index 4d6c894..b25b243 100644
@@ -13,6 +13,7 @@ obj-$(CONFIG_KEYBOARD_ATKBD)		+= atkbd.o
 obj-$(CONFIG_KEYBOARD_BFIN)		+= bf54x-keys.o
 obj-$(CONFIG_KEYBOARD_DAVINCI)		+= davinci_keyscan.o
 obj-$(CONFIG_KEYBOARD_EP93XX)		+= ep93xx_keypad.o
+obj-$(CONFIG_KEYBOARD_GOLDFISH_EVENTS)	+= goldfish_events.o
 obj-$(CONFIG_KEYBOARD_GPIO)		+= gpio_keys.o
 obj-$(CONFIG_KEYBOARD_GPIO_POLLED)	+= gpio_keys_polled.o
 obj-$(CONFIG_KEYBOARD_TCA6416)		+= tca6416-keypad.o
drivers/input/keyboard/goldfish_events.c new file +194 -0

194 lines not on this page · raw message

author
#2 lore raw
Quoted 23 lines · On Wed, 23 Jan 2013 20:15:47 -0800 Dmitry Torokhov <[email protected]>…

Hi Alan,

Quoted 8 lines · Alan Cox

From: Brian Swetland <[email protected]>

This device is a direct pipe from "hardware" to the input event subsystem, allowing us to avoid having to route "keypad" style events through an AT keyboard driver (gross!)

As with the other submissions this driver is cross architecture.

Quoted 11 lines
[Tided up to work on x86]
[Ported to 3.4]
[Cleaned up for 3.7 and submission]
Quoted 2 lines

I do not have drivers/tty/goldfish.c so I dropped that change... I also had a few more cleanups, the result is below.

Looks good to me - I wasn't sure about the remove method so I copied the other keyboard drivers that still had one even though they used devm_ methods for the allocation.

Alan

maintainer
#3 lore raw
Quoted 26 lines · Alan Cox
Quoted 23 lines · On Wed, 23 Jan 2013 20:15:47 -0800 Dmitry Torokhov <[email protected]>…

Hi Alan,

Quoted 19 lines · Alan Cox

From: Brian Swetland <[email protected]>

This device is a direct pipe from "hardware" to the input event subsystem, allowing us to avoid having to route "keypad" style events through an AT keyboard driver (gross!)

As with the other submissions this driver is cross architecture.

[Tided up to work on x86]
[Ported to 3.4]
[Cleaned up for 3.7 and submission]
Quoted 7 lines
Quoted 2 lines

I do not have drivers/tty/goldfish.c so I dropped that change... I also had a few more cleanups, the result is below.

Looks good to me - I wasn't sure about the remove method so I copied the other keyboard drivers that still had one even though they used devm_ methods for the allocation.

Probably because some other resources are not devm managed and we need to preserve order. Or maybe just bugs...

Thanks.

Signature · 1 line
Dmitry