From: Konrad Rzeszutek Wilk Date: Mon, 7 May 2012 20:39:42 +0000 (-0400) Subject: Revert "xen-blkfront: properly name all devices" X-Git-Tag: next-20120724~28^2~20 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=85704d1bed09007b8f7a6befbc79d80b64c41b8a;p=karo-tx-linux.git Revert "xen-blkfront: properly name all devices" This reverts commit 85b69847972081cd5fabf2136d6eb10a0fb4d9f2. [as it should go through Jen's tree] --- diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index 7dae9c38821a..6cd6a08b49a0 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c @@ -538,14 +538,6 @@ static int xen_translate_vdev(int vdevice, int *minor, unsigned int *offset) return 0; } -static char *encode_disk_name(char *ptr, unsigned int n) -{ - if (n >= 26) - ptr = encode_disk_name(ptr, n / 26 - 1); - *ptr = 'a' + n % 26; - return ptr + 1; -} - static int xlvbd_alloc_gendisk(blkif_sector_t capacity, struct blkfront_info *info, u16 vdisk_info, u16 sector_size) @@ -556,7 +548,6 @@ static int xlvbd_alloc_gendisk(blkif_sector_t capacity, unsigned int offset; int minor; int nr_parts; - char *ptr; BUG_ON(info->gd != NULL); BUG_ON(info->rq != NULL); @@ -581,11 +572,7 @@ static int xlvbd_alloc_gendisk(blkif_sector_t capacity, "emulated IDE disks,\n\t choose an xvd device name" "from xvde on\n", info->vdevice); } - if (minor >> MINORBITS) { - pr_warn("blkfront: %#x's minor (%#x) out of range; ignoring\n", - info->vdevice, minor); - return -ENODEV; - } + err = -ENODEV; if ((minor % nr_parts) == 0) nr_minors = nr_parts; @@ -599,14 +586,23 @@ static int xlvbd_alloc_gendisk(blkif_sector_t capacity, if (gd == NULL) goto release; - strcpy(gd->disk_name, DEV_NAME); - ptr = encode_disk_name(gd->disk_name + sizeof(DEV_NAME) - 1, offset); - BUG_ON(ptr >= gd->disk_name + DISK_NAME_LEN); - if (nr_minors > 1) - *ptr = 0; - else - snprintf(ptr, gd->disk_name + DISK_NAME_LEN - ptr, - "%d", minor & (nr_parts - 1)); + if (nr_minors > 1) { + if (offset < 26) + sprintf(gd->disk_name, "%s%c", DEV_NAME, 'a' + offset); + else + sprintf(gd->disk_name, "%s%c%c", DEV_NAME, + 'a' + ((offset / 26)-1), 'a' + (offset % 26)); + } else { + if (offset < 26) + sprintf(gd->disk_name, "%s%c%d", DEV_NAME, + 'a' + offset, + minor & (nr_parts - 1)); + else + sprintf(gd->disk_name, "%s%c%c%d", DEV_NAME, + 'a' + ((offset / 26) - 1), + 'a' + (offset % 26), + minor & (nr_parts - 1)); + } gd->major = XENVBD_MAJOR; gd->first_minor = minor;