diff mbox series

[rft,v1,1/1] pinctrl: Clean up headers

Message ID 20221007103221.57733-1-andriy.shevchenko@linux.intel.com
State New
Headers show
Series [rft,v1,1/1] pinctrl: Clean up headers | expand

Commit Message

Andy Shevchenko Oct. 7, 2022, 10:32 a.m. UTC
There is a few things done:
- include only the headers we are direct user of
- when pointer is in use, provide a forward declaration
- add missed headers
- group generic headers and subsystem headers
- sort each group alphabetically

While at it, fix some awkward indentations.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---

Very well expected to fail broadly due to missed headers in tons of the pin
control drivers.

Comments are welcome anyway!

 drivers/pinctrl/core.c                  | 19 ++++++++-------
 include/linux/pinctrl/consumer.h        | 31 +++++++++++--------------
 include/linux/pinctrl/devinfo.h         |  6 +++--
 include/linux/pinctrl/machine.h         |  8 ++++---
 include/linux/pinctrl/pinconf-generic.h | 23 ++++++++++--------
 include/linux/pinctrl/pinctrl.h         | 16 ++++++-------
 include/linux/pinctrl/pinmux.h          |  5 ++--
 7 files changed, 56 insertions(+), 52 deletions(-)

Comments

kernel test robot Oct. 7, 2022, 12:47 p.m. UTC | #1
Hi Andy,

I love your patch! Yet something to improve:

[auto build test ERROR on linusw-pinctrl/devel]
[also build test ERROR on linus/master v6.0 next-20221007]
[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-Clean-up-headers/20221007-183311
base:   https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git devel
config: sh-allmodconfig
compiler: sh4-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/5b392edeea764a64953fbab65c9a06b2745ebdd7
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Andy-Shevchenko/pinctrl-Clean-up-headers/20221007-183311
        git checkout 5b392edeea764a64953fbab65c9a06b2745ebdd7
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=sh SHELL=/bin/bash drivers/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All error/warnings (new ones prefixed by >>):

   drivers/pinctrl/pinctrl-axp209.c: In function 'axp20x_gpio_input':
>> drivers/pinctrl/pinctrl-axp209.c:122:16: error: implicit declaration of function 'pinctrl_gpio_direction_input' [-Werror=implicit-function-declaration]
     122 |         return pinctrl_gpio_direction_input(chip->base + offset);
         |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   cc1: some warnings being treated as errors
--
   drivers/pinctrl/pinctrl-ocelot.c: In function 'ocelot_gpio_direction_input':
>> drivers/pinctrl/pinctrl-ocelot.c:1775:16: error: implicit declaration of function 'pinctrl_gpio_direction_input'; did you mean 'ocelot_gpio_direction_input'? [-Werror=implicit-function-declaration]
    1775 |         return pinctrl_gpio_direction_input(chip->base + offset);
         |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
         |                ocelot_gpio_direction_input
   drivers/pinctrl/pinctrl-ocelot.c: In function 'ocelot_gpio_direction_output':
>> drivers/pinctrl/pinctrl-ocelot.c:1791:16: error: implicit declaration of function 'pinctrl_gpio_direction_output'; did you mean 'ocelot_gpio_direction_output'? [-Werror=implicit-function-declaration]
    1791 |         return pinctrl_gpio_direction_output(chip->base + offset);
         |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         |                ocelot_gpio_direction_output
   cc1: some warnings being treated as errors
--
   drivers/pinctrl/pinctrl-single.c: In function 'pcs_pin_dbg_show':
>> drivers/pinctrl/pinctrl-single.c:313:9: error: implicit declaration of function 'seq_printf'; did you mean 'bstr_printf'? [-Werror=implicit-function-declaration]
     313 |         seq_printf(s, "%zx %08x %s ", pa, val, DRIVER_NAME);
         |         ^~~~~~~~~~
         |         bstr_printf
   cc1: some warnings being treated as errors
--
   drivers/pinctrl/pinctrl-stmfx.c: In function 'stmfx_pinconf_dbg_show':
>> drivers/pinctrl/pinctrl-stmfx.c:371:17: error: implicit declaration of function 'seq_printf'; did you mean 'bstr_printf'? [-Werror=implicit-function-declaration]
     371 |                 seq_printf(s, "output %s ", val ? "high" : "low");
         |                 ^~~~~~~~~~
         |                 bstr_printf
>> drivers/pinctrl/pinctrl-stmfx.c:376:25: error: implicit declaration of function 'seq_puts' [-Werror=implicit-function-declaration]
     376 |                         seq_puts(s, "push pull no pull ");
         |                         ^~~~~~~~
   cc1: some warnings being treated as errors
--
   drivers/gpio/gpio-tegra186.c: In function 'tegra186_irq_print_chip':
>> drivers/gpio/gpio-tegra186.c:540:9: error: implicit declaration of function 'seq_printf'; did you mean 'bstr_printf'? [-Werror=implicit-function-declaration]
     540 |         seq_printf(p, dev_name(gc->parent));
         |         ^~~~~~~~~~
         |         bstr_printf
   cc1: some warnings being treated as errors
--
   drivers/media/platform/st/sti/c8sectpfe/c8sectpfe-core.c: In function 'configure_memdma_and_inputblock':
>> drivers/media/platform/st/sti/c8sectpfe/c8sectpfe-core.c:524:24: error: implicit declaration of function 'pinctrl_lookup_state' [-Werror=implicit-function-declaration]
     524 |         tsin->pstate = pinctrl_lookup_state(fei->pinctrl, tsin_pin_name);
         |                        ^~~~~~~~~~~~~~~~~~~~
>> drivers/media/platform/st/sti/c8sectpfe/c8sectpfe-core.c:524:22: warning: assignment to 'struct pinctrl_state *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
     524 |         tsin->pstate = pinctrl_lookup_state(fei->pinctrl, tsin_pin_name);
         |                      ^
>> drivers/media/platform/st/sti/c8sectpfe/c8sectpfe-core.c:532:15: error: implicit declaration of function 'pinctrl_select_state' [-Werror=implicit-function-declaration]
     532 |         ret = pinctrl_select_state(fei->pinctrl, tsin->pstate);
         |               ^~~~~~~~~~~~~~~~~~~~
   drivers/media/platform/st/sti/c8sectpfe/c8sectpfe-core.c: In function 'c8sectpfe_probe':
>> drivers/media/platform/st/sti/c8sectpfe/c8sectpfe-core.c:742:24: error: implicit declaration of function 'devm_pinctrl_get'; did you mean 'of_pinctrl_get'? [-Werror=implicit-function-declaration]
     742 |         fei->pinctrl = devm_pinctrl_get(dev);
         |                        ^~~~~~~~~~~~~~~~
         |                        of_pinctrl_get
>> drivers/media/platform/st/sti/c8sectpfe/c8sectpfe-core.c:742:22: warning: assignment to 'struct pinctrl *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
     742 |         fei->pinctrl = devm_pinctrl_get(dev);
         |                      ^
   cc1: some warnings being treated as errors
--
   drivers/pinctrl/freescale/pinctrl-imx.c: In function 'imx_pin_dbg_show':
>> drivers/pinctrl/freescale/pinctrl-imx.c:53:9: error: implicit declaration of function 'seq_printf'; did you mean 'bstr_printf'? [-Werror=implicit-function-declaration]
      53 |         seq_printf(s, "%s", dev_name(pctldev->dev));
         |         ^~~~~~~~~~
         |         bstr_printf
   drivers/pinctrl/freescale/pinctrl-imx.c: In function 'imx_pinconf_dbg_show':
>> drivers/pinctrl/freescale/pinctrl-imx.c:448:25: error: implicit declaration of function 'seq_puts' [-Werror=implicit-function-declaration]
     448 |                         seq_puts(s, "N/A");
         |                         ^~~~~~~~
   cc1: some warnings being treated as errors
--
   drivers/pinctrl/sprd/pinctrl-sprd.c: In function 'sprd_pinctrl_shutdown':
>> drivers/pinctrl/sprd/pinctrl-sprd.c:1125:18: error: implicit declaration of function 'devm_pinctrl_get'; did you mean 'of_pinctrl_get'? [-Werror=implicit-function-declaration]
    1125 |         pinctl = devm_pinctrl_get(&pdev->dev);
         |                  ^~~~~~~~~~~~~~~~
         |                  of_pinctrl_get
>> drivers/pinctrl/sprd/pinctrl-sprd.c:1125:16: warning: assignment to 'struct pinctrl *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
    1125 |         pinctl = devm_pinctrl_get(&pdev->dev);
         |                ^
>> drivers/pinctrl/sprd/pinctrl-sprd.c:1128:17: error: implicit declaration of function 'pinctrl_lookup_state' [-Werror=implicit-function-declaration]
    1128 |         state = pinctrl_lookup_state(pinctl, "shutdown");
         |                 ^~~~~~~~~~~~~~~~~~~~
>> drivers/pinctrl/sprd/pinctrl-sprd.c:1128:15: warning: assignment to 'struct pinctrl_state *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
    1128 |         state = pinctrl_lookup_state(pinctl, "shutdown");
         |               ^
>> drivers/pinctrl/sprd/pinctrl-sprd.c:1131:9: error: implicit declaration of function 'pinctrl_select_state' [-Werror=implicit-function-declaration]
    1131 |         pinctrl_select_state(pinctl, state);
         |         ^~~~~~~~~~~~~~~~~~~~
   cc1: some warnings being treated as errors
--
   drivers/pinctrl/ti/pinctrl-ti-iodelay.c: In function 'ti_iodelay_pin_dbg_show':
>> drivers/pinctrl/ti/pinctrl-ti-iodelay.c:676:9: error: implicit declaration of function 'seq_printf'; did you mean 'bstr_printf'? [-Werror=implicit-function-declaration]
     676 |         seq_printf(s, "%lx a: %i g: %i (%08x %08x %08x) %s ",
         |         ^~~~~~~~~~
         |         bstr_printf
   cc1: some warnings being treated as errors
--
   drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c: In function 'npcmgpio_dbg_show':
>> drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c:134:9: error: implicit declaration of function 'seq_printf'; did you mean 'bstr_printf'? [-Werror=implicit-function-declaration]
     134 |         seq_printf(s, "-- module %d [gpio%d - %d]\n",
         |         ^~~~~~~~~~
         |         bstr_printf
   drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c: In function 'npcmgpio_direction_input':
>> drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c:172:15: error: implicit declaration of function 'pinctrl_gpio_direction_input'; did you mean 'npcmgpio_direction_input'? [-Werror=implicit-function-declaration]
     172 |         ret = pinctrl_gpio_direction_input(offset + chip->base);
         |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
         |               npcmgpio_direction_input
   drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c: In function 'npcmgpio_direction_output':
>> drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c:189:15: error: implicit declaration of function 'pinctrl_gpio_direction_output'; did you mean 'npcmgpio_direction_output'? [-Werror=implicit-function-declaration]
     189 |         ret = pinctrl_gpio_direction_output(offset + chip->base);
         |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         |               npcmgpio_direction_output
   drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c: In function 'npcmgpio_gpio_request':
>> drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c:202:15: error: implicit declaration of function 'pinctrl_gpio_request'; did you mean 'npcmgpio_gpio_request'? [-Werror=implicit-function-declaration]
     202 |         ret = pinctrl_gpio_request(offset + chip->base);
         |               ^~~~~~~~~~~~~~~~~~~~
         |               npcmgpio_gpio_request
   drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c: In function 'npcmgpio_gpio_free':
>> drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c:212:9: error: implicit declaration of function 'pinctrl_gpio_free' [-Werror=implicit-function-declaration]
     212 |         pinctrl_gpio_free(offset + chip->base);
         |         ^~~~~~~~~~~~~~~~~
   cc1: some warnings being treated as errors
--
   drivers/pinctrl/renesas/pinctrl.c: In function 'sh_pfc_pin_dbg_show':
>> drivers/pinctrl/renesas/pinctrl.c:76:9: error: implicit declaration of function 'seq_puts' [-Werror=implicit-function-declaration]
      76 |         seq_puts(s, DRV_NAME);
         |         ^~~~~~~~
   cc1: some warnings being treated as errors
..


vim +/pinctrl_lookup_state +524 drivers/media/platform/st/sti/c8sectpfe/c8sectpfe-core.c

c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  444  
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  445  static int configure_memdma_and_inputblock(struct c8sectpfei *fei,
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  446  				struct channel_info *tsin)
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  447  {
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  448  	int ret;
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  449  	u32 tmp;
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  450  	char tsin_pin_name[MAX_NAME];
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  451  
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  452  	if (!fei || !tsin)
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  453  		return -EINVAL;
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  454  
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  455  	dev_dbg(fei->dev, "%s:%d Configuring channel=%p tsin=%d\n"
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  456  		, __func__, __LINE__, tsin, tsin->tsin_id);
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  457  
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  458  	init_completion(&tsin->idle_completion);
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  459  
64e46b637bbafc drivers/media/platform/st/sti/c8sectpfe/c8sectpfe-core.c Andy Shevchenko 2022-02-09  460  	tsin->back_buffer_start = kzalloc(FEI_BUFFER_SIZE + FEI_ALIGNMENT, GFP_KERNEL);
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  461  	if (!tsin->back_buffer_start) {
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  462  		ret = -ENOMEM;
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  463  		goto err_unmap;
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  464  	}
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  465  
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  466  	/* Ensure backbuffer is 32byte aligned */
64e46b637bbafc drivers/media/platform/st/sti/c8sectpfe/c8sectpfe-core.c Andy Shevchenko 2022-02-09  467  	tsin->back_buffer_aligned = tsin->back_buffer_start + FEI_ALIGNMENT;
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  468  
64e46b637bbafc drivers/media/platform/st/sti/c8sectpfe/c8sectpfe-core.c Andy Shevchenko 2022-02-09  469  	tsin->back_buffer_aligned = PTR_ALIGN(tsin->back_buffer_aligned, FEI_ALIGNMENT);
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  470  
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  471  	tsin->back_buffer_busaddr = dma_map_single(fei->dev,
64e46b637bbafc drivers/media/platform/st/sti/c8sectpfe/c8sectpfe-core.c Andy Shevchenko 2022-02-09  472  					tsin->back_buffer_aligned,
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  473  					FEI_BUFFER_SIZE,
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  474  					DMA_BIDIRECTIONAL);
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  475  
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  476  	if (dma_mapping_error(fei->dev, tsin->back_buffer_busaddr)) {
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  477  		dev_err(fei->dev, "failed to map back_buffer\n");
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  478  		ret = -EFAULT;
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  479  		goto err_unmap;
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  480  	}
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  481  
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  482  	/*
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  483  	 * The pid buffer can be configured (in hw) for byte or bit
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  484  	 * per pid. By powers of deduction we conclude stih407 family
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  485  	 * is configured (at SoC design stage) for bit per pid.
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  486  	 */
64e46b637bbafc drivers/media/platform/st/sti/c8sectpfe/c8sectpfe-core.c Andy Shevchenko 2022-02-09  487  	tsin->pid_buffer_start = kzalloc(PID_TABLE_SIZE + PID_TABLE_SIZE, GFP_KERNEL);
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  488  	if (!tsin->pid_buffer_start) {
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  489  		ret = -ENOMEM;
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  490  		goto err_unmap;
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  491  	}
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  492  
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  493  	/*
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  494  	 * PID buffer needs to be aligned to size of the pid table
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  495  	 * which at bit per pid is 1024 bytes (8192 pids / 8).
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  496  	 * PIDF_BASE register enforces this alignment when writing
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  497  	 * the register.
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  498  	 */
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  499  
64e46b637bbafc drivers/media/platform/st/sti/c8sectpfe/c8sectpfe-core.c Andy Shevchenko 2022-02-09  500  	tsin->pid_buffer_aligned = tsin->pid_buffer_start + PID_TABLE_SIZE;
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  501  
64e46b637bbafc drivers/media/platform/st/sti/c8sectpfe/c8sectpfe-core.c Andy Shevchenko 2022-02-09  502  	tsin->pid_buffer_aligned = PTR_ALIGN(tsin->pid_buffer_aligned, PID_TABLE_SIZE);
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  503  
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  504  	tsin->pid_buffer_busaddr = dma_map_single(fei->dev,
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  505  						tsin->pid_buffer_aligned,
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  506  						PID_TABLE_SIZE,
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  507  						DMA_BIDIRECTIONAL);
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  508  
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  509  	if (dma_mapping_error(fei->dev, tsin->pid_buffer_busaddr)) {
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  510  		dev_err(fei->dev, "failed to map pid_bitmap\n");
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  511  		ret = -EFAULT;
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  512  		goto err_unmap;
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  513  	}
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  514  
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  515  	/* manage cache so pid bitmap is visible to HW */
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  516  	dma_sync_single_for_device(fei->dev,
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  517  				tsin->pid_buffer_busaddr,
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  518  				PID_TABLE_SIZE,
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  519  				DMA_TO_DEVICE);
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  520  
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  521  	snprintf(tsin_pin_name, MAX_NAME, "tsin%d-%s", tsin->tsin_id,
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  522  		(tsin->serial_not_parallel ? "serial" : "parallel"));
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  523  
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30 @524  	tsin->pstate = pinctrl_lookup_state(fei->pinctrl, tsin_pin_name);
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  525  	if (IS_ERR(tsin->pstate)) {
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  526  		dev_err(fei->dev, "%s: pinctrl_lookup_state couldn't find %s state\n"
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  527  			, __func__, tsin_pin_name);
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  528  		ret = PTR_ERR(tsin->pstate);
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  529  		goto err_unmap;
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  530  	}
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  531  
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30 @532  	ret = pinctrl_select_state(fei->pinctrl, tsin->pstate);
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  533  
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  534  	if (ret) {
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  535  		dev_err(fei->dev, "%s: pinctrl_select_state failed\n"
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  536  			, __func__);
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  537  		goto err_unmap;
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  538  	}
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  539  
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  540  	/* Enable this input block */
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  541  	tmp = readl(fei->io + SYS_INPUT_CLKEN);
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  542  	tmp |= BIT(tsin->tsin_id);
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  543  	writel(tmp, fei->io + SYS_INPUT_CLKEN);
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  544  
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  545  	if (tsin->serial_not_parallel)
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  546  		tmp |= C8SECTPFE_SERIAL_NOT_PARALLEL;
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  547  
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  548  	if (tsin->invert_ts_clk)
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  549  		tmp |= C8SECTPFE_INVERT_TSCLK;
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  550  
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  551  	if (tsin->async_not_sync)
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  552  		tmp |= C8SECTPFE_ASYNC_NOT_SYNC;
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  553  
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  554  	tmp |= C8SECTPFE_ALIGN_BYTE_SOP | C8SECTPFE_BYTE_ENDIANNESS_MSB;
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  555  
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  556  	writel(tmp, fei->io + C8SECTPFE_IB_IP_FMT_CFG(tsin->tsin_id));
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  557  
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  558  	writel(C8SECTPFE_SYNC(0x9) |
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  559  		C8SECTPFE_DROP(0x9) |
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  560  		C8SECTPFE_TOKEN(0x47),
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  561  		fei->io + C8SECTPFE_IB_SYNCLCKDRP_CFG(tsin->tsin_id));
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  562  
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  563  	writel(TS_PKT_SIZE, fei->io + C8SECTPFE_IB_PKT_LEN(tsin->tsin_id));
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  564  
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  565  	/* Place the FIFO's at the end of the irec descriptors */
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  566  
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  567  	tsin->fifo = (tsin->tsin_id * FIFO_LEN);
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  568  
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  569  	writel(tsin->fifo, fei->io + C8SECTPFE_IB_BUFF_STRT(tsin->tsin_id));
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  570  	writel(tsin->fifo + FIFO_LEN - 1,
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  571  		fei->io + C8SECTPFE_IB_BUFF_END(tsin->tsin_id));
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  572  
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  573  	writel(tsin->fifo, fei->io + C8SECTPFE_IB_READ_PNT(tsin->tsin_id));
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  574  	writel(tsin->fifo, fei->io + C8SECTPFE_IB_WRT_PNT(tsin->tsin_id));
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  575  
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  576  	writel(tsin->pid_buffer_busaddr,
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  577  		fei->io + PIDF_BASE(tsin->tsin_id));
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  578  
ee105cac24693c drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2016-03-24  579  	dev_dbg(fei->dev, "chan=%d PIDF_BASE=0x%x pid_bus_addr=%pad\n",
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  580  		tsin->tsin_id, readl(fei->io + PIDF_BASE(tsin->tsin_id)),
62e5f051c110a4 drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Fabio Estevam   2015-08-18  581  		&tsin->pid_buffer_busaddr);
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  582  
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  583  	/* Configure and enable HW PID filtering */
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  584  
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  585  	/*
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  586  	 * The PID value is created by assembling the first 8 bytes of
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  587  	 * the TS packet into a 64-bit word in big-endian format. A
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  588  	 * slice of that 64-bit word is taken from
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  589  	 * (PID_OFFSET+PID_NUM_BITS-1) to PID_OFFSET.
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  590  	 */
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  591  	tmp = (C8SECTPFE_PID_ENABLE | C8SECTPFE_PID_NUMBITS(13)
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  592  		| C8SECTPFE_PID_OFFSET(40));
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  593  
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  594  	writel(tmp, fei->io + C8SECTPFE_IB_PID_SET(tsin->tsin_id));
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  595  
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  596  	dev_dbg(fei->dev, "chan=%d setting wp: %d, rp: %d, buf: %d-%d\n",
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  597  		tsin->tsin_id,
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  598  		readl(fei->io + C8SECTPFE_IB_WRT_PNT(tsin->tsin_id)),
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  599  		readl(fei->io + C8SECTPFE_IB_READ_PNT(tsin->tsin_id)),
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  600  		readl(fei->io + C8SECTPFE_IB_BUFF_STRT(tsin->tsin_id)),
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  601  		readl(fei->io + C8SECTPFE_IB_BUFF_END(tsin->tsin_id)));
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  602  
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  603  	/* Get base addpress of pointer record block from DMEM */
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  604  	tsin->irec = fei->io + DMA_MEMDMA_OFFSET + DMA_DMEM_OFFSET +
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  605  			readl(fei->io + DMA_PTRREC_BASE);
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  606  
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  607  	/* fill out pointer record data structure */
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  608  
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  609  	/* advance pointer record block to our channel */
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  610  	tsin->irec += (tsin->tsin_id * DMA_PRDS_SIZE);
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  611  
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  612  	writel(tsin->fifo, tsin->irec + DMA_PRDS_MEMBASE);
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  613  
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  614  	writel(tsin->fifo + FIFO_LEN - 1, tsin->irec + DMA_PRDS_MEMTOP);
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  615  
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  616  	writel((188 + 7)&~7, tsin->irec + DMA_PRDS_PKTSIZE);
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  617  
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  618  	writel(0x1, tsin->irec + DMA_PRDS_TPENABLE);
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  619  
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  620  	/* read/write pointers with physical bus address */
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  621  
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  622  	writel(tsin->back_buffer_busaddr, tsin->irec + DMA_PRDS_BUSBASE_TP(0));
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  623  
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  624  	tmp = tsin->back_buffer_busaddr + FEI_BUFFER_SIZE - 1;
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  625  	writel(tmp, tsin->irec + DMA_PRDS_BUSTOP_TP(0));
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  626  
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  627  	writel(tsin->back_buffer_busaddr, tsin->irec + DMA_PRDS_BUSWP_TP(0));
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  628  	writel(tsin->back_buffer_busaddr, tsin->irec + DMA_PRDS_BUSRP_TP(0));
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  629  
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  630  	/* initialize tasklet */
9db2f6a480021d drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Allen Pais      2020-08-17  631  	tasklet_setup(&tsin->tsklet, channel_swdemux_tsklet);
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  632  
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  633  	return 0;
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  634  
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  635  err_unmap:
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  636  	free_input_block(fei, tsin);
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  637  	return ret;
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  638  }
c5f5d0f99794cf drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c    Peter Griffin   2015-07-30  639
kernel test robot Oct. 7, 2022, 1:33 p.m. UTC | #2
Hi Andy,

I love your patch! Perhaps something to improve:

[auto build test WARNING on linusw-pinctrl/devel]
[also build test WARNING on linus/master v6.0 next-20221007]
[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-Clean-up-headers/20221007-183311
base:   https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git devel
config: arm-defconfig
compiler: arm-linux-gnueabi-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/5b392edeea764a64953fbab65c9a06b2745ebdd7
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Andy-Shevchenko/pinctrl-Clean-up-headers/20221007-183311
        git checkout 5b392edeea764a64953fbab65c9a06b2745ebdd7
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash drivers/pinctrl/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   drivers/pinctrl/pinctrl-st.c: In function 'st_gpio_direction_input':
   drivers/pinctrl/pinctrl-st.c:717:9: error: implicit declaration of function 'pinctrl_gpio_direction_input'; did you mean 'st_gpio_direction_input'? [-Werror=implicit-function-declaration]
     717 |         pinctrl_gpio_direction_input(chip->base + offset);
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
         |         st_gpio_direction_input
   drivers/pinctrl/pinctrl-st.c: In function 'st_gpio_direction_output':
   drivers/pinctrl/pinctrl-st.c:728:9: error: implicit declaration of function 'pinctrl_gpio_direction_output'; did you mean 'st_gpio_direction_output'? [-Werror=implicit-function-declaration]
     728 |         pinctrl_gpio_direction_output(chip->base + offset);
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         |         st_gpio_direction_output
   drivers/pinctrl/pinctrl-st.c: In function 'st_pinconf_dbg_show':
   drivers/pinctrl/pinctrl-st.c:1016:9: error: implicit declaration of function 'seq_printf'; did you mean 'bstr_printf'? [-Werror=implicit-function-declaration]
    1016 |         seq_printf(s, "[OE:%d,PU:%ld,OD:%ld]\t%s\n"
         |         ^~~~~~~~~~
         |         bstr_printf
   drivers/pinctrl/pinctrl-st.c: In function 'st_pctl_probe_dt':
   drivers/pinctrl/pinctrl-st.c:1664:37: error: implicit declaration of function 'devm_kasprintf_strarray' [-Werror=implicit-function-declaration]
    1664 |                         pin_names = devm_kasprintf_strarray(dev, bank_name, ST_GPIO_PINS_PER_BANK);
         |                                     ^~~~~~~~~~~~~~~~~~~~~~~
>> drivers/pinctrl/pinctrl-st.c:1664:35: warning: assignment to 'char **' from 'int' makes pointer from integer without a cast [-Wint-conversion]
    1664 |                         pin_names = devm_kasprintf_strarray(dev, bank_name, ST_GPIO_PINS_PER_BANK);
         |                                   ^
   cc1: some warnings being treated as errors


vim +1664 drivers/pinctrl/pinctrl-st.c

701016c0cba594 Srinivas KANDAGATLA 2013-06-20  1596  
701016c0cba594 Srinivas KANDAGATLA 2013-06-20  1597  static int st_pctl_probe_dt(struct platform_device *pdev,
701016c0cba594 Srinivas KANDAGATLA 2013-06-20  1598  	struct pinctrl_desc *pctl_desc, struct st_pinctrl *info)
701016c0cba594 Srinivas KANDAGATLA 2013-06-20  1599  {
f972707662dbaf Andy Shevchenko     2021-11-05  1600  	struct device *dev = &pdev->dev;
701016c0cba594 Srinivas KANDAGATLA 2013-06-20  1601  	int ret = 0;
701016c0cba594 Srinivas KANDAGATLA 2013-06-20  1602  	int i = 0, j = 0, k = 0, bank;
701016c0cba594 Srinivas KANDAGATLA 2013-06-20  1603  	struct pinctrl_pin_desc *pdesc;
f972707662dbaf Andy Shevchenko     2021-11-05  1604  	struct device_node *np = dev->of_node;
701016c0cba594 Srinivas KANDAGATLA 2013-06-20  1605  	struct device_node *child;
701016c0cba594 Srinivas KANDAGATLA 2013-06-20  1606  	int grp_index = 0;
727b0f71a56de6 Srinivas Kandagatla 2014-01-16  1607  	int irq = 0;
701016c0cba594 Srinivas KANDAGATLA 2013-06-20  1608  
701016c0cba594 Srinivas KANDAGATLA 2013-06-20  1609  	st_pctl_dt_child_count(info, np);
3d4d3e0a7d67a9 Andy Shevchenko     2021-11-05  1610  	if (!info->nbanks)
3d4d3e0a7d67a9 Andy Shevchenko     2021-11-05  1611  		return dev_err_probe(dev, -EINVAL, "you need at least one gpio bank\n");
701016c0cba594 Srinivas KANDAGATLA 2013-06-20  1612  
f972707662dbaf Andy Shevchenko     2021-11-05  1613  	dev_info(dev, "nbanks = %d\n", info->nbanks);
f972707662dbaf Andy Shevchenko     2021-11-05  1614  	dev_info(dev, "nfunctions = %d\n", info->nfunctions);
f972707662dbaf Andy Shevchenko     2021-11-05  1615  	dev_info(dev, "ngroups = %d\n", info->ngroups);
701016c0cba594 Srinivas KANDAGATLA 2013-06-20  1616  
f972707662dbaf Andy Shevchenko     2021-11-05  1617  	info->functions = devm_kcalloc(dev, info->nfunctions, sizeof(*info->functions), GFP_KERNEL);
701016c0cba594 Srinivas KANDAGATLA 2013-06-20  1618  
f972707662dbaf Andy Shevchenko     2021-11-05  1619  	info->groups = devm_kcalloc(dev, info->ngroups, sizeof(*info->groups), GFP_KERNEL);
701016c0cba594 Srinivas KANDAGATLA 2013-06-20  1620  
f972707662dbaf Andy Shevchenko     2021-11-05  1621  	info->banks = devm_kcalloc(dev, info->nbanks, sizeof(*info->banks), GFP_KERNEL);
701016c0cba594 Srinivas KANDAGATLA 2013-06-20  1622  
701016c0cba594 Srinivas KANDAGATLA 2013-06-20  1623  	if (!info->functions || !info->groups || !info->banks)
701016c0cba594 Srinivas KANDAGATLA 2013-06-20  1624  		return -ENOMEM;
701016c0cba594 Srinivas KANDAGATLA 2013-06-20  1625  
701016c0cba594 Srinivas KANDAGATLA 2013-06-20  1626  	info->regmap = syscon_regmap_lookup_by_phandle(np, "st,syscfg");
3d4d3e0a7d67a9 Andy Shevchenko     2021-11-05  1627  	if (IS_ERR(info->regmap))
3d4d3e0a7d67a9 Andy Shevchenko     2021-11-05  1628  		return dev_err_probe(dev, PTR_ERR(info->regmap), "No syscfg phandle specified\n");
701016c0cba594 Srinivas KANDAGATLA 2013-06-20  1629  	info->data = of_match_node(st_pctl_of_match, np)->data;
701016c0cba594 Srinivas KANDAGATLA 2013-06-20  1630  
727b0f71a56de6 Srinivas Kandagatla 2014-01-16  1631  	irq = platform_get_irq(pdev, 0);
727b0f71a56de6 Srinivas Kandagatla 2014-01-16  1632  
727b0f71a56de6 Srinivas Kandagatla 2014-01-16  1633  	if (irq > 0) {
3809671d95a1c4 Andy Shevchenko     2021-11-05  1634  		info->irqmux_base = devm_platform_ioremap_resource_byname(pdev, "irqmux");
727b0f71a56de6 Srinivas Kandagatla 2014-01-16  1635  		if (IS_ERR(info->irqmux_base))
727b0f71a56de6 Srinivas Kandagatla 2014-01-16  1636  			return PTR_ERR(info->irqmux_base);
727b0f71a56de6 Srinivas Kandagatla 2014-01-16  1637  
1b11b0cb799e5f Thomas Gleixner     2015-06-21  1638  		irq_set_chained_handler_and_data(irq, st_gpio_irqmux_handler,
1b11b0cb799e5f Thomas Gleixner     2015-06-21  1639  						 info);
727b0f71a56de6 Srinivas Kandagatla 2014-01-16  1640  	}
727b0f71a56de6 Srinivas Kandagatla 2014-01-16  1641  
701016c0cba594 Srinivas KANDAGATLA 2013-06-20  1642  	pctl_desc->npins = info->nbanks * ST_GPIO_PINS_PER_BANK;
f972707662dbaf Andy Shevchenko     2021-11-05  1643  	pdesc =	devm_kcalloc(dev, pctl_desc->npins, sizeof(*pdesc), GFP_KERNEL);
701016c0cba594 Srinivas KANDAGATLA 2013-06-20  1644  	if (!pdesc)
701016c0cba594 Srinivas KANDAGATLA 2013-06-20  1645  		return -ENOMEM;
701016c0cba594 Srinivas KANDAGATLA 2013-06-20  1646  
701016c0cba594 Srinivas KANDAGATLA 2013-06-20  1647  	pctl_desc->pins = pdesc;
701016c0cba594 Srinivas KANDAGATLA 2013-06-20  1648  
701016c0cba594 Srinivas KANDAGATLA 2013-06-20  1649  	bank = 0;
701016c0cba594 Srinivas KANDAGATLA 2013-06-20  1650  	for_each_child_of_node(np, child) {
701016c0cba594 Srinivas KANDAGATLA 2013-06-20  1651  		if (of_property_read_bool(child, "gpio-controller")) {
701016c0cba594 Srinivas KANDAGATLA 2013-06-20  1652  			const char *bank_name = NULL;
3956d6c85f26b5 Andy Shevchenko     2021-11-05  1653  			char **pin_names;
3956d6c85f26b5 Andy Shevchenko     2021-11-05  1654  
701016c0cba594 Srinivas KANDAGATLA 2013-06-20  1655  			ret = st_gpiolib_register_bank(info, bank, child);
19d17d935b29f3 Nishka Dasgupta     2019-08-15  1656  			if (ret) {
19d17d935b29f3 Nishka Dasgupta     2019-08-15  1657  				of_node_put(child);
701016c0cba594 Srinivas KANDAGATLA 2013-06-20  1658  				return ret;
19d17d935b29f3 Nishka Dasgupta     2019-08-15  1659  			}
701016c0cba594 Srinivas KANDAGATLA 2013-06-20  1660  
701016c0cba594 Srinivas KANDAGATLA 2013-06-20  1661  			k = info->banks[bank].range.pin_base;
701016c0cba594 Srinivas KANDAGATLA 2013-06-20  1662  			bank_name = info->banks[bank].range.name;
3956d6c85f26b5 Andy Shevchenko     2021-11-05  1663  
3956d6c85f26b5 Andy Shevchenko     2021-11-05 @1664  			pin_names = devm_kasprintf_strarray(dev, bank_name, ST_GPIO_PINS_PER_BANK);
3956d6c85f26b5 Andy Shevchenko     2021-11-05  1665  			if (IS_ERR(pin_names)) {
3956d6c85f26b5 Andy Shevchenko     2021-11-05  1666  				of_node_put(child);
3956d6c85f26b5 Andy Shevchenko     2021-11-05  1667  				return PTR_ERR(pin_names);
3956d6c85f26b5 Andy Shevchenko     2021-11-05  1668  			}
3956d6c85f26b5 Andy Shevchenko     2021-11-05  1669  
701016c0cba594 Srinivas KANDAGATLA 2013-06-20  1670  			for (j = 0; j < ST_GPIO_PINS_PER_BANK; j++, k++) {
701016c0cba594 Srinivas KANDAGATLA 2013-06-20  1671  				pdesc->number = k;
3956d6c85f26b5 Andy Shevchenko     2021-11-05  1672  				pdesc->name = pin_names[j];
701016c0cba594 Srinivas KANDAGATLA 2013-06-20  1673  				pdesc++;
701016c0cba594 Srinivas KANDAGATLA 2013-06-20  1674  			}
701016c0cba594 Srinivas KANDAGATLA 2013-06-20  1675  			st_parse_syscfgs(info, bank, child);
701016c0cba594 Srinivas KANDAGATLA 2013-06-20  1676  			bank++;
701016c0cba594 Srinivas KANDAGATLA 2013-06-20  1677  		} else {
701016c0cba594 Srinivas KANDAGATLA 2013-06-20  1678  			ret = st_pctl_parse_functions(child, info,
701016c0cba594 Srinivas KANDAGATLA 2013-06-20  1679  							i++, &grp_index);
701016c0cba594 Srinivas KANDAGATLA 2013-06-20  1680  			if (ret) {
f972707662dbaf Andy Shevchenko     2021-11-05  1681  				dev_err(dev, "No functions found.\n");
19d17d935b29f3 Nishka Dasgupta     2019-08-15  1682  				of_node_put(child);
701016c0cba594 Srinivas KANDAGATLA 2013-06-20  1683  				return ret;
701016c0cba594 Srinivas KANDAGATLA 2013-06-20  1684  			}
701016c0cba594 Srinivas KANDAGATLA 2013-06-20  1685  		}
701016c0cba594 Srinivas KANDAGATLA 2013-06-20  1686  	}
701016c0cba594 Srinivas KANDAGATLA 2013-06-20  1687  
701016c0cba594 Srinivas KANDAGATLA 2013-06-20  1688  	return 0;
701016c0cba594 Srinivas KANDAGATLA 2013-06-20  1689  }
701016c0cba594 Srinivas KANDAGATLA 2013-06-20  1690
kernel test robot Oct. 7, 2022, 1:33 p.m. UTC | #3
Hi Andy,

I love your patch! Perhaps something to improve:

[auto build test WARNING on linusw-pinctrl/devel]
[also build test WARNING on linus/master v6.0 next-20221007]
[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-Clean-up-headers/20221007-183311
base:   https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git devel
config: x86_64-randconfig-a002-20221003
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/5b392edeea764a64953fbab65c9a06b2745ebdd7
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Andy-Shevchenko/pinctrl-Clean-up-headers/20221007-183311
        git checkout 5b392edeea764a64953fbab65c9a06b2745ebdd7
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/pinctrl/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   drivers/pinctrl/pinmux.c:34:46: error: incomplete definition of type 'struct pinctrl_desc'
           const struct pinmux_ops *ops = pctldev->desc->pmxops;
                                          ~~~~~~~~~~~~~^
   drivers/pinctrl/core.h:44:9: note: forward declaration of 'struct pinctrl_desc'
           struct pinctrl_desc *desc;
                  ^
   drivers/pinctrl/pinmux.c:87:46: error: incomplete definition of type 'struct pinctrl_desc'
           const struct pinmux_ops *ops = pctldev->desc->pmxops;
                                          ~~~~~~~~~~~~~^
   drivers/pinctrl/core.h:44:9: note: forward declaration of 'struct pinctrl_desc'
           struct pinctrl_desc *desc;
                  ^
   drivers/pinctrl/pinmux.c:113:46: error: incomplete definition of type 'struct pinctrl_desc'
           const struct pinmux_ops *ops = pctldev->desc->pmxops;
                                          ~~~~~~~~~~~~~^
   drivers/pinctrl/core.h:44:9: note: forward declaration of 'struct pinctrl_desc'
           struct pinctrl_desc *desc;
                  ^
   drivers/pinctrl/pinmux.c:210:46: error: incomplete definition of type 'struct pinctrl_desc'
           const struct pinmux_ops *ops = pctldev->desc->pmxops;
                                          ~~~~~~~~~~~~~^
   drivers/pinctrl/core.h:44:9: note: forward declaration of 'struct pinctrl_desc'
           struct pinctrl_desc *desc;
                  ^
   drivers/pinctrl/pinmux.c:270:46: error: incomplete definition of type 'struct pinctrl_gpio_range'
           owner = kasprintf(GFP_KERNEL, "%s:%d", range->name, gpio);
                                                  ~~~~~^
   include/linux/pinctrl/pinmux.h:17:8: note: forward declaration of 'struct pinctrl_gpio_range'
   struct pinctrl_gpio_range;
          ^
   drivers/pinctrl/pinmux.c:310:21: error: incomplete definition of type 'struct pinctrl_desc'
           ops = pctldev->desc->pmxops;
                 ~~~~~~~~~~~~~^
   drivers/pinctrl/core.h:44:9: note: forward declaration of 'struct pinctrl_desc'
           struct pinctrl_desc *desc;
                  ^
   drivers/pinctrl/pinmux.c:323:46: error: incomplete definition of type 'struct pinctrl_desc'
           const struct pinmux_ops *ops = pctldev->desc->pmxops;
                                          ~~~~~~~~~~~~~^
   drivers/pinctrl/core.h:44:9: note: forward declaration of 'struct pinctrl_desc'
           struct pinctrl_desc *desc;
                  ^
   drivers/pinctrl/pinmux.c:344:49: error: incomplete definition of type 'struct pinctrl_desc'
           const struct pinmux_ops *pmxops = pctldev->desc->pmxops;
                                             ~~~~~~~~~~~~~^
   drivers/pinctrl/core.h:44:9: note: forward declaration of 'struct pinctrl_desc'
           struct pinctrl_desc *desc;
                  ^
   drivers/pinctrl/pinmux.c:408:51: error: incomplete definition of type 'struct pinctrl_desc'
           const struct pinctrl_ops *pctlops = pctldev->desc->pctlops;
                                               ~~~~~~~~~~~~~^
   drivers/pinctrl/core.h:44:9: note: forward declaration of 'struct pinctrl_desc'
           struct pinctrl_desc *desc;
                  ^
   drivers/pinctrl/pinmux.c:409:46: error: incomplete definition of type 'struct pinctrl_desc'
           const struct pinmux_ops *ops = pctldev->desc->pmxops;
                                          ~~~~~~~~~~~~~^
   drivers/pinctrl/core.h:44:9: note: forward declaration of 'struct pinctrl_desc'
           struct pinctrl_desc *desc;
                  ^
   drivers/pinctrl/pinmux.c:416:13: error: incomplete definition of type 'struct pinctrl_ops'
           if (pctlops->get_group_pins)
               ~~~~~~~^
   drivers/pinctrl/pinmux.c:408:15: note: forward declaration of 'struct pinctrl_ops'
           const struct pinctrl_ops *pctlops = pctldev->desc->pctlops;
                        ^
   drivers/pinctrl/pinmux.c:417:16: error: incomplete definition of type 'struct pinctrl_ops'
                   ret = pctlops->get_group_pins(pctldev, setting->data.mux.group,
                         ~~~~~~~^
   drivers/pinctrl/pinmux.c:408:15: note: forward declaration of 'struct pinctrl_ops'
           const struct pinctrl_ops *pctlops = pctldev->desc->pctlops;
                        ^
   drivers/pinctrl/pinmux.c:424:18: error: incomplete definition of type 'struct pinctrl_ops'
                   gname = pctlops->get_group_name(pctldev,
                           ~~~~~~~^
   drivers/pinctrl/pinmux.c:408:15: note: forward declaration of 'struct pinctrl_ops'
           const struct pinctrl_ops *pctlops = pctldev->desc->pctlops;
                        ^
   drivers/pinctrl/pinmux.c:441:19: error: incomplete definition of type 'struct pinctrl_ops'
                           gname = pctlops->get_group_name(pctldev,
                                   ~~~~~~~^
   drivers/pinctrl/pinmux.c:408:15: note: forward declaration of 'struct pinctrl_ops'
           const struct pinctrl_ops *pctlops = pctldev->desc->pctlops;
                        ^
   drivers/pinctrl/pinmux.c:447:5: error: implicit declaration of function 'pinctrl_dev_get_name' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
                                   pinctrl_dev_get_name(pctldev));
                                   ^
>> drivers/pinctrl/pinmux.c:447:5: warning: format specifies type 'char *' but the argument has type 'int' [-Wformat]
                                   pinctrl_dev_get_name(pctldev));
                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/dev_printk.h:144:65: note: expanded from macro 'dev_err'
           dev_printk_index_wrap(_dev_err, KERN_ERR, dev, dev_fmt(fmt), ##__VA_ARGS__)
                                                                  ~~~     ^~~~~~~~~~~
   include/linux/dev_printk.h:110:23: note: expanded from macro 'dev_printk_index_wrap'
                   _p_func(dev, fmt, ##__VA_ARGS__);                       \
                                ~~~    ^~~~~~~~~~~
   drivers/pinctrl/pinmux.c:489:51: error: incomplete definition of type 'struct pinctrl_desc'
           const struct pinctrl_ops *pctlops = pctldev->desc->pctlops;
                                               ~~~~~~~~~~~~~^
   drivers/pinctrl/core.h:44:9: note: forward declaration of 'struct pinctrl_desc'
           struct pinctrl_desc *desc;
                  ^
   drivers/pinctrl/pinmux.c:496:13: error: incomplete definition of type 'struct pinctrl_ops'
           if (pctlops->get_group_pins)
               ~~~~~~~^
   drivers/pinctrl/pinmux.c:489:15: note: forward declaration of 'struct pinctrl_ops'
           const struct pinctrl_ops *pctlops = pctldev->desc->pctlops;
                        ^
   drivers/pinctrl/pinmux.c:497:16: error: incomplete definition of type 'struct pinctrl_ops'
                   ret = pctlops->get_group_pins(pctldev, setting->data.mux.group,
                         ~~~~~~~^
   drivers/pinctrl/pinmux.c:489:15: note: forward declaration of 'struct pinctrl_ops'
           const struct pinctrl_ops *pctlops = pctldev->desc->pctlops;
                        ^
   drivers/pinctrl/pinmux.c:503:18: error: incomplete definition of type 'struct pinctrl_ops'
                   gname = pctlops->get_group_name(pctldev,
                           ~~~~~~~^
   drivers/pinctrl/pinmux.c:489:15: note: forward declaration of 'struct pinctrl_ops'
           const struct pinctrl_ops *pctlops = pctldev->desc->pctlops;
                        ^
   fatal error: too many errors emitted, stopping now [-ferror-limit=]
   1 warning and 20 errors generated.


vim +447 drivers/pinctrl/pinmux.c

2744e8afb3b763 Linus Walleij   2011-05-02  404  
3f713b7c223ebe Masahiro Yamada 2017-08-04  405  int pinmux_enable_setting(const struct pinctrl_setting *setting)
2744e8afb3b763 Linus Walleij   2011-05-02  406  {
7ecdb16fe63e5b Stephen Warren  2012-03-02  407  	struct pinctrl_dev *pctldev = setting->pctldev;
ba110d90c08d96 Stephen Warren  2012-03-02  408  	const struct pinctrl_ops *pctlops = pctldev->desc->pctlops;
2744e8afb3b763 Linus Walleij   2011-05-02  409  	const struct pinmux_ops *ops = pctldev->desc->pmxops;
e5b3b2d9ed2026 Antoine Tenart  2014-04-10  410  	int ret = 0;
e5b3b2d9ed2026 Antoine Tenart  2014-04-10  411  	const unsigned *pins = NULL;
e5b3b2d9ed2026 Antoine Tenart  2014-04-10  412  	unsigned num_pins = 0;
ba110d90c08d96 Stephen Warren  2012-03-02  413  	int i;
ba110d90c08d96 Stephen Warren  2012-03-02  414  	struct pin_desc *desc;
ba110d90c08d96 Stephen Warren  2012-03-02  415  
e5b3b2d9ed2026 Antoine Tenart  2014-04-10  416  	if (pctlops->get_group_pins)
ba110d90c08d96 Stephen Warren  2012-03-02  417  		ret = pctlops->get_group_pins(pctldev, setting->data.mux.group,
ba110d90c08d96 Stephen Warren  2012-03-02  418  					      &pins, &num_pins);
e5b3b2d9ed2026 Antoine Tenart  2014-04-10  419  
ba110d90c08d96 Stephen Warren  2012-03-02  420  	if (ret) {
1c8e794432c2ee Linus Walleij   2013-08-14  421  		const char *gname;
1c8e794432c2ee Linus Walleij   2013-08-14  422  
ba110d90c08d96 Stephen Warren  2012-03-02  423  		/* errors only affect debug data, so just warn */
1c8e794432c2ee Linus Walleij   2013-08-14  424  		gname = pctlops->get_group_name(pctldev,
ba110d90c08d96 Stephen Warren  2012-03-02  425  						setting->data.mux.group);
1c8e794432c2ee Linus Walleij   2013-08-14  426  		dev_warn(pctldev->dev,
1c8e794432c2ee Linus Walleij   2013-08-14  427  			 "could not get pins for group %s\n",
1c8e794432c2ee Linus Walleij   2013-08-14  428  			 gname);
ba110d90c08d96 Stephen Warren  2012-03-02  429  		num_pins = 0;
ba110d90c08d96 Stephen Warren  2012-03-02  430  	}
ba110d90c08d96 Stephen Warren  2012-03-02  431  
1a78958dc212f3 Linus Walleij   2012-10-17  432  	/* Try to allocate all pins in this group, one by one */
1a78958dc212f3 Linus Walleij   2012-10-17  433  	for (i = 0; i < num_pins; i++) {
1a78958dc212f3 Linus Walleij   2012-10-17  434  		ret = pin_request(pctldev, pins[i], setting->dev_name, NULL);
1a78958dc212f3 Linus Walleij   2012-10-17  435  		if (ret) {
1c8e794432c2ee Linus Walleij   2013-08-14  436  			const char *gname;
1c8e794432c2ee Linus Walleij   2013-08-14  437  			const char *pname;
1c8e794432c2ee Linus Walleij   2013-08-14  438  
1c8e794432c2ee Linus Walleij   2013-08-14  439  			desc = pin_desc_get(pctldev, pins[i]);
1c8e794432c2ee Linus Walleij   2013-08-14  440  			pname = desc ? desc->name : "non-existing";
1c8e794432c2ee Linus Walleij   2013-08-14  441  			gname = pctlops->get_group_name(pctldev,
1c8e794432c2ee Linus Walleij   2013-08-14  442  						setting->data.mux.group);
1a78958dc212f3 Linus Walleij   2012-10-17  443  			dev_err(pctldev->dev,
1c8e794432c2ee Linus Walleij   2013-08-14  444  				"could not request pin %d (%s) from group %s "
1c8e794432c2ee Linus Walleij   2013-08-14  445  				" on device %s\n",
1c8e794432c2ee Linus Walleij   2013-08-14  446  				pins[i], pname, gname,
1c8e794432c2ee Linus Walleij   2013-08-14 @447  				pinctrl_dev_get_name(pctldev));
e38d457de7be63 Axel Lin        2012-11-10  448  			goto err_pin_request;
1a78958dc212f3 Linus Walleij   2012-10-17  449  		}
1a78958dc212f3 Linus Walleij   2012-10-17  450  	}
1a78958dc212f3 Linus Walleij   2012-10-17  451  
1a78958dc212f3 Linus Walleij   2012-10-17  452  	/* Now that we have acquired the pins, encode the mux setting */
ba110d90c08d96 Stephen Warren  2012-03-02  453  	for (i = 0; i < num_pins; i++) {
ba110d90c08d96 Stephen Warren  2012-03-02  454  		desc = pin_desc_get(pctldev, pins[i]);
ba110d90c08d96 Stephen Warren  2012-03-02  455  		if (desc == NULL) {
ba110d90c08d96 Stephen Warren  2012-03-02  456  			dev_warn(pctldev->dev,
ba110d90c08d96 Stephen Warren  2012-03-02  457  				 "could not get pin desc for pin %d\n",
ba110d90c08d96 Stephen Warren  2012-03-02  458  				 pins[i]);
ba110d90c08d96 Stephen Warren  2012-03-02  459  			continue;
ba110d90c08d96 Stephen Warren  2012-03-02  460  		}
ba110d90c08d96 Stephen Warren  2012-03-02  461  		desc->mux_setting = &(setting->data.mux);
ba110d90c08d96 Stephen Warren  2012-03-02  462  	}
2744e8afb3b763 Linus Walleij   2011-05-02  463  
03e9f0cac5da6a Linus Walleij   2014-09-03  464  	ret = ops->set_mux(pctldev, setting->data.mux.func,
1e2082b5207217 Stephen Warren  2012-03-02  465  			   setting->data.mux.group);
e38d457de7be63 Axel Lin        2012-11-10  466  
e38d457de7be63 Axel Lin        2012-11-10  467  	if (ret)
03e9f0cac5da6a Linus Walleij   2014-09-03  468  		goto err_set_mux;
e38d457de7be63 Axel Lin        2012-11-10  469  
e38d457de7be63 Axel Lin        2012-11-10  470  	return 0;
e38d457de7be63 Axel Lin        2012-11-10  471  
03e9f0cac5da6a Linus Walleij   2014-09-03  472  err_set_mux:
e38d457de7be63 Axel Lin        2012-11-10  473  	for (i = 0; i < num_pins; i++) {
e38d457de7be63 Axel Lin        2012-11-10  474  		desc = pin_desc_get(pctldev, pins[i]);
e38d457de7be63 Axel Lin        2012-11-10  475  		if (desc)
e38d457de7be63 Axel Lin        2012-11-10  476  			desc->mux_setting = NULL;
e38d457de7be63 Axel Lin        2012-11-10  477  	}
e38d457de7be63 Axel Lin        2012-11-10  478  err_pin_request:
e38d457de7be63 Axel Lin        2012-11-10  479  	/* On error release all taken pins */
e38d457de7be63 Axel Lin        2012-11-10  480  	while (--i >= 0)
e38d457de7be63 Axel Lin        2012-11-10  481  		pin_free(pctldev, pins[i], NULL);
e38d457de7be63 Axel Lin        2012-11-10  482  
e38d457de7be63 Axel Lin        2012-11-10  483  	return ret;
befe5bdfbb698b Linus Walleij   2012-02-09  484  }
2744e8afb3b763 Linus Walleij   2011-05-02  485
kernel test robot Oct. 7, 2022, 1:47 p.m. UTC | #4
Hi Andy,

I love your patch! Yet something to improve:

[auto build test ERROR on linusw-pinctrl/devel]
[also build test ERROR on linus/master v6.0 next-20221007]
[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-Clean-up-headers/20221007-183311
base:   https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git devel
config: hexagon-randconfig-r041-20221003
compiler: clang version 16.0.0 (https://github.com/llvm/llvm-project 791a7ae1ba3efd6bca96338e10ffde557ba83920)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/5b392edeea764a64953fbab65c9a06b2745ebdd7
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Andy-Shevchenko/pinctrl-Clean-up-headers/20221007-183311
        git checkout 5b392edeea764a64953fbab65c9a06b2745ebdd7
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash drivers/pinctrl/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All error/warnings (new ones prefixed by >>):

>> drivers/pinctrl/pinmux.c:34:46: error: incomplete definition of type 'struct pinctrl_desc'
           const struct pinmux_ops *ops = pctldev->desc->pmxops;
                                          ~~~~~~~~~~~~~^
   drivers/pinctrl/core.h:44:9: note: forward declaration of 'struct pinctrl_desc'
           struct pinctrl_desc *desc;
                  ^
   drivers/pinctrl/pinmux.c:87:46: error: incomplete definition of type 'struct pinctrl_desc'
           const struct pinmux_ops *ops = pctldev->desc->pmxops;
                                          ~~~~~~~~~~~~~^
   drivers/pinctrl/core.h:44:9: note: forward declaration of 'struct pinctrl_desc'
           struct pinctrl_desc *desc;
                  ^
   drivers/pinctrl/pinmux.c:113:46: error: incomplete definition of type 'struct pinctrl_desc'
           const struct pinmux_ops *ops = pctldev->desc->pmxops;
                                          ~~~~~~~~~~~~~^
   drivers/pinctrl/core.h:44:9: note: forward declaration of 'struct pinctrl_desc'
           struct pinctrl_desc *desc;
                  ^
   drivers/pinctrl/pinmux.c:210:46: error: incomplete definition of type 'struct pinctrl_desc'
           const struct pinmux_ops *ops = pctldev->desc->pmxops;
                                          ~~~~~~~~~~~~~^
   drivers/pinctrl/core.h:44:9: note: forward declaration of 'struct pinctrl_desc'
           struct pinctrl_desc *desc;
                  ^
>> drivers/pinctrl/pinmux.c:270:46: error: incomplete definition of type 'struct pinctrl_gpio_range'
           owner = kasprintf(GFP_KERNEL, "%s:%d", range->name, gpio);
                                                  ~~~~~^
   include/linux/pinctrl/pinmux.h:17:8: note: forward declaration of 'struct pinctrl_gpio_range'
   struct pinctrl_gpio_range;
          ^
   drivers/pinctrl/pinmux.c:310:21: error: incomplete definition of type 'struct pinctrl_desc'
           ops = pctldev->desc->pmxops;
                 ~~~~~~~~~~~~~^
   drivers/pinctrl/core.h:44:9: note: forward declaration of 'struct pinctrl_desc'
           struct pinctrl_desc *desc;
                  ^
   drivers/pinctrl/pinmux.c:323:46: error: incomplete definition of type 'struct pinctrl_desc'
           const struct pinmux_ops *ops = pctldev->desc->pmxops;
                                          ~~~~~~~~~~~~~^
   drivers/pinctrl/core.h:44:9: note: forward declaration of 'struct pinctrl_desc'
           struct pinctrl_desc *desc;
                  ^
   drivers/pinctrl/pinmux.c:344:49: error: incomplete definition of type 'struct pinctrl_desc'
           const struct pinmux_ops *pmxops = pctldev->desc->pmxops;
                                             ~~~~~~~~~~~~~^
   drivers/pinctrl/core.h:44:9: note: forward declaration of 'struct pinctrl_desc'
           struct pinctrl_desc *desc;
                  ^
   drivers/pinctrl/pinmux.c:408:51: error: incomplete definition of type 'struct pinctrl_desc'
           const struct pinctrl_ops *pctlops = pctldev->desc->pctlops;
                                               ~~~~~~~~~~~~~^
   drivers/pinctrl/core.h:44:9: note: forward declaration of 'struct pinctrl_desc'
           struct pinctrl_desc *desc;
                  ^
   drivers/pinctrl/pinmux.c:409:46: error: incomplete definition of type 'struct pinctrl_desc'
           const struct pinmux_ops *ops = pctldev->desc->pmxops;
                                          ~~~~~~~~~~~~~^
   drivers/pinctrl/core.h:44:9: note: forward declaration of 'struct pinctrl_desc'
           struct pinctrl_desc *desc;
                  ^
>> drivers/pinctrl/pinmux.c:416:13: error: incomplete definition of type 'struct pinctrl_ops'
           if (pctlops->get_group_pins)
               ~~~~~~~^
   include/linux/compiler.h:56:47: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                                                 ^~~~
   include/linux/compiler.h:58:52: note: expanded from macro '__trace_if_var'
   #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : __trace_if_value(cond))
                                                      ^~~~
   drivers/pinctrl/pinmux.c:408:15: note: forward declaration of 'struct pinctrl_ops'
           const struct pinctrl_ops *pctlops = pctldev->desc->pctlops;
                        ^
>> drivers/pinctrl/pinmux.c:416:13: error: incomplete definition of type 'struct pinctrl_ops'
           if (pctlops->get_group_pins)
               ~~~~~~~^
   include/linux/compiler.h:56:47: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                                                 ^~~~
   include/linux/compiler.h:58:61: note: expanded from macro '__trace_if_var'
   #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : __trace_if_value(cond))
                                                               ^~~~
   drivers/pinctrl/pinmux.c:408:15: note: forward declaration of 'struct pinctrl_ops'
           const struct pinctrl_ops *pctlops = pctldev->desc->pctlops;
                        ^
>> drivers/pinctrl/pinmux.c:416:13: error: incomplete definition of type 'struct pinctrl_ops'
           if (pctlops->get_group_pins)
               ~~~~~~~^
   include/linux/compiler.h:56:47: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                                                 ^~~~
   include/linux/compiler.h:58:86: note: expanded from macro '__trace_if_var'
   #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : __trace_if_value(cond))
                                                                                        ^~~~
   include/linux/compiler.h:69:3: note: expanded from macro '__trace_if_value'
           (cond) ?                                        \
            ^~~~
   drivers/pinctrl/pinmux.c:408:15: note: forward declaration of 'struct pinctrl_ops'
           const struct pinctrl_ops *pctlops = pctldev->desc->pctlops;
                        ^
   drivers/pinctrl/pinmux.c:417:16: error: incomplete definition of type 'struct pinctrl_ops'
                   ret = pctlops->get_group_pins(pctldev, setting->data.mux.group,
                         ~~~~~~~^
   drivers/pinctrl/pinmux.c:408:15: note: forward declaration of 'struct pinctrl_ops'
           const struct pinctrl_ops *pctlops = pctldev->desc->pctlops;
                        ^
   drivers/pinctrl/pinmux.c:424:18: error: incomplete definition of type 'struct pinctrl_ops'
                   gname = pctlops->get_group_name(pctldev,
                           ~~~~~~~^
   drivers/pinctrl/pinmux.c:408:15: note: forward declaration of 'struct pinctrl_ops'
           const struct pinctrl_ops *pctlops = pctldev->desc->pctlops;
                        ^
   drivers/pinctrl/pinmux.c:441:19: error: incomplete definition of type 'struct pinctrl_ops'
                           gname = pctlops->get_group_name(pctldev,
                                   ~~~~~~~^
   drivers/pinctrl/pinmux.c:408:15: note: forward declaration of 'struct pinctrl_ops'
           const struct pinctrl_ops *pctlops = pctldev->desc->pctlops;
                        ^
>> drivers/pinctrl/pinmux.c:447:5: error: call to undeclared function 'pinctrl_dev_get_name'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
                                   pinctrl_dev_get_name(pctldev));
                                   ^
>> drivers/pinctrl/pinmux.c:447:5: warning: format specifies type 'char *' but the argument has type 'int' [-Wformat]
                                   pinctrl_dev_get_name(pctldev));
                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/dev_printk.h:144:65: note: expanded from macro 'dev_err'
           dev_printk_index_wrap(_dev_err, KERN_ERR, dev, dev_fmt(fmt), ##__VA_ARGS__)
                                                                  ~~~     ^~~~~~~~~~~
   include/linux/dev_printk.h:110:23: note: expanded from macro 'dev_printk_index_wrap'
                   _p_func(dev, fmt, ##__VA_ARGS__);                       \
                                ~~~    ^~~~~~~~~~~
   drivers/pinctrl/pinmux.c:489:51: error: incomplete definition of type 'struct pinctrl_desc'
           const struct pinctrl_ops *pctlops = pctldev->desc->pctlops;
                                               ~~~~~~~~~~~~~^
   drivers/pinctrl/core.h:44:9: note: forward declaration of 'struct pinctrl_desc'
           struct pinctrl_desc *desc;
                  ^
   drivers/pinctrl/pinmux.c:496:13: error: incomplete definition of type 'struct pinctrl_ops'
           if (pctlops->get_group_pins)
               ~~~~~~~^
   include/linux/compiler.h:56:47: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                                                 ^~~~
   include/linux/compiler.h:58:52: note: expanded from macro '__trace_if_var'
   #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : __trace_if_value(cond))
                                                      ^~~~
   drivers/pinctrl/pinmux.c:489:15: note: forward declaration of 'struct pinctrl_ops'
           const struct pinctrl_ops *pctlops = pctldev->desc->pctlops;
                        ^
   fatal error: too many errors emitted, stopping now [-ferror-limit=]
   1 warning and 20 errors generated.


vim +270 drivers/pinctrl/pinmux.c

2744e8afb3b763 Linus Walleij    2011-05-02  254  
2744e8afb3b763 Linus Walleij    2011-05-02  255  /**
befe5bdfbb698b Linus Walleij    2012-02-09  256   * pinmux_request_gpio() - request pinmuxing for a GPIO pin
befe5bdfbb698b Linus Walleij    2012-02-09  257   * @pctldev: pin controller device affected
befe5bdfbb698b Linus Walleij    2012-02-09  258   * @pin: the pin to mux in for GPIO
befe5bdfbb698b Linus Walleij    2012-02-09  259   * @range: the applicable GPIO range
d340351f8168d2 Lee Jones        2020-07-13  260   * @gpio: number of requested GPIO
2744e8afb3b763 Linus Walleij    2011-05-02  261   */
befe5bdfbb698b Linus Walleij    2012-02-09  262  int pinmux_request_gpio(struct pinctrl_dev *pctldev,
befe5bdfbb698b Linus Walleij    2012-02-09  263  			struct pinctrl_gpio_range *range,
befe5bdfbb698b Linus Walleij    2012-02-09  264  			unsigned pin, unsigned gpio)
2744e8afb3b763 Linus Walleij    2011-05-02  265  {
3cc70ed32cd6c5 Stephen Warren   2012-02-19  266  	const char *owner;
2744e8afb3b763 Linus Walleij    2011-05-02  267  	int ret;
2744e8afb3b763 Linus Walleij    2011-05-02  268  
2744e8afb3b763 Linus Walleij    2011-05-02  269  	/* Conjure some name stating what chip and pin this is taken by */
23a895aee6081c Thomas Petazzoni 2012-09-13 @270  	owner = kasprintf(GFP_KERNEL, "%s:%d", range->name, gpio);
3cc70ed32cd6c5 Stephen Warren   2012-02-19  271  	if (!owner)
1fb1f0540deae6 Masahiro Yamada  2016-05-25  272  		return -ENOMEM;
5d2eaf8090874f Stephen Warren   2011-10-19  273  
3cc70ed32cd6c5 Stephen Warren   2012-02-19  274  	ret = pin_request(pctldev, pin, owner, range);
5d2eaf8090874f Stephen Warren   2011-10-19  275  	if (ret < 0)
3cc70ed32cd6c5 Stephen Warren   2012-02-19  276  		kfree(owner);
5d2eaf8090874f Stephen Warren   2011-10-19  277  
5d2eaf8090874f Stephen Warren   2011-10-19  278  	return ret;
2744e8afb3b763 Linus Walleij    2011-05-02  279  }
2744e8afb3b763 Linus Walleij    2011-05-02  280  
2744e8afb3b763 Linus Walleij    2011-05-02  281  /**
befe5bdfbb698b Linus Walleij    2012-02-09  282   * pinmux_free_gpio() - release a pin from GPIO muxing
befe5bdfbb698b Linus Walleij    2012-02-09  283   * @pctldev: the pin controller device for the pin
befe5bdfbb698b Linus Walleij    2012-02-09  284   * @pin: the affected currently GPIO-muxed in pin
befe5bdfbb698b Linus Walleij    2012-02-09  285   * @range: applicable GPIO range
2744e8afb3b763 Linus Walleij    2011-05-02  286   */
befe5bdfbb698b Linus Walleij    2012-02-09  287  void pinmux_free_gpio(struct pinctrl_dev *pctldev, unsigned pin,
befe5bdfbb698b Linus Walleij    2012-02-09  288  		      struct pinctrl_gpio_range *range)
2744e8afb3b763 Linus Walleij    2011-05-02  289  {
3cc70ed32cd6c5 Stephen Warren   2012-02-19  290  	const char *owner;
2744e8afb3b763 Linus Walleij    2011-05-02  291  
3cc70ed32cd6c5 Stephen Warren   2012-02-19  292  	owner = pin_free(pctldev, pin, range);
3cc70ed32cd6c5 Stephen Warren   2012-02-19  293  	kfree(owner);
2744e8afb3b763 Linus Walleij    2011-05-02  294  }
2744e8afb3b763 Linus Walleij    2011-05-02  295  
befe5bdfbb698b Linus Walleij    2012-02-09  296  /**
befe5bdfbb698b Linus Walleij    2012-02-09  297   * pinmux_gpio_direction() - set the direction of a single muxed-in GPIO pin
befe5bdfbb698b Linus Walleij    2012-02-09  298   * @pctldev: the pin controller handling this pin
befe5bdfbb698b Linus Walleij    2012-02-09  299   * @range: applicable GPIO range
befe5bdfbb698b Linus Walleij    2012-02-09  300   * @pin: the affected GPIO pin in this controller
befe5bdfbb698b Linus Walleij    2012-02-09  301   * @input: true if we set the pin as input, false for output
befe5bdfbb698b Linus Walleij    2012-02-09  302   */
befe5bdfbb698b Linus Walleij    2012-02-09  303  int pinmux_gpio_direction(struct pinctrl_dev *pctldev,
befe5bdfbb698b Linus Walleij    2012-02-09  304  			  struct pinctrl_gpio_range *range,
befe5bdfbb698b Linus Walleij    2012-02-09  305  			  unsigned pin, bool input)
542e704f3ffee1 Linus Walleij    2011-11-14  306  {
542e704f3ffee1 Linus Walleij    2011-11-14  307  	const struct pinmux_ops *ops;
542e704f3ffee1 Linus Walleij    2011-11-14  308  	int ret;
542e704f3ffee1 Linus Walleij    2011-11-14  309  
542e704f3ffee1 Linus Walleij    2011-11-14  310  	ops = pctldev->desc->pmxops;
542e704f3ffee1 Linus Walleij    2011-11-14  311  
542e704f3ffee1 Linus Walleij    2011-11-14  312  	if (ops->gpio_set_direction)
542e704f3ffee1 Linus Walleij    2011-11-14  313  		ret = ops->gpio_set_direction(pctldev, range, pin, input);
542e704f3ffee1 Linus Walleij    2011-11-14  314  	else
542e704f3ffee1 Linus Walleij    2011-11-14  315  		ret = 0;
542e704f3ffee1 Linus Walleij    2011-11-14  316  
542e704f3ffee1 Linus Walleij    2011-11-14  317  	return ret;
542e704f3ffee1 Linus Walleij    2011-11-14  318  }
542e704f3ffee1 Linus Walleij    2011-11-14  319  
7ecdb16fe63e5b Stephen Warren   2012-03-02  320  static int pinmux_func_name_to_selector(struct pinctrl_dev *pctldev,
7ecdb16fe63e5b Stephen Warren   2012-03-02  321  					const char *function)
2744e8afb3b763 Linus Walleij    2011-05-02  322  {
7ecdb16fe63e5b Stephen Warren   2012-03-02  323  	const struct pinmux_ops *ops = pctldev->desc->pmxops;
d1e90e9e7467db Viresh Kumar     2012-03-30  324  	unsigned nfuncs = ops->get_functions_count(pctldev);
7ecdb16fe63e5b Stephen Warren   2012-03-02  325  	unsigned selector = 0;
2744e8afb3b763 Linus Walleij    2011-05-02  326  
7ecdb16fe63e5b Stephen Warren   2012-03-02  327  	/* See if this pctldev has this function */
d1e90e9e7467db Viresh Kumar     2012-03-30  328  	while (selector < nfuncs) {
163dc9f39a26b4 Masahiro Yamada  2015-08-01  329  		const char *fname = ops->get_function_name(pctldev, selector);
2744e8afb3b763 Linus Walleij    2011-05-02  330  
7ecdb16fe63e5b Stephen Warren   2012-03-02  331  		if (!strcmp(function, fname))
7ecdb16fe63e5b Stephen Warren   2012-03-02  332  			return selector;
2744e8afb3b763 Linus Walleij    2011-05-02  333  
7ecdb16fe63e5b Stephen Warren   2012-03-02  334  		selector++;
2744e8afb3b763 Linus Walleij    2011-05-02  335  	}
2744e8afb3b763 Linus Walleij    2011-05-02  336  
7ecdb16fe63e5b Stephen Warren   2012-03-02  337  	return -EINVAL;
2744e8afb3b763 Linus Walleij    2011-05-02  338  }
2744e8afb3b763 Linus Walleij    2011-05-02  339  
3f713b7c223ebe Masahiro Yamada  2017-08-04  340  int pinmux_map_to_setting(const struct pinctrl_map *map,
7ecdb16fe63e5b Stephen Warren   2012-03-02  341  			  struct pinctrl_setting *setting)
2744e8afb3b763 Linus Walleij    2011-05-02  342  {
7ecdb16fe63e5b Stephen Warren   2012-03-02  343  	struct pinctrl_dev *pctldev = setting->pctldev;
2744e8afb3b763 Linus Walleij    2011-05-02  344  	const struct pinmux_ops *pmxops = pctldev->desc->pmxops;
2744e8afb3b763 Linus Walleij    2011-05-02  345  	char const * const *groups;
2744e8afb3b763 Linus Walleij    2011-05-02  346  	unsigned num_groups;
2744e8afb3b763 Linus Walleij    2011-05-02  347  	int ret;
7ecdb16fe63e5b Stephen Warren   2012-03-02  348  	const char *group;
2744e8afb3b763 Linus Walleij    2011-05-02  349  
ad8bb720c23a80 Dong Aisheng     2012-04-10  350  	if (!pmxops) {
ad8bb720c23a80 Dong Aisheng     2012-04-10  351  		dev_err(pctldev->dev, "does not support mux function\n");
ad8bb720c23a80 Dong Aisheng     2012-04-10  352  		return -EINVAL;
ad8bb720c23a80 Dong Aisheng     2012-04-10  353  	}
ad8bb720c23a80 Dong Aisheng     2012-04-10  354  
15f70e1b9a1a63 John Crispin     2012-04-23  355  	ret = pinmux_func_name_to_selector(pctldev, map->data.mux.function);
ad6e1107baa2e7 John Crispin     2012-04-26  356  	if (ret < 0) {
ad6e1107baa2e7 John Crispin     2012-04-26  357  		dev_err(pctldev->dev, "invalid function %s in map table\n",
ad6e1107baa2e7 John Crispin     2012-04-26  358  			map->data.mux.function);
15f70e1b9a1a63 John Crispin     2012-04-23  359  		return ret;
ad6e1107baa2e7 John Crispin     2012-04-26  360  	}
15f70e1b9a1a63 John Crispin     2012-04-23  361  	setting->data.mux.func = ret;
7ecdb16fe63e5b Stephen Warren   2012-03-02  362  
1e2082b5207217 Stephen Warren   2012-03-02  363  	ret = pmxops->get_function_groups(pctldev, setting->data.mux.func,
7ecdb16fe63e5b Stephen Warren   2012-03-02  364  					  &groups, &num_groups);
ad6e1107baa2e7 John Crispin     2012-04-26  365  	if (ret < 0) {
ad6e1107baa2e7 John Crispin     2012-04-26  366  		dev_err(pctldev->dev, "can't query groups for function %s\n",
ad6e1107baa2e7 John Crispin     2012-04-26  367  			map->data.mux.function);
2744e8afb3b763 Linus Walleij    2011-05-02  368  		return ret;
ad6e1107baa2e7 John Crispin     2012-04-26  369  	}
ad6e1107baa2e7 John Crispin     2012-04-26  370  	if (!num_groups) {
ad6e1107baa2e7 John Crispin     2012-04-26  371  		dev_err(pctldev->dev,
ad6e1107baa2e7 John Crispin     2012-04-26  372  			"function %s can't be selected on any group\n",
ad6e1107baa2e7 John Crispin     2012-04-26  373  			map->data.mux.function);
7ecdb16fe63e5b Stephen Warren   2012-03-02  374  		return -EINVAL;
ad6e1107baa2e7 John Crispin     2012-04-26  375  	}
1e2082b5207217 Stephen Warren   2012-03-02  376  	if (map->data.mux.group) {
1e2082b5207217 Stephen Warren   2012-03-02  377  		group = map->data.mux.group;
dff43594481269 Andy Shevchenko  2016-03-17  378  		ret = match_string(groups, num_groups, group);
dff43594481269 Andy Shevchenko  2016-03-17  379  		if (ret < 0) {
ad6e1107baa2e7 John Crispin     2012-04-26  380  			dev_err(pctldev->dev,
ad6e1107baa2e7 John Crispin     2012-04-26  381  				"invalid group \"%s\" for function \"%s\"\n",
ad6e1107baa2e7 John Crispin     2012-04-26  382  				group, map->data.mux.function);
dff43594481269 Andy Shevchenko  2016-03-17  383  			return ret;
ad6e1107baa2e7 John Crispin     2012-04-26  384  		}
7ecdb16fe63e5b Stephen Warren   2012-03-02  385  	} else {
7ecdb16fe63e5b Stephen Warren   2012-03-02  386  		group = groups[0];
2744e8afb3b763 Linus Walleij    2011-05-02  387  	}
2744e8afb3b763 Linus Walleij    2011-05-02  388  
15f70e1b9a1a63 John Crispin     2012-04-23  389  	ret = pinctrl_get_group_selector(pctldev, group);
ad6e1107baa2e7 John Crispin     2012-04-26  390  	if (ret < 0) {
ad6e1107baa2e7 John Crispin     2012-04-26  391  		dev_err(pctldev->dev, "invalid group %s in map table\n",
ad6e1107baa2e7 John Crispin     2012-04-26  392  			map->data.mux.group);
15f70e1b9a1a63 John Crispin     2012-04-23  393  		return ret;
ad6e1107baa2e7 John Crispin     2012-04-26  394  	}
15f70e1b9a1a63 John Crispin     2012-04-23  395  	setting->data.mux.group = ret;
2744e8afb3b763 Linus Walleij    2011-05-02  396  
2744e8afb3b763 Linus Walleij    2011-05-02  397  	return 0;
2744e8afb3b763 Linus Walleij    2011-05-02  398  }
2744e8afb3b763 Linus Walleij    2011-05-02  399  
3f713b7c223ebe Masahiro Yamada  2017-08-04  400  void pinmux_free_setting(const struct pinctrl_setting *setting)
2744e8afb3b763 Linus Walleij    2011-05-02  401  {
1a78958dc212f3 Linus Walleij    2012-10-17  402  	/* This function is currently unused */
2744e8afb3b763 Linus Walleij    2011-05-02  403  }
2744e8afb3b763 Linus Walleij    2011-05-02  404  
3f713b7c223ebe Masahiro Yamada  2017-08-04  405  int pinmux_enable_setting(const struct pinctrl_setting *setting)
2744e8afb3b763 Linus Walleij    2011-05-02  406  {
7ecdb16fe63e5b Stephen Warren   2012-03-02  407  	struct pinctrl_dev *pctldev = setting->pctldev;
ba110d90c08d96 Stephen Warren   2012-03-02  408  	const struct pinctrl_ops *pctlops = pctldev->desc->pctlops;
2744e8afb3b763 Linus Walleij    2011-05-02  409  	const struct pinmux_ops *ops = pctldev->desc->pmxops;
e5b3b2d9ed2026 Antoine Tenart   2014-04-10  410  	int ret = 0;
e5b3b2d9ed2026 Antoine Tenart   2014-04-10  411  	const unsigned *pins = NULL;
e5b3b2d9ed2026 Antoine Tenart   2014-04-10  412  	unsigned num_pins = 0;
ba110d90c08d96 Stephen Warren   2012-03-02  413  	int i;
ba110d90c08d96 Stephen Warren   2012-03-02  414  	struct pin_desc *desc;
ba110d90c08d96 Stephen Warren   2012-03-02  415  
e5b3b2d9ed2026 Antoine Tenart   2014-04-10 @416  	if (pctlops->get_group_pins)
ba110d90c08d96 Stephen Warren   2012-03-02  417  		ret = pctlops->get_group_pins(pctldev, setting->data.mux.group,
ba110d90c08d96 Stephen Warren   2012-03-02  418  					      &pins, &num_pins);
e5b3b2d9ed2026 Antoine Tenart   2014-04-10  419  
ba110d90c08d96 Stephen Warren   2012-03-02  420  	if (ret) {
1c8e794432c2ee Linus Walleij    2013-08-14  421  		const char *gname;
1c8e794432c2ee Linus Walleij    2013-08-14  422  
ba110d90c08d96 Stephen Warren   2012-03-02  423  		/* errors only affect debug data, so just warn */
1c8e794432c2ee Linus Walleij    2013-08-14  424  		gname = pctlops->get_group_name(pctldev,
ba110d90c08d96 Stephen Warren   2012-03-02  425  						setting->data.mux.group);
1c8e794432c2ee Linus Walleij    2013-08-14  426  		dev_warn(pctldev->dev,
1c8e794432c2ee Linus Walleij    2013-08-14  427  			 "could not get pins for group %s\n",
1c8e794432c2ee Linus Walleij    2013-08-14  428  			 gname);
ba110d90c08d96 Stephen Warren   2012-03-02  429  		num_pins = 0;
ba110d90c08d96 Stephen Warren   2012-03-02  430  	}
ba110d90c08d96 Stephen Warren   2012-03-02  431  
1a78958dc212f3 Linus Walleij    2012-10-17  432  	/* Try to allocate all pins in this group, one by one */
1a78958dc212f3 Linus Walleij    2012-10-17  433  	for (i = 0; i < num_pins; i++) {
1a78958dc212f3 Linus Walleij    2012-10-17  434  		ret = pin_request(pctldev, pins[i], setting->dev_name, NULL);
1a78958dc212f3 Linus Walleij    2012-10-17  435  		if (ret) {
1c8e794432c2ee Linus Walleij    2013-08-14  436  			const char *gname;
1c8e794432c2ee Linus Walleij    2013-08-14  437  			const char *pname;
1c8e794432c2ee Linus Walleij    2013-08-14  438  
1c8e794432c2ee Linus Walleij    2013-08-14  439  			desc = pin_desc_get(pctldev, pins[i]);
1c8e794432c2ee Linus Walleij    2013-08-14  440  			pname = desc ? desc->name : "non-existing";
1c8e794432c2ee Linus Walleij    2013-08-14  441  			gname = pctlops->get_group_name(pctldev,
1c8e794432c2ee Linus Walleij    2013-08-14  442  						setting->data.mux.group);
1a78958dc212f3 Linus Walleij    2012-10-17  443  			dev_err(pctldev->dev,
1c8e794432c2ee Linus Walleij    2013-08-14  444  				"could not request pin %d (%s) from group %s "
1c8e794432c2ee Linus Walleij    2013-08-14  445  				" on device %s\n",
1c8e794432c2ee Linus Walleij    2013-08-14  446  				pins[i], pname, gname,
1c8e794432c2ee Linus Walleij    2013-08-14 @447  				pinctrl_dev_get_name(pctldev));
e38d457de7be63 Axel Lin         2012-11-10  448  			goto err_pin_request;
1a78958dc212f3 Linus Walleij    2012-10-17  449  		}
1a78958dc212f3 Linus Walleij    2012-10-17  450  	}
1a78958dc212f3 Linus Walleij    2012-10-17  451  
1a78958dc212f3 Linus Walleij    2012-10-17  452  	/* Now that we have acquired the pins, encode the mux setting */
ba110d90c08d96 Stephen Warren   2012-03-02  453  	for (i = 0; i < num_pins; i++) {
ba110d90c08d96 Stephen Warren   2012-03-02  454  		desc = pin_desc_get(pctldev, pins[i]);
ba110d90c08d96 Stephen Warren   2012-03-02  455  		if (desc == NULL) {
ba110d90c08d96 Stephen Warren   2012-03-02  456  			dev_warn(pctldev->dev,
ba110d90c08d96 Stephen Warren   2012-03-02  457  				 "could not get pin desc for pin %d\n",
ba110d90c08d96 Stephen Warren   2012-03-02  458  				 pins[i]);
ba110d90c08d96 Stephen Warren   2012-03-02  459  			continue;
ba110d90c08d96 Stephen Warren   2012-03-02  460  		}
ba110d90c08d96 Stephen Warren   2012-03-02  461  		desc->mux_setting = &(setting->data.mux);
ba110d90c08d96 Stephen Warren   2012-03-02  462  	}
2744e8afb3b763 Linus Walleij    2011-05-02  463  
03e9f0cac5da6a Linus Walleij    2014-09-03  464  	ret = ops->set_mux(pctldev, setting->data.mux.func,
1e2082b5207217 Stephen Warren   2012-03-02  465  			   setting->data.mux.group);
e38d457de7be63 Axel Lin         2012-11-10  466  
e38d457de7be63 Axel Lin         2012-11-10  467  	if (ret)
03e9f0cac5da6a Linus Walleij    2014-09-03  468  		goto err_set_mux;
e38d457de7be63 Axel Lin         2012-11-10  469  
e38d457de7be63 Axel Lin         2012-11-10  470  	return 0;
e38d457de7be63 Axel Lin         2012-11-10  471  
03e9f0cac5da6a Linus Walleij    2014-09-03  472  err_set_mux:
e38d457de7be63 Axel Lin         2012-11-10  473  	for (i = 0; i < num_pins; i++) {
e38d457de7be63 Axel Lin         2012-11-10  474  		desc = pin_desc_get(pctldev, pins[i]);
e38d457de7be63 Axel Lin         2012-11-10  475  		if (desc)
e38d457de7be63 Axel Lin         2012-11-10  476  			desc->mux_setting = NULL;
e38d457de7be63 Axel Lin         2012-11-10  477  	}
e38d457de7be63 Axel Lin         2012-11-10  478  err_pin_request:
e38d457de7be63 Axel Lin         2012-11-10  479  	/* On error release all taken pins */
e38d457de7be63 Axel Lin         2012-11-10  480  	while (--i >= 0)
e38d457de7be63 Axel Lin         2012-11-10  481  		pin_free(pctldev, pins[i], NULL);
e38d457de7be63 Axel Lin         2012-11-10  482  
e38d457de7be63 Axel Lin         2012-11-10  483  	return ret;
befe5bdfbb698b Linus Walleij    2012-02-09  484  }
2744e8afb3b763 Linus Walleij    2011-05-02  485
diff mbox series

Patch

diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
index 9e57f4c62e60..655f9502e73f 100644
--- a/drivers/pinctrl/core.c
+++ b/drivers/pinctrl/core.c
@@ -12,19 +12,21 @@ 
  */
 #define pr_fmt(fmt) "pinctrl core: " fmt
 
-#include <linux/kernel.h>
-#include <linux/kref.h>
-#include <linux/export.h>
-#include <linux/init.h>
+#include <linux/debugfs.h>
 #include <linux/device.h>
-#include <linux/slab.h>
 #include <linux/err.h>
+#include <linux/export.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/kref.h>
 #include <linux/list.h>
-#include <linux/debugfs.h>
 #include <linux/seq_file.h>
+#include <linux/slab.h>
+
 #include <linux/pinctrl/consumer.h>
-#include <linux/pinctrl/pinctrl.h>
+#include <linux/pinctrl/devinfo.h>
 #include <linux/pinctrl/machine.h>
+#include <linux/pinctrl/pinctrl.h>
 
 #ifdef CONFIG_GPIOLIB
 #include "../gpio/gpiolib.h"
@@ -33,9 +35,8 @@ 
 
 #include "core.h"
 #include "devicetree.h"
-#include "pinmux.h"
 #include "pinconf.h"
-
+#include "pinmux.h"
 
 static bool pinctrl_dummy_state;
 
diff --git a/include/linux/pinctrl/consumer.h b/include/linux/pinctrl/consumer.h
index 019fecd75d0c..4729d54e8995 100644
--- a/include/linux/pinctrl/consumer.h
+++ b/include/linux/pinctrl/consumer.h
@@ -12,14 +12,15 @@ 
 #define __LINUX_PINCTRL_CONSUMER_H
 
 #include <linux/err.h>
-#include <linux/list.h>
-#include <linux/seq_file.h>
+#include <linux/types.h>
+
 #include <linux/pinctrl/pinctrl-state.h>
 
+struct device;
+
 /* This struct is private to the core and should be regarded as a cookie */
 struct pinctrl;
 struct pinctrl_state;
-struct device;
 
 #ifdef CONFIG_PINCTRL
 
@@ -33,9 +34,8 @@  extern int pinctrl_gpio_set_config(unsigned gpio, unsigned long config);
 
 extern struct pinctrl * __must_check pinctrl_get(struct device *dev);
 extern void pinctrl_put(struct pinctrl *p);
-extern struct pinctrl_state * __must_check pinctrl_lookup_state(
-							struct pinctrl *p,
-							const char *name);
+extern struct pinctrl_state * __must_check pinctrl_lookup_state(struct pinctrl *p,
+								const char *name);
 extern int pinctrl_select_state(struct pinctrl *p, struct pinctrl_state *s);
 
 extern struct pinctrl * __must_check devm_pinctrl_get(struct device *dev);
@@ -101,9 +101,8 @@  static inline void pinctrl_put(struct pinctrl *p)
 {
 }
 
-static inline struct pinctrl_state * __must_check pinctrl_lookup_state(
-							struct pinctrl *p,
-							const char *name)
+static inline struct pinctrl_state * __must_check pinctrl_lookup_state(struct pinctrl *p,
+								       const char *name)
 {
 	return NULL;
 }
@@ -145,8 +144,8 @@  static inline int pinctrl_pm_select_idle_state(struct device *dev)
 
 #endif /* CONFIG_PINCTRL */
 
-static inline struct pinctrl * __must_check pinctrl_get_select(
-					struct device *dev, const char *name)
+static inline struct pinctrl * __must_check pinctrl_get_select(struct device *dev,
+							       const char *name)
 {
 	struct pinctrl *p;
 	struct pinctrl_state *s;
@@ -171,14 +170,13 @@  static inline struct pinctrl * __must_check pinctrl_get_select(
 	return p;
 }
 
-static inline struct pinctrl * __must_check pinctrl_get_select_default(
-					struct device *dev)
+static inline struct pinctrl * __must_check pinctrl_get_select_default(struct device *dev)
 {
 	return pinctrl_get_select(dev, PINCTRL_STATE_DEFAULT);
 }
 
-static inline struct pinctrl * __must_check devm_pinctrl_get_select(
-					struct device *dev, const char *name)
+static inline struct pinctrl * __must_check devm_pinctrl_get_select(struct device *dev,
+								    const char *name)
 {
 	struct pinctrl *p;
 	struct pinctrl_state *s;
@@ -203,8 +201,7 @@  static inline struct pinctrl * __must_check devm_pinctrl_get_select(
 	return p;
 }
 
-static inline struct pinctrl * __must_check devm_pinctrl_get_select_default(
-					struct device *dev)
+static inline struct pinctrl * __must_check devm_pinctrl_get_select_default(struct device *dev)
 {
 	return devm_pinctrl_get_select(dev, PINCTRL_STATE_DEFAULT);
 }
diff --git a/include/linux/pinctrl/devinfo.h b/include/linux/pinctrl/devinfo.h
index a48ff69acddd..9e8b559e1253 100644
--- a/include/linux/pinctrl/devinfo.h
+++ b/include/linux/pinctrl/devinfo.h
@@ -14,11 +14,15 @@ 
 #ifndef PINCTRL_DEVINFO_H
 #define PINCTRL_DEVINFO_H
 
+struct device;
+
 #ifdef CONFIG_PINCTRL
 
 /* The device core acts as a consumer toward pinctrl */
 #include <linux/pinctrl/consumer.h>
 
+struct pinctrl;
+
 /**
  * struct dev_pin_info - pin state container for devices
  * @p: pinctrl handle for the containing device
@@ -42,8 +46,6 @@  extern int pinctrl_init_done(struct device *dev);
 
 #else
 
-struct device;
-
 /* Stubs if we're not using pinctrl */
 
 static inline int pinctrl_bind_pins(struct device *dev)
diff --git a/include/linux/pinctrl/machine.h b/include/linux/pinctrl/machine.h
index e987dc9fd2af..0639b36f43c5 100644
--- a/include/linux/pinctrl/machine.h
+++ b/include/linux/pinctrl/machine.h
@@ -11,7 +11,7 @@ 
 #ifndef __LINUX_PINCTRL_MACHINE_H
 #define __LINUX_PINCTRL_MACHINE_H
 
-#include <linux/bug.h>
+#include <linux/kernel.h>	/* ARRAY_SIZE() */
 
 #include <linux/pinctrl/pinctrl-state.h>
 
@@ -149,16 +149,18 @@  struct pinctrl_map {
 #define PIN_MAP_CONFIGS_GROUP_HOG_DEFAULT(dev, grp, cfgs)		\
 	PIN_MAP_CONFIGS_GROUP(dev, PINCTRL_STATE_DEFAULT, dev, grp, cfgs)
 
+struct pinctrl_map;
+
 #ifdef CONFIG_PINCTRL
 
 extern int pinctrl_register_mappings(const struct pinctrl_map *map,
-				unsigned num_maps);
+				     unsigned num_maps);
 extern void pinctrl_unregister_mappings(const struct pinctrl_map *map);
 extern void pinctrl_provide_dummies(void);
 #else
 
 static inline int pinctrl_register_mappings(const struct pinctrl_map *map,
-					   unsigned num_maps)
+					    unsigned num_maps)
 {
 	return 0;
 }
diff --git a/include/linux/pinctrl/pinconf-generic.h b/include/linux/pinctrl/pinconf-generic.h
index 2422211d6a5a..940fc4e9e17c 100644
--- a/include/linux/pinctrl/pinconf-generic.h
+++ b/include/linux/pinctrl/pinconf-generic.h
@@ -11,9 +11,12 @@ 
 #ifndef __LINUX_PINCTRL_PINCONF_GENERIC_H
 #define __LINUX_PINCTRL_PINCONF_GENERIC_H
 
-#include <linux/device.h>
+#include <linux/types.h>
+
 #include <linux/pinctrl/machine.h>
 
+struct device_node;
+
 struct pinctrl_dev;
 struct pinctrl_map;
 
@@ -196,25 +199,25 @@  int pinconf_generic_dt_node_to_map(struct pinctrl_dev *pctldev,
 void pinconf_generic_dt_free_map(struct pinctrl_dev *pctldev,
 		struct pinctrl_map *map, unsigned num_maps);
 
-static inline int pinconf_generic_dt_node_to_map_group(
-		struct pinctrl_dev *pctldev, struct device_node *np_config,
-		struct pinctrl_map **map, unsigned *num_maps)
+static inline int pinconf_generic_dt_node_to_map_group(struct pinctrl_dev *pctldev,
+		struct device_node *np_config, struct pinctrl_map **map,
+		unsigned *num_maps)
 {
 	return pinconf_generic_dt_node_to_map(pctldev, np_config, map, num_maps,
 			PIN_MAP_TYPE_CONFIGS_GROUP);
 }
 
-static inline int pinconf_generic_dt_node_to_map_pin(
-		struct pinctrl_dev *pctldev, struct device_node *np_config,
-		struct pinctrl_map **map, unsigned *num_maps)
+static inline int pinconf_generic_dt_node_to_map_pin(struct pinctrl_dev *pctldev,
+		struct device_node *np_config, struct pinctrl_map **map,
+		unsigned *num_maps)
 {
 	return pinconf_generic_dt_node_to_map(pctldev, np_config, map, num_maps,
 			PIN_MAP_TYPE_CONFIGS_PIN);
 }
 
-static inline int pinconf_generic_dt_node_to_map_all(
-		struct pinctrl_dev *pctldev, struct device_node *np_config,
-		struct pinctrl_map **map, unsigned *num_maps)
+static inline int pinconf_generic_dt_node_to_map_all(struct pinctrl_dev *pctldev,
+		struct device_node *np_config, struct pinctrl_map **map,
+		unsigned *num_maps)
 {
 	/*
 	 * passing the type as PIN_MAP_TYPE_INVALID causes the underlying parser
diff --git a/include/linux/pinctrl/pinctrl.h b/include/linux/pinctrl/pinctrl.h
index 487117ccb1bc..01ac6ff5bec4 100644
--- a/include/linux/pinctrl/pinctrl.h
+++ b/include/linux/pinctrl/pinctrl.h
@@ -11,20 +11,20 @@ 
 #ifndef __LINUX_PINCTRL_PINCTRL_H
 #define __LINUX_PINCTRL_PINCTRL_H
 
-#include <linux/radix-tree.h>
 #include <linux/list.h>
-#include <linux/seq_file.h>
-#include <linux/pinctrl/pinctrl-state.h>
-#include <linux/pinctrl/devinfo.h>
+#include <linux/types.h>
 
 struct device;
+struct device_node;
+struct gpio_chip;
+struct module;
+
+struct pin_config_item;
+struct pinconf_generic_params;
+struct pinconf_ops;
 struct pinctrl_dev;
 struct pinctrl_map;
 struct pinmux_ops;
-struct pinconf_ops;
-struct pin_config_item;
-struct gpio_chip;
-struct device_node;
 
 /**
  * struct pingroup - provides information on pingroup
diff --git a/include/linux/pinctrl/pinmux.h b/include/linux/pinctrl/pinmux.h
index 9a647fa5c8f1..a7e370965c53 100644
--- a/include/linux/pinctrl/pinmux.h
+++ b/include/linux/pinctrl/pinmux.h
@@ -11,11 +11,10 @@ 
 #ifndef __LINUX_PINCTRL_PINMUX_H
 #define __LINUX_PINCTRL_PINMUX_H
 
-#include <linux/list.h>
-#include <linux/seq_file.h>
-#include <linux/pinctrl/pinctrl.h>
+#include <linux/types.h>
 
 struct pinctrl_dev;
+struct pinctrl_gpio_range;
 
 /**
  * struct pinmux_ops - pinmux operations, to be implemented by pin controller