Loading drivers/media/rc/rc-main.c +20 −14 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include <media/rc-core.h> #include <linux/bsearch.h> #include <linux/spinlock.h> #include <linux/delay.h> #include <linux/input.h> Loading Loading @@ -460,6 +461,18 @@ static int ir_setkeytable(struct rc_dev *dev, return rc; } static int rc_map_cmp(const void *key, const void *elt) { const unsigned int *scancode = key; const struct rc_map_table *e = elt; if (*scancode < e->scancode) return -1; else if (*scancode > e->scancode) return 1; return 0; } /** * ir_lookup_by_scancode() - locate mapping by scancode * @rc_map: the struct rc_map to search Loading @@ -472,21 +485,14 @@ static int ir_setkeytable(struct rc_dev *dev, static unsigned int ir_lookup_by_scancode(const struct rc_map *rc_map, unsigned int scancode) { int start = 0; int end = rc_map->len - 1; int mid; while (start <= end) { mid = (start + end) / 2; if (rc_map->scan[mid].scancode < scancode) start = mid + 1; else if (rc_map->scan[mid].scancode > scancode) end = mid - 1; else return mid; } struct rc_map_table *res; res = bsearch(&scancode, rc_map->scan, rc_map->len, sizeof(struct rc_map_table), rc_map_cmp); if (!res) return -1U; else return res - rc_map->scan; } /** Loading Loading
drivers/media/rc/rc-main.c +20 −14 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include <media/rc-core.h> #include <linux/bsearch.h> #include <linux/spinlock.h> #include <linux/delay.h> #include <linux/input.h> Loading Loading @@ -460,6 +461,18 @@ static int ir_setkeytable(struct rc_dev *dev, return rc; } static int rc_map_cmp(const void *key, const void *elt) { const unsigned int *scancode = key; const struct rc_map_table *e = elt; if (*scancode < e->scancode) return -1; else if (*scancode > e->scancode) return 1; return 0; } /** * ir_lookup_by_scancode() - locate mapping by scancode * @rc_map: the struct rc_map to search Loading @@ -472,21 +485,14 @@ static int ir_setkeytable(struct rc_dev *dev, static unsigned int ir_lookup_by_scancode(const struct rc_map *rc_map, unsigned int scancode) { int start = 0; int end = rc_map->len - 1; int mid; while (start <= end) { mid = (start + end) / 2; if (rc_map->scan[mid].scancode < scancode) start = mid + 1; else if (rc_map->scan[mid].scancode > scancode) end = mid - 1; else return mid; } struct rc_map_table *res; res = bsearch(&scancode, rc_map->scan, rc_map->len, sizeof(struct rc_map_table), rc_map_cmp); if (!res) return -1U; else return res - rc_map->scan; } /** Loading