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

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

Merge "drivers: soc: rename block device nodes"

parents 0b8553d1 33755305
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -1061,4 +1061,10 @@ config QCOM_HYP_CORE_CTL
	  An offline CPU is considered as a reserved CPU since this OS can't use
	  it.

config RENAME_BLOCK_DEVICE
	bool "Rename block device node in /dev"
	help
	  This driver is used to rename the block device node assigned by generic driver
	  to a name that is needed.

source "drivers/soc/qcom/wcnss/Kconfig"
+1 −0
Original line number Diff line number Diff line
@@ -118,3 +118,4 @@ obj-$(CONFIG_QCOM_ADSP_MANUAL_VOTE) += adsp_vote_qmi.o adsp_lpm_voting_v01.o
obj-$(CONFIG_CPU_V7) += idle-v7.o
obj-$(CONFIG_MSM_BAM_DMUX) += bam_dmux.o
obj-$(CONFIG_WCNSS_CORE) += wcnss/
obj-$(CONFIG_RENAME_BLOCK_DEVICE) += rename_block_device.o
+65 −0
Original line number Diff line number Diff line
/* Copyright (c) 2020 The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

#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",
								 actual_name);
			return -ENXIO;
		}
		index++;
	}
out:
	return  0;
}

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