USB: usb-skeleton.c: cleanup open_count
It is not necessary to use the 'open_count' for handling runtime pm only, because runtinme pm has built-in counter to handle this, so remove it to make code clean. Signed-off-by: Ming Lei <tom.leiming@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
26c71a79ca
commit
e28dbb0661
@@ -62,7 +62,6 @@ struct usb_skel {
|
|||||||
__u8 bulk_in_endpointAddr; /* the address of the bulk in endpoint */
|
__u8 bulk_in_endpointAddr; /* the address of the bulk in endpoint */
|
||||||
__u8 bulk_out_endpointAddr; /* the address of the bulk out endpoint */
|
__u8 bulk_out_endpointAddr; /* the address of the bulk out endpoint */
|
||||||
int errors; /* the last request tanked */
|
int errors; /* the last request tanked */
|
||||||
int open_count; /* count the number of openers */
|
|
||||||
bool ongoing_read; /* a read is going on */
|
bool ongoing_read; /* a read is going on */
|
||||||
bool processed_urb; /* indicates we haven't processed the urb */
|
bool processed_urb; /* indicates we haven't processed the urb */
|
||||||
spinlock_t err_lock; /* lock for errors */
|
spinlock_t err_lock; /* lock for errors */
|
||||||
@@ -122,22 +121,9 @@ static int skel_open(struct inode *inode, struct file *file)
|
|||||||
goto out_err;
|
goto out_err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dev->open_count++) {
|
|
||||||
retval = usb_autopm_get_interface(interface);
|
retval = usb_autopm_get_interface(interface);
|
||||||
if (retval) {
|
if (retval)
|
||||||
dev->open_count--;
|
goto out_err;
|
||||||
mutex_unlock(&dev->io_mutex);
|
|
||||||
kref_put(&dev->kref, skel_delete);
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
} /* else { //uncomment this block if you want exclusive open
|
|
||||||
retval = -EBUSY;
|
|
||||||
dev->open_count--;
|
|
||||||
mutex_unlock(&dev->io_mutex);
|
|
||||||
kref_put(&dev->kref, skel_delete);
|
|
||||||
goto exit;
|
|
||||||
} */
|
|
||||||
/* prevent the device from being autosuspended */
|
|
||||||
|
|
||||||
/* save our object in the file's private structure */
|
/* save our object in the file's private structure */
|
||||||
file->private_data = dev;
|
file->private_data = dev;
|
||||||
@@ -161,7 +147,7 @@ static int skel_release(struct inode *inode, struct file *file)
|
|||||||
|
|
||||||
/* allow the device to be autosuspended */
|
/* allow the device to be autosuspended */
|
||||||
mutex_lock(&dev->io_mutex);
|
mutex_lock(&dev->io_mutex);
|
||||||
if (!--dev->open_count && dev->interface)
|
if (dev->interface)
|
||||||
usb_autopm_put_interface(dev->interface);
|
usb_autopm_put_interface(dev->interface);
|
||||||
mutex_unlock(&dev->io_mutex);
|
mutex_unlock(&dev->io_mutex);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user