Re: [PATCH] drivers/input/keyboard: convert to dynamic input_dev allocation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 2005-10-29 00:59:36 -0500, Dmitry Torokhov <[email protected]> wrote:
> On Friday 28 October 2005 02:05, Dmitry Torokhov wrote:
>  drivers/input/keyboard/lkkbd.c |   28 +++++-----------------------
>  1 files changed, 5 insertions(+), 23 deletions(-)
> 
> Index: work/drivers/input/keyboard/lkkbd.c
> ===================================================================
> --- work.orig/drivers/input/keyboard/lkkbd.c
> +++ work/drivers/input/keyboard/lkkbd.c
> @@ -440,38 +440,20 @@ lkkbd_interrupt (struct serio *serio, un
>  					input_report_key (lk->dev, lk->keycode[i], 0);
>  			input_sync (lk->dev);
>  			break;
> +
>  		case LK_METRONOME:
> -			DBG (KERN_INFO "Got %#d and don't "
> -					"know how to handle...\n");
> -			break;
>  		case LK_OUTPUT_ERROR:
> -			DBG (KERN_INFO "Got LK_OUTPUT_ERROR and don't "
> -					"know how to handle...\n");
> -			break;
>  		case LK_INPUT_ERROR:
> -			DBG (KERN_INFO "Got LK_INPUT_ERROR and don't "
> -					"know how to handle...\n");
> -			break;
>  		case LK_KBD_LOCKED:
> -			DBG (KERN_INFO "Got LK_KBD_LOCKED and don't "
> -					"know how to handle...\n");
> -			break;
>  		case LK_KBD_TEST_MODE_ACK:
> -			DBG (KERN_INFO "Got LK_KBD_TEST_MODE_ACK and don't "
> -					"know how to handle...\n");
> -			break;
>  		case LK_PREFIX_KEY_DOWN:
> -			DBG (KERN_INFO "Got LK_PREFIX_KEY_DOWN and don't "
> -					"know how to handle...\n");
> -			break;
>  		case LK_MODE_CHANGE_ACK:
> -			DBG (KERN_INFO "Got LK_MODE_CHANGE_ACK and ignored "
> -					"it properly...\n");
> -			break;
>  		case LK_RESPONSE_RESERVED:
> -			DBG (KERN_INFO "Got LK_RESPONSE_RESERVED and don't "
> -					"know how to handle...\n");
> +			DBG (KERN_INFO
> +			     "Got 0x%02x and don't know how to handle...\n",
> +			     data);
>  			break;
> +
>  		case 0x01:
>  			DBG (KERN_INFO "Got 0x01, scheduling re-initialization\n");
>  			lk->ignore_bytes = LK_NUM_IGNORE_BYTES;

That'll greatly help in debugging it if needed. Thanks.

If you really want to make that switch smaller, please put some small
table like

#define RESPONSE(x) { .value = x, .name = #x, }
struct {
	unsigned char value;
	unsigned char *name;
} response[] {
	RESPONSE (LK_KBD_TEST_MODE_ACK),
	RESPONSE (LK_PREFIX_KEY_DOWN),
	...
};

into the driver along with a small search function like

unsigned char *
find_response_name (unsigned char value)
{
	int i;

	for (i = 0; i < ARRAY_SIZE (response); i++)
		if (response[i].value == value)
			return response[i].name;
	
	return NULL;
}

MfG, JBG

-- 
Jan-Benedict Glaw       [email protected]    . +49-172-7608481             _ O _
"Eine Freie Meinung in  einem Freien Kopf    | Gegen Zensur | Gegen Krieg  _ _ O
 für einen Freien Staat voll Freier Bürger"  | im Internet! |   im Irak!   O O O
ret = do_actions((curr | FREE_SPEECH) & ~(NEW_COPYRIGHT_LAW | DRM | TCPA));

Attachment: signature.asc
Description: Digital signature


[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux