@@ -105,8 +105,6 @@ static int scatter_elem_sz_prev = SG_SCATTER_SZ;
105
105
static int sg_add (struct device * , struct class_interface * );
106
106
static void sg_remove (struct device * , struct class_interface * );
107
107
108
- static DEFINE_SPINLOCK (sg_open_exclusive_lock );
109
-
110
108
static DEFINE_IDR (sg_index_idr );
111
109
static DEFINE_RWLOCK (sg_index_lock ); /* Also used to lock
112
110
file descriptor list for device */
@@ -176,7 +174,6 @@ typedef struct sg_device { /* holds the state of each scsi generic device */
176
174
struct list_head sfds ;
177
175
struct rw_semaphore o_sem ; /* exclude open should hold this rwsem */
178
176
volatile char detached ; /* 0->attached, 1->detached pending removal */
179
- /* exclude protected by sg_open_exclusive_lock */
180
177
char exclude ; /* opened for exclusive access */
181
178
char sgdebug ; /* 0->off, 1->sense, 9->dump dev, 10-> all devs */
182
179
struct gendisk * disk ;
@@ -225,27 +222,6 @@ static int sg_allow_access(struct file *filp, unsigned char *cmd)
225
222
return blk_verify_command (cmd , filp -> f_mode & FMODE_WRITE );
226
223
}
227
224
228
- static int get_exclude (Sg_device * sdp )
229
- {
230
- unsigned long flags ;
231
- int ret ;
232
-
233
- spin_lock_irqsave (& sg_open_exclusive_lock , flags );
234
- ret = sdp -> exclude ;
235
- spin_unlock_irqrestore (& sg_open_exclusive_lock , flags );
236
- return ret ;
237
- }
238
-
239
- static int set_exclude (Sg_device * sdp , char val )
240
- {
241
- unsigned long flags ;
242
-
243
- spin_lock_irqsave (& sg_open_exclusive_lock , flags );
244
- sdp -> exclude = val ;
245
- spin_unlock_irqrestore (& sg_open_exclusive_lock , flags );
246
- return val ;
247
- }
248
-
249
225
static int sfds_list_empty (Sg_device * sdp )
250
226
{
251
227
unsigned long flags ;
@@ -317,7 +293,7 @@ sg_open(struct inode *inode, struct file *filp)
317
293
}
318
294
/* Since write lock is held, no need to check sfd_list */
319
295
if (flags & O_EXCL )
320
- set_exclude ( sdp , 1 );
296
+ sdp -> exclude = 1 ; /* used by release lock */
321
297
322
298
if (sdp -> detached ) {
323
299
retval = - ENODEV ;
@@ -337,7 +313,7 @@ sg_open(struct inode *inode, struct file *filp)
337
313
retval = - ENOMEM ;
338
314
sem_out :
339
315
if (flags & O_EXCL ) {
340
- set_exclude ( sdp , 0 ) ; /* undo if error */
316
+ sdp -> exclude = 0 ; /* undo if error */
341
317
up_write (& sdp -> o_sem );
342
318
} else
343
319
up_read (& sdp -> o_sem );
@@ -364,8 +340,8 @@ sg_release(struct inode *inode, struct file *filp)
364
340
return - ENXIO ;
365
341
SCSI_LOG_TIMEOUT (3 , printk ("sg_release: %s\n" , sdp -> disk -> disk_name ));
366
342
367
- excl = get_exclude ( sdp ) ;
368
- set_exclude ( sdp , 0 ) ;
343
+ excl = sdp -> exclude ;
344
+ sdp -> exclude = 0 ;
369
345
if (excl )
370
346
up_write (& sdp -> o_sem );
371
347
else
@@ -2622,7 +2598,7 @@ static int sg_proc_seq_show_debug(struct seq_file *s, void *v)
2622
2598
scsidp -> lun ,
2623
2599
scsidp -> host -> hostt -> emulated );
2624
2600
seq_printf (s , " sg_tablesize=%d excl=%d\n" ,
2625
- sdp -> sg_tablesize , get_exclude ( sdp ) );
2601
+ sdp -> sg_tablesize , sdp -> exclude );
2626
2602
sg_proc_debug_helper (s , sdp );
2627
2603
}
2628
2604
read_unlock_irqrestore (& sg_index_lock , iflags );
0 commit comments