[PATCH 3/3] USB: storage: register disks as usbdiskx symlink

Jean-Christophe PLAGNIOL-VILLARD plagnioj at jcrosoft.com
Fri Oct 18 12:33:12 EDT 2013


From: Sascha Hauer <s.hauer at pengutronix.de>

To better identify them as USB storage devices. Also make the
info message look nicer.

We keep the old disk%d to do not brake backword compatibility for env.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/usb/storage/usb.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index e4b08b9..6833983 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -25,6 +25,7 @@
 #include <scsi.h>
 #include <usb/usb.h>
 #include <usb/usb_defs.h>
+#include <linux/err.h>
 
 #undef USB_STOR_DEBUG
 
@@ -376,6 +377,7 @@ static int usb_stor_add_blkdev(struct us_data *us, struct device_d *dev,
 							unsigned char lun)
 {
 	struct us_blk_dev *pblk_dev;
+	struct cdev *cdev;
 	int result;
 
 	/* allocate a new USB block device */
@@ -406,6 +408,12 @@ static int usb_stor_add_blkdev(struct us_data *us, struct device_d *dev,
 		goto BadDevice;
 	}
 
+	cdev = devfs_add_symlink_index("usbdisk", &pblk_dev->blk.cdev);
+	if (IS_ERR(cdev))
+		dev_warn(dev, "Cannot create symlink usbdisk\n");
+	else
+		dev_info(dev, "registered /dev/%s\n", cdev->name);
+
 	/* create partitions on demand */
 	result = parse_partition_table(&pblk_dev->blk);
 	if (result != 0)
-- 
1.8.4.rc3




More information about the barebox mailing list