mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	pinctrl: zynqmp: some code cleanups
Some minor code cleanups and updates which includes - Mention module name under help in Kconfig. - Remove extra lines and duplicate Pin range checks. - Replace 'return ret' with 'return 0' in success path. - Copyright year update. - use devm_pinctrl_register() instead pinctrl_register() in probe. Signed-off-by: Sai Krishna Potthuri <lakshmi.sai.krishna.potthuri@xilinx.com> Link: https://lore.kernel.org/r/1624273214-66849-1-git-send-email-lakshmi.sai.krishna.potthuri@xilinx.com Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
		
							parent
							
								
									0c3ae641a2
								
							
						
					
					
						commit
						fa99e70138
					
				
					 2 changed files with 22 additions and 30 deletions
				
			
		| 
						 | 
				
			
			@ -336,6 +336,8 @@ config PINCTRL_ZYNQMP
 | 
			
		|||
	  Configuration can include the mux function to select on those
 | 
			
		||||
	  pin(s)/group(s), and various pin configuration parameters
 | 
			
		||||
	  such as pull-up, slew rate, etc.
 | 
			
		||||
	  This driver can also be built as a module. If so, the module
 | 
			
		||||
	  will be called pinctrl-zynqmp.
 | 
			
		||||
 | 
			
		||||
config PINCTRL_INGENIC
 | 
			
		||||
	bool "Pinctrl driver for the Ingenic JZ47xx SoCs"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,7 +2,7 @@
 | 
			
		|||
/*
 | 
			
		||||
 * ZynqMP pin controller
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (C) 2020 Xilinx, Inc.
 | 
			
		||||
 * Copyright (C) 2020, 2021 Xilinx, Inc.
 | 
			
		||||
 *
 | 
			
		||||
 * Sai Krishna Potthuri <lakshmi.sai.krishna.potthuri@xilinx.com>
 | 
			
		||||
 * Rajan Vaja <rajan.vaja@xilinx.com>
 | 
			
		||||
| 
						 | 
				
			
			@ -252,9 +252,6 @@ static int zynqmp_pinconf_cfg_get(struct pinctrl_dev *pctldev,
 | 
			
		|||
	unsigned int arg, param = pinconf_to_config_param(*config);
 | 
			
		||||
	int ret;
 | 
			
		||||
 | 
			
		||||
	if (pin >= zynqmp_desc.npins)
 | 
			
		||||
		return -EOPNOTSUPP;
 | 
			
		||||
 | 
			
		||||
	switch (param) {
 | 
			
		||||
	case PIN_CONFIG_SLEW_RATE:
 | 
			
		||||
		param = PM_PINCTRL_CONFIG_SLEW_RATE;
 | 
			
		||||
| 
						 | 
				
			
			@ -317,7 +314,7 @@ static int zynqmp_pinconf_cfg_get(struct pinctrl_dev *pctldev,
 | 
			
		|||
		}
 | 
			
		||||
		break;
 | 
			
		||||
	default:
 | 
			
		||||
		ret = -EOPNOTSUPP;
 | 
			
		||||
		ret = -ENOTSUPP;
 | 
			
		||||
		break;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -348,9 +345,6 @@ static int zynqmp_pinconf_cfg_set(struct pinctrl_dev *pctldev,
 | 
			
		|||
{
 | 
			
		||||
	int i, ret;
 | 
			
		||||
 | 
			
		||||
	if (pin >= zynqmp_desc.npins)
 | 
			
		||||
		return -EOPNOTSUPP;
 | 
			
		||||
 | 
			
		||||
	for (i = 0; i < num_configs; i++) {
 | 
			
		||||
		unsigned int param = pinconf_to_config_param(configs[i]);
 | 
			
		||||
		unsigned int arg = pinconf_to_config_argument(configs[i]);
 | 
			
		||||
| 
						 | 
				
			
			@ -428,7 +422,7 @@ static int zynqmp_pinconf_cfg_set(struct pinctrl_dev *pctldev,
 | 
			
		|||
			dev_warn(pctldev->dev,
 | 
			
		||||
				 "unsupported configuration parameter '%u'\n",
 | 
			
		||||
				 param);
 | 
			
		||||
			ret = -EOPNOTSUPP;
 | 
			
		||||
			ret = -ENOTSUPP;
 | 
			
		||||
			break;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -504,7 +498,7 @@ static int zynqmp_pinctrl_get_function_groups(u32 fid, u32 index, u16 *groups)
 | 
			
		|||
 | 
			
		||||
	memcpy(groups, &payload[1], PINCTRL_GET_FUNC_GROUPS_RESP_LEN);
 | 
			
		||||
 | 
			
		||||
	return ret;
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int zynqmp_pinctrl_get_func_num_groups(u32 fid, unsigned int *ngroups)
 | 
			
		||||
| 
						 | 
				
			
			@ -522,7 +516,7 @@ static int zynqmp_pinctrl_get_func_num_groups(u32 fid, unsigned int *ngroups)
 | 
			
		|||
 | 
			
		||||
	*ngroups = payload[1];
 | 
			
		||||
 | 
			
		||||
	return ret;
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
| 
						 | 
				
			
			@ -533,16 +527,16 @@ static int zynqmp_pinctrl_get_func_num_groups(u32 fid, unsigned int *ngroups)
 | 
			
		|||
 * @groups:	Groups data.
 | 
			
		||||
 *
 | 
			
		||||
 * Query firmware to get group IDs for each function. Firmware returns
 | 
			
		||||
 * group IDs. Based on group index for the function, group names in
 | 
			
		||||
 * group IDs. Based on the group index for the function, group names in
 | 
			
		||||
 * the function are stored. For example, the first group in "eth0" function
 | 
			
		||||
 * is named as "eth0_0" and second group as "eth0_1" and so on.
 | 
			
		||||
 * is named as "eth0_0" and the second group as "eth0_1" and so on.
 | 
			
		||||
 *
 | 
			
		||||
 * Based on the group ID received from the firmware, function stores name of
 | 
			
		||||
 * the group for that group ID. For example, if "eth0" first group ID
 | 
			
		||||
 * is x, groups[x] name will be stored as "eth0_0".
 | 
			
		||||
 *
 | 
			
		||||
 * Once done for each function, each function would have its group names
 | 
			
		||||
 * and each groups would also have their names.
 | 
			
		||||
 * and each group would also have their names.
 | 
			
		||||
 *
 | 
			
		||||
 * Return: 0 on success else error code.
 | 
			
		||||
 */
 | 
			
		||||
| 
						 | 
				
			
			@ -552,7 +546,7 @@ static int zynqmp_pinctrl_prepare_func_groups(struct device *dev, u32 fid,
 | 
			
		|||
{
 | 
			
		||||
	u16 resp[NUM_GROUPS_PER_RESP] = {0};
 | 
			
		||||
	const char **fgroups;
 | 
			
		||||
	int ret = 0, index, i;
 | 
			
		||||
	int ret, index, i;
 | 
			
		||||
 | 
			
		||||
	fgroups = devm_kzalloc(dev, sizeof(*fgroups) * func->ngroups, GFP_KERNEL);
 | 
			
		||||
	if (!fgroups)
 | 
			
		||||
| 
						 | 
				
			
			@ -588,7 +582,7 @@ static int zynqmp_pinctrl_prepare_func_groups(struct device *dev, u32 fid,
 | 
			
		|||
done:
 | 
			
		||||
	func->groups = fgroups;
 | 
			
		||||
 | 
			
		||||
	return ret;
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void zynqmp_pinctrl_get_function_name(u32 fid, char *name)
 | 
			
		||||
| 
						 | 
				
			
			@ -622,7 +616,7 @@ static int zynqmp_pinctrl_get_num_functions(unsigned int *nfuncs)
 | 
			
		|||
 | 
			
		||||
	*nfuncs = payload[1];
 | 
			
		||||
 | 
			
		||||
	return ret;
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int zynqmp_pinctrl_get_pin_groups(u32 pin, u32 index, u16 *groups)
 | 
			
		||||
| 
						 | 
				
			
			@ -641,7 +635,7 @@ static int zynqmp_pinctrl_get_pin_groups(u32 pin, u32 index, u16 *groups)
 | 
			
		|||
 | 
			
		||||
	memcpy(groups, &payload[1], PINCTRL_GET_PIN_GROUPS_RESP_LEN);
 | 
			
		||||
 | 
			
		||||
	return ret;
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void zynqmp_pinctrl_group_add_pin(struct zynqmp_pctrl_group *group,
 | 
			
		||||
| 
						 | 
				
			
			@ -660,7 +654,7 @@ static void zynqmp_pinctrl_group_add_pin(struct zynqmp_pctrl_group *group,
 | 
			
		|||
 * Based on the firmware response(group IDs for the pin), add
 | 
			
		||||
 * pin number to the respective group's pin array.
 | 
			
		||||
 *
 | 
			
		||||
 * Once all pins are queries, each groups would have its number
 | 
			
		||||
 * Once all pins are queries, each group would have its number
 | 
			
		||||
 * of pins and pin numbers data.
 | 
			
		||||
 *
 | 
			
		||||
 * Return: 0 on success else error code.
 | 
			
		||||
| 
						 | 
				
			
			@ -689,7 +683,7 @@ static int zynqmp_pinctrl_create_pin_groups(struct device *dev,
 | 
			
		|||
		index += NUM_GROUPS_PER_RESP;
 | 
			
		||||
	} while (index <= MAX_PIN_GROUPS);
 | 
			
		||||
 | 
			
		||||
	return ret;
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
| 
						 | 
				
			
			@ -727,7 +721,7 @@ static int zynqmp_pinctrl_prepare_group_pins(struct device *dev,
 | 
			
		|||
 * prepare pin control driver data.
 | 
			
		||||
 *
 | 
			
		||||
 * Query number of functions and number of function groups (number
 | 
			
		||||
 * of groups in given function) to allocate required memory buffers
 | 
			
		||||
 * of groups in the given function) to allocate required memory buffers
 | 
			
		||||
 * for functions and groups. Once buffers are allocated to store
 | 
			
		||||
 * functions and groups data, query and store required information
 | 
			
		||||
 * (number of groups and group names for each function, number of
 | 
			
		||||
| 
						 | 
				
			
			@ -778,7 +772,7 @@ static int zynqmp_pinctrl_prepare_function_info(struct device *dev,
 | 
			
		|||
	pctrl->funcs = funcs;
 | 
			
		||||
	pctrl->groups = groups;
 | 
			
		||||
 | 
			
		||||
	return ret;
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int zynqmp_pinctrl_get_num_pins(unsigned int *npins)
 | 
			
		||||
| 
						 | 
				
			
			@ -795,7 +789,7 @@ static int zynqmp_pinctrl_get_num_pins(unsigned int *npins)
 | 
			
		|||
 | 
			
		||||
	*npins = payload[1];
 | 
			
		||||
 | 
			
		||||
	return ret;
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
| 
						 | 
				
			
			@ -853,19 +847,17 @@ static int zynqmp_pinctrl_probe(struct platform_device *pdev)
 | 
			
		|||
					      &zynqmp_desc.pins,
 | 
			
		||||
					      &zynqmp_desc.npins);
 | 
			
		||||
	if (ret) {
 | 
			
		||||
		dev_err(&pdev->dev, "pin desc prepare fail with %d\n",
 | 
			
		||||
			ret);
 | 
			
		||||
		dev_err(&pdev->dev, "pin desc prepare fail with %d\n", ret);
 | 
			
		||||
		return ret;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	ret = zynqmp_pinctrl_prepare_function_info(&pdev->dev, pctrl);
 | 
			
		||||
	if (ret) {
 | 
			
		||||
		dev_err(&pdev->dev, "function info prepare fail with %d\n",
 | 
			
		||||
			ret);
 | 
			
		||||
		dev_err(&pdev->dev, "function info prepare fail with %d\n", ret);
 | 
			
		||||
		return ret;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	pctrl->pctrl = pinctrl_register(&zynqmp_desc, &pdev->dev, pctrl);
 | 
			
		||||
	pctrl->pctrl = devm_pinctrl_register(&pdev->dev, &zynqmp_desc, pctrl);
 | 
			
		||||
	if (IS_ERR(pctrl->pctrl))
 | 
			
		||||
		return PTR_ERR(pctrl->pctrl);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -887,7 +879,6 @@ static const struct of_device_id zynqmp_pinctrl_of_match[] = {
 | 
			
		|||
	{ .compatible = "xlnx,zynqmp-pinctrl" },
 | 
			
		||||
	{ }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
MODULE_DEVICE_TABLE(of, zynqmp_pinctrl_of_match);
 | 
			
		||||
 | 
			
		||||
static struct platform_driver zynqmp_pinctrl_driver = {
 | 
			
		||||
| 
						 | 
				
			
			@ -898,7 +889,6 @@ static struct platform_driver zynqmp_pinctrl_driver = {
 | 
			
		|||
	.probe = zynqmp_pinctrl_probe,
 | 
			
		||||
	.remove = zynqmp_pinctrl_remove,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
module_platform_driver(zynqmp_pinctrl_driver);
 | 
			
		||||
 | 
			
		||||
MODULE_AUTHOR("Sai Krishna Potthuri <lakshmi.sai.krishna.potthuri@xilinx.com>");
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue