From 0bc490b1b50ead698f8592dc6887135537b83e4a Mon Sep 17 00:00:00 2001 From: Daniel Hillenbrand Date: Tue, 28 May 2013 20:07:41 +0200 Subject: usb gadget: use two luns on devices with two cards - ported from Codeworkx's smdk4210 patch (https://github.com/CyanogenMod/android_kernel_samsung_smdk4210/commit/7f87bd61861a7c6dfc74c6f113f4df655b8925ff) - allows to use both internal and external sd-card as mass-storage on devices with two cards Change-Id: I3345097081bc1e306b8a63c0ae2b0edcccbff018 --- drivers/usb/gadget/android.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/gadget/android.c b/drivers/usb/gadget/android.c index c528f4b..f4c1ef3 100644 --- a/drivers/usb/gadget/android.c +++ b/drivers/usb/gadget/android.c @@ -689,7 +689,7 @@ static int mass_storage_function_init(struct android_usb_function *f, { struct mass_storage_function_config *config; struct fsg_common *common; - int err; + int err, i; #ifdef CONFIG_USB_ANDROID_SAMSUNG_COMPOSITE int i; unsigned int cdfs = 0; @@ -768,11 +768,16 @@ static int mass_storage_function_init(struct android_usb_function *f, } } else { #endif - /* original mainline code */ - printk(KERN_DEBUG "usb: %s pdata is not available. nluns=1\n", - __func__); + // default number of luns +#ifdef CONFIG_MACH_U1 + config->fsg.nluns = 2; +#else config->fsg.nluns = 1; - config->fsg.luns[0].removable = 1; +#endif + for (i = 0; i < config->fsg.nluns; i++) { + config->fsg.luns[i].removable = 1; + config->fsg.luns[i].nofua = 1; + } common = fsg_common_init(NULL, cdev, &config->fsg); if (IS_ERR(common)) { @@ -780,12 +785,20 @@ static int mass_storage_function_init(struct android_usb_function *f, return PTR_ERR(common); } - err = sysfs_create_link(&f->dev->kobj, - &common->luns[0].dev.kobj, - "lun"); - if (err) { - kfree(config); - return err; + for (i = 0; i < config->fsg.nluns; i++) { + char luns[5]; + err = snprintf(luns, 5, "lun%d", i); + if (err == 0) { + printk(KERN_ERR "usb: %s snprintf error\n", __func__); + return err; + } + err = sysfs_create_link(&f->dev->kobj, + &common->luns[i].dev.kobj, + luns); + if (err) { + kfree(config); + return err; + } } #ifdef CONFIG_USB_ANDROID_SAMSUNG_COMPOSITE } -- cgit v1.1