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

Commit c14114cf authored by Sujeev Dias's avatar Sujeev Dias Committed by Gerrit - the friendly Code Review server
Browse files

msm: msm_bus: add support for device driver to register with msm bus



Not all msm bus clients are platform devices, adding support
for any device driver to register with msm bus framework.

CRs-Fixed: 2253996
Change-Id: I6c2d65707c11834638084972259bc39d809891a3
Signed-off-by: default avatarSujeev Dias <sdias@codeaurora.org>
parent c2d7e72a
Loading
Loading
Loading
Loading
+41 −10
Original line number Diff line number Diff line
/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2018, 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
@@ -41,7 +41,7 @@ static int get_num(const char *const str[], const char *name)
	return -EINVAL;
}

static struct msm_bus_scale_pdata *get_pdata(struct platform_device *pdev,
static struct msm_bus_scale_pdata *get_pdata(struct device *dev,
	struct device_node *of_node)
{
	struct msm_bus_scale_pdata *pdata = NULL;
@@ -51,12 +51,12 @@ static struct msm_bus_scale_pdata *get_pdata(struct platform_device *pdev,
	const uint32_t *vec_arr = NULL;
	bool mem_err = false;

	if (!pdev) {
		pr_err("Error: Null Platform device\n");
	if (!dev) {
		pr_err("Error: Null device\n");
		return NULL;
	}

	pdata = devm_kzalloc(&pdev->dev, sizeof(struct msm_bus_scale_pdata),
	pdata = devm_kzalloc(dev, sizeof(struct msm_bus_scale_pdata),
		GFP_KERNEL);
	if (!pdata) {
		mem_err = true;
@@ -89,7 +89,7 @@ static struct msm_bus_scale_pdata *get_pdata(struct platform_device *pdev,
	pdata->alc = of_property_read_bool(of_node, "qcom,msm-bus,alc-voter");

	if (pdata->alc) {
		usecase_lat = devm_kzalloc(&pdev->dev,
		usecase_lat = devm_kzalloc(dev,
				(sizeof(struct msm_bus_lat_vectors) *
				pdata->num_usecases), GFP_KERNEL);
		if (!usecase_lat) {
@@ -122,7 +122,7 @@ static struct msm_bus_scale_pdata *get_pdata(struct platform_device *pdev,
		return pdata;
	}

	usecase = devm_kzalloc(&pdev->dev, (sizeof(struct msm_bus_paths) *
	usecase = devm_kzalloc(dev, (sizeof(struct msm_bus_paths) *
		pdata->num_usecases), GFP_KERNEL);
	if (!usecase) {
		mem_err = true;
@@ -149,7 +149,7 @@ static struct msm_bus_scale_pdata *get_pdata(struct platform_device *pdev,

	for (i = 0; i < num_usecases; i++) {
		usecase[i].num_paths = num_paths;
		usecase[i].vectors = devm_kzalloc(&pdev->dev, num_paths *
		usecase[i].vectors = devm_kzalloc(dev, num_paths *
			sizeof(struct msm_bus_vectors), GFP_KERNEL);
		if (!usecase[i].vectors) {
			mem_err = true;
@@ -206,7 +206,7 @@ struct msm_bus_scale_pdata *msm_bus_cl_get_pdata(struct platform_device *pdev)
	}

	of_node = pdev->dev.of_node;
	pdata = get_pdata(pdev, of_node);
	pdata = get_pdata(&pdev->dev, of_node);
	if (!pdata) {
		pr_err("client has to provide missing entry for successful registration\n");
		return NULL;
@@ -216,6 +216,37 @@ struct msm_bus_scale_pdata *msm_bus_cl_get_pdata(struct platform_device *pdev)
}
EXPORT_SYMBOL(msm_bus_cl_get_pdata);

/**
 * msm_bus_cl_get_pdata_from_dev() - Generate bus client data from device tree
 * provided by clients.
 *
 * of_node: Device tree node to extract information from
 *
 * The function returns a valid pointer to the allocated bus-scale-pdata
 * if the vectors were correctly read from the client's device node.
 * Any error in reading or parsing the device node will return NULL
 * to the caller.
 */
struct msm_bus_scale_pdata *msm_bus_cl_get_pdata_from_dev(struct device *dev)
{
	struct device_node *of_node;
	struct msm_bus_scale_pdata *pdata = NULL;

	of_node = dev->of_node;

	if (!of_node)
		return NULL;

	pdata = get_pdata(dev, of_node);
	if (!pdata) {
		pr_err("client has to provide missing entry for successful registration\n");
		return NULL;
	}

	return pdata;
}
EXPORT_SYMBOL(msm_bus_cl_get_pdata_from_dev);

/**
 * msm_bus_cl_pdata_from_node() - Generate bus client data from device tree
 * node provided by clients. This function should be used when a client
@@ -247,7 +278,7 @@ struct msm_bus_scale_pdata *msm_bus_pdata_from_node(
		return NULL;
	}

	pdata = get_pdata(pdev, of_node);
	pdata = get_pdata(&pdev->dev, of_node);
	if (!pdata) {
		pr_err("client has to provide missing entry for successful registration\n");
		return NULL;
+2 −1
Original line number Diff line number Diff line
/* Copyright (c) 2010-2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2010-2018, 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
@@ -217,6 +217,7 @@ static inline int msm_bus_scale_query_tcs_cmd_all(struct msm_bus_tcs_handle
struct msm_bus_scale_pdata *msm_bus_pdata_from_node(
		struct platform_device *pdev, struct device_node *of_node);
struct msm_bus_scale_pdata *msm_bus_cl_get_pdata(struct platform_device *pdev);
struct msm_bus_scale_pdata *msm_bus_cl_get_pdata_from_dev(struct device *dev);
void msm_bus_cl_clear_pdata(struct msm_bus_scale_pdata *pdata);
#else
static inline struct msm_bus_scale_pdata