[PATCH 6/9] console: factorize kfifo input support

Sascha Hauer s.hauer at pengutronix.de
Mon Jan 5 03:18:45 PST 2015


On Tue, Dec 23, 2014 at 07:21:55PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> handle input fifo at console framework level instead of driver
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
> ---
>  common/Kconfig                 |  3 ++
>  common/console.c               |  8 +++++
>  common/console_common.c        | 71 ++++++++++++++++++++++++++++++++++++++++++
>  common/console_simple.c        |  4 +++
>  drivers/input/Kconfig          |  4 +++
>  drivers/input/gpio_keys.c      | 43 ++++---------------------
>  drivers/input/imx_keypad.c     | 29 ++---------------
>  drivers/input/qt1070.c         | 28 ++---------------
>  drivers/input/twl6030_pwrbtn.c | 32 ++-----------------
>  include/console.h              | 22 +++++++++++++
>  include/gpio_keys.h            |  1 -
>  11 files changed, 124 insertions(+), 121 deletions(-)

Instead of integrating this into the core code can we make this a helper
function? Something like:

struct console_poller {
	struct poller poller;
	struct kfifo fifo;
	struct console_device *cdev;
	int (*tstc)(struct console_device *cdev)
	int (*getc)(struct console_device *cdev)
};

int console_init_input_fifo(struct console_poller *copo)
{
	if (!copo->cdev || !copo->getc || !copo->tstc)
		return -EINVAL;

	copo->cdev->tstc = console_fifo_tstc;
	copo->cdev->getc = console_fifo_getc;

	/* init kfifo / poller */

	return 0;
}

...

struct gpio_keys {
	...
	struct console_poller copo;
	...
};

static int __init gpio_keys_probe(struct device_d *dev)
{
	...

	gk->copo.getc = gpio_keys_getc;
	gk->copo.tstc = gpio_keys_tstc;

	console_init_input_fifo(&gk->copo);
}

That would make the Kconfig option unnecessary and the core wouldn't get
more complicated.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list