Commit 135c1870 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] paride cleanup and fixes (22/25)

Now disk->present is not needed - we can always check for disk->gd.
Field removed, pd_probe_drive() became void(struct pd_unit *), pd_detect()
cleaned up,
parent bf444155
...@@ -252,7 +252,6 @@ struct pd_unit { ...@@ -252,7 +252,6 @@ struct pd_unit {
int removable; /* removable media device ? */ int removable; /* removable media device ? */
int standby; int standby;
int alt_geom; int alt_geom;
int present;
char name[PD_NAMELEN]; /* pda, pdb, etc ... */ char name[PD_NAMELEN]; /* pda, pdb, etc ... */
struct gendisk *gd; struct gendisk *gd;
}; };
...@@ -279,7 +278,6 @@ static void pd_init_units(void) ...@@ -279,7 +278,6 @@ static void pd_init_units(void)
disk->changed = 1; disk->changed = 1;
disk->capacity = 0; disk->capacity = 0;
disk->drive = parm[D_SLV]; disk->drive = parm[D_SLV];
disk->present = 0;
snprintf(disk->name, PD_NAMELEN, "%s%c", name, 'a'+unit); snprintf(disk->name, PD_NAMELEN, "%s%c", name, 'a'+unit);
disk->alt_geom = parm[D_GEO]; disk->alt_geom = parm[D_GEO];
disk->standby = parm[D_SBY]; disk->standby = parm[D_SBY];
...@@ -864,11 +862,11 @@ static struct block_device_operations pd_fops = { ...@@ -864,11 +862,11 @@ static struct block_device_operations pd_fops = {
.revalidate_disk= pd_revalidate .revalidate_disk= pd_revalidate
}; };
static int pd_probe_drive(struct pd_unit *disk) static void pd_probe_drive(struct pd_unit *disk)
{ {
struct gendisk *p = alloc_disk(1 << PD_BITS); struct gendisk *p = alloc_disk(1 << PD_BITS);
if (!p) if (!p)
return 0; return;
strcpy(p->disk_name, disk->name); strcpy(p->disk_name, disk->name);
p->fops = &pd_fops; p->fops = &pd_fops;
p->major = major; p->major = major;
...@@ -880,28 +878,24 @@ static int pd_probe_drive(struct pd_unit *disk) ...@@ -880,28 +878,24 @@ static int pd_probe_drive(struct pd_unit *disk)
if (disk->drive == -1) { if (disk->drive == -1) {
for (disk->drive = 0; disk->drive <= 1; disk->drive++) for (disk->drive = 0; disk->drive <= 1; disk->drive++)
if (pd_identify(disk)) if (pd_identify(disk))
return 1; return;
} else if (pd_identify(disk)) } else if (pd_identify(disk))
return 1; return;
disk->gd = NULL; disk->gd = NULL;
put_disk(p); put_disk(p);
return 0;
} }
static int pd_detect(void) static int pd_detect(void)
{ {
int k, unit; int found = 0, unit;
struct pd_unit *disk; struct pd_unit *disk;
k = 0;
if (pd_drive_count == 0) { /* nothing spec'd - so autoprobe for 1 */ if (pd_drive_count == 0) { /* nothing spec'd - so autoprobe for 1 */
disk = pd; disk = pd;
if (pi_init(disk->pi, 1, -1, -1, -1, -1, -1, pd_scratch, if (pi_init(disk->pi, 1, -1, -1, -1, -1, -1, pd_scratch,
PI_PD, verbose, disk->name)) { PI_PD, verbose, disk->name)) {
if (pd_probe_drive(disk)) { pd_probe_drive(disk);
disk->present = 1; if (!disk->gd)
k = 1;
} else
pi_release(disk->pi); pi_release(disk->pi);
} }
...@@ -913,24 +907,22 @@ static int pd_detect(void) ...@@ -913,24 +907,22 @@ static int pd_detect(void)
if (pi_init(disk->pi, 0, parm[D_PRT], parm[D_MOD], if (pi_init(disk->pi, 0, parm[D_PRT], parm[D_MOD],
parm[D_UNI], parm[D_PRO], parm[D_DLY], parm[D_UNI], parm[D_PRO], parm[D_DLY],
pd_scratch, PI_PD, verbose, disk->name)) { pd_scratch, PI_PD, verbose, disk->name)) {
if (pd_probe_drive(disk)) { pd_probe_drive(disk);
disk->present = 1; if (!disk->gd)
k = unit + 1;
} else
pi_release(disk->pi); pi_release(disk->pi);
} }
} }
} }
for (unit = 0, disk = pd; unit < PD_UNITS; unit++, disk++) { for (unit = 0, disk = pd; unit < PD_UNITS; unit++, disk++) {
if (disk->present) { if (disk->gd) {
set_capacity(disk->gd, disk->capacity); set_capacity(disk->gd, disk->capacity);
add_disk(disk->gd); add_disk(disk->gd);
found = 1;
} }
} }
if (k) if (!found)
return 1;
printk("%s: no valid drive found\n", name); printk("%s: no valid drive found\n", name);
return 0; return found;
} }
static int __init pd_init(void) static int __init pd_init(void)
...@@ -969,8 +961,8 @@ static void __exit pd_exit(void) ...@@ -969,8 +961,8 @@ static void __exit pd_exit(void)
int unit; int unit;
unregister_blkdev(major, name); unregister_blkdev(major, name);
for (unit = 0, disk = pd; unit < PD_UNITS; unit++, disk++) { for (unit = 0, disk = pd; unit < PD_UNITS; unit++, disk++) {
if (disk->present) {
struct gendisk *p = disk->gd; struct gendisk *p = disk->gd;
if (p) {
disk->gd = NULL; disk->gd = NULL;
del_gendisk(p); del_gendisk(p);
put_disk(p); put_disk(p);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment