Skip to content

Commit

Permalink
HID: simplify an index check in hid_lookup_collection
Browse files Browse the repository at this point in the history
Save the struct hid_collection * in a temporary to shorten
the generated code a bit and perhaps improve readability.

$ size drivers/hid/hid-core.o*
   text	   data	    bss	    dec	    hex	filename
  16460	     78	      8	  16546	   40a2	drivers/hid/hid-core.o.new
  16469	     78	      8	  16555	   40ab	drivers/hid/hid-core.o.old

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
  • Loading branch information
Joe Perches authored and Jiri Kosina committed Dec 10, 2010
1 parent a3789a1 commit 504499f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions drivers/hid/hid-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,14 @@ static int close_collection(struct hid_parser *parser)

static unsigned hid_lookup_collection(struct hid_parser *parser, unsigned type)
{
struct hid_collection *collection = parser->device->collection;
int n;
for (n = parser->collection_stack_ptr - 1; n >= 0; n--)
if (parser->device->collection[parser->collection_stack[n]].type == type)
return parser->device->collection[parser->collection_stack[n]].usage;

for (n = parser->collection_stack_ptr - 1; n >= 0; n--) {
unsigned index = parser->collection_stack[n];
if (collection[index].type == type)
return collection[index].usage;
}
return 0; /* we know nothing about this usage type */
}

Expand Down

0 comments on commit 504499f

Please sign in to comment.