From bf444155b235adcba569046ec68a5484bc48e8f4 Mon Sep 17 00:00:00 2001 From: Alexander Viro Date: Wed, 4 Feb 2004 17:25:22 -0800 Subject: [PATCH] [PATCH] paride cleanup and fixes (21/25) Moved allocation and setup (but not adding) of gendisk into pd_probe_drive(). --- drivers/block/paride/pd.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/block/paride/pd.c b/drivers/block/paride/pd.c index 810846ad7a54f..a46c2cc8b349c 100644 --- a/drivers/block/paride/pd.c +++ b/drivers/block/paride/pd.c @@ -866,13 +866,26 @@ static struct block_device_operations pd_fops = { static int pd_probe_drive(struct pd_unit *disk) { + struct gendisk *p = alloc_disk(1 << PD_BITS); + if (!p) + return 0; + strcpy(p->disk_name, disk->name); + p->fops = &pd_fops; + p->major = major; + p->first_minor = (disk - pd) << PD_BITS; + disk->gd = p; + p->private_data = disk; + p->queue = pd_queue; + if (disk->drive == -1) { for (disk->drive = 0; disk->drive <= 1; disk->drive++) if (pd_identify(disk)) return 1; - return 0; - } - return pd_identify(disk); + } else if (pd_identify(disk)) + return 1; + disk->gd = NULL; + put_disk(p); + return 0; } static int pd_detect(void) @@ -910,21 +923,8 @@ static int pd_detect(void) } for (unit = 0, disk = pd; unit < PD_UNITS; unit++, disk++) { if (disk->present) { - struct gendisk *p = alloc_disk(1 << PD_BITS); - if (!p) { - disk->present = 0; - k--; - continue; - } - strcpy(p->disk_name, disk->name); - p->fops = &pd_fops; - p->major = major; - p->first_minor = unit << PD_BITS; - set_capacity(p, disk->capacity); - disk->gd = p; - p->private_data = disk; - p->queue = pd_queue; - add_disk(p); + set_capacity(disk->gd, disk->capacity); + add_disk(disk->gd); } } if (k) -- 2.53.0