diff mbox series

[v1,05/11] pinctrl: pinmux: Add a convenient define PINCTRL_FUNCTION_DESC()

Message ID 20240527212742.1432960-6-andy.shevchenko@gmail.com (mailing list archive)
State Superseded
Headers show
Series pinctrl: pinmux: Embed and reuse struct pinfunction | expand

Commit Message

Andy Shevchenko May 27, 2024, 9:24 p.m. UTC
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Add PINCTRL_FUNCTION_DESC() macro for inline use.

While at it, fix adjective form in the comment of PINCTRL_GROUP_DESC().

Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/pinctrl/core.h   |  2 +-
 drivers/pinctrl/pinmux.c |  7 ++-----
 drivers/pinctrl/pinmux.h | 11 ++++++++++-
 3 files changed, 13 insertions(+), 7 deletions(-)

Comments

kernel test robot May 28, 2024, 12:19 a.m. UTC | #1
Hi Andy,

kernel test robot noticed the following build warnings:

[auto build test WARNING on linusw-pinctrl/devel]
[also build test WARNING on linusw-pinctrl/for-next linus/master v6.10-rc1 next-20240523]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/pinctrl-berlin-Make-use-of-struct-pinfunction/20240528-053304
base:   https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git devel
patch link:    https://lore.kernel.org/r/20240527212742.1432960-6-andy.shevchenko%40gmail.com
patch subject: [PATCH v1 05/11] pinctrl: pinmux: Add a convenient define PINCTRL_FUNCTION_DESC()
config: sh-defconfig (https://download.01.org/0day-ci/archive/20240528/202405280739.VSX5oEnr-lkp@intel.com/config)
compiler: sh4-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240528/202405280739.VSX5oEnr-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202405280739.VSX5oEnr-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/pinctrl/pinmux.c:863: warning: Function parameter or struct member 'ngroups' not described in 'pinmux_generic_add_function'
>> drivers/pinctrl/pinmux.c:863: warning: Excess function parameter 'num_groups' description in 'pinmux_generic_add_function'


vim +863 drivers/pinctrl/pinmux.c

a76edc89b100e4 Tony Lindgren      2016-12-27  849  
a76edc89b100e4 Tony Lindgren      2016-12-27  850  /**
6bffa7e1631d55 Geert Uytterhoeven 2017-04-03  851   * pinmux_generic_add_function() - adds a function group
a76edc89b100e4 Tony Lindgren      2016-12-27  852   * @pctldev: pin controller device
a76edc89b100e4 Tony Lindgren      2016-12-27  853   * @name: name of the function
a76edc89b100e4 Tony Lindgren      2016-12-27  854   * @groups: array of pin groups
a76edc89b100e4 Tony Lindgren      2016-12-27  855   * @num_groups: number of pin groups
a76edc89b100e4 Tony Lindgren      2016-12-27  856   * @data: pin controller driver specific data
a76edc89b100e4 Tony Lindgren      2016-12-27  857   */
a76edc89b100e4 Tony Lindgren      2016-12-27  858  int pinmux_generic_add_function(struct pinctrl_dev *pctldev,
a76edc89b100e4 Tony Lindgren      2016-12-27  859  				const char *name,
bd0aae66c48208 Rafał Miłecki      2021-12-16  860  				const char * const *groups,
368512f04e89e0 Andy Shevchenko    2024-05-28  861  				const unsigned int ngroups,
a76edc89b100e4 Tony Lindgren      2016-12-27  862  				void *data)
a76edc89b100e4 Tony Lindgren      2016-12-27 @863  {
a76edc89b100e4 Tony Lindgren      2016-12-27  864  	struct function_desc *function;
6ec89cd4d17bd5 Sergey Shtylyov    2023-07-19  865  	int selector, error;
f913cfce4ee49a Tony Lindgren      2018-07-05  866  
f913cfce4ee49a Tony Lindgren      2018-07-05  867  	if (!name)
f913cfce4ee49a Tony Lindgren      2018-07-05  868  		return -EINVAL;
f913cfce4ee49a Tony Lindgren      2018-07-05  869  
f913cfce4ee49a Tony Lindgren      2018-07-05  870  	selector = pinmux_func_name_to_selector(pctldev, name);
f913cfce4ee49a Tony Lindgren      2018-07-05  871  	if (selector >= 0)
f913cfce4ee49a Tony Lindgren      2018-07-05  872  		return selector;
f913cfce4ee49a Tony Lindgren      2018-07-05  873  
f913cfce4ee49a Tony Lindgren      2018-07-05  874  	selector = pctldev->num_functions;
a76edc89b100e4 Tony Lindgren      2016-12-27  875  
a76edc89b100e4 Tony Lindgren      2016-12-27  876  	function = devm_kzalloc(pctldev->dev, sizeof(*function), GFP_KERNEL);
a76edc89b100e4 Tony Lindgren      2016-12-27  877  	if (!function)
a76edc89b100e4 Tony Lindgren      2016-12-27  878  		return -ENOMEM;
a76edc89b100e4 Tony Lindgren      2016-12-27  879  
368512f04e89e0 Andy Shevchenko    2024-05-28  880  	function = PINCTRL_FUNCTION_DESC(name, groups, ngroups, data);
a76edc89b100e4 Tony Lindgren      2016-12-27  881  
6ec89cd4d17bd5 Sergey Shtylyov    2023-07-19  882  	error = radix_tree_insert(&pctldev->pin_function_tree, selector, function);
6ec89cd4d17bd5 Sergey Shtylyov    2023-07-19  883  	if (error)
6ec89cd4d17bd5 Sergey Shtylyov    2023-07-19  884  		return error;
a76edc89b100e4 Tony Lindgren      2016-12-27  885  
a76edc89b100e4 Tony Lindgren      2016-12-27  886  	pctldev->num_functions++;
a76edc89b100e4 Tony Lindgren      2016-12-27  887  
f913cfce4ee49a Tony Lindgren      2018-07-05  888  	return selector;
a76edc89b100e4 Tony Lindgren      2016-12-27  889  }
a76edc89b100e4 Tony Lindgren      2016-12-27  890  EXPORT_SYMBOL_GPL(pinmux_generic_add_function);
a76edc89b100e4 Tony Lindgren      2016-12-27  891
kernel test robot May 28, 2024, 12:30 a.m. UTC | #2
Hi Andy,

kernel test robot noticed the following build errors:

[auto build test ERROR on linusw-pinctrl/devel]
[also build test ERROR on linusw-pinctrl/for-next linus/master v6.10-rc1 next-20240523]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/pinctrl-berlin-Make-use-of-struct-pinfunction/20240528-053304
base:   https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git devel
patch link:    https://lore.kernel.org/r/20240527212742.1432960-6-andy.shevchenko%40gmail.com
patch subject: [PATCH v1 05/11] pinctrl: pinmux: Add a convenient define PINCTRL_FUNCTION_DESC()
config: riscv-defconfig (https://download.01.org/0day-ci/archive/20240528/202405280821.FcDAyD2b-lkp@intel.com/config)
compiler: clang version 19.0.0git (https://github.com/llvm/llvm-project bafda89a0944d947fc4b3b5663185e07a397ac30)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240528/202405280821.FcDAyD2b-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202405280821.FcDAyD2b-lkp@intel.com/

All errors (new ones prefixed by >>):

>> drivers/pinctrl/pinmux.c:880:11: error: assigning to 'struct function_desc *' from incompatible type 'struct function_desc'; take the address with &
     880 |         function = PINCTRL_FUNCTION_DESC(name, groups, ngroups, data);
         |                  ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         |                    &(                                                )
   1 error generated.


vim +880 drivers/pinctrl/pinmux.c

   849	
   850	/**
   851	 * pinmux_generic_add_function() - adds a function group
   852	 * @pctldev: pin controller device
   853	 * @name: name of the function
   854	 * @groups: array of pin groups
   855	 * @num_groups: number of pin groups
   856	 * @data: pin controller driver specific data
   857	 */
   858	int pinmux_generic_add_function(struct pinctrl_dev *pctldev,
   859					const char *name,
   860					const char * const *groups,
   861					const unsigned int ngroups,
   862					void *data)
   863	{
   864		struct function_desc *function;
   865		int selector, error;
   866	
   867		if (!name)
   868			return -EINVAL;
   869	
   870		selector = pinmux_func_name_to_selector(pctldev, name);
   871		if (selector >= 0)
   872			return selector;
   873	
   874		selector = pctldev->num_functions;
   875	
   876		function = devm_kzalloc(pctldev->dev, sizeof(*function), GFP_KERNEL);
   877		if (!function)
   878			return -ENOMEM;
   879	
 > 880		function = PINCTRL_FUNCTION_DESC(name, groups, ngroups, data);
   881	
   882		error = radix_tree_insert(&pctldev->pin_function_tree, selector, function);
   883		if (error)
   884			return error;
   885	
   886		pctldev->num_functions++;
   887	
   888		return selector;
   889	}
   890	EXPORT_SYMBOL_GPL(pinmux_generic_add_function);
   891
diff mbox series

Patch

diff --git a/drivers/pinctrl/core.h b/drivers/pinctrl/core.h
index 837fd5bd903d..4e07707d2435 100644
--- a/drivers/pinctrl/core.h
+++ b/drivers/pinctrl/core.h
@@ -206,7 +206,7 @@  struct group_desc {
 	void *data;
 };
 
-/* Convenience macro to define a generic pin group descriptor */
+/* Convenient macro to define a generic pin group descriptor */
 #define PINCTRL_GROUP_DESC(_name, _pins, _num_pins, _data)	\
 (struct group_desc) {						\
 	.grp = PINCTRL_PINGROUP(_name, _pins, _num_pins),	\
diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c
index addba55334d9..89b42e05f368 100644
--- a/drivers/pinctrl/pinmux.c
+++ b/drivers/pinctrl/pinmux.c
@@ -858,7 +858,7 @@  EXPORT_SYMBOL_GPL(pinmux_generic_get_function);
 int pinmux_generic_add_function(struct pinctrl_dev *pctldev,
 				const char *name,
 				const char * const *groups,
-				const unsigned int num_groups,
+				const unsigned int ngroups,
 				void *data)
 {
 	struct function_desc *function;
@@ -877,10 +877,7 @@  int pinmux_generic_add_function(struct pinctrl_dev *pctldev,
 	if (!function)
 		return -ENOMEM;
 
-	function->name = name;
-	function->group_names = groups;
-	function->num_group_names = num_groups;
-	function->data = data;
+	function = PINCTRL_FUNCTION_DESC(name, groups, ngroups, data);
 
 	error = radix_tree_insert(&pctldev->pin_function_tree, selector, function);
 	if (error)
diff --git a/drivers/pinctrl/pinmux.h b/drivers/pinctrl/pinmux.h
index 7c8aa25ccc80..52e6e4db88b4 100644
--- a/drivers/pinctrl/pinmux.h
+++ b/drivers/pinctrl/pinmux.h
@@ -145,6 +145,15 @@  struct function_desc {
 	void *data;
 };
 
+/* Convenient macro to define a generic pin function descriptor */
+#define PINCTRL_FUNCTION_DESC(_name, _grps, _num_grps, _data)	\
+(struct function_desc) {					\
+	.name = _name,						\
+	.group_names = _grps,					\
+	.num_group_names = _num_grps,				\
+	.data = _data,						\
+}
+
 int pinmux_generic_get_function_count(struct pinctrl_dev *pctldev);
 
 const char *
@@ -162,7 +171,7 @@  struct function_desc *pinmux_generic_get_function(struct pinctrl_dev *pctldev,
 int pinmux_generic_add_function(struct pinctrl_dev *pctldev,
 				const char *name,
 				const char * const *groups,
-				unsigned int const num_groups,
+				unsigned int const ngroups,
 				void *data);
 
 int pinmux_generic_remove_function(struct pinctrl_dev *pctldev,