Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 185384
b: refs/heads/master
c: a79df50
h: refs/heads/master
v: v3
  • Loading branch information
Thomas Gleixner authored and Greg Kroah-Hartman committed Mar 2, 2010
1 parent 2ad2181 commit cdc21ed
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b00ce11f00c9e86442de000e8bd3dd42f089c8e1
refs/heads/master: a79df50bbad3b58efb5f2c730ca20573a674de10
39 changes: 21 additions & 18 deletions trunk/drivers/usb/gadget/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ enum ep_state {
};

struct ep_data {
struct semaphore lock;
struct mutex lock;
enum ep_state state;
atomic_t count;
struct dev_data *dev;
Expand Down Expand Up @@ -298,18 +298,19 @@ get_ready_ep (unsigned f_flags, struct ep_data *epdata)
int val;

if (f_flags & O_NONBLOCK) {
if (down_trylock (&epdata->lock) != 0)
if (!mutex_trylock(&epdata->lock))
goto nonblock;
if (epdata->state != STATE_EP_ENABLED) {
up (&epdata->lock);
mutex_unlock(&epdata->lock);
nonblock:
val = -EAGAIN;
} else
val = 0;
return val;
}

if ((val = down_interruptible (&epdata->lock)) < 0)
val = mutex_lock_interruptible(&epdata->lock);
if (val < 0)
return val;

switch (epdata->state) {
Expand All @@ -323,7 +324,7 @@ get_ready_ep (unsigned f_flags, struct ep_data *epdata)
// FALLTHROUGH
case STATE_EP_UNBOUND: /* clean disconnect */
val = -ENODEV;
up (&epdata->lock);
mutex_unlock(&epdata->lock);
}
return val;
}
Expand Down Expand Up @@ -393,7 +394,7 @@ ep_read (struct file *fd, char __user *buf, size_t len, loff_t *ptr)
if (likely (data->ep != NULL))
usb_ep_set_halt (data->ep);
spin_unlock_irq (&data->dev->lock);
up (&data->lock);
mutex_unlock(&data->lock);
return -EBADMSG;
}

Expand All @@ -411,7 +412,7 @@ ep_read (struct file *fd, char __user *buf, size_t len, loff_t *ptr)
value = -EFAULT;

free1:
up (&data->lock);
mutex_unlock(&data->lock);
kfree (kbuf);
return value;
}
Expand All @@ -436,7 +437,7 @@ ep_write (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
if (likely (data->ep != NULL))
usb_ep_set_halt (data->ep);
spin_unlock_irq (&data->dev->lock);
up (&data->lock);
mutex_unlock(&data->lock);
return -EBADMSG;
}

Expand All @@ -455,7 +456,7 @@ ep_write (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
VDEBUG (data->dev, "%s write %zu IN, status %d\n",
data->name, len, (int) value);
free1:
up (&data->lock);
mutex_unlock(&data->lock);
kfree (kbuf);
return value;
}
Expand All @@ -466,7 +467,8 @@ ep_release (struct inode *inode, struct file *fd)
struct ep_data *data = fd->private_data;
int value;

if ((value = down_interruptible(&data->lock)) < 0)
value = mutex_lock_interruptible(&data->lock);
if (value < 0)
return value;

/* clean up if this can be reopened */
Expand All @@ -476,7 +478,7 @@ ep_release (struct inode *inode, struct file *fd)
data->hs_desc.bDescriptorType = 0;
usb_ep_disable(data->ep);
}
up (&data->lock);
mutex_unlock(&data->lock);
put_ep (data);
return 0;
}
Expand Down Expand Up @@ -507,7 +509,7 @@ static long ep_ioctl(struct file *fd, unsigned code, unsigned long value)
} else
status = -ENODEV;
spin_unlock_irq (&data->dev->lock);
up (&data->lock);
mutex_unlock(&data->lock);
return status;
}

Expand Down Expand Up @@ -673,7 +675,7 @@ ep_aio_rwtail(
value = -ENODEV;
spin_unlock_irq(&epdata->dev->lock);

up(&epdata->lock);
mutex_unlock(&epdata->lock);

if (unlikely(value)) {
kfree(priv);
Expand Down Expand Up @@ -765,7 +767,8 @@ ep_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
u32 tag;
int value, length = len;

if ((value = down_interruptible (&data->lock)) < 0)
value = mutex_lock_interruptible(&data->lock);
if (value < 0)
return value;

if (data->state != STATE_EP_READY) {
Expand Down Expand Up @@ -854,7 +857,7 @@ ep_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
data->desc.bDescriptorType = 0;
data->hs_desc.bDescriptorType = 0;
}
up (&data->lock);
mutex_unlock(&data->lock);
return value;
fail0:
value = -EINVAL;
Expand All @@ -870,7 +873,7 @@ ep_open (struct inode *inode, struct file *fd)
struct ep_data *data = inode->i_private;
int value = -EBUSY;

if (down_interruptible (&data->lock) != 0)
if (mutex_lock_interruptible(&data->lock) != 0)
return -EINTR;
spin_lock_irq (&data->dev->lock);
if (data->dev->state == STATE_DEV_UNBOUND)
Expand All @@ -885,7 +888,7 @@ ep_open (struct inode *inode, struct file *fd)
DBG (data->dev, "%s state %d\n",
data->name, data->state);
spin_unlock_irq (&data->dev->lock);
up (&data->lock);
mutex_unlock(&data->lock);
return value;
}

Expand Down Expand Up @@ -1631,7 +1634,7 @@ static int activate_ep_files (struct dev_data *dev)
if (!data)
goto enomem0;
data->state = STATE_EP_DISABLED;
init_MUTEX (&data->lock);
mutex_init(&data->lock);
init_waitqueue_head (&data->wait);

strncpy (data->name, ep->name, sizeof (data->name) - 1);
Expand Down

0 comments on commit cdc21ed

Please sign in to comment.