mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-07 15:18:15 +00:00
Input: factor out and export input_device_id matching code
Factor out and export input_match_device_id() so that modules may use it. It will be needed by joydev to blacklist accelerometers in composite devices. Tested-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
This commit is contained in:
parent
9b5db7aab4
commit
55dfce873d
2 changed files with 41 additions and 45 deletions
|
@ -933,58 +933,51 @@ int input_set_keycode(struct input_dev *dev,
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(input_set_keycode);
|
EXPORT_SYMBOL(input_set_keycode);
|
||||||
|
|
||||||
|
bool input_match_device_id(const struct input_dev *dev,
|
||||||
|
const struct input_device_id *id)
|
||||||
|
{
|
||||||
|
if (id->flags & INPUT_DEVICE_ID_MATCH_BUS)
|
||||||
|
if (id->bustype != dev->id.bustype)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (id->flags & INPUT_DEVICE_ID_MATCH_VENDOR)
|
||||||
|
if (id->vendor != dev->id.vendor)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (id->flags & INPUT_DEVICE_ID_MATCH_PRODUCT)
|
||||||
|
if (id->product != dev->id.product)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (id->flags & INPUT_DEVICE_ID_MATCH_VERSION)
|
||||||
|
if (id->version != dev->id.version)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!bitmap_subset(id->evbit, dev->evbit, EV_MAX) ||
|
||||||
|
!bitmap_subset(id->keybit, dev->keybit, KEY_MAX) ||
|
||||||
|
!bitmap_subset(id->relbit, dev->relbit, REL_MAX) ||
|
||||||
|
!bitmap_subset(id->absbit, dev->absbit, ABS_MAX) ||
|
||||||
|
!bitmap_subset(id->mscbit, dev->mscbit, MSC_MAX) ||
|
||||||
|
!bitmap_subset(id->ledbit, dev->ledbit, LED_MAX) ||
|
||||||
|
!bitmap_subset(id->sndbit, dev->sndbit, SND_MAX) ||
|
||||||
|
!bitmap_subset(id->ffbit, dev->ffbit, FF_MAX) ||
|
||||||
|
!bitmap_subset(id->swbit, dev->swbit, SW_MAX)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(input_match_device_id);
|
||||||
|
|
||||||
static const struct input_device_id *input_match_device(struct input_handler *handler,
|
static const struct input_device_id *input_match_device(struct input_handler *handler,
|
||||||
struct input_dev *dev)
|
struct input_dev *dev)
|
||||||
{
|
{
|
||||||
const struct input_device_id *id;
|
const struct input_device_id *id;
|
||||||
|
|
||||||
for (id = handler->id_table; id->flags || id->driver_info; id++) {
|
for (id = handler->id_table; id->flags || id->driver_info; id++) {
|
||||||
|
if (input_match_device_id(dev, id) &&
|
||||||
if (id->flags & INPUT_DEVICE_ID_MATCH_BUS)
|
(!handler->match || handler->match(handler, dev))) {
|
||||||
if (id->bustype != dev->id.bustype)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (id->flags & INPUT_DEVICE_ID_MATCH_VENDOR)
|
|
||||||
if (id->vendor != dev->id.vendor)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (id->flags & INPUT_DEVICE_ID_MATCH_PRODUCT)
|
|
||||||
if (id->product != dev->id.product)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (id->flags & INPUT_DEVICE_ID_MATCH_VERSION)
|
|
||||||
if (id->version != dev->id.version)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!bitmap_subset(id->evbit, dev->evbit, EV_MAX))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!bitmap_subset(id->keybit, dev->keybit, KEY_MAX))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!bitmap_subset(id->relbit, dev->relbit, REL_MAX))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!bitmap_subset(id->absbit, dev->absbit, ABS_MAX))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!bitmap_subset(id->mscbit, dev->mscbit, MSC_MAX))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!bitmap_subset(id->ledbit, dev->ledbit, LED_MAX))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!bitmap_subset(id->sndbit, dev->sndbit, SND_MAX))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!bitmap_subset(id->ffbit, dev->ffbit, FF_MAX))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!bitmap_subset(id->swbit, dev->swbit, SW_MAX))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!handler->match || handler->match(handler, dev))
|
|
||||||
return id;
|
return id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -469,6 +469,9 @@ int input_get_keycode(struct input_dev *dev, struct input_keymap_entry *ke);
|
||||||
int input_set_keycode(struct input_dev *dev,
|
int input_set_keycode(struct input_dev *dev,
|
||||||
const struct input_keymap_entry *ke);
|
const struct input_keymap_entry *ke);
|
||||||
|
|
||||||
|
bool input_match_device_id(const struct input_dev *dev,
|
||||||
|
const struct input_device_id *id);
|
||||||
|
|
||||||
void input_enable_softrepeat(struct input_dev *dev, int delay, int period);
|
void input_enable_softrepeat(struct input_dev *dev, int delay, int period);
|
||||||
|
|
||||||
extern struct class input_class;
|
extern struct class input_class;
|
||||||
|
|
Loading…
Add table
Reference in a new issue