mirror of
https://github.com/hardkernel/linux.git
synced 2026-04-19 20:10:43 +09:00
USB: gadget: f_mass_storage: Integrate android customizations
Integrate support for android composite driver and platform data within CONFIG_USB_ANDROID_MASS_STORAGE. Signed-off-by: Mike Lockwood <lockwood@android.com>
This commit is contained in:
committed by
Colin Cross
parent
7dc0be13b0
commit
ff9cdcd465
@@ -67,6 +67,6 @@ obj-$(CONFIG_USB_G_WEBCAM) += g_webcam.o
|
||||
obj-$(CONFIG_USB_ANDROID) += android.o
|
||||
obj-$(CONFIG_USB_ANDROID_ACM) += f_acm.o u_serial.o
|
||||
obj-$(CONFIG_USB_ANDROID_ADB) += f_adb.o
|
||||
obj-$(CONFIG_USB_ANDROID_MASS_STORAGE) += f_mass_storage_tmp.o
|
||||
obj-$(CONFIG_USB_ANDROID_MASS_STORAGE) += f_mass_storage.o
|
||||
obj-$(CONFIG_USB_ANDROID_RNDIS) += f_rndis.o u_ether.o
|
||||
|
||||
|
||||
@@ -295,7 +295,12 @@
|
||||
|
||||
#include "gadget_chips.h"
|
||||
|
||||
#ifdef CONFIG_USB_ANDROID_MASS_STORAGE
|
||||
#include <linux/usb/android_composite.h>
|
||||
#include <linux/platform_device.h>
|
||||
|
||||
#define FUNCTION_NAME "usb_mass_storage"
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
@@ -424,6 +429,10 @@ struct fsg_config {
|
||||
u16 release;
|
||||
|
||||
char can_stall;
|
||||
|
||||
#ifdef CONFIG_USB_ANDROID_MASS_STORAGE
|
||||
struct platform_device *pdev;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
@@ -2746,7 +2755,13 @@ static struct fsg_common *fsg_common_init(struct fsg_common *common,
|
||||
curlun->ro = lcfg->cdrom || lcfg->ro;
|
||||
curlun->removable = lcfg->removable;
|
||||
curlun->dev.release = fsg_lun_release;
|
||||
|
||||
#ifdef CONFIG_USB_ANDROID_MASS_STORAGE
|
||||
/* use "usb_mass_storage" platform device as parent */
|
||||
curlun->dev.parent = &cfg->pdev->dev;
|
||||
#else
|
||||
curlun->dev.parent = &gadget->dev;
|
||||
#endif
|
||||
/* curlun->dev.driver = &fsg_driver.driver; XXX */
|
||||
dev_set_drvdata(&curlun->dev, &common->filesem);
|
||||
dev_set_name(&curlun->dev,
|
||||
@@ -3029,7 +3044,11 @@ static int fsg_bind_config(struct usb_composite_dev *cdev,
|
||||
if (unlikely(!fsg))
|
||||
return -ENOMEM;
|
||||
|
||||
#ifdef CONFIG_USB_ANDROID_MASS_STORAGE
|
||||
fsg->function.name = FUNCTION_NAME;
|
||||
#else
|
||||
fsg->function.name = FSG_DRIVER_DESC;
|
||||
#endif
|
||||
fsg->function.strings = fsg_strings_array;
|
||||
fsg->function.bind = fsg_bind;
|
||||
fsg->function.unbind = fsg_unbind;
|
||||
@@ -3153,3 +3172,63 @@ fsg_common_from_params(struct fsg_common *common,
|
||||
return fsg_common_init(common, cdev, &cfg);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_USB_ANDROID_MASS_STORAGE
|
||||
|
||||
static struct fsg_config fsg_cfg;
|
||||
|
||||
static int __init fsg_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct usb_mass_storage_platform_data *pdata = pdev->dev.platform_data;
|
||||
int i, nluns;
|
||||
|
||||
printk(KERN_INFO "fsg_probe pdev: %p, pdata: %p\n", pdev, pdata);
|
||||
if (!pdata)
|
||||
return -1;
|
||||
|
||||
nluns = pdata->nluns;
|
||||
if (nluns > FSG_MAX_LUNS)
|
||||
nluns = FSG_MAX_LUNS;
|
||||
fsg_cfg.nluns = nluns;
|
||||
for (i = 0; i < nluns; i++)
|
||||
fsg_cfg.luns[i].removable = 1;
|
||||
|
||||
fsg_cfg.vendor_name = pdata->vendor;
|
||||
fsg_cfg.product_name = pdata->product;
|
||||
fsg_cfg.release = pdata->release;
|
||||
fsg_cfg.can_stall = 0;
|
||||
fsg_cfg.pdev = pdev;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct platform_driver fsg_platform_driver = {
|
||||
.driver = { .name = FUNCTION_NAME, },
|
||||
.probe = fsg_probe,
|
||||
};
|
||||
|
||||
int mass_storage_bind_config(struct usb_configuration *c)
|
||||
{
|
||||
struct fsg_common *common = fsg_common_init(NULL, c->cdev, &fsg_cfg);
|
||||
if (IS_ERR(common))
|
||||
return -1;
|
||||
return fsg_add(c->cdev, c, common);
|
||||
}
|
||||
|
||||
static struct android_usb_function mass_storage_function = {
|
||||
.name = FUNCTION_NAME,
|
||||
.bind_config = mass_storage_bind_config,
|
||||
};
|
||||
|
||||
static int __init init(void)
|
||||
{
|
||||
int rc;
|
||||
printk(KERN_INFO "f_mass_storage init\n");
|
||||
rc = platform_driver_register(&fsg_platform_driver);
|
||||
if (rc != 0)
|
||||
return rc;
|
||||
android_register_function(&mass_storage_function);
|
||||
return 0;
|
||||
}module_init(init);
|
||||
|
||||
#endif /* CONFIG_USB_ANDROID_MASS_STORAGE */
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user