diff options
Diffstat (limited to 'drivers/block/paride/pd.c')
-rw-r--r-- | drivers/block/paride/pd.c | 89 |
1 files changed, 32 insertions, 57 deletions
diff --git a/drivers/block/paride/pd.c b/drivers/block/paride/pd.c index 902e40a65..577d1354c 100644 --- a/drivers/block/paride/pd.c +++ b/drivers/block/paride/pd.c @@ -263,7 +263,6 @@ void pd_setup(char * str, int * ints); #ifdef MODULE void cleanup_module( void ); #endif -static void pd_geninit(struct gendisk *ignored); static int pd_open(struct inode *inode, struct file *file); static void do_pd_request(request_queue_t * q); static int pd_ioctl(struct inode *inode,struct file *file, @@ -345,8 +344,6 @@ static struct gendisk pd_gendisk = { PD_NAME, /* Major name */ PD_BITS, /* Bits to shift to get real from partition */ PD_PARTNS, /* Number of partitions per real */ - PD_UNITS, /* maximum number of real */ - pd_geninit, /* init function */ pd_hd, /* hd struct */ pd_sizes, /* block sizes */ 0, /* number */ @@ -401,26 +398,25 @@ int pd_init (void) pd_gendisk.major = major; pd_gendisk.major_name = name; pd_gendisk.next = gendisk_head; - gendisk_head = &pd_gendisk; + gendisk_head = &pd_gendisk; - for(i=0;i<PD_DEVS;i++) pd_blocksizes[i] = 1024; - blksize_size[MAJOR_NR] = pd_blocksizes; + for(i=0;i<PD_DEVS;i++) pd_blocksizes[i] = 1024; + blksize_size[MAJOR_NR] = pd_blocksizes; - printk("%s: %s version %s, major %d, cluster %d, nice %d\n", - name,name,PD_VERSION,major,cluster,nice); - - return 0; -} - -static void pd_geninit (struct gendisk *ignored) - -{ pd_init_units(); + printk("%s: %s version %s, major %d, cluster %d, nice %d\n", + name,name,PD_VERSION,major,cluster,nice); + pd_init_units(); + pd_valid = 0; pd_gendisk.nr_real = pd_detect(); + pd_valid = 1; #ifdef MODULE - if (!pd_gendisk.nr_real) cleanup_module(); + if (!pd_gendisk.nr_real) { + cleanup_module(); + return -1; + } #endif - + return 0; } static int pd_open (struct inode *inode, struct file *file) @@ -502,8 +498,6 @@ static int pd_release (struct inode *inode, struct file *file) { kdev_t devp; int unit; - struct super_block *sb; - devp = inode->i_rdev; unit = DEVICE_NR(devp); @@ -512,15 +506,8 @@ static int pd_release (struct inode *inode, struct file *file) PD.access--; - if (!PD.access) { - fsync_dev(devp); - - sb = get_super(devp); - if (sb) invalidate_inodes(sb); - - invalidate_buffers(devp); - if (PD.removable) pd_doorlock(unit,IDE_DOORUNLOCK); - } + if (!PD.access && PD.removable) + pd_doorlock(unit,IDE_DOORUNLOCK); MOD_DEC_USE_COUNT; @@ -573,8 +560,8 @@ static int pd_revalidate(kdev_t dev) pd_hd[minor].nr_sects = 0; } - pd_identify(unit); - resetup_one_dev(&pd_gendisk,unit); + if (pd_identify(unit)) + grok_partitions(&pd_gendisk,unit,1<<PD_BITS,PD.capacity); pd_valid = 1; wake_up(&pd_wait_open); @@ -597,20 +584,7 @@ int init_module(void) paride_init(); } #endif - - err = pd_init(); - if (err) return err; - - pd_geninit(&pd_gendisk); - - if (!pd_gendisk.nr_real) return -1; - - pd_valid = 0; - for (unit=0;unit<PD_UNITS;unit++) - if (PD.present) resetup_one_dev(&pd_gendisk,unit); - pd_valid = 1; - - return 0; + return pd_init(); } void cleanup_module(void) @@ -822,21 +796,19 @@ static int pd_identify( int unit ) if (PD.capacity) pd_init_dev_parms(unit); if (!PD.standby) pd_standby_off(unit); - - pd_hd[unit<<PD_BITS].nr_sects = PD.capacity; - pd_hd[unit<<PD_BITS].start_sect = 0; return 1; } static int pd_probe_drive( int unit ) - -{ if (PD.drive == -1) { - for (PD.drive=0;PD.drive<=1;PD.drive++) - if (pd_identify(unit)) return 1; - return 0; - } - else return pd_identify(unit); +{ + if (PD.drive == -1) { + for (PD.drive=0;PD.drive<=1;PD.drive++) + if (pd_identify(unit)) + return 1; + return 0; + } + return pd_identify(unit); } static int pd_detect( void ) @@ -863,15 +835,18 @@ static int pd_detect( void ) k = unit+1; } else pi_release(PI); } + for (unit=0;unit<PD_UNITS;unit++) + register_disk(&pd_gendisk,MKDEV(MAJOR_NR,unit<<PD_BITS), + PD_PARTNS,&pd_fops, + PD.present?PD.capacity:0); /* We lie about the number of drives found, as the generic partition scanner assumes that the drives are numbered sequentially from 0. This can result in some bogus error messages if non-sequential drive numbers are used. */ - - if (k) return k; - + if (k) + return k; printk("%s: no valid drive found\n",name); return 0; } |