nidas v1.2.3
Macros | Functions | Variables
usbtwod.c File Reference
#include "usbtwod.h"
#include <linux/kernel.h>
#include <linux/version.h>
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/uaccess.h>
#include <linux/usb.h>
#include <linux/poll.h>
#include <linux/timer.h>
#include <linux/moduleparam.h>
#include <nidas/linux/klog.h>
#include <nidas/linux/Revision.h>

Macros

#define REPO_REVISION   "unknown"
 
#define NCAR_VENDOR_ID   0x2D2D
 
#define USB2D_64_PRODUCT_ID   0x2D00
 
#define USB2D_32_PRODUCT_ID   0x2D01
 
#define USB2D_64_V3_PRODUCT_ID   0x2D03
 
#define TWOD_MUTEX_LOCK(d)   mutex_lock(d);
 
#define TWOD_MUTEX_UNLOCK(d)   mutex_unlock(d);
 

Functions

 MODULE_DEVICE_TABLE (usb, twod_table)
 
static DEFINE_MUTEX (twod_open_lock)
 
 MODULE_PARM_DESC (throttleRate, "image/sec: 0 for no throttling, or (N X " __stringify(MAX_THROTTLE_FUNC_RATE) "), for N in [1:" __stringify(IMG_URBS_IN_FLIGHT) "]")
 
 module_param (throttleRate, uint, 0)
 
static void klog_shutdown (const char *devname, const char *func, const char *status)
 
static void klog_error (const char *devname, const char *func, const char *status, int err)
 
static int check_urb_status (int urbstatus, struct usb_twod *dev, const char *func)
 
static void twod_dev_free (struct usb_twod *dev)
 
static void twod_dev_delete (struct kref *kref)
 
static void twod_tas_tx_bulk_callback (struct urb *urb)
 
static struct urb * twod_make_tas_urb (struct usb_twod *dev)
 
static int write_tas (struct usb_twod *dev)
 
static void send_tas_timer_func (struct timer_list *tlist)
 
static int twod_set_sor_rate (struct usb_twod *dev, int rate)
 
static int usb_twod_submit_img_urb (struct usb_twod *dev, struct urb *urb)
 
static int usb_twod_submit_sor_urb (struct usb_twod *dev, struct urb *urb)
 
static void urb_throttle_func (struct timer_list *tlist)
 
static void twod_img_rx_bulk_callback (struct urb *urb)
 
static struct urb * twod_make_img_urb (struct usb_twod *dev)
 
static void twod_sor_rx_bulk_callback (struct urb *urb)
 
static struct urb * twod_make_sor_urb (struct usb_twod *dev)
 
static int twod_open (struct inode *inode, struct file *file)
 
static int twod_release (struct inode *inode, struct file *file)
 
static unsigned int twod_poll (struct file *file, poll_table *wait)
 
static ssize_t twod_read (struct file *file, char __user *buffer, size_t count, loff_t *ppos)
 
static long twod_ioctl (struct file *file, unsigned int cmd, unsigned long arg)
 
static int twod_probe (struct usb_interface *interface, const struct usb_device_id *id)
 
static void twod_disconnect (struct usb_interface *interface)
 
static int __init usb_twod_init (void)
 
static void __exit usb_twod_exit (void)
 
 module_init (usb_twod_init)
 
 module_exit (usb_twod_exit)
 
 MODULE_LICENSE ("GPL")
 
 MODULE_AUTHOR ("Chris Webster <cjw@ucar.edu>")
 
 MODULE_DESCRIPTION ("USB PMS-2D Probe Driver")
 
 MODULE_VERSION (REPO_REVISION)
 

Variables

static struct usb_device_id twod_table []
 
static unsigned int throttleRate = 0
 
static struct usb_driver twod_driver
 
static struct file_operations twod_fops
 
static struct usb_class_driver usbtwod_64
 
static struct usb_class_driver usbtwod_32
 

Macro Definition Documentation

◆ NCAR_VENDOR_ID

#define NCAR_VENDOR_ID   0x2D2D

◆ REPO_REVISION

#define REPO_REVISION   "unknown"

Referenced by usb_twod_init().

◆ TWOD_MUTEX_LOCK

#define TWOD_MUTEX_LOCK ( d)    mutex_lock(d);

Referenced by twod_disconnect(), and twod_open().

◆ TWOD_MUTEX_UNLOCK

#define TWOD_MUTEX_UNLOCK ( d)    mutex_unlock(d);

Referenced by twod_disconnect(), and twod_open().

◆ USB2D_32_PRODUCT_ID

#define USB2D_32_PRODUCT_ID   0x2D01

◆ USB2D_64_PRODUCT_ID

#define USB2D_64_PRODUCT_ID   0x2D00

◆ USB2D_64_V3_PRODUCT_ID

#define USB2D_64_V3_PRODUCT_ID   0x2D03

Referenced by twod_probe().

Function Documentation

◆ check_urb_status()

static int check_urb_status ( int urbstatus,
struct usb_twod * dev,
const char * func )
static

◆ DEFINE_MUTEX()

static DEFINE_MUTEX ( twod_open_lock )
static

◆ klog_error()

static void klog_error ( const char * devname,
const char * func,
const char * status,
int err )
static

References err.

Referenced by check_urb_status().

◆ klog_shutdown()

static void klog_shutdown ( const char * devname,
const char * func,
const char * status )
static

◆ MODULE_AUTHOR()

MODULE_AUTHOR ( "Chris Webster <cjw@ucar.edu>" )

◆ MODULE_DESCRIPTION()

MODULE_DESCRIPTION ( "USB PMS-2D Probe Driver" )

◆ MODULE_DEVICE_TABLE()

MODULE_DEVICE_TABLE ( usb ,
twod_table  )

◆ module_exit()

module_exit ( usb_twod_exit )

◆ module_init()

module_init ( usb_twod_init )

◆ MODULE_LICENSE()

MODULE_LICENSE ( "GPL" )

◆ module_param()

module_param ( throttleRate ,
uint ,
0  )

◆ MODULE_PARM_DESC()

MODULE_PARM_DESC ( throttleRate ,
"image/sec: 0 for no throttling,
or(N X " __stringify(MAX_THROTTLE_FUNC_RATE) ") ,
for N in " [1:" __stringify(IMG_URBS_IN_FLIGHT) "] )

◆ MODULE_VERSION()

MODULE_VERSION ( REPO_REVISION )

◆ send_tas_timer_func()

static void send_tas_timer_func ( struct timer_list * tlist)
static

References write_tas().

Referenced by twod_open().

◆ twod_dev_delete()

static void twod_dev_delete ( struct kref * kref)
static

◆ twod_dev_free()

static void twod_dev_free ( struct usb_twod * dev)
static

Referenced by twod_dev_delete(), and twod_release().

◆ twod_disconnect()

static void twod_disconnect ( struct usb_interface * interface)
static

◆ twod_img_rx_bulk_callback()

static void twod_img_rx_bulk_callback ( struct urb * urb)
static

◆ twod_ioctl()

static long twod_ioctl ( struct file * file,
unsigned int cmd,
unsigned long arg )
static

◆ twod_make_img_urb()

static struct urb * twod_make_img_urb ( struct usb_twod * dev)
static

References twod_img_rx_bulk_callback().

Referenced by twod_open().

◆ twod_make_sor_urb()

static struct urb * twod_make_sor_urb ( struct usb_twod * dev)
static

References twod_sor_rx_bulk_callback().

Referenced by twod_open().

◆ twod_make_tas_urb()

static struct urb * twod_make_tas_urb ( struct usb_twod * dev)
static

References twod_tas_tx_bulk_callback().

Referenced by twod_open().

◆ twod_open()

static int twod_open ( struct inode * inode,
struct file * file )
static

◆ twod_poll()

static unsigned int twod_poll ( struct file * file,
poll_table * wait )
static

◆ twod_probe()

static int twod_probe ( struct usb_interface * interface,
const struct usb_device_id * id )
static

◆ twod_read()

static ssize_t twod_read ( struct file * file,
char __user * buffer,
size_t count,
loff_t * ppos )
static

◆ twod_release()

static int twod_release ( struct inode * inode,
struct file * file )
static

◆ twod_set_sor_rate()

static int twod_set_sor_rate ( struct usb_twod * dev,
int rate )
static

References rate, and TMSECS_PER_SEC.

Referenced by twod_ioctl(), and twod_release().

◆ twod_sor_rx_bulk_callback()

static void twod_sor_rx_bulk_callback ( struct urb * urb)
static

◆ twod_tas_tx_bulk_callback()

static void twod_tas_tx_bulk_callback ( struct urb * urb)
static

References check_urb_status().

Referenced by twod_make_tas_urb().

◆ urb_throttle_func()

static void urb_throttle_func ( struct timer_list * tlist)
static

References klog_shutdown().

Referenced by twod_open().

◆ usb_twod_exit()

static void __exit usb_twod_exit ( void )
static

References twod_driver.

◆ usb_twod_init()

static int __init usb_twod_init ( void )
static

References REPO_REVISION, and twod_driver.

◆ usb_twod_submit_img_urb()

static int usb_twod_submit_img_urb ( struct usb_twod * dev,
struct urb * urb )
static

◆ usb_twod_submit_sor_urb()

static int usb_twod_submit_sor_urb ( struct usb_twod * dev,
struct urb * urb )
static

◆ write_tas()

static int write_tas ( struct usb_twod * dev)
static

References klog_shutdown().

Referenced by send_tas_timer_func().

Variable Documentation

◆ throttleRate

unsigned int throttleRate = 0
static

◆ twod_driver

static struct usb_driver twod_driver
static
Initial value:
= {
.name = "usbtwod",
.id_table = twod_table,
.probe = twod_probe,
.disconnect = twod_disconnect,
}
static struct usb_device_id twod_table[]
Definition usbtwod.c:82
static void twod_disconnect(struct usb_interface *interface)
Definition usbtwod.c:1507
static int twod_probe(struct usb_interface *interface, const struct usb_device_id *id)
Definition usbtwod.c:1334

Referenced by twod_open(), usb_twod_exit(), and usb_twod_init().

◆ twod_fops

struct file_operations twod_fops
static
Initial value:
= {
.owner = THIS_MODULE,
.read = twod_read,
.poll = twod_poll,
.unlocked_ioctl = twod_ioctl,
.open = twod_open,
.release = twod_release,
.llseek = no_llseek,
}
static int twod_release(struct inode *inode, struct file *file)
Definition usbtwod.c:1071
static ssize_t twod_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos)
Definition usbtwod.c:1156
static unsigned int twod_poll(struct file *file, poll_table *wait)
Definition usbtwod.c:1143
static long twod_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
Definition usbtwod.c:1246
static int twod_open(struct inode *inode, struct file *file)
Definition usbtwod.c:859

◆ twod_table

struct usb_device_id twod_table[]
static
Initial value:
= {
{}
}
#define USB2D_64_PRODUCT_ID
Definition usbtwod.c:72
#define USB2D_32_PRODUCT_ID
Definition usbtwod.c:73
#define NCAR_VENDOR_ID
Definition usbtwod.c:71
#define USB2D_64_V3_PRODUCT_ID
Definition usbtwod.c:74

◆ usbtwod_32

struct usb_class_driver usbtwod_32
static
Initial value:
= {
.name = "usbtwod_32_%d",
.fops = &twod_fops,
.minor_base = USB_TWOD_32_MINOR_BASE,
}
static struct file_operations twod_fops
Definition usbtwod.c:1304

Referenced by twod_disconnect(), and twod_probe().

◆ usbtwod_64

struct usb_class_driver usbtwod_64
static
Initial value:
= {
.name = "usbtwod_64_%d",
.fops = &twod_fops,
.minor_base = USB_TWOD_64_MINOR_BASE,
}

Referenced by twod_disconnect(), and twod_probe().