LCOV - code coverage report
Current view: top level - drivers/hid - hid-kensington.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 6 16.7 %
Date: 2023-03-27 20:00:47 Functions: 1 3 33.3 %

          Line data    Source code
       1             : // SPDX-License-Identifier: GPL-2.0-or-later
       2             : /*
       3             :  *  HID driver for Kensigton Slimblade Trackball
       4             :  *
       5             :  *  Copyright (c) 2009 Jiri Kosina
       6             :  */
       7             : 
       8             : /*
       9             :  */
      10             : 
      11             : #include <linux/device.h>
      12             : #include <linux/input.h>
      13             : #include <linux/hid.h>
      14             : #include <linux/module.h>
      15             : 
      16             : #include "hid-ids.h"
      17             : 
      18             : #define ks_map_key(c)   hid_map_usage(hi, usage, bit, max, EV_KEY, (c))
      19             : 
      20           0 : static int ks_input_mapping(struct hid_device *hdev, struct hid_input *hi,
      21             :                 struct hid_field *field, struct hid_usage *usage,
      22             :                 unsigned long **bit, int *max)
      23             : {
      24           0 :         if ((usage->hid & HID_USAGE_PAGE) != HID_UP_MSVENDOR)
      25             :                 return 0;
      26             : 
      27           0 :         switch (usage->hid & HID_USAGE) {
      28           0 :         case 0x01: ks_map_key(BTN_MIDDLE);      break;
      29           0 :         case 0x02: ks_map_key(BTN_SIDE);        break;
      30             :         default:
      31             :                 return 0;
      32             :         }
      33             :         return 1;
      34             : }
      35             : 
      36             : static const struct hid_device_id ks_devices[] = {
      37             :         { HID_USB_DEVICE(USB_VENDOR_ID_KENSINGTON, USB_DEVICE_ID_KS_SLIMBLADE) },
      38             :         { }
      39             : };
      40             : MODULE_DEVICE_TABLE(hid, ks_devices);
      41             : 
      42             : static struct hid_driver ks_driver = {
      43             :         .name = "kensington",
      44             :         .id_table = ks_devices,
      45             :         .input_mapping = ks_input_mapping,
      46             : };
      47           1 : module_hid_driver(ks_driver);
      48             : 
      49             : MODULE_LICENSE("GPL");

Generated by: LCOV version 1.14