/************************************************************************\ 
 
##                                                                      ## 
 
##  Creation Date: 19 Mar 2007                                          ## 
 
##  Last Update:   19 Mar 2007                                          ## 
 
##  Author:       XInstruments                                          ## 
 
##                                                                      ## 
 
##  Desc: Driver main module header.                                    ## 
 
##                                                                      ## 
 
\************************************************************************/
 
 
 
 
 
#include        <linux/usb.h>
 
 
 
 
 
#define         USMC_DEV_NAME           "8SMC-USB1h"
 
#define         USMC_PRODUCT_ID         0x0230
 
#define         USMC_VENDOR_ID          0x10c4
 
#define         USB_USMC_MINOR_BASE     192             // Get a minor range for your devices from the usb maintainer
 
#define         WRITES_IN_FLIGHT        8
 
#define         USMC_SUCCESS            0
 
 
 
 
 
 
 
 
 
// Connect/Disconnect:
 
static int  usmc_probe      ( struct usb_interface * interface,
 
                              const struct usb_device_id * id );
 
static void usmc_disconnect ( struct usb_interface * interface );
 
// File operations:
 
static long usmc_ioctl   ( struct file * file, unsigned int ioctl_num, unsigned long ioctl_param );
 
static int usmc_open    ( struct inode * inode, struct file * file );
 
static int usmc_release ( struct inode * inode, struct file * file );
 
// Util functions:
 
static void usmc_delete ( struct kref * kref );
 
 
 
 
 
static struct usb_device_id usmc_table [] = {
 
        { USB_DEVICE ( USMC_VENDOR_ID, USMC_PRODUCT_ID ) },
 
        {}              // Terminating element.
 
};
 
 
 
 
 
static struct usb_driver usmc_driver = {
 
        .name       = USMC_DEV_NAME,
 
        .probe      = usmc_probe,
 
        .disconnect = usmc_disconnect,
 
        .id_table   = usmc_table
 
};
 
 
 
 
 
/* Structure to hold all of our device specific stuff */
 
struct usb_usmc
 
{
 
        struct usb_device    * udev;                    /* the usb device for this device */
 
        struct usb_interface * interface;               /* the interface for this device */
 
        struct semaphore       limit_sem;               /* limiting the number of writes in progress */
 
//      unsigned char        * bulk_in_buffer;          /* the buffer to receive data */
 
//      size_t                 bulk_in_size;            /* the size of the receive buffer */
 
//      __u8                   bulk_in_endpointAddr;    /* the address of the bulk in endpoint */
 
//      __u8                   bulk_out_endpointAddr;   /* the address of the bulk out endpoint */
 
        struct kref            kref;
 
};
 
 
 
#define to_usmc_dev(d) container_of(d, struct usb_usmc, kref)
 
 
 
 
 
static struct file_operations usmc_fops = {
 
        .owner   = THIS_MODULE,
 
/*      .read    = usmc_read,
 
        .write   = usmc_write,*/
 
        .open    = usmc_open,
 
        .release = usmc_release,
 
        .unlocked_ioctl   = usmc_ioctl
 
};
 
 
 
/*
 
struct file_operations {
 
        struct module *owner;
 
        loff_t (*llseek) (struct file *, loff_t, int);
 
        ssize_t (*read) (struct file *, char __user *, size_t, loff_t *);
 
        ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *);
 
        ssize_t (*aio_read) (struct kiocb *, const struct iovec *, unsigned long, loff_t);
 
        ssize_t (*aio_write) (struct kiocb *, const struct iovec *, unsigned long, loff_t);
 
        int (*readdir) (struct file *, void *, filldir_t);
 
        unsigned int (*poll) (struct file *, struct poll_table_struct *);
 
        long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
 
   .....
 
*/
 
 
 
 
 
/* 
 
 * usb class driver info in order to get a minor number from the usb core,
 
 * and to have the device registered with the driver core
 
 */
 
static struct usb_class_driver usmc_class = {
 
        .name =       "usmc%d",
 
        .fops =       &usmc_fops,
 
        .minor_base = USB_USMC_MINOR_BASE
 
};