Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fe81e5ee authored by Pavankumar Kondeti's avatar Pavankumar Kondeti
Browse files

USB: android: Allow multiple luns creation during init



The current code assumes that there is only one lun created
during init. If more luns are created during init, the dynamic
luns creation is failing due to kobjects duplication.

Change-Id: Ic8003c4c76545cbe19705345a58f25ceea83b3db
Signed-off-by: default avatarPavankumar Kondeti <pkondeti@codeaurora.org>
parent b5c75c4d
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -2282,7 +2282,7 @@ static void mass_storage_function_enable(struct android_usb_function *f)
	struct mass_storage_function_config *config = f->config;
	struct fsg_common *common = config->common;
	char *lun_type;
	int i, err;
	int i, err, prev_nluns;
	char buf[MAX_LUN_STR_LEN], *b;
	int number_of_luns = 0;
	char buf1[5];
@@ -2292,6 +2292,8 @@ static void mass_storage_function_enable(struct android_usb_function *f)
	if (msc_initialized)
		return;

	prev_nluns = config->fsg.nluns;

	if (lun_info[0] != '\0') {
		strlcpy(buf, lun_info, sizeof(buf));
		b = strim(buf);
@@ -2316,14 +2318,14 @@ static void mass_storage_function_enable(struct android_usb_function *f)
	}

	pr_debug("fsg.nluns:%d\n", config->fsg.nluns);
	for (i = 1; i < config->fsg.nluns; i++) {
		snprintf(lun_name, sizeof(buf), "lun%d", (i-1));
	for (i = prev_nluns; i < config->fsg.nluns; i++) {
		snprintf(lun_name, sizeof(buf), "lun%d", (i-prev_nluns));
		pr_debug("sysfs: LUN name:%s\n", lun_name);
		err = sysfs_create_link(&f->dev->kobj,
			&common->luns[i].dev.kobj, lun_name);
		if (err)
			pr_err("sysfs file creation failed: lun%d err:%d\n",
								i, err);
							(i-prev_nluns), err);
	}

	msc_initialized = 1;
+2 −4
Original line number Diff line number Diff line
@@ -2782,10 +2782,8 @@ static int create_lun_device(struct fsg_common *common,
	 * Check if index is non-zero, increment current lun_config
	 * and cur_lun pointers.
	 */
	if (add_lun_index) {
		lcfg++;
		curlun++;
	}
	lcfg += add_lun_index;
	curlun += add_lun_index;

	for (i = add_lun_index; i < nluns; ++i, ++curlun, ++lcfg) {
		curlun->cdrom = !!lcfg->cdrom;