aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/usb-skeleton.c
diff options
context:
space:
mode:
authorMing Lei <tom.leiming@gmail.com>2011-12-16 09:20:44 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2012-01-04 18:52:41 -0500
commite28dbb0661ca49ada2d6a307a1ec93dd75d515e0 (patch)
tree269aac42395eace3a010f77cd5fc29a328899d88 /drivers/usb/usb-skeleton.c
parent26c71a79cade5ccad80e0752cd82f3518df48fb3 (diff)
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>
Diffstat (limited to 'drivers/usb/usb-skeleton.c')
-rw-r--r--drivers/usb/usb-skeleton.c22
1 files changed, 4 insertions, 18 deletions
diff --git a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c
index 3635f9e37559..d9a95847ec1f 100644
--- a/drivers/usb/usb-skeleton.c
+++ b/drivers/usb/usb-skeleton.c
@@ -62,7 +62,6 @@ struct usb_skel {
62 __u8 bulk_in_endpointAddr; /* the address of the bulk in endpoint */ 62 __u8 bulk_in_endpointAddr; /* the address of the bulk in endpoint */
63 __u8 bulk_out_endpointAddr; /* the address of the bulk out endpoint */ 63 __u8 bulk_out_endpointAddr; /* the address of the bulk out endpoint */
64 int errors; /* the last request tanked */ 64 int errors; /* the last request tanked */
65 int open_count; /* count the number of openers */
66 bool ongoing_read; /* a read is going on */ 65 bool ongoing_read; /* a read is going on */
67 bool processed_urb; /* indicates we haven't processed the urb */ 66 bool processed_urb; /* indicates we haven't processed the urb */
68 spinlock_t err_lock; /* lock for errors */ 67 spinlock_t err_lock; /* lock for errors */
@@ -122,22 +121,9 @@ static int skel_open(struct inode *inode, struct file *file)
122 goto out_err; 121 goto out_err;
123 } 122 }
124 123
125 if (!dev->open_count++) { 124 retval = usb_autopm_get_interface(interface);
126 retval = usb_autopm_get_interface(interface); 125 if (retval)
127 if (retval) { 126 goto out_err;
128 dev->open_count--;
129 mutex_unlock(&dev->io_mutex);
130 kref_put(&dev->kref, skel_delete);
131 goto exit;
132 }
133 } /* else { //uncomment this block if you want exclusive open
134 retval = -EBUSY;
135 dev->open_count--;
136 mutex_unlock(&dev->io_mutex);
137 kref_put(&dev->kref, skel_delete);
138 goto exit;
139 } */
140 /* prevent the device from being autosuspended */
141 127
142 /* save our object in the file's private structure */ 128 /* save our object in the file's private structure */
143 file->private_data = dev; 129 file->private_data = dev;
@@ -161,7 +147,7 @@ static int skel_release(struct inode *inode, struct file *file)
161 147
162 /* allow the device to be autosuspended */ 148 /* allow the device to be autosuspended */
163 mutex_lock(&dev->io_mutex); 149 mutex_lock(&dev->io_mutex);
164 if (!--dev->open_count && dev->interface) 150 if (dev->interface)
165 usb_autopm_put_interface(dev->interface); 151 usb_autopm_put_interface(dev->interface);
166 mutex_unlock(&dev->io_mutex); 152 mutex_unlock(&dev->io_mutex);
167 153