Release 4.7 drivers/usb/gadget/legacy/inode.c
/*
* inode.c -- user mode filesystem api for usb gadget controllers
*
* Copyright (C) 2003-2004 David Brownell
* Copyright (C) 2003 Agilent Technologies
*
* 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.
*/
/* #define VERBOSE_DEBUG */
#include <linux/init.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/pagemap.h>
#include <linux/uts.h>
#include <linux/wait.h>
#include <linux/compiler.h>
#include <asm/uaccess.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/poll.h>
#include <linux/mmu_context.h>
#include <linux/aio.h>
#include <linux/uio.h>
#include <linux/device.h>
#include <linux/moduleparam.h>
#include <linux/usb/gadgetfs.h>
#include <linux/usb/gadget.h>
/*
* The gadgetfs API maps each endpoint to a file descriptor so that you
* can use standard synchronous read/write calls for I/O. There's some
* O_NONBLOCK and O_ASYNC/FASYNC style i/o support. Example usermode
* drivers show how this works in practice. You can also use AIO to
* eliminate I/O gaps between requests, to help when streaming data.
*
* Key parts that must be USB-specific are protocols defining how the
* read/write operations relate to the hardware state machines. There
* are two types of files. One type is for the device, implementing ep0.
* The other type is for each IN or OUT endpoint. In both cases, the
* user mode driver must configure the hardware before using it.
*
* - First, dev_config() is called when /dev/gadget/$CHIP is configured
* (by writing configuration and device descriptors). Afterwards it
* may serve as a source of device events, used to handle all control
* requests other than basic enumeration.
*
* - Then, after a SET_CONFIGURATION control request, ep_config() is
* called when each /dev/gadget/ep* file is configured (by writing
* endpoint descriptors). Afterwards these files are used to write()
* IN data or to read() OUT data. To halt the endpoint, a "wrong
* direction" request is issued (like reading an IN endpoint).
*
* Unlike "usbfs" the only ioctl()s are for things that are rare, and maybe
* not possible on all hardware. For example, precise fault handling with
* respect to data left in endpoint fifos after aborted operations; or
* selective clearing of endpoint halts, to implement SET_INTERFACE.
*/
#define DRIVER_DESC "USB Gadget filesystem"
#define DRIVER_VERSION "24 Aug 2004"
static const char driver_desc [] = DRIVER_DESC;
static const char shortname [] = "gadgetfs";
MODULE_DESCRIPTION (DRIVER_DESC);
MODULE_AUTHOR ("David Brownell");
MODULE_LICENSE ("GPL");
static int ep_open(struct inode *, struct file *);
/*----------------------------------------------------------------------*/
#define GADGETFS_MAGIC 0xaee71ee7
/* /dev/gadget/$CHIP represents ep0 and the whole device */
enum ep0_state {
/* DISBLED is the initial state.
*/
STATE_DEV_DISABLED = 0,
/* Only one open() of /dev/gadget/$CHIP; only one file tracks
* ep0/device i/o modes and binding to the controller. Driver
* must always write descriptors to initialize the device, then
* the device becomes UNCONNECTED until enumeration.
*/
STATE_DEV_OPENED,
/* From then on, ep0 fd is in either of two basic modes:
* - (UN)CONNECTED: read usb_gadgetfs_event(s) from it
* - SETUP: read/write will transfer control data and succeed;
* or if "wrong direction", performs protocol stall
*/
STATE_DEV_UNCONNECTED,
STATE_DEV_CONNECTED,
STATE_DEV_SETUP,
/* UNBOUND means the driver closed ep0, so the device won't be
* accessible again (DEV_DISABLED) until all fds are closed.
*/
STATE_DEV_UNBOUND,
};
/* enough for the whole queue: most events invalidate others */
#define N_EVENT 5
struct dev_data {
spinlock_t lock;
atomic_t count;
enum ep0_state state; /* P: lock */
struct usb_gadgetfs_event event [N_EVENT];
unsigned ev_next;
struct fasync_struct *fasync;
u8 current_config;
/* drivers reading ep0 MUST handle control requests (SETUP)
* reported that way; else the host will time out.
*/
unsigned usermode_setup : 1,
setup_in : 1,
setup_can_stall : 1,
setup_out_ready : 1,
setup_out_error : 1,
setup_abort : 1,
gadget_registered : 1;
unsigned setup_wLength;
/* the rest is basically write-once */
struct usb_config_descriptor *config, *hs_config;
struct usb_device_descriptor *dev;
struct usb_request *req;
struct usb_gadget *gadget;
struct list_head epfiles;
void *buf;
wait_queue_head_t wait;
struct super_block *sb;
struct dentry *dentry;
/* except this scratch i/o buffer for ep0 */
u8 rbuf [256];
};
static inline void get_dev (struct dev_data *data)
{
atomic_inc (&data->count);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david brownell | david brownell | 20 | 100.00% | 1 | 100.00% |
| Total | 20 | 100.00% | 1 | 100.00% |
static void put_dev (struct dev_data *data)
{
if (likely (!atomic_dec_and_test (&data->count)))
return;
/* needs no more cleanup */
BUG_ON (waitqueue_active (&data->wait));
kfree (data);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david brownell | david brownell | 43 | 100.00% | 1 | 100.00% |
| Total | 43 | 100.00% | 1 | 100.00% |
static struct dev_data *dev_new (void)
{
struct dev_data *dev;
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if (!dev)
return NULL;
dev->state = STATE_DEV_DISABLED;
atomic_set (&dev->count, 1);
spin_lock_init (&dev->lock);
INIT_LIST_HEAD (&dev->epfiles);
init_waitqueue_head (&dev->wait);
return dev;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david brownell | david brownell | 74 | 93.67% | 1 | 33.33% |
eric sesterhenn | eric sesterhenn | 4 | 5.06% | 1 | 33.33% |
al viro | al viro | 1 | 1.27% | 1 | 33.33% |
| Total | 79 | 100.00% | 3 | 100.00% |
/*----------------------------------------------------------------------*/
/* other /dev/gadget/$ENDPOINT files represent endpoints */
enum ep_state {
STATE_EP_DISABLED = 0,
STATE_EP_READY,
STATE_EP_ENABLED,
STATE_EP_UNBOUND,
};
struct ep_data {
struct mutex lock;
enum ep_state state;
atomic_t count;
struct dev_data *dev;
/* must hold dev->lock before accessing ep or req */
struct usb_ep *ep;
struct usb_request *req;
ssize_t status;
char name [16];
struct usb_endpoint_descriptor desc, hs_desc;
struct list_head epfiles;
wait_queue_head_t wait;
struct dentry *dentry;
};
static inline void get_ep (struct ep_data *data)
{
atomic_inc (&data->count);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david brownell | david brownell | 20 | 100.00% | 1 | 100.00% |
| Total | 20 | 100.00% | 1 | 100.00% |
static void put_ep (struct ep_data *data)
{
if (likely (!atomic_dec_and_test (&data->count)))
return;
put_dev (data->dev);
/* needs no more cleanup */
BUG_ON (!list_empty (&data->epfiles));
BUG_ON (waitqueue_active (&data->wait));
kfree (data);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david brownell | david brownell | 62 | 100.00% | 1 | 100.00% |
| Total | 62 | 100.00% | 1 | 100.00% |
/*----------------------------------------------------------------------*/
/* most "how to use the hardware" policy choices are in userspace:
* mapping endpoint roles (which the driver needs) to the capabilities
* which the usb controller has. most of those capabilities are exposed
* implicitly, starting with the driver name and then endpoint names.
*/
static const char *CHIP;
/*----------------------------------------------------------------------*/
/* NOTE: don't use dev_printk calls before binding to the gadget
* at the end of ep0 configuration, or after unbind.
*/
/* too wordy: dev_printk(level , &(d)->gadget->dev , fmt , ## args) */
#define xprintk(d,level,fmt,args...) \
printk(level "%s: " fmt , shortname , ## args)
#ifdef DEBUG
#define DBG(dev,fmt,args...) \
xprintk(dev , KERN_DEBUG , fmt , ## args)
#else
#define DBG(dev,fmt,args...) \
do { } while (0)
#endif /* DEBUG */
#ifdef VERBOSE_DEBUG
#define VDEBUG DBG
#else
#define VDEBUG(dev,fmt,args...) \
do { } while (0)
#endif /* DEBUG */
#define ERROR(dev,fmt,args...) \
xprintk(dev , KERN_ERR , fmt , ## args)
#define INFO(dev,fmt,args...) \
xprintk(dev , KERN_INFO , fmt , ## args)
/*----------------------------------------------------------------------*/
/* SYNCHRONOUS ENDPOINT OPERATIONS (bulk/intr/iso)
*
* After opening, configure non-control endpoints. Then use normal
* stream read() and write() requests; and maybe ioctl() to get more
* precise FIFO status when recovering from cancellation.
*/
static void epio_complete (struct usb_ep *ep, struct usb_request *req)
{
struct ep_data *epdata = ep->driver_data;
if (!req->context)
return;
if (req->status)
epdata->status = req->status;
else
epdata->status = req->actual;
complete ((struct completion *)req->context);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david brownell | david brownell | 68 | 100.00% | 1 | 100.00% |
| Total | 68 | 100.00% | 1 | 100.00% |
/* tasklock endpoint, returning when it's connected.
* still need dev->lock to use epdata->ep.
*/
static int
get_ready_ep (unsigned f_flags, struct ep_data *epdata, bool is_write)
{
int val;
if (f_flags & O_NONBLOCK) {
if (!mutex_trylock(&epdata->lock))
goto nonblock;
if (epdata->state != STATE_EP_ENABLED &&
(!is_write || epdata->state != STATE_EP_READY)) {
mutex_unlock(&epdata->lock);
nonblock:
val = -EAGAIN;
} else
val = 0;
return val;
}
val = mutex_lock_interruptible(&epdata->lock);
if (val < 0)
return val;
switch (epdata->state) {
case STATE_EP_ENABLED:
return 0;
case STATE_EP_READY: /* not configured yet */
if (is_write)
return 0;
// FALLTHRU
case STATE_EP_UNBOUND: /* clean disconnect */
break;
// case STATE_EP_DISABLED: /* "can't happen" */
default: /* error! */
pr_debug ("%s: ep %p not available, state %d\n",
shortname, epdata, epdata->state);
}
mutex_unlock(&epdata->lock);
return -ENODEV;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david brownell | david brownell | 119 | 72.56% | 1 | 33.33% |
al viro | al viro | 36 | 21.95% | 1 | 33.33% |
thomas gleixner | thomas gleixner | 9 | 5.49% | 1 | 33.33% |
| Total | 164 | 100.00% | 3 | 100.00% |
static ssize_t
ep_io (struct ep_data *epdata, void *buf, unsigned len)
{
DECLARE_COMPLETION_ONSTACK (done);
int value;
spin_lock_irq (&epdata->dev->lock);
if (likely (epdata->ep != NULL)) {
struct usb_request *req = epdata->req;
req->context = &done;
req->complete = epio_complete;
req->buf = buf;
req->length = len;
value = usb_ep_queue (epdata->ep, req, GFP_ATOMIC);
} else
value = -ENODEV;
spin_unlock_irq (&epdata->dev->lock);
if (likely (value == 0)) {
value = wait_event_interruptible (done.wait, done.done);
if (value != 0) {
spin_lock_irq (&epdata->dev->lock);
if (likely (epdata->ep != NULL)) {
DBG (epdata->dev, "%s i/o interrupted\n",
epdata->name);
usb_ep_dequeue (epdata->ep, epdata->req);
spin_unlock_irq (&epdata->dev->lock);
wait_event (done.wait, done.done);
if (epdata->status == -ECONNRESET)
epdata->status = -EINTR;
} else {
spin_unlock_irq (&epdata->dev->lock);
DBG (epdata->dev, "endpoint gone\n");
epdata->status = -ENODEV;
}
}
return epdata->status;
}
return value;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david brownell | david brownell | 264 | 99.62% | 2 | 66.67% |
peter zijlstra | peter zijlstra | 1 | 0.38% | 1 | 33.33% |
| Total | 265 | 100.00% | 3 | 100.00% |
static int
ep_release (struct inode *inode, struct file *fd)
{
struct ep_data *data = fd->private_data;
int value;
value = mutex_lock_interruptible(&data->lock);
if (value < 0)
return value;
/* clean up if this can be reopened */
if (data->state != STATE_EP_UNBOUND) {
data->state = STATE_EP_DISABLED;
data->desc.bDescriptorType = 0;
data->hs_desc.bDescriptorType = 0;
usb_ep_disable(data->ep);
}
mutex_unlock(&data->lock);
put_ep (data);
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david brownell | david brownell | 62 | 60.19% | 2 | 40.00% |
al viro | al viro | 37 | 35.92% | 1 | 20.00% |
matthias kaehlcke | matthias kaehlcke | 3 | 2.91% | 1 | 20.00% |
thomas gleixner | thomas gleixner | 1 | 0.97% | 1 | 20.00% |
| Total | 103 | 100.00% | 5 | 100.00% |
static long ep_ioctl(struct file *fd, unsigned code, unsigned long value)
{
struct ep_data *data = fd->private_data;
int status;
if ((status = get_ready_ep (fd->f_flags, data, false)) < 0)
return status;
spin_lock_irq (&data->dev->lock);
if (likely (data->ep != NULL)) {
switch (code) {
case GADGETFS_FIFO_STATUS:
status = usb_ep_fifo_status (data->ep);
break;
case GADGETFS_FIFO_FLUSH:
usb_ep_fifo_flush (data->ep);
break;
case GADGETFS_CLEAR_HALT:
status = usb_ep_clear_halt (data->ep);
break;
default:
status = -ENOTTY;
}
} else
status = -ENODEV;
spin_unlock_irq (&data->dev->lock);
mutex_unlock(&data->lock);
return status;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david brownell | david brownell | 129 | 85.43% | 1 | 20.00% |
al viro | al viro | 18 | 11.92% | 2 | 40.00% |
matthias kaehlcke | matthias kaehlcke | 3 | 1.99% | 1 | 20.00% |
thomas gleixner | thomas gleixner | 1 | 0.66% | 1 | 20.00% |
| Total | 151 | 100.00% | 5 | 100.00% |
/*----------------------------------------------------------------------*/
/* ASYNCHRONOUS ENDPOINT I/O OPERATIONS (bulk/intr/iso) */
struct kiocb_priv {
struct usb_request *req;
struct ep_data *epdata;
struct kiocb *iocb;
struct mm_struct *mm;
struct work_struct work;
void *buf;
struct iov_iter to;
const void *to_free;
unsigned actual;
};
static int ep_aio_cancel(struct kiocb *iocb)
{
struct kiocb_priv *priv = iocb->private;
struct ep_data *epdata;
int value;
local_irq_disable();
epdata = priv->epdata;
// spin_lock(&epdata->dev->lock);
if (likely(epdata && epdata->ep && priv->req))
value = usb_ep_dequeue (epdata->ep, priv->req);
else
value = -EINVAL;
// spin_unlock(&epdata->dev->lock);
local_irq_enable();
return value;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david brownell | david brownell | 79 | 100.00% | 2 | 100.00% |
| Total | 79 | 100.00% | 2 | 100.00% |
static void ep_user_copy_worker(struct work_struct *work)
{
struct kiocb_priv *priv = container_of(work, struct kiocb_priv, work);
struct mm_struct *mm = priv->mm;
struct kiocb *iocb = priv->iocb;
size_t ret;
use_mm(mm);
ret = copy_to_iter(priv->buf, priv->actual, &priv->to);
unuse_mm(mm);
if (!ret)
ret = -EFAULT;
/* completing the iocb can drop the ctx and mm, don't touch mm after */
iocb->ki_complete(iocb, ret, ret);
kfree(priv->buf);
kfree(priv->to_free);
kfree(priv);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
zach brown | zach brown | 71 | 61.21% | 1 | 14.29% |
al viro | al viro | 29 | 25.00% | 2 | 28.57% |
david brownell | david brownell | 13 | 11.21% | 3 | 42.86% |
christoph hellwig | christoph hellwig | 3 | 2.59% | 1 | 14.29% |
| Total | 116 | 100.00% | 7 | 100.00% |
static void ep_aio_complete(struct usb_ep *ep, struct usb_request *req)
{
struct kiocb *iocb = req->context;
struct kiocb_priv *priv = iocb->private;
struct ep_data *epdata = priv->epdata;
/* lock against disconnect (and ideally, cancel) */
spin_lock(&epdata->dev->lock);
priv->req = NULL;
priv->epdata = NULL;
/* if this was a write or a read returning no data then we
* don't need to copy anything to userspace, so we can
* complete the aio request immediately.
*/
if (priv->to_free == NULL || unlikely(req->actual == 0)) {
kfree(req->buf);
kfree(priv->to_free);
kfree(priv);
iocb->private = NULL;
/* aio_complete() reports bytes-transferred _and_ faults */
iocb->ki_complete(iocb, req->actual ? req->actual : req->status,
req->status);
} else {
/* ep_copy_to_user() won't report both; we hide some faults */
if (unlikely(0 != req->status))
DBG(epdata->dev, "%s fault %d len %d\n",
ep->name, req->status, req->actual);
priv->buf = req->buf;
priv->actual = req->actual;
INIT_WORK(&priv->work, ep_user_copy_worker);
schedule_work(&priv->work);
}
spin_unlock(&epdata->dev->lock);
usb_ep_free_request(ep, req);
put_ep(epdata);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david brownell | david brownell | 165 | 72.69% | 2 | 20.00% |
al viro | al viro | 50 | 22.03% | 4 | 40.00% |
alan stern | alan stern | 6 | 2.64% | 2 | 20.00% |
christoph hellwig | christoph hellwig | 3 | 1.32% | 1 | 10.00% |
zach brown | zach brown | 3 | 1.32% | 1 | 10.00% |
| Total | 227 | 100.00% | 10 | 100.00% |
static ssize_t ep_aio(struct kiocb *iocb,
struct kiocb_priv *priv,
struct ep_data *epdata,
char *buf,
size_t len)
{
struct usb_request *req;
ssize_t value;
iocb->private = priv;
priv->iocb = iocb;
kiocb_set_cancel_fn(iocb, ep_aio_cancel);
get_ep(epdata);
priv->epdata = epdata;
priv->actual = 0;
priv->mm = current->mm; /* mm teardown waits for iocbs in exit_aio() */
/* each kiocb is coupled to one usb_request, but we can't
* allocate or submit those if the host disconnected.
*/
spin_lock_irq(&epdata->dev->lock);
value = -ENODEV;
if (unlikely(epdata->ep))
goto fail;
req = usb_ep_alloc_request(epdata->ep, GFP_ATOMIC);
value = -ENOMEM;
if (unlikely(!req))
goto fail;
priv->req = req;
req->buf = buf;
req->length = len;
req->complete = ep_aio_complete;
req->context = iocb;
value = usb_ep_queue(epdata->ep, req, GFP_ATOMIC);
if (unlikely(0 != value)) {
usb_ep_free_request(epdata->ep, req);
goto fail;
}
spin_unlock_irq(&epdata->dev->lock);
return -EIOCBQUEUED;
fail:
spin_unlock_irq(&epdata->dev->lock);
kfree(priv->to_free);
kfree(priv);
put_ep(epdata);
return value;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
al viro | al viro | 227 | 91.53% | 1 | 33.33% |
david brownell | david brownell | 20 | 8.06% | 1 | 33.33% |
zach brown | zach brown | 1 | 0.40% | 1 | 33.33% |
| Total | 248 | 100.00% | 3 | 100.00% |
static ssize_t
ep_read_iter(struct kiocb *iocb, struct iov_iter *to)
{
struct file *file = iocb->ki_filp;
struct ep_data *epdata = file->private_data;
size_t len = iov_iter_count(to);
ssize_t value;
char *buf;
if ((value = get_ready_ep(file->f_flags, epdata, false)) < 0)
return value;
/* halt any endpoint by doing a "wrong direction" i/o call */
if (usb_endpoint_dir_in(&epdata->desc)) {
if (usb_endpoint_xfer_isoc(&epdata->desc) ||
!is_sync_kiocb(iocb)) {
mutex_unlock(&epdata->lock);
return -EINVAL;
}
DBG (epdata->dev, "%s halt\n", epdata->name);
spin_lock_irq(&epdata->dev->lock);
if (likely(epdata->ep != NULL))
usb_ep_set_halt(epdata->ep);
spin_unlock_irq(&epdata->dev->lock);
mutex_unlock(&epdata->lock);
return -EBADMSG;
}
buf = kmalloc(len, GFP_KERNEL);
if (unlikely(!buf)) {
mutex_unlock(&epdata->lock);
return -ENOMEM;
}
if (is_sync_kiocb(iocb)) {
value = ep_io(epdata, buf, len);
if (value >= 0 && copy_to_iter(buf, value, to))
value = -EFAULT;
} else {
struct kiocb_priv *priv = kzalloc(sizeof *priv, GFP_KERNEL);
value = -ENOMEM;
if (!priv)
goto fail;
priv->to_free = dup_iter(&priv->to, to, GFP_KERNEL);
if (!priv->to_free) {
kfree(priv);
goto fail;
}
value = ep_aio(iocb, priv, epdata, buf, len);
if (value == -EIOCBQUEUED)
buf = NULL;
}
fail:
kfree(buf);
mutex_unlock(&epdata->lock);
return value;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
al viro | al viro | 230 | 64.79% | 3 | 42.86% |
david brownell | david brownell | 116 | 32.68% | 2 | 28.57% |
zach brown | zach brown | 7 | 1.97% | 1 | 14.29% |
badari pulavarty | badari pulavarty | 2 | 0.56% | 1 | 14.29% |
| Total | 355 | 100.00% | 7 | 100.00% |
static ssize_t ep_config(struct ep_data *, const char *, size_t);
static ssize_t
ep_write_iter(struct kiocb *iocb, struct iov_iter *from)
{
struct file *file = iocb->ki_filp;
struct ep_data *epdata = file->private_data;
size_t len = iov_iter_count(from);
bool configured;
ssize_t value;
char *buf;
if ((value = get_ready_ep(file->f_flags, epdata, true)) < 0)
return value;
configured = epdata->state == STATE_EP_ENABLED;
/* halt any endpoint by doing a "wrong direction" i/o call */
if (configured && !usb_endpoint_dir_in(&epdata->desc)) {
if (usb_endpoint_xfer_isoc(&epdata->desc) ||
!is_sync_kiocb(iocb)) {
mutex_unlock(&epdata->lock);
return -EINVAL;
}
DBG (epdata->dev, "%s halt\n", epdata->name);
spin_lock_irq(&epdata->dev->lock);
if (likely(epdata->ep != NULL))
usb_ep_set_halt(epdata->ep);
spin_unlock_irq(&epdata->dev->lock);
mutex_unlock(&epdata->lock);
return -EBADMSG;
}
buf = kmalloc(len, GFP_KERNEL);
if (unlikely(!buf)) {
mutex_unlock(&epdata->lock);
return -ENOMEM;
}
if (unlikely(copy_from_iter(buf, len, from) != len)) {
value = -EFAULT;
goto out;
}
if (unlikely(!configured)) {
value = ep_config(epdata, buf, len);
} else if (is_sync_kiocb(iocb)) {
value = ep_io(epdata, buf, len);
} else {
struct kiocb_priv *priv = kzalloc(sizeof *priv, GFP_KERNEL);
value = -ENOMEM;
if (priv) {
value = ep_aio(iocb, priv, epdata, buf, len);
if (value == -EIOCBQUEUED)
buf = NULL;
}
}
out:
kfree(buf);
mutex_unlock(&epdata->lock);
return value;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
al viro | al viro | 247 | 68.23% | 2 | 33.33% |
david brownell | david brownell | 104 | 28.73% | 2 | 33.33% |
matthias kaehlcke | matthias kaehlcke | 6 | 1.66% | 1 | 16.67% |
badari pulavarty | badari pulavarty | 5 | 1.38% | 1 | 16.67% |
| Total | 362 | 100.00% | 6 | 100.00% |
/*----------------------------------------------------------------------*/
/* used after endpoint configuration */
static const struct file_operations ep_io_operations = {
.owner = THIS_MODULE,
.open = ep_open,
.release = ep_release,
.llseek = no_llseek,
.unlocked_ioctl = ep_ioctl,
.read_iter = ep_read_iter,
.write_iter = ep_write_iter,
};
/* ENDPOINT INITIALIZATION
*
* fd = open ("/dev/gadget/$ENDPOINT", O_RDWR)
* status = write (fd, descriptors, sizeof descriptors)
*
* That write establishes the endpoint configuration, configuring
* the controller to process bulk, interrupt, or isochronous transfers
* at the right maxpacket size, and so on.
*
* The descriptors are message type 1, identified by a host order u32
* at the beginning of what's written. Descriptor order is: full/low
* speed descriptor, then optional high speed descriptor.
*/
static ssize_t
ep_config (struct ep_data *data, const char *buf, size_t len)
{
struct usb_ep *ep;
u32 tag;
int value, length = len;
if (data->state != STATE_EP_READY) {
value = -EL2HLT;
goto fail;
}
value = len;
if (len < USB_DT_ENDPOINT_SIZE + 4)
goto fail0;
/* we might need to change message format someday */
memcpy(&tag, buf, 4);
if (tag != 1) {
DBG(data->dev, "config %s, bad tag %d\n", data->name, tag);
goto fail0;
}
buf += 4;
len -= 4;
/* NOTE: audio endpoint extensions not accepted here;
* just don't include the extra bytes.
*/
/* full/low speed descriptor, then high speed */
memcpy(&data->desc, buf, USB_DT_ENDPOINT_SIZE);
if (data->desc.bLength != USB_DT_ENDPOINT_SIZE
|| data->desc.bDescriptorType != USB_DT_ENDPOINT)
goto fail0;
if (len != USB_DT_ENDPOINT_SIZE) {
if (len != 2 * USB_DT_ENDPOINT_SIZE)
goto fail0;
memcpy(&data->hs_desc, buf + USB_DT_ENDPOINT_SIZE,
USB_DT_ENDPOINT_SIZE);
if (data->hs_desc.bLength != USB_DT_ENDPOINT_SIZE
|| data->hs_desc.bDescriptorType
!= USB_DT_ENDPOINT) {
DBG(data->dev, "config %s, bad hs length or type\n",
data->name);
goto fail0;
}
}
spin_lock_irq (&data->dev->lock);
if (data->dev->state == STATE_DEV_UNBOUND) {
value = -ENOENT;
goto gone;
} else {
ep = data->ep;
if (ep == NULL) {
value = -ENODEV;
goto gone;
}
}
switch (data->dev->gadget->speed) {
case USB_SPEED_LOW:
case USB_SPEED_FULL:
ep->desc = &data->desc;
break;
case USB_SPEED_HIGH:
/* fails if caller didn't provide that descriptor... */
ep->desc = &data->hs_desc;
break;
default:
DBG(data->dev, "unconnected, %s init abandoned\n",
data->name);
value = -EINVAL;
goto gone;
}
value = usb_ep_enable(ep);
if (value == 0) {
data->state = STATE_EP_ENABLED;
value = length;
}
gone:
spin_unlock_irq (&data->dev->lock);
if (value < 0) {
fail:
data->desc.bDescriptorType = 0;
data->hs_desc.bDescriptorType = 0;
}
return value;
fail0:
value = -EINVAL;
goto fail;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david brownell | david brownell | 361 | 87.83% | 1 | 16.67% |
al viro | al viro | 21 | 5.11% | 1 | 16.67% |
milan svoboda | milan svoboda | 10 | 2.43% | 1 | 16.67% |
tatyana brokhman | tatyana brokhman | 8 | 1.95% | 1 | 16.67% |
greg kroah-hartman | greg kroah-hartman | 7 | 1.70% | 1 | 16.67% |
phil endecott | phil endecott | 4 | 0.97% | 1 | 16.67% |
| Total | 411 | 100.00% | 6 | 100.00% |
static int
ep_open (struct inode *inode, struct file *fd)
{
struct ep_data *data = inode->i_private;
int value = -EBUSY;
if (mutex_lock_interruptible(&data->lock) != 0)
return -EINTR;
spin_lock_irq (&data->dev->lock);
if (data->dev->state == STATE_DEV_UNBOUND)
value = -ENOENT;
else if (data->state == STATE_EP_DISABLED) {
value = 0;
data->state = STATE_EP_READY;
get_ep (data);
fd->private_data = data;
VDEBUG (data->dev, "%s ready\n", data->name);
} else
DBG (data->dev, "%s state %d\n",
data->name, data->state);
spin_unlock_irq (&data->dev->lock);
mutex_unlock(&data->lock);
return value;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david brownell | david brownell | 153 | 98.08% | 1 | 33.33% |
thomas gleixner | thomas gleixner | 2 | 1.28% | 1 | 33.33% |
theodore tso | theodore tso | 1 | 0.64% | 1 | 33.33% |
| Total | 156 | 100.00% | 3 | 100.00% |
/*----------------------------------------------------------------------*/
/* EP0 IMPLEMENTATION can be partly in userspace.
*
* Drivers that use this facility receive various events, including
* control requests the kernel doesn't handle. Drivers that don't
* use this facility may be too simple-minded for real applications.
*/
static inline void ep0_readable (struct dev_data *dev)
{
wake_up (&dev->wait);
kill_fasync (&dev->fasync, SIGIO, POLL_IN);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david brownell | david brownell | 32 | 100.00% | 1 | 100.00% |
| Total | 32 | 100.00% | 1 | 100.00% |
static void clean_req (struct usb_ep *ep, struct usb_request *req)
{
struct dev_data *dev = ep->driver_data;
if (req->buf != dev->rbuf) {
kfree(req->buf);
req->buf = dev->rbuf;
}
req->complete = epio_complete;
dev->setup_out_ready = 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david brownell | david brownell | 64 | 100.00% | 2 | 100.00% |
| Total | 64 | 100.00% | 2 | 100.00% |
static void ep0_complete (struct usb_ep *ep, struct usb_request *req)
{
struct dev_data *dev = ep->driver_data;
unsigned long flags;
int free = 1;
/* for control OUT, data must still get to userspace */
spin_lock_irqsave(&dev->lock, flags);
if (!dev->setup_in) {
dev->setup_out_error = (req->status != 0);
if (!dev->setup_out_error)
free = 0;
dev->setup_out_ready = 1;
ep0_readable (dev);
}
/* clean up as appropriate */
if (free && req->buf != &dev->rbuf)
clean_req (ep, req);
req->complete = epio_complete;
spin_unlock_irqrestore(&dev->lock, flags);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david brownell | david brownell | 125 | 100.00% | 2 | 100.00% |
| Total | 125 | 100.00% | 2 | 100.00% |
static int setup_req (struct usb_ep *ep, struct usb_request *req, u16 len)
{
struct dev_data *dev = ep->driver_data;
if (dev->setup_out_ready) {
DBG (dev, "ep0 request busy!\n");
return -EBUSY;
}
if (len > sizeof (dev->rbuf))
req->buf = kmalloc(len, GFP_ATOMIC);
if (req->buf == NULL) {
req->buf = dev->rbuf;
return -ENOMEM;
}
req->complete = ep0_complete;
req->length = len;
req->zero = 0;
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david brownell | david brownell | 106 | 94.64% | 3 | 75.00% |
alan stern | alan stern | 6 | 5.36% | 1 | 25.00% |
| Total | 112 | 100.00% | 4 | 100.00% |
static ssize_t
ep0_read (struct file *fd, char __user *buf, size_t len, loff_t *ptr)
{
struct dev_data *dev = fd->private_data;
ssize_t retval;
enum ep0_state state;
spin_lock_irq (&dev->lock);
if (dev->state <= STATE_DEV_OPENED) {
retval = -EINVAL;
goto done;
}
/* report fd mode change before acting on it */
if (dev->setup_abort) {
dev->setup_abort = 0;
retval = -EIDRM;
goto done;
}
/* control DATA stage */
if ((state = dev->state) == STATE_DEV_SETUP) {
if (dev->setup_in) { /* stall IN */
VDEBUG(dev, "ep0in stall\n");
(void) usb_ep_set_halt (dev->gadget->ep0);
retval = -EL2HLT;
dev->state = STATE_DEV_CONNECTED;
} else if (len == 0) { /* ack SET_CONFIGURATION etc */
struct usb_ep *ep = dev->gadget->ep0;
struct usb_request *req = dev->req;
if ((retval = setup_req (ep, req, 0)) == 0) {
spin_unlock_irq (&dev->lock);
retval = usb_ep_queue (ep, req, GFP_KERNEL);
spin_lock_irq (&dev->lock);
}
dev->state = STATE_DEV_CONNECTED;
/* assume that was SET_CONFIGURATION */
if (dev->current_config) {
unsigned power;
if (gadget_is_dualspeed(dev->gadget)
&& (dev->gadget->speed
== USB_SPEED_HIGH))
power = dev->hs_config->bMaxPower;
else
power = dev->config->bMaxPower;
usb_gadget_vbus_draw(dev->gadget, 2 * power);
}
} else { /* collect OUT data */
if ((fd->f_flags & O_NONBLOCK) != 0
&& !dev->setup_out_ready) {
retval = -EAGAIN;
goto done;
}
spin_unlock_irq (&dev->lock);
retval = wait_event_interruptible (dev->wait,
dev->setup_out_ready != 0);
/* FIXME state could change from under us */
spin_lock_irq (&dev->lock);
if (retval)
goto done;
if (dev->state != STATE_DEV_SETUP) {
retval = -ECANCELED;
goto done;
}
dev->state = STATE_DEV_CONNECTED;
if (dev->setup_out_error)
retval = -EIO;
else {
len = min (len, (size_t)dev->req->actual);
// FIXME don't call this with the spinlock held ...
if (copy_to_user (buf, dev->req->buf, len))
retval = -EFAULT;
else
retval = len;
clean_req (dev->gadget->ep0, dev->req);
/* NOTE userspace can't yet choose to stall */
}
}
goto done;
}
/* else normal: return event data */
if (len < sizeof dev->event [0]) {
retval = -EINVAL;
goto done;
}
len -= len % sizeof (struct usb_gadgetfs_event);
dev->usermode_setup = 1;
scan:
/* return queued events right away */
if (dev->ev_next != 0) {
unsigned i, n;
n = len / sizeof (struct usb_gadgetfs_event);
if (dev->ev_next < n)
n = dev->ev_next;
/* ep0 i/o has special semantics during STATE_DEV_SETUP */
for (i = 0; i < n; i++) {
if (dev->event [i].type == GADGETFS_SETUP) {
dev->state = STATE_DEV_SETUP;
n = i + 1;
break;
}
}
spin_unlock_irq (&dev->lock);
len = n * sizeof (struct usb_gadgetfs_event);
if (copy_to_user (buf, &dev->event, len))
retval = -EFAULT;
else
retval = len;
if (len > 0) {
/* NOTE this doesn't guard against broken drivers;
* concurrent ep0 readers may lose events.
*/
spin_lock_irq (&dev->lock);
if (dev->ev_next > n) {
memmove(&dev->event[0], &dev->event[n],
sizeof (struct usb_gadgetfs_event)
* (dev->ev_next - n));
}
dev->ev_next -= n;
spin_unlock_irq (&dev->lock);
}
return retval;
}
if (fd->f_flags & O_NONBLOCK) {
retval = -EAGAIN;
goto done;
}
switch (state) {
default:
DBG (dev, "fail %s, state %d\n", __func__, state);
retval = -ESRCH;
break;
case STATE_DEV_UNCONNECTED:
case STATE_DEV_CONNECTED:
spin_unlock_irq (&dev->lock);
DBG (dev, "%s wait\n", __func__);
/* wait for events */
retval = wait_event_interruptible (dev->wait,
dev->ev_next != 0);
if (retval < 0)
return retval;
spin_lock_irq (&dev->lock);
goto scan;
}
done:
spin_unlock_irq (&dev->lock);
return retval;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david brownell | david brownell | 760 | 94.06% | 6 | 50.00% |
bin liu | bin liu | 19 | 2.35% | 1 | 8.33% |
alan stern | alan stern | 18 | 2.23% | 1 | 8.33% |
thomas faber | thomas faber | 5 | 0.62% | 1 | 8.33% |
greg kroah-hartman | greg kroah-hartman | 3 | 0.37% | 1 | 8.33% |
harvey harrison | harvey harrison | 2 | 0.25% | 1 | 8.33% |
al viro | al viro | 1 | 0.12% | 1 | 8.33% |
| Total | 808 | 100.00% | 12 | 100.00% |
static struct usb_gadgetfs_event *
next_event (struct dev_data *dev, enum usb_gadgetfs_event_type type)
{
struct usb_gadgetfs_event *event;
unsigned i;
switch (type) {
/* these events purge the queue */
case GADGETFS_DISCONNECT:
if (dev->state == STATE_DEV_SETUP)
dev->setup_abort = 1;
// FALL THROUGH
case GADGETFS_CONNECT:
dev->ev_next = 0;
break;
case GADGETFS_SETUP: /* previous request timed out */
case GADGETFS_SUSPEND: /* same effect */
/* these events can't be repeated */
for (i = 0; i != dev->ev_next; i++) {
if (dev->event [i].type != type)
continue;
DBG(dev, "discard old event[%d] %d\n", i, type);
dev->ev_next--;
if (i == dev->ev_next)
break;
/* indices start at zero, for simplicity */
memmove (&dev->event [i], &dev->event [i + 1],
sizeof (struct usb_gadgetfs_event)
* (dev->ev_next - i));
}
break;
default:
BUG ();
}
VDEBUG(dev, "event[%d] = %d\n", dev->ev_next, type);
event = &dev->event [dev->ev_next++];
BUG_ON (dev->ev_next > N_EVENT);
memset (event, 0, sizeof *event);
event->type = type;
return event;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david brownell | david brownell | 221 | 100.00% | 3 | 100.00% |
| Total | 221 | 100.00% | 3 | 100.00% |
static ssize_t
ep0_write (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
{
struct dev_data *dev = fd->private_data;
ssize_t retval = -ESRCH;
/* report fd mode change before acting on it */
if (dev->setup_abort) {
dev->setup_abort = 0;
retval = -EIDRM;
/* data and/or status stage for control request */
} else if (dev->state == STATE_DEV_SETUP) {
/* IN DATA+STATUS caller makes len <= wLength */
if (dev->setup_in) {
retval = setup_req (dev->gadget->ep0, dev->req, len);
if (retval == 0) {
dev->state = STATE_DEV_CONNECTED;
spin_unlock_irq (&dev->lock);
if (copy_from_user (dev->req->buf, buf, len))
retval = -EFAULT;
else {
if (len < dev->setup_wLength)
dev->req->zero = 1;
retval = usb_ep_queue (
dev->gadget->ep0, dev->req,
GFP_KERNEL);
}
spin_lock_irq(&dev->lock);
if (retval < 0) {
clean_req (dev->gadget->ep0, dev->req);
} else
retval = len;
return retval;
}
/* can stall some OUT transfers */
} else if (dev->setup_can_stall) {
VDEBUG(dev, "ep0out stall\n");
(void) usb_ep_set_halt (dev->gadget->ep0);
retval = -EL2HLT;
dev->state = STATE_DEV_CONNECTED;
} else {
DBG(dev, "bogus ep0out stall!\n");
}
} else
DBG (dev, "fail %s, state %d\n", __func__, dev->state);
return retval;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david brownell | david brownell | 252 | 90.32% | 3 | 42.86% |
alan stern | alan stern | 18 | 6.45% | 1 | 14.29% |
david eccher | david eccher | 7 | 2.51% | 1 | 14.29% |
al viro | al viro | 1 | 0.36% | 1 | 14.29% |
harvey harrison | harvey harrison | 1 | 0.36% | 1 | 14.29% |
| Total | 279 | 100.00% | 7 | 100.00% |
static int
ep0_fasync (int f, struct file *fd, int on)
{
struct dev_data *dev = fd->private_data;
// caller must F_SETOWN before signal delivery happens
VDEBUG (dev, "%s %s\n", __func__, on ? "on" : "off");
return fasync_helper (f, fd, on, &dev->fasync);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david brownell | david brownell | 56 | 98.25% | 1 | 50.00% |
harvey harrison | harvey harrison | 1 | 1.75% | 1 | 50.00% |
| Total | 57 | 100.00% | 2 | 100.00% |
static struct usb_gadget_driver gadgetfs_driver;
static int
dev_release (struct inode *inode, struct file *fd)
{
struct dev_data *dev = fd->private_data;
/* closing ep0 === shutdown all */
if (dev->gadget_registered)
usb_gadget_unregister_driver (&gadgetfs_driver);
/* at this point "good" hardware has disconnected the
* device from USB; the host won't see it any more.
* alternatively, all host requests will time out.
*/
kfree (dev->buf);
dev->buf = NULL;
/* other endpoints were all decoupled from this device */
spin_lock_irq(&dev->lock);
dev->state = STATE_DEV_DISABLED;
spin_unlock_irq(&dev->lock);
put_dev (dev);
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david brownell | david brownell | 53 | 63.86% | 1 | 25.00% |
marcus nutzinger | marcus nutzinger | 23 | 27.71% | 1 | 25.00% |
marek szyprowski | marek szyprowski | 6 | 7.23% | 1 | 25.00% |
al viro | al viro | 1 | 1.20% | 1 | 25.00% |
| Total | 83 | 100.00% | 4 | 100.00% |
static unsigned int
ep0_poll (struct file *fd, poll_table *wait)
{
struct dev_data *dev = fd->private_data;
int mask = 0;
if (dev->state <= STATE_DEV_OPENED)
return DEFAULT_POLLMASK;
poll_wait(fd, &dev->wait, wait);
spin_lock_irq (&dev->lock);
/* report fd mode change before acting on it */
if (dev->setup_abort) {
dev->setup_abort = 0;
mask = POLLHUP;
goto out;
}
if (dev->state == STATE_DEV_SETUP) {
if (dev->setup_in || dev->setup_can_stall)
mask = POLLOUT;
} else {
if (dev->ev_next != 0)
mask = POLLIN;
}
out:
spin_unlock_irq(&dev->lock);
return mask;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
milan svoboda | milan svoboda | 123 | 91.11% | 1 | 33.33% |
alan stern | alan stern | 11 | 8.15% | 1 | 33.33% |
david brownell | david brownell | 1 | 0.74% | 1 | 33.33% |
| Total | 135 | 100.00% | 3 | 100.00% |
static long dev_ioctl (struct file *fd, unsigned code, unsigned long value)
{
struct dev_data *dev = fd->private_data;
struct usb_gadget *gadget = dev->gadget;
long ret = -ENOTTY;
if (gadget->ops->ioctl)
ret = gadget->ops->ioctl (gadget, code, value);
return ret;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david brownell | david brownell | 57 | 83.82% | 1 | 50.00% |
alan cox | alan cox | 11 | 16.18% | 1 | 50.00% |
| Total | 68 | 100.00% | 2 | 100.00% |
/*----------------------------------------------------------------------*/
/* The in-kernel gadget driver handles most ep0 issues, in particular
* enumerating the single configuration (as provided from user space).
*
* Unrecognized ep0 requests may be handled in user space.
*/
static void make_qualifier (struct dev_data *dev)
{
struct usb_qualifier_descriptor qual;
struct usb_device_descriptor *desc;
qual.bLength = sizeof qual;
qual.bDescriptorType = USB_DT_DEVICE_QUALIFIER;
qual.bcdUSB = cpu_to_le16 (0x0200);
desc = dev->dev;
qual.bDeviceClass = desc->bDeviceClass;
qual.bDeviceSubClass = desc->bDeviceSubClass;
qual.bDeviceProtocol = desc->bDeviceProtocol;
/* assumes ep0 uses the same value for both speeds ... */
qual.bMaxPacketSize0 = dev->gadget->ep0->maxpacket;
qual.bNumConfigurations = 1;
qual.bRESERVED = 0;
memcpy (dev->rbuf, &qual, sizeof qual);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david brownell | david brownell | 103 | 93.64% | 1 | 33.33% |
sebastian andrzej siewior | sebastian andrzej siewior | 6 | 5.45% | 1 | 33.33% |
harvey harrison | harvey harrison | 1 | 0.91% | 1 | 33.33% |
| Total | 110 | 100.00% | 3 | 100.00% |
static int
config_buf (struct dev_data *dev, u8 type, unsigned index)
{
int len;
int hs = 0;
/* only one configuration */
if (index > 0)
return -EINVAL;
if (gadget_is_dualspeed(dev->gadget)) {
hs = (dev->gadget->speed == USB_SPEED_HIGH);
if (type == USB_DT_OTHER_SPEED_CONFIG)
hs = !hs;
}
if (hs) {
dev->req->buf = dev->hs_config;
len = le16_to_cpu(dev->hs_config->wTotalLength);
} else {
dev->req->buf = dev->config;
len = le16_to_cpu(dev->config->wTotalLength);
}
((u8 *)dev->req->buf) [1] = type;
return len;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david brownell | david brownell | 141 | 100.00% | 3 | 100.00% |
| Total | 141 | 100.00% | 3 | 100.00% |
static int
gadgetfs_setup (struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
{
struct dev_data *dev = get_gadget_data (gadget);
struct usb_request *req = dev->req;
int value = -EOPNOTSUPP;
struct usb_gadgetfs_event *event;
u16 w_value = le16_to_cpu(ctrl->wValue);
u16 w_length = le16_to_cpu(ctrl->wLength);
spin_lock (&dev->lock);
dev->setup_abort = 0;
if (dev->state == STATE_DEV_UNCONNECTED) {
if (gadget_is_dualspeed(gadget)
&& gadget->speed == USB_SPEED_HIGH
&& dev->hs_config == NULL) {
spin_unlock(&dev->lock);
ERROR (dev, "no high speed config??\n");
return -EINVAL;
}
dev->state = STATE_DEV_CONNECTED;
INFO (dev, "connected\n");
event = next_event (dev, GADGETFS_CONNECT);
event->u.speed = gadget->speed;
ep0_readable (dev);
/* host may have given up waiting for response. we can miss control
* requests handled lower down (device/endpoint status and features);
* then ep0_{read,write} will report the wrong status. controller
* driver will have aborted pending i/o.
*/
} else if (dev->state == STATE_DEV_SETUP)
dev->setup_abort = 1;
req->buf = dev->rbuf;
req->context = NULL;
value = -EOPNOTSUPP;
switch (ctrl->bRequest) {
case USB_REQ_GET_DESCRIPTOR:
if (ctrl->bRequestType != USB_DIR_IN)
goto unrecognized;
switch (w_value >> 8) {
case USB_DT_DEVICE:
value = min (w_length, (u16) sizeof *dev->dev);
dev->dev->bMaxPacketSize0 = dev->gadget->ep0->maxpacket;
req->buf = dev->dev;
break;
case USB_DT_DEVICE_QUALIFIER:
if (!dev->hs_config)
break;
value = min (w_length, (u16)
sizeof (struct usb_qualifier_descriptor));
make_qualifier (dev);
break;
case USB_DT_OTHER_SPEED_CONFIG:
// FALLTHROUGH
case USB_DT_CONFIG:
value = config_buf (dev,
w_value >> 8,
w_value & 0xff);
if (value >= 0)
value = min (w_length, (u16) value);
break;
case USB_DT_STRING:
goto unrecognized;
default: // all others are errors
break;
}
break;
/* currently one config, two speeds */
case USB_REQ_SET_CONFIGURATION:
if (ctrl->bRequestType != 0)
goto unrecognized;
if (0 == (u8) w_value) {
value = 0;
dev->current_config = 0;
usb_gadget_vbus_draw(gadget, 8 /* mA */ );
// user mode expected to disable endpoints
} else {
u8 config, power;
if (gadget_is_dualspeed(gadget)
&& gadget->speed == USB_SPEED_HIGH) {
config = dev->hs_config->bConfigurationValue;
power = dev->hs_config->bMaxPower;
} else {
config = dev->config->bConfigurationValue;
power = dev->config->bMaxPower;
}
if (config == (u8) w_value) {
value = 0;
dev->current_config = config;
usb_gadget_vbus_draw(gadget, 2 * power);
}
}
/* report SET_CONFIGURATION like any other control request,
* except that usermode may not stall this. the next
* request mustn't be allowed start until this finishes:
* endpoints and threads set up, etc.
*
* NOTE: older PXA hardware (before PXA 255: without UDCCFR)
* has bad/racey automagic that prevents synchronizing here.
* even kernel mode drivers often miss them.
*/
if (value == 0) {
INFO (dev, "configuration #%d\n", dev->current_config);
usb_gadget_set_state(gadget, USB_STATE_CONFIGURED);
if (dev->usermode_setup) {
dev->setup_can_stall = 0;
goto delegate;
}
}
break;
#ifndef CONFIG_USB_PXA25X
/* PXA automagically handles this request too */
case USB_REQ_GET_CONFIGURATION:
if (ctrl->bRequestType != 0x80)
goto unrecognized;
*(u8 *)req->buf = dev->current_config;
value = min (w_length, (u16) 1);
break;
#endif
default:
unrecognized:
VDEBUG (dev, "%s req%02x.%02x v%04x i%04x l%d\n",
dev->usermode_setup ? "delegate" : "fail",
ctrl->bRequestType, ctrl->bRequest,
w_value, le16_to_cpu(ctrl->wIndex), w_length);
/* if there's an ep0 reader, don't stall */
if (dev->usermode_setup) {
dev->setup_can_stall = 1;
delegate:
dev->setup_in = (ctrl->bRequestType & USB_DIR_IN)
? 1 : 0;
dev->setup_wLength = w_length;
dev->setup_out_ready = 0;
dev->setup_out_error = 0;
value = 0;
/* read DATA stage for OUT right away */
if (unlikely (!dev->setup_in && w_length)) {
value = setup_req (gadget->ep0, dev->req,
w_length);
if (value < 0)
break;
spin_unlock (&dev->lock);
value = usb_ep_queue (gadget->ep0, dev->req,
GFP_KERNEL);
spin_lock (&dev->lock);
if (value < 0) {
clean_req (gadget->ep0, dev->req);
break;
}
/* we can't currently stall these */
dev->setup_can_stall = 0;
}
/* state changes when reader collects event */
event = next_event (dev, GADGETFS_SETUP);
event->u.setup = *ctrl;
ep0_readable (dev);
spin_unlock (&dev->lock);
return 0;
}
}
/* proceed with data transfer and status phases? */
if (value >= 0 && dev->state != STATE_DEV_SETUP) {
req->length = value;
req->zero = value < w_length;
spin_unlock (&dev->lock);
value = usb_ep_queue (gadget->ep0, req, GFP_KERNEL);
if (value < 0) {
DBG (dev, "ep_queue --> %d\n", value);
req->status = 0;
}
return value;
}
/* device stalls when value < 0 */
spin_unlock (&dev->lock);
return value;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david brownell | david brownell | 829 | 92.83% | 10 | 58.82% |
bin liu | bin liu | 29 | 3.25% | 1 | 5.88% |
sebastian andrzej siewior | sebastian andrzej siewior | 14 | 1.57% | 1 | 5.88% |
peter chen | peter chen | 7 | 0.78% | 1 | 5.88% |
roy hashimoto | roy hashimoto | 6 | 0.67% | 1 | 5.88% |
alan stern | alan stern | 6 | 0.67% | 1 | 5.88% |
paul bolle | paul bolle | 1 | 0.11% | 1 | 5.88% |
al viro | al viro | 1 | 0.11% | 1 | 5.88% |
| Total | 893 | 100.00% | 17 | 100.00% |
static void destroy_ep_files (struct dev_data *dev)
{
DBG (dev, "%s %d\n", __func__, dev->state);
/* dev->state must prevent interference */
spin_lock_irq (&dev->lock);
while (!list_empty(&dev->epfiles)) {
struct ep_data *ep;
struct inode *parent;
struct dentry *dentry;
/* break link to FS */
ep = list_first_entry (&dev->epfiles, struct ep_data, epfiles);
list_del_init (&ep->epfiles);
dentry = ep->dentry;
ep->dentry = NULL;
parent = d_inode(dentry->d_parent);
/* break link to controller */
if (ep->state == STATE_EP_ENABLED)
(void) usb_ep_disable (ep->ep);
ep->state = STATE_EP_UNBOUND;
usb_ep_free_request (ep->ep, ep->req);
ep->ep = NULL;
wake_up (&ep->wait);
put_ep (ep);
spin_unlock_irq (&dev->lock);
/* break link to dcache */
inode_lock(parent);
d_delete (dentry);
dput (dentry);
inode_unlock(parent);
spin_lock_irq (&dev->lock);
}
spin_unlock_irq (&dev->lock);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david brownell | david brownell | 176 | 85.44% | 1 | 16.67% |
al viro | al viro | 26 | 12.62% | 3 | 50.00% |
david howells | david howells | 3 | 1.46% | 1 | 16.67% |
harvey harrison | harvey harrison | 1 | 0.49% | 1 | 16.67% |
| Total | 206 | 100.00% | 6 | 100.00% |
static struct dentry *
gadgetfs_create_file (struct super_block *sb, char const *name,
void *data, const struct file_operations *fops);
static int activate_ep_files (struct dev_data *dev)
{
struct usb_ep *ep;
struct ep_data *data;
gadget_for_each_ep (ep, dev->gadget) {
data = kzalloc(sizeof(*data), GFP_KERNEL);
if (!data)
goto enomem0;
data->state = STATE_EP_DISABLED;
mutex_init(&data->lock);
init_waitqueue_head (&data->wait);
strncpy (data->name, ep->name, sizeof (data->name) - 1);
atomic_set (&data->count, 1);
data->dev = dev;
get_dev (dev);
data->ep = ep;
ep->driver_data = data;
data->req = usb_ep_alloc_request (ep, GFP_KERNEL);
if (!data->req)
goto enomem1;
data->dentry = gadgetfs_create_file (dev->sb, data->name,
data, &ep_io_operations);
if (!data->dentry)
goto enomem2;
list_add_tail (&data->epfiles, &dev->epfiles);
}
return 0;
enomem2:
usb_ep_free_request (ep, data->req);
enomem1:
put_dev (dev);
kfree (data);
enomem0:
DBG (dev, "%s enomem\n", __func__);
destroy_ep_files (dev);
return -ENOMEM;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david brownell | david brownell | 194 | 82.55% | 1 | 14.29% |
alan stern | alan stern | 32 | 13.62% | 1 | 14.29% |
eric sesterhenn | eric sesterhenn | 4 | 1.70% | 1 | 14.29% |
al viro | al viro | 3 | 1.28% | 2 | 28.57% |
harvey harrison | harvey harrison | 1 | 0.43% | 1 | 14.29% |
thomas gleixner | thomas gleixner | 1 | 0.43% | 1 | 14.29% |
| Total | 235 | 100.00% | 7 | 100.00% |
static void
gadgetfs_unbind (struct usb_gadget *gadget)
{
struct dev_data *dev = get_gadget_data (gadget);
DBG (dev, "%s\n", __func__);
spin_lock_irq (&dev->lock);
dev->state = STATE_DEV_UNBOUND;
spin_unlock_irq (&dev->lock);
destroy_ep_files (dev);
gadget->ep0->driver_data = NULL;
set_gadget_data (gadget, NULL);
/* we've already been disconnected ... no i/o is active */
if (dev->req)
usb_ep_free_request (gadget->ep0, dev->req);
DBG (dev, "%s done\n", __func__);
put_dev (dev);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david brownell | david brownell | 100 | 96.15% | 1 | 33.33% |
al viro | al viro | 2 | 1.92% | 1 | 33.33% |
harvey harrison | harvey harrison | 2 | 1.92% | 1 | 33.33% |
| Total | 104 | 100.00% | 3 | 100.00% |
static struct dev_data *the_device;
static int gadgetfs_bind(struct usb_gadget *gadget,
struct usb_gadget_driver *driver)
{
struct dev_data *dev = the_device;
if (!dev)
return -ESRCH;
if (0 != strcmp (CHIP, gadget->name)) {
pr_err("%s expected %s controller not %s\n",
shortname, CHIP, gadget->name);
return -ENODEV;
}
set_gadget_data (gadget, dev);
dev->gadget = gadget;
gadget->ep0->driver_data = dev;
/* preallocate control response and buffer */
dev->req = usb_ep_alloc_request (gadget->ep0, GFP_KERNEL);
if (!dev->req)
goto enomem;
dev->req->context = NULL;
dev->req->complete = epio_complete;
if (activate_ep_files (dev) < 0)
goto enomem;
INFO (dev, "bound to %s driver\n", gadget->name);
spin_lock_irq(&dev->lock);
dev->state = STATE_DEV_UNCONNECTED;
spin_unlock_irq(&dev->lock);
get_dev (dev);
return 0;
enomem:
gadgetfs_unbind (gadget);
return -ENOMEM;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david brownell | david brownell | 183 | 96.83% | 4 | 66.67% |
sebastian andrzej siewior | sebastian andrzej siewior | 5 | 2.65% | 1 | 16.67% |
al viro | al viro | 1 | 0.53% | 1 | 16.67% |
| Total | 189 | 100.00% | 6 | 100.00% |
static void
gadgetfs_disconnect (struct usb_gadget *gadget)
{
struct dev_data *dev = get_gadget_data (gadget);
unsigned long flags;
spin_lock_irqsave (&dev->lock, flags);
if (dev->state == STATE_DEV_UNCONNECTED)
goto exit;
dev->state = STATE_DEV_UNCONNECTED;
INFO (dev, "disconnected\n");
next_event (dev, GADGETFS_DISCONNECT);
ep0_readable (dev);
exit:
spin_unlock_irqrestore (&dev->lock, flags);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david brownell | david brownell | 61 | 73.49% | 2 | 50.00% |
milan svoboda | milan svoboda | 12 | 14.46% | 1 | 25.00% |
marc kleine-budde | marc kleine-budde | 10 | 12.05% | 1 | 25.00% |
| Total | 83 | 100.00% | 4 | 100.00% |
static void
gadgetfs_suspend (struct usb_gadget *gadget)
{
struct dev_data *dev = get_gadget_data (gadget);
INFO (dev, "suspended from state %d\n", dev->state);
spin_lock (&dev->lock);
switch (dev->state) {
case STATE_DEV_SETUP: // VERY odd... host died??
case STATE_DEV_CONNECTED:
case STATE_DEV_UNCONNECTED:
next_event (dev, GADGETFS_SUSPEND);
ep0_readable (dev);
/* FALLTHROUGH */
default:
break;
}
spin_unlock (&dev->lock);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david brownell | david brownell | 81 | 100.00% | 2 | 100.00% |
| Total | 81 | 100.00% | 2 | 100.00% |
static struct usb_gadget_driver gadgetfs_driver = {
.function = (char *) driver_desc,
.bind = gadgetfs_bind,
.unbind = gadgetfs_unbind,
.setup = gadgetfs_setup,
.reset = gadgetfs_disconnect,
.disconnect = gadgetfs_disconnect,
.suspend = gadgetfs_suspend,
.driver = {
.name = (char *) shortname,
},
};
/*----------------------------------------------------------------------*/
/* DEVICE INITIALIZATION
*
* fd = open ("/dev/gadget/$CHIP", O_RDWR)
* status = write (fd, descriptors, sizeof descriptors)
*
* That write establishes the device configuration, so the kernel can
* bind to the controller ... guaranteeing it can handle enumeration
* at all necessary speeds. Descriptor order is:
*
* . message tag (u32, host order) ... for now, must be zero; it
* would change to support features like multi-config devices
* . full/low speed config ... all wTotalLength bytes (with interface,
* class, altsetting, endpoint, and other descriptors)
* . high speed config ... all descriptors, for high speed operation;
* this one's optional except for high-speed hardware
* . device descriptor
*
* Endpoints are not yet enabled. Drivers must wait until device
* configuration and interface altsetting changes create
* the need to configure (or unconfigure) them.
*
* After initialization, the device stays active for as long as that
* $CHIP file is open. Events must then be read from that descriptor,
* such as configuration notifications.
*/
static int is_valid_config (struct usb_config_descriptor *config)
{
return config->bDescriptorType == USB_DT_CONFIG
&& config->bLength == USB_DT_CONFIG_SIZE
&& config->bConfigurationValue != 0
&& (config->bmAttributes & USB_CONFIG_ATT_ONE) != 0
&& (config->bmAttributes & USB_CONFIG_ATT_WAKEUP) == 0;
/* FIXME if gadget->is_otg, _must_ include an otg descriptor */
/* FIXME check lengths: walk to end */
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david brownell | david brownell | 52 | 100.00% | 2 | 100.00% |
| Total | 52 | 100.00% | 2 | 100.00% |
static ssize_t
dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
{
struct dev_data *dev = fd->private_data;
ssize_t value = len, length = len;
unsigned total;
u32 tag;
char *kbuf;
spin_lock_irq(&dev->lock);
if (dev->state > STATE_DEV_OPENED) {
value = ep0_write(fd, buf, len, ptr);
spin_unlock_irq(&dev->lock);
return value;
}
spin_unlock_irq(&dev->lock);
if (len < (USB_DT_CONFIG_SIZE + USB_DT_DEVICE_SIZE + 4))
return -EINVAL;
/* we might need to change message format someday */
if (copy_from_user (&tag, buf, 4))
return -EFAULT;
if (tag != 0)
return -EINVAL;
buf += 4;
length -= 4;
kbuf = memdup_user(buf, length);
if (IS_ERR(kbuf))
return PTR_ERR(kbuf);
spin_lock_irq (&dev->lock);
value = -EINVAL;
if (dev->buf)
goto fail;
dev->buf = kbuf;
/* full or low speed config */
dev->config = (void *) kbuf;
total = le16_to_cpu(dev->config->wTotalLength);
if (!is_valid_config (dev->config) || total >= length)
goto fail;
kbuf += total;
length -= total;
/* optional high speed config */
if (kbuf [1] == USB_DT_CONFIG) {
dev->hs_config = (void *) kbuf;
total = le16_to_cpu(dev->hs_config->wTotalLength);
if (!is_valid_config (dev->hs_config) || total >= length)
goto fail;
kbuf += total;
length -= total;
}
/* could support multiple configs, using another encoding! */
/* device descriptor (tweaked for paranoia) */
if (length != USB_DT_DEVICE_SIZE)
goto fail;
dev->dev = (void *)kbuf;
if (dev->dev->bLength != USB_DT_DEVICE_SIZE
|| dev->dev->bDescriptorType != USB_DT_DEVICE
|| dev->dev->bNumConfigurations != 1)
goto fail;
dev->dev->bNumConfigurations = 1;
dev->dev->bcdUSB = cpu_to_le16 (0x0200);
/* triggers gadgetfs_bind(); then we can enumerate. */
spin_unlock_irq (&dev->lock);
if (dev->hs_config)
gadgetfs_driver.max_speed = USB_SPEED_HIGH;
else
gadgetfs_driver.max_speed = USB_SPEED_FULL;
value = usb_gadget_probe_driver(&gadgetfs_driver);
if (value != 0) {
kfree (dev->buf);
dev->buf = NULL;
} else {
/* at this point "good" hardware has for the first time
* let the USB the host see us. alternatively, if users
* unplug/replug that will clear all the error state.
*
* note: everything running before here was guaranteed
* to choke driver model style diagnostics. from here
* on, they can work ... except in cleanup paths that
* kick in after the ep0 descriptor is closed.
*/
value = len;
dev->gadget_registered = true;
}
return value;
fail:
spin_unlock_irq (&dev->lock);
pr_debug ("%s: %s fail %Zd, %p\n", shortname, __func__, value, dev);
kfree (dev->buf);
dev->buf = NULL;
return value;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david brownell | david brownell | 402 | 82.04% | 2 | 16.67% |
alan stern | alan stern | 50 | 10.20% | 1 | 8.33% |
michal nazarewicz | michal nazarewicz | 19 | 3.88% | 1 | 8.33% |
julia lawall | julia lawall | 6 | 1.22% | 1 | 8.33% |
marek szyprowski | marek szyprowski | 6 | 1.22% | 1 | 8.33% |
al viro | al viro | 3 | 0.61% | 2 | 16.67% |
harvey harrison | harvey harrison | 2 | 0.41% | 2 | 16.67% |
greg kroah-hartman | greg kroah-hartman | 1 | 0.20% | 1 | 8.33% |
uwe kleine-koenig | uwe kleine-koenig | 1 | 0.20% | 1 | 8.33% |
| Total | 490 | 100.00% | 12 | 100.00% |
static int
dev_open (struct inode *inode, struct file *fd)
{
struct dev_data *dev = inode->i_private;
int value = -EBUSY;
spin_lock_irq(&dev->lock);
if (dev->state == STATE_DEV_DISABLED) {
dev->ev_next = 0;
dev->state = STATE_DEV_OPENED;
fd->private_data = dev;
get_dev (dev);
value = 0;
}
spin_unlock_irq(&dev->lock);
return value;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david brownell | david brownell | 86 | 98.85% | 2 | 66.67% |
theodore tso | theodore tso | 1 | 1.15% | 1 | 33.33% |
| Total | 87 | 100.00% | 3 | 100.00% |
static const struct file_operations ep0_operations = {
.llseek = no_llseek,
.open = dev_open,
.read = ep0_read,
.write = dev_config,
.fasync = ep0_fasync,
.poll = ep0_poll,
.unlocked_ioctl = dev_ioctl,
.release = dev_release,
};
/*----------------------------------------------------------------------*/
/* FILESYSTEM AND SUPERBLOCK OPERATIONS
*
* Mounting the filesystem creates a controller file, used first for
* device configuration then later for event monitoring.
*/
/* FIXME PAM etc could set this security policy without mount options
* if epfiles inherited ownership and permissons from ep0 ...
*/
static unsigned default_uid;
static unsigned default_gid;
static unsigned default_perm = S_IRUSR | S_IWUSR;
module_param (default_uid, uint, 0644);
module_param (default_gid, uint, 0644);
module_param (default_perm, uint, 0644);
static struct inode *
gadgetfs_make_inode (struct super_block *sb,
void *data, const struct file_operations *fops,
int mode)
{
struct inode *inode = new_inode (sb);
if (inode) {
inode->i_ino = get_next_ino();
inode->i_mode = mode;
inode->i_uid = make_kuid(&init_user_ns, default_uid);
inode->i_gid = make_kgid(&init_user_ns, default_gid);
inode->i_atime = inode->i_mtime = inode->i_ctime
= CURRENT_TIME;
inode->i_private = data;
inode->i_fop = fops;
}
return inode;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david brownell | david brownell | 87 | 80.56% | 1 | 20.00% |
eric w. biederman | eric w. biederman | 12 | 11.11% | 1 | 20.00% |
christoph hellwig | christoph hellwig | 7 | 6.48% | 1 | 20.00% |
arjan van de ven | arjan van de ven | 1 | 0.93% | 1 | 20.00% |
theodore tso | theodore tso | 1 | 0.93% | 1 | 20.00% |
| Total | 108 | 100.00% | 5 | 100.00% |
/* creates in fs root directory, so non-renamable and non-linkable.
* so inode and dentry are paired, until device reconfig.
*/
static struct dentry *
gadgetfs_create_file (struct super_block *sb, char const *name,
void *data, const struct file_operations *fops)
{
struct dentry *dentry;
struct inode *inode;
dentry = d_alloc_name(sb->s_root, name);
if (!dentry)
return NULL;
inode = gadgetfs_make_inode (sb, data, fops,
S_IFREG | (default_perm & S_IRWXUGO));
if (!inode) {
dput(dentry);
return NULL;
}
d_add (dentry, inode);
return dentry;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david brownell | david brownell | 94 | 93.07% | 1 | 20.00% |
al viro | al viro | 4 | 3.96% | 2 | 40.00% |
james morris | james morris | 2 | 1.98% | 1 | 20.00% |
arjan van de ven | arjan van de ven | 1 | 0.99% | 1 | 20.00% |
| Total | 101 | 100.00% | 5 | 100.00% |
static const struct super_operations gadget_fs_operations = {
.statfs = simple_statfs,
.drop_inode = generic_delete_inode,
};
static int
gadgetfs_fill_super (struct super_block *sb, void *opts, int silent)
{
struct inode *inode;
struct dev_data *dev;
if (the_device)
return -ESRCH;
CHIP = usb_get_gadget_udc_name();
if (!CHIP)
return -ENODEV;
/* superblock */
sb->s_blocksize = PAGE_SIZE;
sb->s_blocksize_bits = PAGE_SHIFT;
sb->s_magic = GADGETFS_MAGIC;
sb->s_op = &gadget_fs_operations;
sb->s_time_gran = 1;
/* root inode */
inode = gadgetfs_make_inode (sb,
NULL, &simple_dir_operations,
S_IFDIR | S_IRUGO | S_IXUGO);
if (!inode)
goto Enomem;
inode->i_op = &simple_dir_inode_operations;
if (!(sb->s_root = d_make_root (inode)))
goto Enomem;
/* the ep0 file is named after the controller we expect;
* user mode code can use it for sanity checks, like we do.
*/
dev = dev_new ();
if (!dev)
goto Enomem;
dev->sb = sb;
dev->dentry = gadgetfs_create_file(sb, CHIP, dev, &ep0_operations);
if (!dev->dentry) {
put_dev(dev);
goto Enomem;
}
/* other endpoint files are available after hardware setup,
* from binding to a controller.
*/
the_device = dev;
return 0;
Enomem:
return -ENOMEM;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david brownell | david brownell | 139 | 69.50% | 2 | 15.38% |
al viro | al viro | 31 | 15.50% | 5 | 38.46% |
alan stern | alan stern | 18 | 9.00% | 2 | 15.38% |
andi kleen | andi kleen | 6 | 3.00% | 1 | 7.69% |
lubomir rintel | lubomir rintel | 2 | 1.00% | 1 | 7.69% |
kirill a. shutemov | kirill a. shutemov | 2 | 1.00% | 1 | 7.69% |
marek szyprowski | marek szyprowski | 2 | 1.00% | 1 | 7.69% |
| Total | 200 | 100.00% | 13 | 100.00% |
/* "mount -t gadgetfs path /dev/gadget" ends up here */
static struct dentry *
gadgetfs_mount (struct file_system_type *t, int flags,
const char *path, void *opts)
{
return mount_single (t, flags, opts, gadgetfs_fill_super);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david brownell | david brownell | 32 | 86.49% | 1 | 50.00% |
al viro | al viro | 5 | 13.51% | 1 | 50.00% |
| Total | 37 | 100.00% | 2 | 100.00% |
static void
gadgetfs_kill_sb (struct super_block *sb)
{
kill_litter_super (sb);
if (the_device) {
put_dev (the_device);
the_device = NULL;
}
kfree(CHIP);
CHIP = NULL;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david brownell | david brownell | 24 | 60.00% | 1 | 25.00% |
marek szyprowski | marek szyprowski | 9 | 22.50% | 1 | 25.00% |
al viro | al viro | 7 | 17.50% | 2 | 50.00% |
| Total | 40 | 100.00% | 4 | 100.00% |
/*----------------------------------------------------------------------*/
static struct file_system_type gadgetfs_type = {
.owner = THIS_MODULE,
.name = shortname,
.mount = gadgetfs_mount,
.kill_sb = gadgetfs_kill_sb,
};
MODULE_ALIAS_FS("gadgetfs");
/*----------------------------------------------------------------------*/
static int __init init (void)
{
int status;
status = register_filesystem (&gadgetfs_type);
if (status == 0)
pr_info ("%s: %s, version " DRIVER_VERSION "\n",
shortname, driver_desc);
return status;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david brownell | david brownell | 40 | 100.00% | 1 | 100.00% |
| Total | 40 | 100.00% | 1 | 100.00% |
module_init (init);
static void __exit cleanup (void)
{
pr_debug ("unregister %s\n", shortname);
unregister_filesystem (&gadgetfs_type);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david brownell | david brownell | 22 | 100.00% | 1 | 100.00% |
| Total | 22 | 100.00% | 1 | 100.00% |
module_exit (cleanup);
Overall Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david brownell | david brownell | 7138 | 79.74% | 18 | 20.45% |
al viro | al viro | 1033 | 11.54% | 13 | 14.77% |
alan stern | alan stern | 179 | 2.00% | 5 | 5.68% |
milan svoboda | milan svoboda | 148 | 1.65% | 3 | 3.41% |
zach brown | zach brown | 99 | 1.11% | 1 | 1.14% |
bin liu | bin liu | 48 | 0.54% | 1 | 1.14% |
sebastian andrzej siewior | sebastian andrzej siewior | 30 | 0.34% | 3 | 3.41% |
marek szyprowski | marek szyprowski | 27 | 0.30% | 2 | 2.27% |
marcus nutzinger | marcus nutzinger | 23 | 0.26% | 1 | 1.14% |
michal nazarewicz | michal nazarewicz | 19 | 0.21% | 1 | 1.14% |
eric w. biederman | eric w. biederman | 17 | 0.19% | 2 | 2.27% |
christoph hellwig | christoph hellwig | 16 | 0.18% | 3 | 3.41% |
thomas gleixner | thomas gleixner | 15 | 0.17% | 1 | 1.14% |
alan cox | alan cox | 13 | 0.15% | 1 | 1.14% |
peter chen | peter chen | 12 | 0.13% | 2 | 2.27% |
matthias kaehlcke | matthias kaehlcke | 12 | 0.13% | 1 | 1.14% |
greg kroah-hartman | greg kroah-hartman | 11 | 0.12% | 2 | 2.27% |
harvey harrison | harvey harrison | 11 | 0.12% | 2 | 2.27% |
marc kleine-budde | marc kleine-budde | 10 | 0.11% | 1 | 1.14% |
badari pulavarty | badari pulavarty | 9 | 0.10% | 1 | 1.14% |
eric sesterhenn | eric sesterhenn | 8 | 0.09% | 1 | 1.14% |
tatyana brokhman | tatyana brokhman | 8 | 0.09% | 1 | 1.14% |
david eccher | david eccher | 7 | 0.08% | 1 | 1.14% |
andi kleen | andi kleen | 6 | 0.07% | 1 | 1.14% |
julia lawall | julia lawall | 6 | 0.07% | 1 | 1.14% |
phil endecott | phil endecott | 6 | 0.07% | 1 | 1.14% |
roy hashimoto | roy hashimoto | 6 | 0.07% | 1 | 1.14% |
thomas faber | thomas faber | 5 | 0.06% | 1 | 1.14% |
alexey dobriyan | alexey dobriyan | 4 | 0.04% | 2 | 2.27% |
arjan van de ven | arjan van de ven | 3 | 0.03% | 1 | 1.14% |
david howells | david howells | 3 | 0.03% | 1 | 1.14% |
theodore tso | theodore tso | 3 | 0.03% | 1 | 1.14% |
kent overstreet | kent overstreet | 3 | 0.03% | 1 | 1.14% |
james morris | james morris | 2 | 0.02% | 1 | 1.14% |
kirill a. shutemov | kirill a. shutemov | 2 | 0.02% | 1 | 1.14% |
luiz fernando capitulino | luiz fernando capitulino | 2 | 0.02% | 1 | 1.14% |
lubomir rintel | lubomir rintel | 2 | 0.02% | 1 | 1.14% |
russell king | russell king | 1 | 0.01% | 1 | 1.14% |
klaus schwarzkopf | klaus schwarzkopf | 1 | 0.01% | 1 | 1.14% |
peter zijlstra | peter zijlstra | 1 | 0.01% | 1 | 1.14% |
paul bolle | paul bolle | 1 | 0.01% | 1 | 1.14% |
steven cole | steven cole | 1 | 0.01% | 1 | 1.14% |
uwe kleine-koenig | uwe kleine-koenig | 1 | 0.01% | 1 | 1.14% |
| Total | 8952 | 100.00% | 88 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.