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

Commit f4dfd154 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "drivers: soc: rename block device nodes"

parents 75f7b23e 9330da93
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -1156,5 +1156,14 @@ config QCOM_RTIC
	  will trigger RTIC kernel MP.s (measurement parameters) generation
	  during the kernel build.

config RENAME_BLOCK_DEVICE
	tristate "Rename block device node in /dev"
	default n
	help
	  Say 'Y' to to rename the block device node assigned by generic
	  driver to a name that is needed. This is used for rename block
	  device names created by default as sda1, sda2 etc. to the
	  names system is needed.this is applicable for block devices only.

source "drivers/soc/qcom/icnss2/Kconfig"
endmenu
+1 −0
Original line number Diff line number Diff line
@@ -104,3 +104,4 @@ obj-$(CONFIG_QTI_HW_MEMLAT_SCMI_CLIENT) += memlat_scmi.o
obj-$(CONFIG_QTI_HW_MEMLAT) += rimps_memlat.o
obj-$(CONFIG_QTI_HW_MEMLAT_LOG)	+= rimps_log.o
obj-$(CONFIG_QCOM_QFPROM_SYS) += qfprom-sys.o
obj-$(CONFIG_RENAME_BLOCK_DEVICE) += rename_block_device.o
+58 −0
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2021, The Linux Foundation. All rights reserved.
 */

#include <linux/init.h>
#include <linux/module.h>
#include <linux/mount.h>
#include <linux/genhd.h>
#include <linux/device.h>
#include <linux/of.h>
#define PATH_SIZE	32

static int rename_blk_dev_init(void)
{
	dev_t dev;
	int index = 0, partno;
	struct gendisk *disk;
	struct device_node *node;
	char dev_path[PATH_SIZE];
	const char *actual_name, *modified_name;

	node = of_find_compatible_node(NULL, NULL, "qcom,blkdev-rename");
	if (!node) {
		pr_err("qcom,blkdev-rename is missing\n");
		goto out;
	}
	while (!of_property_read_string_index(node, "actual-dev", index,
						&actual_name)) {
		memset(dev_path, '\0', PATH_SIZE);
		snprintf(dev_path, PATH_SIZE, "/dev/%s", actual_name);
		dev = name_to_dev_t(dev_path);
		if (!dev) {
			pr_err("No device path : %s\n", dev_path);
			return -EINVAL;
		}
		disk = get_gendisk(dev, &partno);
		if (!disk) {
			pr_err("No device with dev path : %s\n", dev_path);
			return -ENXIO;
		}
		if (!of_property_read_string_index(node, "rename-dev", index,
							&modified_name)) {
			device_rename(disk_to_dev(disk), modified_name);
		} else {
			pr_err("rename-dev for actual-dev = %s is missing\n",
								 actual_name);
			return -ENXIO;
		}
		index++;
	}
out:
	return  0;
}

late_initcall(rename_blk_dev_init);
MODULE_DESCRIPTION("Rename block devices");
MODULE_LICENSE("GPL v2");