lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <44C746D6.1010506@ccoss.com.cn>
Date:	Wed, 26 Jul 2006 18:41:26 +0800
From:	liyu <liyu@...ss.com.cn>
To:	LKML <linux-kernel@...r.kernel.org>, Greg KH <greg@...ah.com>,
	Peter <peter@...bp.freeserve.co.uk>,
	The Doctor <thedoctor@...dis.homelinux.org>
Subject: [PATCH 1/2] usbhid: HID device simple driver interface

==================================
HID device simple driver interface
==================================

------------------------
Version
------------------------

    This is the second version, this patch can apply on 2.6.17.6 kernel 
tree (also can apply for 2.6.17.7).

    The last version can find here:

        http://www.gossamer-threads.com/lists/linux/kernel/603843.

    As Greg KH words, I split this driver into some more littler patches, and
break some long line in source.

------------------------
Goal
------------------------

    Let us write HID device driver more easier.


------------------------
Basic idea
------------------------

    Under current HID device driver development technique, We need write 
one new interrupt handler for each new HID device to report event to 
input subsystem. However, the most of them have only some extended keys, 
e.g. many remote controllers. I think it seem break a fly on the wheel, 
which write one new interrupt handler for this reason.
    My idea is reuse the interrupt handler in hid-core.c. so  writing 
driver for new simple HID device will be more easier, quickly, and need 
not touch hid core.
    In essence, this interface just is some hooks in HID core.
        
------------------------
Limitation
------------------------
    
    In the last version of this interface, Each driver use this 
interface only can work with one device at same time. As the Greg KH 
words, this limitation make this interface too useless. e.g. we often 
can find there are two joysticks connected with one host. In this 
version, the driver can work with more than one device at same time. 
However, I still do not recommend you use this interface, if your driver 
need handle a lot of devices (e.g. more than 20) at same time, beacause 
of I used simple algorithm to search/insert/delete each device.
    
    This interface can not support the more drivers handle one device at 
same time yet. I can not sure if we need this feature? What do you 
think, Greg KH?


------------------------    
Testing
------------------------

    Tested on i386.

        
------------------------
The driver use this interface
------------------------
    
    I wrote a driver for MS Natural Ergonomic Keyboard 4000. 

------------------------
Usage
------------------------    

    Although this simple driver have not direct relation with Linux 
device driver architecture, but I still make its API like it on purpose.

    The simple driver have five methods:

1.    int (*connect)(struct hid_device *, struct hid_input *);
2.    void (*disconnect)(struct hid_device *, struct hid_input *);

    When you simple driver is to bind with one real HID device, we will 
call connect() method first. To return 0 flag if it complete its mission 
successfully, so we can continue, return any other value is looked as 
error. any thing do not happen.
    When the HID device that your simple driver connect with is down, or 
you unregister this simple driver, we will call disconnect() method, it 
have none return value.
    Note: the these method may be called more times on one device. 
beacause of some device will yield more than one hid_device/hid_input 
instances. of course, you can ignore them that you do not interest.
    
3.    void (*setup_usage)(struct hid_field *,   struct hid_usage *);
4.    void (*clear_usage)(struct hid_field *,   struct hid_usage *);
    
    The setup_usage() method is like hidinput_configure_usage() in 
hid_input.c. You also can setup input_dev here. In most time, I think 
you should be fill the pointer slot for this method, elsewise the 
event() method do not work for you at all. Please see example in "MS 
Natural Ergonomic Keyboard 4000" driver.
    The clear_usage() method is used to clear side-effect that came from 
setup_usage() method, if they are there. Of course, you can do same 
things in disconnect() method, but this method let your life more 
simpler.    

6.    int (*pre_event)(const struct hid_device *, const struct hid_field 
*, const struct hid_usage *, const __s32, const struct pt_regs *regs);

    First, you can use this method send event to input subsystem, 
moreover, you can use this as one usage code filter: if it return 
non-zero , any event handling method do not be called , even the 
hidinput_hid_event().
    If this method return zero, the normally event handling process will 
continue.
    Note again, if you do not correctly configure usage in 
setup_usage(), this method do not work as you want.

7.    void (*post_event)(const struct hid_device *, const struct 
hid_field *, const struct hid_usage *, const __s32, const struct pt_regs 
*regs);

    Its behavior like with hidinput_hid_event() exactly. but if 
pre_event() return non-zero value, this method also do not called at all.
    Note again, if you do not correctly configure usage in 
setup_usage(), this method do not work as you want.
    This method have not return value.
    
    All these methods are optional, but if they are all NULL pointers, 
what are you want? If you do not supply one method, We see as it 
complete its task successfully.

    For detailed usage, you can find out in the MS Natural Ergonomic 
Keyboard 4000 driver , usbnek4k.c. it is in my other patch.

    The last words that I want to say are sorry, this new version have 
not compatibility with the last version.
        
    Good luck.

-Liyu









View attachment "usbhid-simple-driver.kernel-2.6.17.7.patch" of type "text/x-patch" (15629 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ