From: Peng Fan <peng.fan@xxxxxxx> Make pinctrl_ops a global variable not able to support multiple protocol@19 nodes, so make it per scmi_pinctrl. Signed-off-by: Peng Fan <peng.fan@xxxxxxx> --- drivers/pinctrl/pinctrl-scmi.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/drivers/pinctrl/pinctrl-scmi.c b/drivers/pinctrl/pinctrl-scmi.c index 036bc1e3fc6c..682ff595c3c7 100644 --- a/drivers/pinctrl/pinctrl-scmi.c +++ b/drivers/pinctrl/pinctrl-scmi.c @@ -30,8 +30,6 @@ /* Define num configs, if not large than 4 use stack, else use kcalloc() */ #define SCMI_NUM_CONFIGS 4 -static const struct scmi_pinctrl_proto_ops *pinctrl_ops; - struct scmi_pinctrl { struct device *dev; struct scmi_protocol_handle *ph; @@ -41,13 +39,14 @@ struct scmi_pinctrl { unsigned int nr_functions; struct pinctrl_pin_desc *pins; unsigned int nr_pins; + const struct scmi_pinctrl_proto_ops *ops; }; static int pinctrl_scmi_get_groups_count(struct pinctrl_dev *pctldev) { struct scmi_pinctrl *pmx = pinctrl_dev_get_drvdata(pctldev); - return pinctrl_ops->count_get(pmx->ph, GROUP_TYPE); + return pmx->ops->count_get(pmx->ph, GROUP_TYPE); } static const char *pinctrl_scmi_get_group_name(struct pinctrl_dev *pctldev, @@ -57,7 +56,7 @@ static const char *pinctrl_scmi_get_group_name(struct pinctrl_dev *pctldev, const char *name; struct scmi_pinctrl *pmx = pinctrl_dev_get_drvdata(pctldev); - ret = pinctrl_ops->name_get(pmx->ph, selector, GROUP_TYPE, &name); + ret = pmx->ops->name_get(pmx->ph, selector, GROUP_TYPE, &name); if (ret) { dev_err(pmx->dev, "get name failed with err %d", ret); return NULL; @@ -73,7 +72,7 @@ static int pinctrl_scmi_get_group_pins(struct pinctrl_dev *pctldev, { struct scmi_pinctrl *pmx = pinctrl_dev_get_drvdata(pctldev); - return pinctrl_ops->group_pins_get(pmx->ph, selector, pins, num_pins); + return pmx->ops->group_pins_get(pmx->ph, selector, pins, num_pins); } static const struct pinctrl_ops pinctrl_scmi_pinctrl_ops = { @@ -90,7 +89,7 @@ static int pinctrl_scmi_get_functions_count(struct pinctrl_dev *pctldev) { struct scmi_pinctrl *pmx = pinctrl_dev_get_drvdata(pctldev); - return pinctrl_ops->count_get(pmx->ph, FUNCTION_TYPE); + return pmx->ops->count_get(pmx->ph, FUNCTION_TYPE); } static const char *pinctrl_scmi_get_function_name(struct pinctrl_dev *pctldev, @@ -100,7 +99,7 @@ static const char *pinctrl_scmi_get_function_name(struct pinctrl_dev *pctldev, const char *name; struct scmi_pinctrl *pmx = pinctrl_dev_get_drvdata(pctldev); - ret = pinctrl_ops->name_get(pmx->ph, selector, FUNCTION_TYPE, &name); + ret = pmx->ops->name_get(pmx->ph, selector, FUNCTION_TYPE, &name); if (ret) { dev_err(pmx->dev, "get name failed with err %d", ret); return NULL; @@ -131,7 +130,7 @@ static int pinctrl_scmi_get_function_groups(struct pinctrl_dev *pctldev, if (func->ngroups) goto done; - ret = pinctrl_ops->function_groups_get(pmx->ph, selector, &num_groups, + ret = pmx->ops->function_groups_get(pmx->ph, selector, &num_groups, &group_ids); if (ret) { dev_err(pmx->dev, "Unable to get function groups, err %d", ret); @@ -171,7 +170,7 @@ static int pinctrl_scmi_func_set_mux(struct pinctrl_dev *pctldev, { struct scmi_pinctrl *pmx = pinctrl_dev_get_drvdata(pctldev); - return pinctrl_ops->mux_set(pmx->ph, selector, group); + return pmx->ops->mux_set(pmx->ph, selector, group); } static int pinctrl_scmi_request(struct pinctrl_dev *pctldev, @@ -179,14 +178,14 @@ static int pinctrl_scmi_request(struct pinctrl_dev *pctldev, { struct scmi_pinctrl *pmx = pinctrl_dev_get_drvdata(pctldev); - return pinctrl_ops->pin_request(pmx->ph, offset); + return pmx->ops->pin_request(pmx->ph, offset); } static int pinctrl_scmi_free(struct pinctrl_dev *pctldev, unsigned int offset) { struct scmi_pinctrl *pmx = pinctrl_dev_get_drvdata(pctldev); - return pinctrl_ops->pin_free(pmx->ph, offset); + return pmx->ops->pin_free(pmx->ph, offset); } static const struct pinmux_ops pinctrl_scmi_pinmux_ops = { @@ -295,7 +294,7 @@ static int pinctrl_scmi_pinconf_get(struct pinctrl_dev *pctldev, if (ret) return ret; - ret = pinctrl_ops->settings_get_one(pmx->ph, pin, PIN_TYPE, type, + ret = pmx->ops->settings_get_one(pmx->ph, pin, PIN_TYPE, type, &config_value); /* Convert SCMI error code to PINCTRL expected error code */ if (ret == -EOPNOTSUPP) @@ -372,7 +371,7 @@ static int pinctrl_scmi_pinconf_set(struct pinctrl_dev *pctldev, p_config_value[i] = pinconf_to_config_argument(configs[i]); } - ret = pinctrl_ops->settings_conf(pmx->ph, pin, PIN_TYPE, num_configs, + ret = pmx->ops->settings_conf(pmx->ph, pin, PIN_TYPE, num_configs, p_config_type, p_config_value); if (ret) dev_err(pmx->dev, "Error parsing config %d\n", ret); @@ -415,7 +414,7 @@ static int pinctrl_scmi_pinconf_group_set(struct pinctrl_dev *pctldev, p_config_value[i] = pinconf_to_config_argument(configs[i]); } - ret = pinctrl_ops->settings_conf(pmx->ph, group, GROUP_TYPE, + ret = pmx->ops->settings_conf(pmx->ph, group, GROUP_TYPE, num_configs, p_config_type, p_config_value); if (ret) @@ -447,7 +446,7 @@ static int pinctrl_scmi_pinconf_group_get(struct pinctrl_dev *pctldev, return ret; } - ret = pinctrl_ops->settings_get_one(pmx->ph, group, GROUP_TYPE, type, + ret = pmx->ops->settings_get_one(pmx->ph, group, GROUP_TYPE, type, &config_value); /* Convert SCMI error code to PINCTRL expected error code */ if (ret == -EOPNOTSUPP) @@ -476,7 +475,7 @@ static int pinctrl_scmi_get_pins(struct scmi_pinctrl *pmx, unsigned int npins; int ret, i; - npins = pinctrl_ops->count_get(pmx->ph, PIN_TYPE); + npins = pmx->ops->count_get(pmx->ph, PIN_TYPE); /* * npins will never be zero, the scmi pinctrl driver has bailed out * if npins is zero. @@ -491,7 +490,7 @@ static int pinctrl_scmi_get_pins(struct scmi_pinctrl *pmx, * The memory for name is handled by the scmi firmware driver, * no need free here */ - ret = pinctrl_ops->name_get(pmx->ph, i, PIN_TYPE, &pins[i].name); + ret = pmx->ops->name_get(pmx->ph, i, PIN_TYPE, &pins[i].name); if (ret) return dev_err_probe(pmx->dev, ret, "Can't get name for pin %d", i); @@ -511,6 +510,7 @@ static int scmi_pinctrl_probe(struct scmi_device *sdev) struct scmi_pinctrl *pmx; const struct scmi_handle *handle; struct scmi_protocol_handle *ph; + const struct scmi_pinctrl_proto_ops *pinctrl_ops; if (!sdev->handle) return -EINVAL; @@ -526,6 +526,7 @@ static int scmi_pinctrl_probe(struct scmi_device *sdev) return -ENOMEM; pmx->ph = ph; + pmx->ops = pinctrl_ops; pmx->dev = dev; pmx->pctl_desc.name = DRV_NAME; -- 2.37.1