📄 usb-mininurse.h
字号:
/* * USB Mini-Nurse Driver - 0.1 * * Copyright (C) 2004 Marco (Chopin_1998@Sina.com) * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * * This driver is just to drive Mini-Nurse, Just for Fun. * * Thanks to Linus, USBCORE guys, and all Open-Source World, * * BUG: * - Yes,I canNOT run on a SMP machine or even Sigle-CPU with preemptive kernel. * * TODO: * - let it running on a SMP and Linux2.6 preemptive kernel * - enhence it to use more feature of PDIUSBD12 (and of course it should be supported by MN's FIRMWARE) * - add more feature of kernel (like procfs) * * History: * * 2004_05_26 - 0.1 - the first version */#include <linux/kernel.h>#include <linux/init.h>#include <linux/slab.h>#include <linux/module.h>#include <linux/devfs_fs_kernel.h>#include <linux/usb.h>/* Version Information */#define DRIVER_VERSION "v0.1"#define DRIVER_AUTHOR "Marco, Chopin_1998@Sina.com"#define DRIVER_DESC "USB Mini-Nurse Driver"/* Define these values to match device */#define USB_MN_VENDOR_ID 0x0471 /* Philips PDIUSBD12 */#define USB_MN_PRODUCT_ID 0x0666 /* Marco's MiniNurse *//* table of devices that work with this driver */static struct usb_device_id mn_table [] = { { USB_DEVICE(USB_MN_VENDOR_ID, USB_MN_PRODUCT_ID) }, { } /* Terminating entry */};MODULE_DEVICE_TABLE (usb, mn_table);/* Get a minor range for devices from the usb maintainer */#define USB_MN_MINOR_BASE 192/* we can have up to this number of device plugged in at once */#define MAX_DEVICES 16/* Structure to hold all of our device specific stuff */struct usb_mn { struct usb_device * udev; /* save off the usb device pointer */ struct usb_interface * interface; /* the interface for this device */ devfs_handle_t devfs; /* devfs device node */ unsigned char minor; /* the starting minor number for this device */ unsigned int open_count; /* record for times of open this port*/};/* the global usb devfs handle */extern devfs_handle_t usb_devfs_handle;/* local function prototypes */static int mn_ioctl (struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg);static int mn_open (struct inode *inode, struct file *file);static int mn_release (struct inode *inode, struct file *file);static void * mn_probe (struct usb_device *dev, unsigned int ifnum, const struct usb_device_id *id);static void mn_disconnect (struct usb_device *dev, void *ptr);/* array of pointers to our devices that are currently connected */static struct usb_mn *minor_table[MAX_DEVICES];static int usb_mn_init(void);static void usb_mn_exit(void);module_init (usb_mn_init);module_exit (usb_mn_exit);MODULE_AUTHOR(DRIVER_AUTHOR);MODULE_DESCRIPTION(DRIVER_DESC);MODULE_LICENSE("GPL");EXPORT_NO_SYMBOLS;static struct file_operations mn_fops = { owner: THIS_MODULE, ioctl: mn_ioctl, open: mn_open, release: mn_release,};struct usb_driver mn_driver = { name: "usb-mininurse", probe: mn_probe, disconnect: mn_disconnect, fops: &mn_fops, //minor: USB_MN_MINOR_BASE, id_table: mn_table,};/* information of prod */#define LEDon 0#define LEDoff 1/* only two LEDs?! 555555555 */#define LED0 0x04#define LED1 0x08#define LEDA 0x0C
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -