]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
pinctrl: equilibrium: Make use of struct pinfunction
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Thu, 30 May 2024 08:55:11 +0000 (11:55 +0300)
committerLinus Walleij <linus.walleij@linaro.org>
Mon, 17 Jun 2024 07:23:43 +0000 (09:23 +0200)
Since pin control provides a generic data type for the pin function,
use it in the driver.

Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20240530085745.1539925-3-andy.shevchenko@gmail.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/pinctrl/pinctrl-equilibrium.c
drivers/pinctrl/pinctrl-equilibrium.h

index 6e1be38865c32cd1820042535de30016d872525a..a6d089eaaae50f8e5842e0e0b498458fd2d0d459 100644 (file)
@@ -566,8 +566,8 @@ static const struct pinconf_ops eqbr_pinconf_ops = {
        .pin_config_config_dbg_show     = pinconf_generic_dump_config,
 };
 
-static bool is_func_exist(struct eqbr_pmx_func *funcs, const char *name,
-                        unsigned int nr_funcs, unsigned int *idx)
+static bool is_func_exist(struct pinfunction *funcs, const char *name,
+                         unsigned int nr_funcs, unsigned int *idx)
 {
        int i;
 
@@ -584,13 +584,14 @@ static bool is_func_exist(struct eqbr_pmx_func *funcs, const char *name,
        return false;
 }
 
-static int funcs_utils(struct device *dev, struct eqbr_pmx_func *funcs,
+static int funcs_utils(struct device *dev, struct pinfunction *funcs,
                       unsigned int *nr_funcs, funcs_util_ops op)
 {
        struct device_node *node = dev->of_node;
        struct device_node *np;
        struct property *prop;
        const char *fn_name;
+       const char **groups;
        unsigned int fid;
        int i, j;
 
@@ -620,15 +621,16 @@ static int funcs_utils(struct device *dev, struct eqbr_pmx_func *funcs,
 
                case OP_COUNT_NR_FUNC_GRPS:
                        if (is_func_exist(funcs, fn_name, *nr_funcs, &fid))
-                               funcs[fid].nr_groups++;
+                               funcs[fid].ngroups++;
                        break;
 
                case OP_ADD_FUNC_GRPS:
                        if (is_func_exist(funcs, fn_name, *nr_funcs, &fid)) {
-                               for (j = 0; j < funcs[fid].nr_groups; j++)
-                                       if (!funcs[fid].groups[j])
+                               groups = (const char **)funcs[fid].groups;
+                               for (j = 0; j < funcs[fid].ngroups; j++)
+                                       if (!groups[j])
                                                break;
-                               funcs[fid].groups[j] = prop->value;
+                               groups[j] = prop->value;
                        }
                        break;
 
@@ -645,7 +647,7 @@ static int funcs_utils(struct device *dev, struct eqbr_pmx_func *funcs,
 static int eqbr_build_functions(struct eqbr_pinctrl_drv_data *drvdata)
 {
        struct device *dev = drvdata->dev;
-       struct eqbr_pmx_func *funcs = NULL;
+       struct pinfunction *funcs = NULL;
        unsigned int nr_funcs = 0;
        int i, ret;
 
@@ -666,9 +668,9 @@ static int eqbr_build_functions(struct eqbr_pinctrl_drv_data *drvdata)
                return ret;
 
        for (i = 0; i < nr_funcs; i++) {
-               if (!funcs[i].nr_groups)
+               if (!funcs[i].ngroups)
                        continue;
-               funcs[i].groups = devm_kcalloc(dev, funcs[i].nr_groups,
+               funcs[i].groups = devm_kcalloc(dev, funcs[i].ngroups,
                                               sizeof(*(funcs[i].groups)),
                                               GFP_KERNEL);
                if (!funcs[i].groups)
@@ -688,7 +690,7 @@ static int eqbr_build_functions(struct eqbr_pinctrl_drv_data *drvdata)
                ret = pinmux_generic_add_function(drvdata->pctl_dev,
                                                  funcs[i].name,
                                                  funcs[i].groups,
-                                                 funcs[i].nr_groups,
+                                                 funcs[i].ngroups,
                                                  drvdata);
                if (ret < 0) {
                        dev_err(dev, "Failed to register function %s\n",
index 83768cc8b3db2dcd69965db15e82a48c42a2373b..b4d149bde39d8dd08a962bb05ccf026364dd9f68 100644 (file)
@@ -67,18 +67,6 @@ struct gpio_irq_type {
        unsigned int logic_type;
 };
 
-/**
- * struct eqbr_pmx_func: represent a pin function.
- * @name: name of the pin function, used to lookup the function.
- * @groups: one or more names of pin groups that provide this function.
- * @nr_groups: number of groups included in @groups.
- */
-struct eqbr_pmx_func {
-       const char              *name;
-       const char              **groups;
-       unsigned int            nr_groups;
-};
-
 /**
  * struct eqbr_pin_bank: represent a pin bank.
  * @membase: base address of the pin bank register.