[v5,16/16] scripts: kernel-doc: validate kernel-doc markup with the actual names
diff mbox series

Message ID 03ac429b0d41755e491c8fd80ca927d65b87d7d1.1606823973.git.mchehab+huawei@kernel.org
State New, archived
Headers show
Series
  • Fix several bad kernel-doc markups
Related show

Commit Message

Mauro Carvalho Chehab Dec. 1, 2020, 12:09 p.m. UTC
Kernel-doc currently expects that the kernel-doc markup to come
just before the function/enum/struct/union/typedef prototype.

Yet, if it find things like:

	/**
	 * refcount_add - add a value to a refcount
	 * @i: the value to add to the refcount
	 * @r: the refcount
	 */
	static inline void __refcount_add(int i, refcount_t *r, int *oldp);
	static inline void refcount_add(int i, refcount_t *r);

Kernel-doc will do the wrong thing:

	foobar.h:6: warning: Function parameter or member 'oldp' not described in '__refcount_add'
	.. c:function:: void __refcount_add (int i, refcount_t *r, int *oldp)

	   add a value to a refcount

	**Parameters**

	``int i``
	  the value to add to the refcount

	``refcount_t *r``
	  the refcount

	``int *oldp``
	  *undescribed*

Basically, it will document "__refcount_add" with the kernel-doc
markup for refcount_add.

If both functions have the same arguments, this won't even
produce any warning!

Add a logic to check if the kernel-doc identifier matches the actual
name of the C function or data structure that will be documented.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 scripts/kernel-doc | 62 ++++++++++++++++++++++++++++++++++------------
 1 file changed, 46 insertions(+), 16 deletions(-)

Comments

kernel test robot Dec. 1, 2020, 3:06 p.m. UTC | #1
Hi Mauro,

I love your patch! Perhaps something to improve:

[auto build test WARNING on next-20201201]
[cannot apply to lwn/docs-next tip/sched/core hsi/for-next linus/master v5.10-rc6 v5.10-rc5 v5.10-rc4 v5.10-rc6]
[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]

url:    https://github.com/0day-ci/linux/commits/Mauro-Carvalho-Chehab/HSI-fix-a-kernel-doc-markup/20201201-210930
base:    0eedceafd3a63fd082743c914853ef4b9247dbe6
config: parisc-randconfig-s032-20201201 (attached as .config)
compiler: hppa-linux-gcc (GCC) 9.3.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # apt-get install sparse
        # sparse version: v0.6.3-170-g3bc348f6-dirty
        # https://github.com/0day-ci/linux/commit/7c52ba119279c74e6c7e968e3fa7290bd0f3b837
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Mauro-Carvalho-Chehab/HSI-fix-a-kernel-doc-markup/20201201-210930
        git checkout 7c52ba119279c74e6c7e968e3fa7290bd0f3b837
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=parisc 

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

All warnings (new ones prefixed by >>):

   arch/parisc/kernel/firmware.c:144: warning: Function parameter or member 'addr' not described in 'convert_to_wide'
   arch/parisc/kernel/firmware.c:144: warning: Excess function parameter 'address' description in 'convert_to_wide'
   arch/parisc/kernel/firmware.c:260: warning: Function parameter or member 'led_info' not described in 'pdc_chassis_info'
   arch/parisc/kernel/firmware.c:260: warning: Excess function parameter 'result' description in 'pdc_chassis_info'
   arch/parisc/kernel/firmware.c:284: warning: Function parameter or member 'state' not described in 'pdc_pat_chassis_send_log'
   arch/parisc/kernel/firmware.c:284: warning: Function parameter or member 'data' not described in 'pdc_pat_chassis_send_log'
   arch/parisc/kernel/firmware.c:284: warning: Excess function parameter 'retval' description in 'pdc_pat_chassis_send_log'
   arch/parisc/kernel/firmware.c:304: warning: Function parameter or member 'disp' not described in 'pdc_chassis_disp'
   arch/parisc/kernel/firmware.c:304: warning: Excess function parameter 'retval' description in 'pdc_chassis_disp'
>> arch/parisc/kernel/firmware.c:320: warning: expecting prototype for pdc_cpu_rendenzvous(). Prototype was for __pdc_cpu_rendezvous() instead
   arch/parisc/kernel/firmware.c:333: warning: Function parameter or member 'warn' not described in 'pdc_chassis_warn'
   arch/parisc/kernel/firmware.c:333: warning: Excess function parameter 'retval' description in 'pdc_chassis_warn'
   arch/parisc/kernel/firmware.c:519: warning: Function parameter or member 'versions' not described in 'pdc_model_versions'
   arch/parisc/kernel/firmware.c:519: warning: Excess function parameter 'cpu_id' description in 'pdc_model_versions'
   arch/parisc/kernel/firmware.c:963: warning: Function parameter or member 'hpa' not described in 'pdc_pci_config_read'
   arch/parisc/kernel/firmware.c:963: warning: Function parameter or member 'cfg_addr' not described in 'pdc_pci_config_read'
   arch/parisc/kernel/firmware.c:987: warning: Function parameter or member 'hpa' not described in 'pdc_pci_config_write'
   arch/parisc/kernel/firmware.c:987: warning: Function parameter or member 'cfg_addr' not described in 'pdc_pci_config_write'
   arch/parisc/kernel/firmware.c:987: warning: Function parameter or member 'val' not described in 'pdc_pci_config_write'
   arch/parisc/kernel/firmware.c:1464: warning: Function parameter or member 'actual_len' not described in 'pdc_pat_pd_get_addr_map'
   arch/parisc/kernel/firmware.c:1464: warning: Excess function parameter 'actlen' description in 'pdc_pat_pd_get_addr_map'
>> arch/parisc/kernel/firmware.c:1487: warning: expecting prototype for pdc_pat_pd_get_PDC_interface_revisions(). Prototype was for pdc_pat_pd_get_pdc_revisions() instead
   arch/parisc/kernel/firmware.c:1539: warning: Function parameter or member 'val' not described in 'pdc_pat_io_pci_cfg_write'
   arch/parisc/kernel/firmware.c:1539: warning: Excess function parameter 'value' description in 'pdc_pat_io_pci_cfg_write'
>> arch/parisc/kernel/firmware.c:1557: warning: expecting prototype for pdc_pat_mem_pdc_info(). Prototype was for pdc_pat_mem_pdt_info() instead
--
   arch/parisc/kernel/pdc_chassis.c:47: warning: Function parameter or member 'str' not described in 'pdc_chassis_setup'
   arch/parisc/kernel/pdc_chassis.c:64: warning: Excess function parameter 'pdc_chassis_old' description in 'pdc_chassis_checkold'
   arch/parisc/kernel/pdc_chassis.c:88: warning: Function parameter or member 'this' not described in 'pdc_chassis_panic_event'
   arch/parisc/kernel/pdc_chassis.c:88: warning: Function parameter or member 'event' not described in 'pdc_chassis_panic_event'
   arch/parisc/kernel/pdc_chassis.c:88: warning: Function parameter or member 'ptr' not described in 'pdc_chassis_panic_event'
   arch/parisc/kernel/pdc_chassis.c:108: warning: Function parameter or member 'this' not described in 'pdc_chassis_reboot_event'
   arch/parisc/kernel/pdc_chassis.c:108: warning: Function parameter or member 'event' not described in 'pdc_chassis_reboot_event'
   arch/parisc/kernel/pdc_chassis.c:108: warning: Function parameter or member 'ptr' not described in 'pdc_chassis_reboot_event'
>> arch/parisc/kernel/pdc_chassis.c:108: warning: expecting prototype for parisc_reboot_event(). Prototype was for pdc_chassis_reboot_event() instead
   arch/parisc/kernel/pdc_chassis.c:162: warning: Function parameter or member 'message' not described in 'pdc_chassis_send_status'
   arch/parisc/kernel/pdc_chassis.c:162: warning: Excess function parameter 'retval' description in 'pdc_chassis_send_status'
--
>> arch/parisc/kernel/processor.c:67: warning: expecting prototype for init_cpu_profiler(). Prototype was for init_percpu_prof() instead
--
   drivers/tty/serial/mux.c:118: warning: Function parameter or member 'port' not described in 'mux_set_mctrl'
   drivers/tty/serial/mux.c:118: warning: Excess function parameter 'ports' description in 'mux_set_mctrl'
>> drivers/tty/serial/mux.c:371: warning: expecting prototype for mux_drv_poll(). Prototype was for mux_poll() instead

vim +320 arch/parisc/kernel/firmware.c

^1da177e4c3f415 Linus Torvalds 2005-04-16  134  
^1da177e4c3f415 Linus Torvalds 2005-04-16  135  /**
^1da177e4c3f415 Linus Torvalds 2005-04-16  136   * convert_to_wide - Convert the return buffer addresses into kernel addresses.
^1da177e4c3f415 Linus Torvalds 2005-04-16  137   * @address: The return buffer from PDC.
^1da177e4c3f415 Linus Torvalds 2005-04-16  138   *
^1da177e4c3f415 Linus Torvalds 2005-04-16  139   * This function is used to convert the return buffer addresses retrieved from PDC
^1da177e4c3f415 Linus Torvalds 2005-04-16  140   * into kernel addresses when the PDC address size and kernel address size are
^1da177e4c3f415 Linus Torvalds 2005-04-16  141   * different.
^1da177e4c3f415 Linus Torvalds 2005-04-16  142   */
^1da177e4c3f415 Linus Torvalds 2005-04-16  143  static void convert_to_wide(unsigned long *addr)
^1da177e4c3f415 Linus Torvalds 2005-04-16 @144  {
a8f44e3889b6868 Helge Deller   2007-01-28  145  #ifdef CONFIG_64BIT
^1da177e4c3f415 Linus Torvalds 2005-04-16  146  	int i;
^1da177e4c3f415 Linus Torvalds 2005-04-16  147  	unsigned int *p = (unsigned int *)addr;
^1da177e4c3f415 Linus Torvalds 2005-04-16  148  
^1da177e4c3f415 Linus Torvalds 2005-04-16  149  	if (unlikely(parisc_narrow_firmware)) {
8a5aa00e6b9630d Helge Deller   2017-08-04  150  		for (i = (NUM_PDC_RESULT-1); i >= 0; --i)
^1da177e4c3f415 Linus Torvalds 2005-04-16  151  			addr[i] = p[i];
^1da177e4c3f415 Linus Torvalds 2005-04-16  152  	}
^1da177e4c3f415 Linus Torvalds 2005-04-16  153  #endif
^1da177e4c3f415 Linus Torvalds 2005-04-16  154  }
^1da177e4c3f415 Linus Torvalds 2005-04-16  155  
24b574d052a1996 Kyle McMartin  2008-07-29  156  #ifdef CONFIG_64BIT
60ffef065dd40b9 Paul Gortmaker 2013-06-17  157  void set_firmware_width_unlocked(void)
24b574d052a1996 Kyle McMartin  2008-07-29  158  {
24b574d052a1996 Kyle McMartin  2008-07-29  159  	int ret;
24b574d052a1996 Kyle McMartin  2008-07-29  160  
24b574d052a1996 Kyle McMartin  2008-07-29  161  	ret = mem_pdc_call(PDC_MODEL, PDC_MODEL_CAPABILITIES,
24b574d052a1996 Kyle McMartin  2008-07-29  162  		__pa(pdc_result), 0);
24b574d052a1996 Kyle McMartin  2008-07-29  163  	convert_to_wide(pdc_result);
24b574d052a1996 Kyle McMartin  2008-07-29  164  	if (pdc_result[0] != NARROW_FIRMWARE)
24b574d052a1996 Kyle McMartin  2008-07-29  165  		parisc_narrow_firmware = 0;
24b574d052a1996 Kyle McMartin  2008-07-29  166  }
24b574d052a1996 Kyle McMartin  2008-07-29  167  	
^1da177e4c3f415 Linus Torvalds 2005-04-16  168  /**
^1da177e4c3f415 Linus Torvalds 2005-04-16  169   * set_firmware_width - Determine if the firmware is wide or narrow.
^1da177e4c3f415 Linus Torvalds 2005-04-16  170   * 
24b574d052a1996 Kyle McMartin  2008-07-29  171   * This function must be called before any pdc_* function that uses the
24b574d052a1996 Kyle McMartin  2008-07-29  172   * convert_to_wide function.
^1da177e4c3f415 Linus Torvalds 2005-04-16  173   */
60ffef065dd40b9 Paul Gortmaker 2013-06-17  174  void set_firmware_width(void)
^1da177e4c3f415 Linus Torvalds 2005-04-16  175  {
09690b18b7b9696 Kyle McMartin  2006-10-05  176  	unsigned long flags;
09690b18b7b9696 Kyle McMartin  2006-10-05  177  	spin_lock_irqsave(&pdc_lock, flags);
24b574d052a1996 Kyle McMartin  2008-07-29  178  	set_firmware_width_unlocked();
09690b18b7b9696 Kyle McMartin  2006-10-05  179  	spin_unlock_irqrestore(&pdc_lock, flags);
^1da177e4c3f415 Linus Torvalds 2005-04-16  180  }
24b574d052a1996 Kyle McMartin  2008-07-29  181  #else
60ffef065dd40b9 Paul Gortmaker 2013-06-17  182  void set_firmware_width_unlocked(void)
60ffef065dd40b9 Paul Gortmaker 2013-06-17  183  {
24b574d052a1996 Kyle McMartin  2008-07-29  184  	return;
24b574d052a1996 Kyle McMartin  2008-07-29  185  }
24b574d052a1996 Kyle McMartin  2008-07-29  186  
60ffef065dd40b9 Paul Gortmaker 2013-06-17  187  void set_firmware_width(void)
60ffef065dd40b9 Paul Gortmaker 2013-06-17  188  {
24b574d052a1996 Kyle McMartin  2008-07-29  189  	return;
24b574d052a1996 Kyle McMartin  2008-07-29  190  }
24b574d052a1996 Kyle McMartin  2008-07-29  191  #endif /*CONFIG_64BIT*/
^1da177e4c3f415 Linus Torvalds 2005-04-16  192  
f5213b2c40f5749 Helge Deller   2017-08-20  193  
f5213b2c40f5749 Helge Deller   2017-08-20  194  #if !defined(BOOTLOADER)
^1da177e4c3f415 Linus Torvalds 2005-04-16  195  /**
^1da177e4c3f415 Linus Torvalds 2005-04-16  196   * pdc_emergency_unlock - Unlock the linux pdc lock
^1da177e4c3f415 Linus Torvalds 2005-04-16  197   *
^1da177e4c3f415 Linus Torvalds 2005-04-16  198   * This call unlocks the linux pdc lock in case we need some PDC functions
^1da177e4c3f415 Linus Torvalds 2005-04-16  199   * (like pdc_add_valid) during kernel stack dump.
^1da177e4c3f415 Linus Torvalds 2005-04-16  200   */
^1da177e4c3f415 Linus Torvalds 2005-04-16  201  void pdc_emergency_unlock(void)
^1da177e4c3f415 Linus Torvalds 2005-04-16  202  {
^1da177e4c3f415 Linus Torvalds 2005-04-16  203   	/* Spinlock DEBUG code freaks out if we unconditionally unlock */
^1da177e4c3f415 Linus Torvalds 2005-04-16  204          if (spin_is_locked(&pdc_lock))
^1da177e4c3f415 Linus Torvalds 2005-04-16  205  		spin_unlock(&pdc_lock);
^1da177e4c3f415 Linus Torvalds 2005-04-16  206  }
^1da177e4c3f415 Linus Torvalds 2005-04-16  207  
^1da177e4c3f415 Linus Torvalds 2005-04-16  208  
^1da177e4c3f415 Linus Torvalds 2005-04-16  209  /**
^1da177e4c3f415 Linus Torvalds 2005-04-16  210   * pdc_add_valid - Verify address can be accessed without causing a HPMC.
^1da177e4c3f415 Linus Torvalds 2005-04-16  211   * @address: Address to be verified.
^1da177e4c3f415 Linus Torvalds 2005-04-16  212   *
^1da177e4c3f415 Linus Torvalds 2005-04-16  213   * This PDC call attempts to read from the specified address and verifies
^1da177e4c3f415 Linus Torvalds 2005-04-16  214   * if the address is valid.
^1da177e4c3f415 Linus Torvalds 2005-04-16  215   * 
^1da177e4c3f415 Linus Torvalds 2005-04-16  216   * The return value is PDC_OK (0) in case accessing this address is valid.
^1da177e4c3f415 Linus Torvalds 2005-04-16  217   */
^1da177e4c3f415 Linus Torvalds 2005-04-16  218  int pdc_add_valid(unsigned long address)
^1da177e4c3f415 Linus Torvalds 2005-04-16  219  {
^1da177e4c3f415 Linus Torvalds 2005-04-16  220          int retval;
09690b18b7b9696 Kyle McMartin  2006-10-05  221  	unsigned long flags;
^1da177e4c3f415 Linus Torvalds 2005-04-16  222  
09690b18b7b9696 Kyle McMartin  2006-10-05  223          spin_lock_irqsave(&pdc_lock, flags);
^1da177e4c3f415 Linus Torvalds 2005-04-16  224          retval = mem_pdc_call(PDC_ADD_VALID, PDC_ADD_VALID_VERIFY, address);
09690b18b7b9696 Kyle McMartin  2006-10-05  225          spin_unlock_irqrestore(&pdc_lock, flags);
^1da177e4c3f415 Linus Torvalds 2005-04-16  226  
^1da177e4c3f415 Linus Torvalds 2005-04-16  227          return retval;
^1da177e4c3f415 Linus Torvalds 2005-04-16  228  }
^1da177e4c3f415 Linus Torvalds 2005-04-16  229  EXPORT_SYMBOL(pdc_add_valid);
^1da177e4c3f415 Linus Torvalds 2005-04-16  230  
77089c5274fe2f7 Helge Deller   2017-09-17  231  /**
77089c5274fe2f7 Helge Deller   2017-09-17  232   * pdc_instr - Get instruction that invokes PDCE_CHECK in HPMC handler.
77089c5274fe2f7 Helge Deller   2017-09-17  233   * @instr: Pointer to variable which will get instruction opcode.
77089c5274fe2f7 Helge Deller   2017-09-17  234   *
77089c5274fe2f7 Helge Deller   2017-09-17  235   * The return value is PDC_OK (0) in case call succeeded.
77089c5274fe2f7 Helge Deller   2017-09-17  236   */
77089c5274fe2f7 Helge Deller   2017-09-17  237  int __init pdc_instr(unsigned int *instr)
77089c5274fe2f7 Helge Deller   2017-09-17  238  {
77089c5274fe2f7 Helge Deller   2017-09-17  239  	int retval;
77089c5274fe2f7 Helge Deller   2017-09-17  240  	unsigned long flags;
77089c5274fe2f7 Helge Deller   2017-09-17  241  
77089c5274fe2f7 Helge Deller   2017-09-17  242  	spin_lock_irqsave(&pdc_lock, flags);
77089c5274fe2f7 Helge Deller   2017-09-17  243  	retval = mem_pdc_call(PDC_INSTR, 0UL, __pa(pdc_result));
77089c5274fe2f7 Helge Deller   2017-09-17  244  	convert_to_wide(pdc_result);
77089c5274fe2f7 Helge Deller   2017-09-17  245  	*instr = pdc_result[0];
77089c5274fe2f7 Helge Deller   2017-09-17  246  	spin_unlock_irqrestore(&pdc_lock, flags);
77089c5274fe2f7 Helge Deller   2017-09-17  247  
77089c5274fe2f7 Helge Deller   2017-09-17  248  	return retval;
77089c5274fe2f7 Helge Deller   2017-09-17  249  }
77089c5274fe2f7 Helge Deller   2017-09-17  250  
^1da177e4c3f415 Linus Torvalds 2005-04-16  251  /**
^1da177e4c3f415 Linus Torvalds 2005-04-16  252   * pdc_chassis_info - Return chassis information.
^1da177e4c3f415 Linus Torvalds 2005-04-16  253   * @result: The return buffer.
^1da177e4c3f415 Linus Torvalds 2005-04-16  254   * @chassis_info: The memory buffer address.
^1da177e4c3f415 Linus Torvalds 2005-04-16  255   * @len: The size of the memory buffer address.
^1da177e4c3f415 Linus Torvalds 2005-04-16  256   *
^1da177e4c3f415 Linus Torvalds 2005-04-16  257   * An HVERSION dependent call for returning the chassis information.
^1da177e4c3f415 Linus Torvalds 2005-04-16  258   */
^1da177e4c3f415 Linus Torvalds 2005-04-16  259  int __init pdc_chassis_info(struct pdc_chassis_info *chassis_info, void *led_info, unsigned long len)
^1da177e4c3f415 Linus Torvalds 2005-04-16  260  {
^1da177e4c3f415 Linus Torvalds 2005-04-16  261          int retval;
09690b18b7b9696 Kyle McMartin  2006-10-05  262  	unsigned long flags;
^1da177e4c3f415 Linus Torvalds 2005-04-16  263  
09690b18b7b9696 Kyle McMartin  2006-10-05  264          spin_lock_irqsave(&pdc_lock, flags);
^1da177e4c3f415 Linus Torvalds 2005-04-16  265          memcpy(&pdc_result, chassis_info, sizeof(*chassis_info));
^1da177e4c3f415 Linus Torvalds 2005-04-16  266          memcpy(&pdc_result2, led_info, len);
^1da177e4c3f415 Linus Torvalds 2005-04-16  267          retval = mem_pdc_call(PDC_CHASSIS, PDC_RETURN_CHASSIS_INFO,
^1da177e4c3f415 Linus Torvalds 2005-04-16  268                                __pa(pdc_result), __pa(pdc_result2), len);
^1da177e4c3f415 Linus Torvalds 2005-04-16  269          memcpy(chassis_info, pdc_result, sizeof(*chassis_info));
^1da177e4c3f415 Linus Torvalds 2005-04-16  270          memcpy(led_info, pdc_result2, len);
09690b18b7b9696 Kyle McMartin  2006-10-05  271          spin_unlock_irqrestore(&pdc_lock, flags);
^1da177e4c3f415 Linus Torvalds 2005-04-16  272  
^1da177e4c3f415 Linus Torvalds 2005-04-16  273          return retval;
^1da177e4c3f415 Linus Torvalds 2005-04-16  274  }
^1da177e4c3f415 Linus Torvalds 2005-04-16  275  
^1da177e4c3f415 Linus Torvalds 2005-04-16  276  /**
^1da177e4c3f415 Linus Torvalds 2005-04-16  277   * pdc_pat_chassis_send_log - Sends a PDC PAT CHASSIS log message.
^1da177e4c3f415 Linus Torvalds 2005-04-16  278   * @retval: -1 on error, 0 on success. Other value are PDC errors
^1da177e4c3f415 Linus Torvalds 2005-04-16  279   * 
^1da177e4c3f415 Linus Torvalds 2005-04-16  280   * Must be correctly formatted or expect system crash
^1da177e4c3f415 Linus Torvalds 2005-04-16  281   */
a8f44e3889b6868 Helge Deller   2007-01-28  282  #ifdef CONFIG_64BIT
^1da177e4c3f415 Linus Torvalds 2005-04-16  283  int pdc_pat_chassis_send_log(unsigned long state, unsigned long data)
^1da177e4c3f415 Linus Torvalds 2005-04-16  284  {
^1da177e4c3f415 Linus Torvalds 2005-04-16  285  	int retval = 0;
09690b18b7b9696 Kyle McMartin  2006-10-05  286  	unsigned long flags;
^1da177e4c3f415 Linus Torvalds 2005-04-16  287          
^1da177e4c3f415 Linus Torvalds 2005-04-16  288  	if (!is_pdc_pat())
^1da177e4c3f415 Linus Torvalds 2005-04-16  289  		return -1;
^1da177e4c3f415 Linus Torvalds 2005-04-16  290  
09690b18b7b9696 Kyle McMartin  2006-10-05  291  	spin_lock_irqsave(&pdc_lock, flags);
^1da177e4c3f415 Linus Torvalds 2005-04-16  292  	retval = mem_pdc_call(PDC_PAT_CHASSIS_LOG, PDC_PAT_CHASSIS_WRITE_LOG, __pa(&state), __pa(&data));
09690b18b7b9696 Kyle McMartin  2006-10-05  293  	spin_unlock_irqrestore(&pdc_lock, flags);
^1da177e4c3f415 Linus Torvalds 2005-04-16  294  
^1da177e4c3f415 Linus Torvalds 2005-04-16  295  	return retval;
^1da177e4c3f415 Linus Torvalds 2005-04-16  296  }
^1da177e4c3f415 Linus Torvalds 2005-04-16  297  #endif
^1da177e4c3f415 Linus Torvalds 2005-04-16  298  
^1da177e4c3f415 Linus Torvalds 2005-04-16  299  /**
8ffaeaf42e91930 Thibaut Varene 2006-05-03  300   * pdc_chassis_disp - Updates chassis code
^1da177e4c3f415 Linus Torvalds 2005-04-16  301   * @retval: -1 on error, 0 on success
^1da177e4c3f415 Linus Torvalds 2005-04-16  302   */
^1da177e4c3f415 Linus Torvalds 2005-04-16  303  int pdc_chassis_disp(unsigned long disp)
^1da177e4c3f415 Linus Torvalds 2005-04-16  304  {
^1da177e4c3f415 Linus Torvalds 2005-04-16  305  	int retval = 0;
09690b18b7b9696 Kyle McMartin  2006-10-05  306  	unsigned long flags;
^1da177e4c3f415 Linus Torvalds 2005-04-16  307  
09690b18b7b9696 Kyle McMartin  2006-10-05  308  	spin_lock_irqsave(&pdc_lock, flags);
^1da177e4c3f415 Linus Torvalds 2005-04-16  309  	retval = mem_pdc_call(PDC_CHASSIS, PDC_CHASSIS_DISP, disp);
09690b18b7b9696 Kyle McMartin  2006-10-05  310  	spin_unlock_irqrestore(&pdc_lock, flags);
^1da177e4c3f415 Linus Torvalds 2005-04-16  311  
^1da177e4c3f415 Linus Torvalds 2005-04-16  312  	return retval;
^1da177e4c3f415 Linus Torvalds 2005-04-16  313  }
^1da177e4c3f415 Linus Torvalds 2005-04-16  314  
507efd63d98c443 Sven Schnelle  2019-09-08  315  /**
507efd63d98c443 Sven Schnelle  2019-09-08  316   * pdc_cpu_rendenzvous - Stop currently executing CPU
507efd63d98c443 Sven Schnelle  2019-09-08  317   * @retval: -1 on error, 0 on success
507efd63d98c443 Sven Schnelle  2019-09-08  318   */
507efd63d98c443 Sven Schnelle  2019-09-08  319  int __pdc_cpu_rendezvous(void)
507efd63d98c443 Sven Schnelle  2019-09-08 @320  {
507efd63d98c443 Sven Schnelle  2019-09-08  321  	if (is_pdc_pat())
507efd63d98c443 Sven Schnelle  2019-09-08  322  		return mem_pdc_call(PDC_PAT_CPU, PDC_PAT_CPU_RENDEZVOUS);
507efd63d98c443 Sven Schnelle  2019-09-08  323  	else
507efd63d98c443 Sven Schnelle  2019-09-08  324  		return mem_pdc_call(PDC_PROC, 1, 0);
507efd63d98c443 Sven Schnelle  2019-09-08  325  }
507efd63d98c443 Sven Schnelle  2019-09-08  326  
507efd63d98c443 Sven Schnelle  2019-09-08  327  
8ffaeaf42e91930 Thibaut Varene 2006-05-03  328  /**
8ffaeaf42e91930 Thibaut Varene 2006-05-03  329   * pdc_chassis_warn - Fetches chassis warnings
8ffaeaf42e91930 Thibaut Varene 2006-05-03  330   * @retval: -1 on error, 0 on success
8ffaeaf42e91930 Thibaut Varene 2006-05-03  331   */
8ffaeaf42e91930 Thibaut Varene 2006-05-03  332  int pdc_chassis_warn(unsigned long *warn)
8ffaeaf42e91930 Thibaut Varene 2006-05-03  333  {
8ffaeaf42e91930 Thibaut Varene 2006-05-03  334  	int retval = 0;
09690b18b7b9696 Kyle McMartin  2006-10-05  335  	unsigned long flags;
8ffaeaf42e91930 Thibaut Varene 2006-05-03  336  
09690b18b7b9696 Kyle McMartin  2006-10-05  337  	spin_lock_irqsave(&pdc_lock, flags);
8ffaeaf42e91930 Thibaut Varene 2006-05-03  338  	retval = mem_pdc_call(PDC_CHASSIS, PDC_CHASSIS_WARN, __pa(pdc_result));
8ffaeaf42e91930 Thibaut Varene 2006-05-03  339  	*warn = pdc_result[0];
09690b18b7b9696 Kyle McMartin  2006-10-05  340  	spin_unlock_irqrestore(&pdc_lock, flags);
8ffaeaf42e91930 Thibaut Varene 2006-05-03  341  
8ffaeaf42e91930 Thibaut Varene 2006-05-03  342  	return retval;
8ffaeaf42e91930 Thibaut Varene 2006-05-03  343  }
8ffaeaf42e91930 Thibaut Varene 2006-05-03  344  
60ffef065dd40b9 Paul Gortmaker 2013-06-17  345  int pdc_coproc_cfg_unlocked(struct pdc_coproc_cfg *pdc_coproc_info)
24b574d052a1996 Kyle McMartin  2008-07-29  346  {
24b574d052a1996 Kyle McMartin  2008-07-29  347  	int ret;
24b574d052a1996 Kyle McMartin  2008-07-29  348  
24b574d052a1996 Kyle McMartin  2008-07-29  349  	ret = mem_pdc_call(PDC_COPROC, PDC_COPROC_CFG, __pa(pdc_result));
24b574d052a1996 Kyle McMartin  2008-07-29  350  	convert_to_wide(pdc_result);
24b574d052a1996 Kyle McMartin  2008-07-29  351  	pdc_coproc_info->ccr_functional = pdc_result[0];
24b574d052a1996 Kyle McMartin  2008-07-29  352  	pdc_coproc_info->ccr_present = pdc_result[1];
24b574d052a1996 Kyle McMartin  2008-07-29  353  	pdc_coproc_info->revision = pdc_result[17];
24b574d052a1996 Kyle McMartin  2008-07-29  354  	pdc_coproc_info->model = pdc_result[18];
24b574d052a1996 Kyle McMartin  2008-07-29  355  
24b574d052a1996 Kyle McMartin  2008-07-29  356  	return ret;
24b574d052a1996 Kyle McMartin  2008-07-29  357  }
24b574d052a1996 Kyle McMartin  2008-07-29  358  
^1da177e4c3f415 Linus Torvalds 2005-04-16  359  /**
^1da177e4c3f415 Linus Torvalds 2005-04-16  360   * pdc_coproc_cfg - To identify coprocessors attached to the processor.
^1da177e4c3f415 Linus Torvalds 2005-04-16  361   * @pdc_coproc_info: Return buffer address.
^1da177e4c3f415 Linus Torvalds 2005-04-16  362   *
^1da177e4c3f415 Linus Torvalds 2005-04-16  363   * This PDC call returns the presence and status of all the coprocessors
^1da177e4c3f415 Linus Torvalds 2005-04-16  364   * attached to the processor.
^1da177e4c3f415 Linus Torvalds 2005-04-16  365   */
60ffef065dd40b9 Paul Gortmaker 2013-06-17  366  int pdc_coproc_cfg(struct pdc_coproc_cfg *pdc_coproc_info)
^1da177e4c3f415 Linus Torvalds 2005-04-16  367  {
24b574d052a1996 Kyle McMartin  2008-07-29  368  	int ret;
09690b18b7b9696 Kyle McMartin  2006-10-05  369  	unsigned long flags;
^1da177e4c3f415 Linus Torvalds 2005-04-16  370  
09690b18b7b9696 Kyle McMartin  2006-10-05  371  	spin_lock_irqsave(&pdc_lock, flags);
24b574d052a1996 Kyle McMartin  2008-07-29  372  	ret = pdc_coproc_cfg_unlocked(pdc_coproc_info);
09690b18b7b9696 Kyle McMartin  2006-10-05  373  	spin_unlock_irqrestore(&pdc_lock, flags);
^1da177e4c3f415 Linus Torvalds 2005-04-16  374  
24b574d052a1996 Kyle McMartin  2008-07-29  375  	return ret;
^1da177e4c3f415 Linus Torvalds 2005-04-16  376  }
^1da177e4c3f415 Linus Torvalds 2005-04-16  377  
^1da177e4c3f415 Linus Torvalds 2005-04-16  378  /**
^1da177e4c3f415 Linus Torvalds 2005-04-16  379   * pdc_iodc_read - Read data from the modules IODC.
^1da177e4c3f415 Linus Torvalds 2005-04-16  380   * @actcnt: The actual number of bytes.
^1da177e4c3f415 Linus Torvalds 2005-04-16  381   * @hpa: The HPA of the module for the iodc read.
^1da177e4c3f415 Linus Torvalds 2005-04-16  382   * @index: The iodc entry point.
^1da177e4c3f415 Linus Torvalds 2005-04-16  383   * @iodc_data: A buffer memory for the iodc options.
^1da177e4c3f415 Linus Torvalds 2005-04-16  384   * @iodc_data_size: Size of the memory buffer.
^1da177e4c3f415 Linus Torvalds 2005-04-16  385   *
^1da177e4c3f415 Linus Torvalds 2005-04-16  386   * This PDC call reads from the IODC of the module specified by the hpa
^1da177e4c3f415 Linus Torvalds 2005-04-16  387   * argument.
^1da177e4c3f415 Linus Torvalds 2005-04-16  388   */
^1da177e4c3f415 Linus Torvalds 2005-04-16  389  int pdc_iodc_read(unsigned long *actcnt, unsigned long hpa, unsigned int index,
^1da177e4c3f415 Linus Torvalds 2005-04-16  390  		  void *iodc_data, unsigned int iodc_data_size)
^1da177e4c3f415 Linus Torvalds 2005-04-16  391  {
^1da177e4c3f415 Linus Torvalds 2005-04-16  392  	int retval;
09690b18b7b9696 Kyle McMartin  2006-10-05  393  	unsigned long flags;
^1da177e4c3f415 Linus Torvalds 2005-04-16  394  
09690b18b7b9696 Kyle McMartin  2006-10-05  395  	spin_lock_irqsave(&pdc_lock, flags);
^1da177e4c3f415 Linus Torvalds 2005-04-16  396  	retval = mem_pdc_call(PDC_IODC, PDC_IODC_READ, __pa(pdc_result), hpa, 
^1da177e4c3f415 Linus Torvalds 2005-04-16  397  			      index, __pa(pdc_result2), iodc_data_size);
^1da177e4c3f415 Linus Torvalds 2005-04-16  398  	convert_to_wide(pdc_result);
^1da177e4c3f415 Linus Torvalds 2005-04-16  399  	*actcnt = pdc_result[0];
^1da177e4c3f415 Linus Torvalds 2005-04-16  400  	memcpy(iodc_data, pdc_result2, iodc_data_size);
09690b18b7b9696 Kyle McMartin  2006-10-05  401  	spin_unlock_irqrestore(&pdc_lock, flags);
^1da177e4c3f415 Linus Torvalds 2005-04-16  402  
^1da177e4c3f415 Linus Torvalds 2005-04-16  403  	return retval;
^1da177e4c3f415 Linus Torvalds 2005-04-16  404  }
^1da177e4c3f415 Linus Torvalds 2005-04-16  405  EXPORT_SYMBOL(pdc_iodc_read);
^1da177e4c3f415 Linus Torvalds 2005-04-16  406  
^1da177e4c3f415 Linus Torvalds 2005-04-16  407  /**
^1da177e4c3f415 Linus Torvalds 2005-04-16  408   * pdc_system_map_find_mods - Locate unarchitected modules.
^1da177e4c3f415 Linus Torvalds 2005-04-16  409   * @pdc_mod_info: Return buffer address.
^1da177e4c3f415 Linus Torvalds 2005-04-16  410   * @mod_path: pointer to dev path structure.
^1da177e4c3f415 Linus Torvalds 2005-04-16  411   * @mod_index: fixed address module index.
^1da177e4c3f415 Linus Torvalds 2005-04-16  412   *
^1da177e4c3f415 Linus Torvalds 2005-04-16  413   * To locate and identify modules which reside at fixed I/O addresses, which
^1da177e4c3f415 Linus Torvalds 2005-04-16  414   * do not self-identify via architected bus walks.
^1da177e4c3f415 Linus Torvalds 2005-04-16  415   */
^1da177e4c3f415 Linus Torvalds 2005-04-16  416  int pdc_system_map_find_mods(struct pdc_system_map_mod_info *pdc_mod_info,
^1da177e4c3f415 Linus Torvalds 2005-04-16  417  			     struct pdc_module_path *mod_path, long mod_index)
^1da177e4c3f415 Linus Torvalds 2005-04-16  418  {
^1da177e4c3f415 Linus Torvalds 2005-04-16  419  	int retval;
09690b18b7b9696 Kyle McMartin  2006-10-05  420  	unsigned long flags;
^1da177e4c3f415 Linus Torvalds 2005-04-16  421  
09690b18b7b9696 Kyle McMartin  2006-10-05  422  	spin_lock_irqsave(&pdc_lock, flags);
^1da177e4c3f415 Linus Torvalds 2005-04-16  423  	retval = mem_pdc_call(PDC_SYSTEM_MAP, PDC_FIND_MODULE, __pa(pdc_result), 
^1da177e4c3f415 Linus Torvalds 2005-04-16  424  			      __pa(pdc_result2), mod_index);
^1da177e4c3f415 Linus Torvalds 2005-04-16  425  	convert_to_wide(pdc_result);
^1da177e4c3f415 Linus Torvalds 2005-04-16  426  	memcpy(pdc_mod_info, pdc_result, sizeof(*pdc_mod_info));
^1da177e4c3f415 Linus Torvalds 2005-04-16  427  	memcpy(mod_path, pdc_result2, sizeof(*mod_path));
09690b18b7b9696 Kyle McMartin  2006-10-05  428  	spin_unlock_irqrestore(&pdc_lock, flags);
^1da177e4c3f415 Linus Torvalds 2005-04-16  429  
^1da177e4c3f415 Linus Torvalds 2005-04-16  430  	pdc_mod_info->mod_addr = f_extend(pdc_mod_info->mod_addr);
^1da177e4c3f415 Linus Torvalds 2005-04-16  431  	return retval;
^1da177e4c3f415 Linus Torvalds 2005-04-16  432  }
^1da177e4c3f415 Linus Torvalds 2005-04-16  433  
^1da177e4c3f415 Linus Torvalds 2005-04-16  434  /**
^1da177e4c3f415 Linus Torvalds 2005-04-16  435   * pdc_system_map_find_addrs - Retrieve additional address ranges.
^1da177e4c3f415 Linus Torvalds 2005-04-16  436   * @pdc_addr_info: Return buffer address.
^1da177e4c3f415 Linus Torvalds 2005-04-16  437   * @mod_index: Fixed address module index.
^1da177e4c3f415 Linus Torvalds 2005-04-16  438   * @addr_index: Address range index.
^1da177e4c3f415 Linus Torvalds 2005-04-16  439   * 
^1da177e4c3f415 Linus Torvalds 2005-04-16  440   * Retrieve additional information about subsequent address ranges for modules
^1da177e4c3f415 Linus Torvalds 2005-04-16  441   * with multiple address ranges.  
^1da177e4c3f415 Linus Torvalds 2005-04-16  442   */
^1da177e4c3f415 Linus Torvalds 2005-04-16  443  int pdc_system_map_find_addrs(struct pdc_system_map_addr_info *pdc_addr_info, 
^1da177e4c3f415 Linus Torvalds 2005-04-16  444  			      long mod_index, long addr_index)
^1da177e4c3f415 Linus Torvalds 2005-04-16  445  {
^1da177e4c3f415 Linus Torvalds 2005-04-16  446  	int retval;
09690b18b7b9696 Kyle McMartin  2006-10-05  447  	unsigned long flags;
^1da177e4c3f415 Linus Torvalds 2005-04-16  448  
09690b18b7b9696 Kyle McMartin  2006-10-05  449  	spin_lock_irqsave(&pdc_lock, flags);
^1da177e4c3f415 Linus Torvalds 2005-04-16  450  	retval = mem_pdc_call(PDC_SYSTEM_MAP, PDC_FIND_ADDRESS, __pa(pdc_result),
^1da177e4c3f415 Linus Torvalds 2005-04-16  451  			      mod_index, addr_index);
^1da177e4c3f415 Linus Torvalds 2005-04-16  452  	convert_to_wide(pdc_result);
^1da177e4c3f415 Linus Torvalds 2005-04-16  453  	memcpy(pdc_addr_info, pdc_result, sizeof(*pdc_addr_info));
09690b18b7b9696 Kyle McMartin  2006-10-05  454  	spin_unlock_irqrestore(&pdc_lock, flags);
^1da177e4c3f415 Linus Torvalds 2005-04-16  455  
^1da177e4c3f415 Linus Torvalds 2005-04-16  456  	pdc_addr_info->mod_addr = f_extend(pdc_addr_info->mod_addr);
^1da177e4c3f415 Linus Torvalds 2005-04-16  457  	return retval;
^1da177e4c3f415 Linus Torvalds 2005-04-16  458  }
^1da177e4c3f415 Linus Torvalds 2005-04-16  459  
^1da177e4c3f415 Linus Torvalds 2005-04-16  460  /**
^1da177e4c3f415 Linus Torvalds 2005-04-16  461   * pdc_model_info - Return model information about the processor.
^1da177e4c3f415 Linus Torvalds 2005-04-16  462   * @model: The return buffer.
^1da177e4c3f415 Linus Torvalds 2005-04-16  463   *
^1da177e4c3f415 Linus Torvalds 2005-04-16  464   * Returns the version numbers, identifiers, and capabilities from the processor module.
^1da177e4c3f415 Linus Torvalds 2005-04-16  465   */
^1da177e4c3f415 Linus Torvalds 2005-04-16  466  int pdc_model_info(struct pdc_model *model) 
^1da177e4c3f415 Linus Torvalds 2005-04-16  467  {
^1da177e4c3f415 Linus Torvalds 2005-04-16  468  	int retval;
09690b18b7b9696 Kyle McMartin  2006-10-05  469  	unsigned long flags;
^1da177e4c3f415 Linus Torvalds 2005-04-16  470  
09690b18b7b9696 Kyle McMartin  2006-10-05  471  	spin_lock_irqsave(&pdc_lock, flags);
^1da177e4c3f415 Linus Torvalds 2005-04-16  472  	retval = mem_pdc_call(PDC_MODEL, PDC_MODEL_INFO, __pa(pdc_result), 0);
^1da177e4c3f415 Linus Torvalds 2005-04-16  473  	convert_to_wide(pdc_result);
^1da177e4c3f415 Linus Torvalds 2005-04-16  474  	memcpy(model, pdc_result, sizeof(*model));
09690b18b7b9696 Kyle McMartin  2006-10-05  475  	spin_unlock_irqrestore(&pdc_lock, flags);
^1da177e4c3f415 Linus Torvalds 2005-04-16  476  
^1da177e4c3f415 Linus Torvalds 2005-04-16  477  	return retval;
^1da177e4c3f415 Linus Torvalds 2005-04-16  478  }
^1da177e4c3f415 Linus Torvalds 2005-04-16  479  
^1da177e4c3f415 Linus Torvalds 2005-04-16  480  /**
^1da177e4c3f415 Linus Torvalds 2005-04-16  481   * pdc_model_sysmodel - Get the system model name.
^1da177e4c3f415 Linus Torvalds 2005-04-16  482   * @name: A char array of at least 81 characters.
^1da177e4c3f415 Linus Torvalds 2005-04-16  483   *
ec1fdc24c2ae012 Kyle McMartin  2006-06-21  484   * Get system model name from PDC ROM (e.g. 9000/715 or 9000/778/B160L).
ec1fdc24c2ae012 Kyle McMartin  2006-06-21  485   * Using OS_ID_HPUX will return the equivalent of the 'modelname' command
ec1fdc24c2ae012 Kyle McMartin  2006-06-21  486   * on HP/UX.
^1da177e4c3f415 Linus Torvalds 2005-04-16  487   */
^1da177e4c3f415 Linus Torvalds 2005-04-16  488  int pdc_model_sysmodel(char *name)
^1da177e4c3f415 Linus Torvalds 2005-04-16  489  {
^1da177e4c3f415 Linus Torvalds 2005-04-16  490          int retval;
09690b18b7b9696 Kyle McMartin  2006-10-05  491  	unsigned long flags;
^1da177e4c3f415 Linus Torvalds 2005-04-16  492  
09690b18b7b9696 Kyle McMartin  2006-10-05  493          spin_lock_irqsave(&pdc_lock, flags);
^1da177e4c3f415 Linus Torvalds 2005-04-16  494          retval = mem_pdc_call(PDC_MODEL, PDC_MODEL_SYSMODEL, __pa(pdc_result),
^1da177e4c3f415 Linus Torvalds 2005-04-16  495                                OS_ID_HPUX, __pa(name));
^1da177e4c3f415 Linus Torvalds 2005-04-16  496          convert_to_wide(pdc_result);
^1da177e4c3f415 Linus Torvalds 2005-04-16  497  
^1da177e4c3f415 Linus Torvalds 2005-04-16  498          if (retval == PDC_OK) {
^1da177e4c3f415 Linus Torvalds 2005-04-16  499                  name[pdc_result[0]] = '\0'; /* add trailing '\0' */
^1da177e4c3f415 Linus Torvalds 2005-04-16  500          } else {
^1da177e4c3f415 Linus Torvalds 2005-04-16  501                  name[0] = 0;
^1da177e4c3f415 Linus Torvalds 2005-04-16  502          }
09690b18b7b9696 Kyle McMartin  2006-10-05  503          spin_unlock_irqrestore(&pdc_lock, flags);
^1da177e4c3f415 Linus Torvalds 2005-04-16  504  
^1da177e4c3f415 Linus Torvalds 2005-04-16  505          return retval;
^1da177e4c3f415 Linus Torvalds 2005-04-16  506  }
^1da177e4c3f415 Linus Torvalds 2005-04-16  507  
^1da177e4c3f415 Linus Torvalds 2005-04-16  508  /**
^1da177e4c3f415 Linus Torvalds 2005-04-16  509   * pdc_model_versions - Identify the version number of each processor.
^1da177e4c3f415 Linus Torvalds 2005-04-16  510   * @cpu_id: The return buffer.
^1da177e4c3f415 Linus Torvalds 2005-04-16  511   * @id: The id of the processor to check.
^1da177e4c3f415 Linus Torvalds 2005-04-16  512   *
^1da177e4c3f415 Linus Torvalds 2005-04-16  513   * Returns the version number for each processor component.
^1da177e4c3f415 Linus Torvalds 2005-04-16  514   *
^1da177e4c3f415 Linus Torvalds 2005-04-16  515   * This comment was here before, but I do not know what it means :( -RB
^1da177e4c3f415 Linus Torvalds 2005-04-16  516   * id: 0 = cpu revision, 1 = boot-rom-version
^1da177e4c3f415 Linus Torvalds 2005-04-16  517   */
^1da177e4c3f415 Linus Torvalds 2005-04-16  518  int pdc_model_versions(unsigned long *versions, int id)
^1da177e4c3f415 Linus Torvalds 2005-04-16 @519  {
^1da177e4c3f415 Linus Torvalds 2005-04-16  520          int retval;
09690b18b7b9696 Kyle McMartin  2006-10-05  521  	unsigned long flags;
^1da177e4c3f415 Linus Torvalds 2005-04-16  522  
09690b18b7b9696 Kyle McMartin  2006-10-05  523          spin_lock_irqsave(&pdc_lock, flags);
^1da177e4c3f415 Linus Torvalds 2005-04-16  524          retval = mem_pdc_call(PDC_MODEL, PDC_MODEL_VERSIONS, __pa(pdc_result), id);
^1da177e4c3f415 Linus Torvalds 2005-04-16  525          convert_to_wide(pdc_result);
^1da177e4c3f415 Linus Torvalds 2005-04-16  526          *versions = pdc_result[0];
09690b18b7b9696 Kyle McMartin  2006-10-05  527          spin_unlock_irqrestore(&pdc_lock, flags);
^1da177e4c3f415 Linus Torvalds 2005-04-16  528  
^1da177e4c3f415 Linus Torvalds 2005-04-16  529          return retval;
^1da177e4c3f415 Linus Torvalds 2005-04-16  530  }
^1da177e4c3f415 Linus Torvalds 2005-04-16  531  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
kernel test robot Dec. 1, 2020, 3:25 p.m. UTC | #2
Hi Mauro,

I love your patch! Perhaps something to improve:

[auto build test WARNING on next-20201201]
[cannot apply to lwn/docs-next tip/sched/core hsi/for-next linus/master v5.10-rc6 v5.10-rc5 v5.10-rc4 v5.10-rc6]
[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]

url:    https://github.com/0day-ci/linux/commits/Mauro-Carvalho-Chehab/HSI-fix-a-kernel-doc-markup/20201201-210930
base:    0eedceafd3a63fd082743c914853ef4b9247dbe6
config: x86_64-randconfig-s021-20201201 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.3-170-g3bc348f6-dirty
        # https://github.com/0day-ci/linux/commit/7c52ba119279c74e6c7e968e3fa7290bd0f3b837
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Mauro-Carvalho-Chehab/HSI-fix-a-kernel-doc-markup/20201201-210930
        git checkout 7c52ba119279c74e6c7e968e3fa7290bd0f3b837
        # save the attached .config to linux build tree
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=x86_64 

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

All warnings (new ones prefixed by >>):

>> mm/vmscan.c:1614: warning: wrong kernel-doc identifier on line:
    * Isolating page from the lruvec to fill in @dst list by nr_to_scan times.
--
>> drivers/hv/vmbus_drv.c:1536: warning: expecting prototype for __vmbus_child_driver_register(). Prototype was for __vmbus_driver_register() instead
--
   drivers/rtc/class.c:326: warning: Function parameter or member 'data' not described in 'devm_rtc_unregister_device'
>> drivers/rtc/class.c:326: warning: expecting prototype for rtc_device_unregister(). Prototype was for devm_rtc_unregister_device() instead

vim +1614 mm/vmscan.c

b4536f0c829c85 Michal Hocko            2017-01-10  1612  
f4b7e272b5c042 Andrey Ryabinin         2019-03-05  1613  /**
f46cdc387708fb Hugh Dickins            2020-11-24 @1614   * Isolating page from the lruvec to fill in @dst list by nr_to_scan times.
f46cdc387708fb Hugh Dickins            2020-11-24  1615   *
f46cdc387708fb Hugh Dickins            2020-11-24  1616   * lruvec->lru_lock is heavily contended.  Some of the functions that
^1da177e4c3f41 Linus Torvalds          2005-04-16  1617   * shrink the lists perform better by taking out a batch of pages
^1da177e4c3f41 Linus Torvalds          2005-04-16  1618   * and working on them outside the LRU lock.
^1da177e4c3f41 Linus Torvalds          2005-04-16  1619   *
^1da177e4c3f41 Linus Torvalds          2005-04-16  1620   * For pagecache intensive workloads, this function is the hottest
^1da177e4c3f41 Linus Torvalds          2005-04-16  1621   * spot in the kernel (apart from copy_*_user functions).
^1da177e4c3f41 Linus Torvalds          2005-04-16  1622   *
f46cdc387708fb Hugh Dickins            2020-11-24  1623   * Lru_lock must be held before calling this function.
^1da177e4c3f41 Linus Torvalds          2005-04-16  1624   *
791b48b642324c Minchan Kim             2017-05-12  1625   * @nr_to_scan:	The number of eligible pages to look through on the list.
5dc35979e444b5 Konstantin Khlebnikov   2012-05-29  1626   * @lruvec:	The LRU vector to pull pages from.
^1da177e4c3f41 Linus Torvalds          2005-04-16  1627   * @dst:	The temp list to put pages on to.
f626012db08b9e Hugh Dickins            2012-01-12  1628   * @nr_scanned:	The number of pages that were scanned.
fe2c2a10666313 Rik van Riel            2012-03-21  1629   * @sc:		The scan_control struct for this reclaim session
3cb9945179bd04 Konstantin Khlebnikov   2012-05-29  1630   * @lru:	LRU list id for isolating
^1da177e4c3f41 Linus Torvalds          2005-04-16  1631   *
^1da177e4c3f41 Linus Torvalds          2005-04-16  1632   * returns how many pages were moved onto *@dst.
^1da177e4c3f41 Linus Torvalds          2005-04-16  1633   */
69e05944af39fc Andrew Morton           2006-03-22  1634  static unsigned long isolate_lru_pages(unsigned long nr_to_scan,
5dc35979e444b5 Konstantin Khlebnikov   2012-05-29  1635  		struct lruvec *lruvec, struct list_head *dst,
fe2c2a10666313 Rik van Riel            2012-03-21  1636  		unsigned long *nr_scanned, struct scan_control *sc,
a9e7c39fa9fd90 Kirill Tkhai            2019-03-05  1637  		enum lru_list lru)
^1da177e4c3f41 Linus Torvalds          2005-04-16  1638  {
75b00af77ed5b5 Hugh Dickins            2012-05-29  1639  	struct list_head *src = &lruvec->lists[lru];
69e05944af39fc Andrew Morton           2006-03-22  1640  	unsigned long nr_taken = 0;
599d0c954f91d0 Mel Gorman              2016-07-28  1641  	unsigned long nr_zone_taken[MAX_NR_ZONES] = { 0 };
7cc30fcfd2a894 Mel Gorman              2016-07-28  1642  	unsigned long nr_skipped[MAX_NR_ZONES] = { 0, };
3db65812d68883 Johannes Weiner         2017-05-03  1643  	unsigned long skipped = 0;
791b48b642324c Minchan Kim             2017-05-12  1644  	unsigned long scan, total_scan, nr_pages;
b2e18757f2c9d1 Mel Gorman              2016-07-28  1645  	LIST_HEAD(pages_skipped);
a9e7c39fa9fd90 Kirill Tkhai            2019-03-05  1646  	isolate_mode_t mode = (sc->may_unmap ? 0 : ISOLATE_UNMAPPED);
^1da177e4c3f41 Linus Torvalds          2005-04-16  1647  
98879b3b9edc16 Yang Shi                2019-07-11  1648  	total_scan = 0;
791b48b642324c Minchan Kim             2017-05-12  1649  	scan = 0;
98879b3b9edc16 Yang Shi                2019-07-11  1650  	while (scan < nr_to_scan && !list_empty(src)) {
5ad333eb66ff1e Andy Whitcroft          2007-07-17  1651  		struct page *page;
5ad333eb66ff1e Andy Whitcroft          2007-07-17  1652  
^1da177e4c3f41 Linus Torvalds          2005-04-16  1653  		page = lru_to_page(src);
^1da177e4c3f41 Linus Torvalds          2005-04-16  1654  		prefetchw_prev_lru_page(page, src, flags);
^1da177e4c3f41 Linus Torvalds          2005-04-16  1655  
d8c6546b1aea84 Matthew Wilcox (Oracle  2019-09-23  1656) 		nr_pages = compound_nr(page);
98879b3b9edc16 Yang Shi                2019-07-11  1657  		total_scan += nr_pages;
98879b3b9edc16 Yang Shi                2019-07-11  1658  
b2e18757f2c9d1 Mel Gorman              2016-07-28  1659  		if (page_zonenum(page) > sc->reclaim_idx) {
b2e18757f2c9d1 Mel Gorman              2016-07-28  1660  			list_move(&page->lru, &pages_skipped);
98879b3b9edc16 Yang Shi                2019-07-11  1661  			nr_skipped[page_zonenum(page)] += nr_pages;
b2e18757f2c9d1 Mel Gorman              2016-07-28  1662  			continue;
b2e18757f2c9d1 Mel Gorman              2016-07-28  1663  		}
b2e18757f2c9d1 Mel Gorman              2016-07-28  1664  
791b48b642324c Minchan Kim             2017-05-12  1665  		/*
791b48b642324c Minchan Kim             2017-05-12  1666  		 * Do not count skipped pages because that makes the function
791b48b642324c Minchan Kim             2017-05-12  1667  		 * return with no isolated pages if the LRU mostly contains
791b48b642324c Minchan Kim             2017-05-12  1668  		 * ineligible pages.  This causes the VM to not reclaim any
791b48b642324c Minchan Kim             2017-05-12  1669  		 * pages, triggering a premature OOM.
98879b3b9edc16 Yang Shi                2019-07-11  1670  		 *
98879b3b9edc16 Yang Shi                2019-07-11  1671  		 * Account all tail pages of THP.  This would not cause
98879b3b9edc16 Yang Shi                2019-07-11  1672  		 * premature OOM since __isolate_lru_page() returns -EBUSY
98879b3b9edc16 Yang Shi                2019-07-11  1673  		 * only when the page is being freed somewhere else.
791b48b642324c Minchan Kim             2017-05-12  1674  		 */
98879b3b9edc16 Yang Shi                2019-07-11  1675  		scan += nr_pages;
0499e1a60797d4 Alex Shi                2020-11-24  1676  		if (!__isolate_lru_page_prepare(page, mode)) {
0499e1a60797d4 Alex Shi                2020-11-24  1677  			/* It is being freed elsewhere */
0499e1a60797d4 Alex Shi                2020-11-24  1678  			list_move(&page->lru, src);
0499e1a60797d4 Alex Shi                2020-11-24  1679  			continue;
0499e1a60797d4 Alex Shi                2020-11-24  1680  		}
ce8d4ae1c160d4 Alex Shi                2020-11-24  1681  		/*
ce8d4ae1c160d4 Alex Shi                2020-11-24  1682  		 * Be careful not to clear PageLRU until after we're
ce8d4ae1c160d4 Alex Shi                2020-11-24  1683  		 * sure the page is not being freed elsewhere -- the
ce8d4ae1c160d4 Alex Shi                2020-11-24  1684  		 * page release code relies on it.
ce8d4ae1c160d4 Alex Shi                2020-11-24  1685  		 */
0499e1a60797d4 Alex Shi                2020-11-24  1686  		if (unlikely(!get_page_unless_zero(page))) {
0499e1a60797d4 Alex Shi                2020-11-24  1687  			list_move(&page->lru, src);
0499e1a60797d4 Alex Shi                2020-11-24  1688  			continue;
0499e1a60797d4 Alex Shi                2020-11-24  1689  		}
ce8d4ae1c160d4 Alex Shi                2020-11-24  1690  
ce8d4ae1c160d4 Alex Shi                2020-11-24  1691  		if (!TestClearPageLRU(page)) {
0499e1a60797d4 Alex Shi                2020-11-24  1692  			/* Another thread is already isolating this page */
ce8d4ae1c160d4 Alex Shi                2020-11-24  1693  			put_page(page);
0499e1a60797d4 Alex Shi                2020-11-24  1694  			list_move(&page->lru, src);
0499e1a60797d4 Alex Shi                2020-11-24  1695  			continue;
ce8d4ae1c160d4 Alex Shi                2020-11-24  1696  		}
ce8d4ae1c160d4 Alex Shi                2020-11-24  1697  
599d0c954f91d0 Mel Gorman              2016-07-28  1698  		nr_taken += nr_pages;
599d0c954f91d0 Mel Gorman              2016-07-28  1699  		nr_zone_taken[page_zonenum(page)] += nr_pages;
5ad333eb66ff1e Andy Whitcroft          2007-07-17  1700  		list_move(&page->lru, dst);
^1da177e4c3f41 Linus Torvalds          2005-04-16  1701  	}
^1da177e4c3f41 Linus Torvalds          2005-04-16  1702  
b2e18757f2c9d1 Mel Gorman              2016-07-28  1703  	/*
b2e18757f2c9d1 Mel Gorman              2016-07-28  1704  	 * Splice any skipped pages to the start of the LRU list. Note that
b2e18757f2c9d1 Mel Gorman              2016-07-28  1705  	 * this disrupts the LRU order when reclaiming for lower zones but
b2e18757f2c9d1 Mel Gorman              2016-07-28  1706  	 * we cannot splice to the tail. If we did then the SWAP_CLUSTER_MAX
b2e18757f2c9d1 Mel Gorman              2016-07-28  1707  	 * scanning would soon rescan the same pages to skip and put the
b2e18757f2c9d1 Mel Gorman              2016-07-28  1708  	 * system at risk of premature OOM.
b2e18757f2c9d1 Mel Gorman              2016-07-28  1709  	 */
7cc30fcfd2a894 Mel Gorman              2016-07-28  1710  	if (!list_empty(&pages_skipped)) {
7cc30fcfd2a894 Mel Gorman              2016-07-28  1711  		int zid;
7cc30fcfd2a894 Mel Gorman              2016-07-28  1712  
3db65812d68883 Johannes Weiner         2017-05-03  1713  		list_splice(&pages_skipped, src);
7cc30fcfd2a894 Mel Gorman              2016-07-28  1714  		for (zid = 0; zid < MAX_NR_ZONES; zid++) {
7cc30fcfd2a894 Mel Gorman              2016-07-28  1715  			if (!nr_skipped[zid])
7cc30fcfd2a894 Mel Gorman              2016-07-28  1716  				continue;
7cc30fcfd2a894 Mel Gorman              2016-07-28  1717  
7cc30fcfd2a894 Mel Gorman              2016-07-28  1718  			__count_zid_vm_events(PGSCAN_SKIP, zid, nr_skipped[zid]);
1265e3a69f1ea9 Michal Hocko            2017-02-22  1719  			skipped += nr_skipped[zid];
7cc30fcfd2a894 Mel Gorman              2016-07-28  1720  		}
7cc30fcfd2a894 Mel Gorman              2016-07-28  1721  	}
791b48b642324c Minchan Kim             2017-05-12  1722  	*nr_scanned = total_scan;
1265e3a69f1ea9 Michal Hocko            2017-02-22  1723  	trace_mm_vmscan_lru_isolate(sc->reclaim_idx, sc->order, nr_to_scan,
791b48b642324c Minchan Kim             2017-05-12  1724  				    total_scan, skipped, nr_taken, mode, lru);
b4536f0c829c85 Michal Hocko            2017-01-10  1725  	update_lru_sizes(lruvec, lru, nr_zone_taken);
^1da177e4c3f41 Linus Torvalds          2005-04-16  1726  	return nr_taken;
^1da177e4c3f41 Linus Torvalds          2005-04-16  1727  }
^1da177e4c3f41 Linus Torvalds          2005-04-16  1728  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

Patch
diff mbox series

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 9b6ddeb097e9..919acae23fad 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -353,64 +353,67 @@  my $lineprefix="";
 
 # Parser states
 use constant {
     STATE_NORMAL        => 0,        # normal code
     STATE_NAME          => 1,        # looking for function name
     STATE_BODY_MAYBE    => 2,        # body - or maybe more description
     STATE_BODY          => 3,        # the body of the comment
     STATE_BODY_WITH_BLANK_LINE => 4, # the body, which has a blank line
     STATE_PROTO         => 5,        # scanning prototype
     STATE_DOCBLOCK      => 6,        # documentation block
     STATE_INLINE        => 7,        # gathering doc outside main block
 };
 my $state;
 my $in_doc_sect;
 my $leading_space;
 
 # Inline documentation state
 use constant {
     STATE_INLINE_NA     => 0, # not applicable ($state != STATE_INLINE)
     STATE_INLINE_NAME   => 1, # looking for member name (@foo:)
     STATE_INLINE_TEXT   => 2, # looking for member documentation
     STATE_INLINE_END    => 3, # done
     STATE_INLINE_ERROR  => 4, # error - Comment without header was found.
                               # Spit a warning as it's not
                               # proper kernel-doc and ignore the rest.
 };
 my $inline_doc_state;
 
 #declaration types: can be
 # 'function', 'struct', 'union', 'enum', 'typedef'
 my $decl_type;
 
+# Name of the kernel-doc identifier for non-DOC markups
+my $identifier;
+
 my $doc_start = '^/\*\*\s*$'; # Allow whitespace at end of comment start.
 my $doc_end = '\*/';
 my $doc_com = '\s*\*\s*';
 my $doc_com_body = '\s*\* ?';
 my $doc_decl = $doc_com . '(\w+)';
 # @params and a strictly limited set of supported section names
 my $doc_sect = $doc_com .
     '\s*(\@[.\w]+|\@\.\.\.|description|context|returns?|notes?|examples?)\s*:(.*)';
 my $doc_content = $doc_com_body . '(.*)';
 my $doc_block = $doc_com . 'DOC:\s*(.*)?';
 my $doc_inline_start = '^\s*/\*\*\s*$';
 my $doc_inline_sect = '\s*\*\s*(@\s*[\w][\w\.]*\s*):(.*)';
 my $doc_inline_end = '^\s*\*/\s*$';
 my $doc_inline_oneline = '^\s*/\*\*\s*(@[\w\s]+):\s*(.*)\s*\*/\s*$';
 my $export_symbol = '^\s*EXPORT_SYMBOL(_GPL)?\s*\(\s*(\w+)\s*\)\s*;';
 
 my %parameterdescs;
 my %parameterdesc_start_lines;
 my @parameterlist;
 my %sections;
 my @sectionlist;
 my %section_start_lines;
 my $sectcheck;
 my $struct_actual;
 
 my $contents = "";
 my $new_start_line = 0;
 
 # the canonical section names. see also $doc_sect above.
 my $section_default = "Description";	# default section
 my $section_intro = "Introduction";
 my $section = $section_default;
@@ -1174,64 +1177,69 @@  sub output_declaration {
 ##
 # generic output function - calls the right one based on current output mode.
 sub output_blockhead {
     no strict 'refs';
     my $func = "output_blockhead_" . $output_mode;
     &$func(@_);
     $section_counter++;
 }
 
 ##
 # takes a declaration (struct, union, enum, typedef) and
 # invokes the right handler. NOT called for functions.
 sub dump_declaration($$) {
     no strict 'refs';
     my ($prototype, $file) = @_;
     my $func = "dump_" . $decl_type;
     &$func(@_);
 }
 
 sub dump_union($$) {
     dump_struct(@_);
 }
 
 sub dump_struct($$) {
     my $x = shift;
     my $file = shift;
 
     if ($x =~ /(struct|union)\s+(\w+)\s*\{(.*)\}(\s*(__packed|__aligned|____cacheline_aligned_in_smp|____cacheline_aligned|__attribute__\s*\(\([a-z0-9,_\s\(\)]*\)\)))*/) {
 	my $decl_type = $1;
 	$declaration_name = $2;
 	my $members = $3;
 
+	if ($identifier ne $declaration_name) {
+	    print STDERR "${file}:$.: warning: expecting prototype for $decl_type $identifier. Prototype was for $decl_type $declaration_name instead\n";
+	    return;
+	}
+
 	# ignore members marked private:
 	$members =~ s/\/\*\s*private:.*?\/\*\s*public:.*?\*\///gosi;
 	$members =~ s/\/\*\s*private:.*//gosi;
 	# strip comments:
 	$members =~ s/\/\*.*?\*\///gos;
 	# strip attributes
 	$members =~ s/\s*__attribute__\s*\(\([a-z0-9,_\*\s\(\)]*\)\)/ /gi;
 	$members =~ s/\s*__aligned\s*\([^;]*\)/ /gos;
 	$members =~ s/\s*__packed\s*/ /gos;
 	$members =~ s/\s*CRYPTO_MINALIGN_ATTR/ /gos;
 	$members =~ s/\s*____cacheline_aligned_in_smp/ /gos;
 	$members =~ s/\s*____cacheline_aligned/ /gos;
 
 	# replace DECLARE_BITMAP
 	$members =~ s/__ETHTOOL_DECLARE_LINK_MODE_MASK\s*\(([^\)]+)\)/DECLARE_BITMAP($1, __ETHTOOL_LINK_MODE_MASK_NBITS)/gos;
 	$members =~ s/DECLARE_BITMAP\s*\(([^,)]+),\s*([^,)]+)\)/unsigned long $1\[BITS_TO_LONGS($2)\]/gos;
 	# replace DECLARE_HASHTABLE
 	$members =~ s/DECLARE_HASHTABLE\s*\(([^,)]+),\s*([^,)]+)\)/unsigned long $1\[1 << (($2) - 1)\]/gos;
 	# replace DECLARE_KFIFO
 	$members =~ s/DECLARE_KFIFO\s*\(([^,)]+),\s*([^,)]+),\s*([^,)]+)\)/$2 \*$1/gos;
 	# replace DECLARE_KFIFO_PTR
 	$members =~ s/DECLARE_KFIFO_PTR\s*\(([^,)]+),\s*([^,)]+)\)/$2 \*$1/gos;
 
 	my $declaration = $members;
 
 	# Split nested struct/union elements as newer ones
 	while ($members =~ m/(struct|union)([^\{\};]+)\{([^\{\}]*)\}([^\{\}\;]*)\;/) {
 		my $newmember;
 		my $maintype = $1;
 		my $ids = $4;
 		my $content = $3;
 		foreach my $id(split /,/, $ids) {
@@ -1362,150 +1370,165 @@  sub show_warnings($$) {
 			return 0;
 		}
 	}
 	if ($output_selection == OUTPUT_INCLUDE) {
 		if (defined($function_table{$name})) {
 			return 1;
 		} else {
 			return 0;
 		}
 	}
 	die("Please add the new output type at show_warnings()");
 }
 
 sub dump_enum($$) {
     my $x = shift;
     my $file = shift;
     my $members;
 
 
     $x =~ s@/\*.*?\*/@@gos;	# strip comments.
     # strip #define macros inside enums
     $x =~ s@#\s*((define|ifdef)\s+|endif)[^;]*;@@gos;
 
     if ($x =~ /typedef\s+enum\s*\{(.*)\}\s*(\w*)\s*;/) {
 	$declaration_name = $2;
 	$members = $1;
     } elsif ($x =~ /enum\s+(\w*)\s*\{(.*)\}/) {
 	$declaration_name = $1;
 	$members = $2;
     }
 
     if ($members) {
+	if ($identifier ne $declaration_name) {
+	    print STDERR "${file}:$.: warning: expecting prototype for enum $identifier. Prototype was for enum $declaration_name instead\n";
+	    return;
+	}
+
 	my %_members;
 
 	$members =~ s/\s+$//;
 
 	foreach my $arg (split ',', $members) {
 	    $arg =~ s/^\s*(\w+).*/$1/;
 	    push @parameterlist, $arg;
 	    if (!$parameterdescs{$arg}) {
 		$parameterdescs{$arg} = $undescribed;
 	        if (show_warnings("enum", $declaration_name)) {
 			print STDERR "${file}:$.: warning: Enum value '$arg' not described in enum '$declaration_name'\n";
 		}
 	    }
 	    $_members{$arg} = 1;
 	}
 
 	while (my ($k, $v) = each %parameterdescs) {
 	    if (!exists($_members{$k})) {
 	        if (show_warnings("enum", $declaration_name)) {
 		     print STDERR "${file}:$.: warning: Excess enum value '$k' description in '$declaration_name'\n";
 		}
 	    }
         }
 
 	output_declaration($declaration_name,
 			   'enum',
 			   {'enum' => $declaration_name,
 			    'module' => $modulename,
 			    'parameterlist' => \@parameterlist,
 			    'parameterdescs' => \%parameterdescs,
 			    'sectionlist' => \@sectionlist,
 			    'sections' => \%sections,
 			    'purpose' => $declaration_purpose
 			   });
     } else {
 	print STDERR "${file}:$.: error: Cannot parse enum!\n";
 	++$errors;
     }
 }
 
 my $typedef_type = qr { ((?:\s+[\w\*]+){1,8})\s* }x;
 my $typedef_ident = qr { \*?\s*(\w\S+)\s* }x;
 my $typedef_args = qr { \s*\((.*)\); }x;
 
 my $typedef1 = qr { typedef$typedef_type\($typedef_ident\)$typedef_args }x;
 my $typedef2 = qr { typedef$typedef_type$typedef_ident$typedef_args }x;
 
 sub dump_typedef($$) {
     my $x = shift;
     my $file = shift;
 
     $x =~ s@/\*.*?\*/@@gos;	# strip comments.
 
     # Parse function typedef prototypes
     if ($x =~ $typedef1 || $x =~ $typedef2) {
 	$return_type = $1;
 	$declaration_name = $2;
 	my $args = $3;
 	$return_type =~ s/^\s+//;
 
+	if ($identifier ne $declaration_name) {
+	    print STDERR "${file}:$.: warning: expecting prototype for typedef $identifier. Prototype was for typedef $declaration_name instead\n";
+	    return;
+	}
+
 	create_parameterlist($args, ',', $file, $declaration_name);
 
 	output_declaration($declaration_name,
 			   'function',
 			   {'function' => $declaration_name,
 			    'typedef' => 1,
 			    'module' => $modulename,
 			    'functiontype' => $return_type,
 			    'parameterlist' => \@parameterlist,
 			    'parameterdescs' => \%parameterdescs,
 			    'parametertypes' => \%parametertypes,
 			    'sectionlist' => \@sectionlist,
 			    'sections' => \%sections,
 			    'purpose' => $declaration_purpose
 			   });
 	return;
     }
 
     while (($x =~ /\(*.\)\s*;$/) || ($x =~ /\[*.\]\s*;$/)) {
 	$x =~ s/\(*.\)\s*;$/;/;
 	$x =~ s/\[*.\]\s*;$/;/;
     }
 
     if ($x =~ /typedef.*\s+(\w+)\s*;/) {
 	$declaration_name = $1;
 
+	if ($identifier ne $declaration_name) {
+	    print STDERR "${file}:$.: warning: expecting prototype for typedef $identifier. Prototype was for typedef $declaration_name instead\n";
+	    return;
+	}
+
 	output_declaration($declaration_name,
 			   'typedef',
 			   {'typedef' => $declaration_name,
 			    'module' => $modulename,
 			    'sectionlist' => \@sectionlist,
 			    'sections' => \%sections,
 			    'purpose' => $declaration_purpose
 			   });
     }
     else {
 	print STDERR "${file}:$.: error: Cannot parse typedef!\n";
 	++$errors;
     }
 }
 
 sub save_struct_actual($) {
     my $actual = shift;
 
     # strip all spaces from the actual param so that it looks like one string item
     $actual =~ s/\s*//g;
     $struct_actual = $struct_actual . $actual . " ";
 }
 
 sub create_parameterlist($$$$) {
     my $args = shift;
     my $splitter = shift;
     my $file = shift;
     my $declaration_name = shift;
     my $type;
     my $param;
 
     # temporarily replace commas inside function pointer definition
@@ -1767,64 +1790,69 @@  sub dump_function($$) {
         # Function-like macros are not allowed to have spaces between
         # declaration_name and opening parenthesis (notice the \s+).
         $return_type = $1;
         $declaration_name = $2;
         $noret = 1;
     } elsif ($prototype =~ m/^()([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ ||
 	$prototype =~ m/^(\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ ||
 	$prototype =~ m/^(\w+\s*\*+)\s*([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ ||
 	$prototype =~ m/^(\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ ||
 	$prototype =~ m/^(\w+\s+\w+\s*\*+)\s*([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ ||
 	$prototype =~ m/^(\w+\s+\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ ||
 	$prototype =~ m/^(\w+\s+\w+\s+\w+\s*\*+)\s*([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ ||
 	$prototype =~ m/^()([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
 	$prototype =~ m/^(\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
 	$prototype =~ m/^(\w+\s*\*+)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
 	$prototype =~ m/^(\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
 	$prototype =~ m/^(\w+\s+\w+\s*\*+)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
 	$prototype =~ m/^(\w+\s+\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
 	$prototype =~ m/^(\w+\s+\w+\s+\w+\s*\*+)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
 	$prototype =~ m/^(\w+\s+\w+\s+\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
 	$prototype =~ m/^(\w+\s+\w+\s+\w+\s+\w+\s*\*+)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
 	$prototype =~ m/^(\w+\s+\w+\s*\*+\s*\w+\s*\*+\s*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/)  {
 	$return_type = $1;
 	$declaration_name = $2;
 	my $args = $3;
 
 	create_parameterlist($args, ',', $file, $declaration_name);
     } else {
 	print STDERR "${file}:$.: warning: cannot understand function prototype: '$prototype'\n";
 	return;
     }
 
+    if ($identifier ne $declaration_name) {
+	print STDERR "${file}:$.: warning: expecting prototype for $identifier(). Prototype was for $declaration_name() instead\n";
+	return;
+    }
+
     my $prms = join " ", @parameterlist;
     check_sections($file, $declaration_name, "function", $sectcheck, $prms);
 
     # This check emits a lot of warnings at the moment, because many
     # functions don't have a 'Return' doc section. So until the number
     # of warnings goes sufficiently down, the check is only performed in
     # verbose mode.
     # TODO: always perform the check.
     if ($verbose && !$noret) {
 	    check_return_section($file, $declaration_name, $return_type);
     }
 
     # The function parser can be called with a typedef parameter.
     # Handle it.
     if ($return_type =~ /typedef/) {
 	output_declaration($declaration_name,
 			   'function',
 			   {'function' => $declaration_name,
 			    'typedef' => 1,
 			    'module' => $modulename,
 			    'functiontype' => $return_type,
 			    'parameterlist' => \@parameterlist,
 			    'parameterdescs' => \%parameterdescs,
 			    'parametertypes' => \%parametertypes,
 			    'sectionlist' => \@sectionlist,
 			    'sections' => \%sections,
 			    'purpose' => $declaration_purpose
 			   });
     } else {
 	output_declaration($declaration_name,
 			   'function',
 			   {'function' => $declaration_name,
@@ -1849,64 +1877,65 @@  sub reset_state {
     @sectionlist = ();
     $sectcheck = "";
     $struct_actual = "";
     $prototype = "";
 
     $state = STATE_NORMAL;
     $inline_doc_state = STATE_INLINE_NA;
 }
 
 sub tracepoint_munge($) {
 	my $file = shift;
 	my $tracepointname = 0;
 	my $tracepointargs = 0;
 
 	if ($prototype =~ m/TRACE_EVENT\((.*?),/) {
 		$tracepointname = $1;
 	}
 	if ($prototype =~ m/DEFINE_SINGLE_EVENT\((.*?),/) {
 		$tracepointname = $1;
 	}
 	if ($prototype =~ m/DEFINE_EVENT\((.*?),(.*?),/) {
 		$tracepointname = $2;
 	}
 	$tracepointname =~ s/^\s+//; #strip leading whitespace
 	if ($prototype =~ m/TP_PROTO\((.*?)\)/) {
 		$tracepointargs = $1;
 	}
 	if (($tracepointname eq 0) || ($tracepointargs eq 0)) {
 		print STDERR "${file}:$.: warning: Unrecognized tracepoint format: \n".
 			     "$prototype\n";
 	} else {
 		$prototype = "static inline void trace_$tracepointname($tracepointargs)";
+		$identifier = "trace_$identifier";
 	}
 }
 
 sub syscall_munge() {
 	my $void = 0;
 
 	$prototype =~ s@[\r\n]+@ @gos; # strip newlines/CR's
 ##	if ($prototype =~ m/SYSCALL_DEFINE0\s*\(\s*(a-zA-Z0-9_)*\s*\)/) {
 	if ($prototype =~ m/SYSCALL_DEFINE0/) {
 		$void = 1;
 ##		$prototype = "long sys_$1(void)";
 	}
 
 	$prototype =~ s/SYSCALL_DEFINE.*\(/long sys_/; # fix return type & func name
 	if ($prototype =~ m/long (sys_.*?),/) {
 		$prototype =~ s/,/\(/;
 	} elsif ($void) {
 		$prototype =~ s/\)/\(void\)/;
 	}
 
 	# now delete all of the odd-number commas in $prototype
 	# so that arg types & arg names don't have a comma between them
 	my $count = 0;
 	my $len = length($prototype);
 	if ($void) {
 		$len = 0;	# skip the for-loop
 	}
 	for (my $ix = 0; $ix < $len; $ix++) {
 		if (substr($prototype, $ix, 1) eq ',') {
 			$count++;
 			if ($count % 2 == 1) {
 				substr($prototype, $ix, 1) = ' ';
@@ -2012,122 +2041,123 @@  sub process_export_file($) {
 	++$errors;
 	return;
     }
 
     while (<IN>) {
 	if (/$export_symbol/) {
 	    next if (defined($nosymbol_table{$2}));
 	    $function_table{$2} = 1;
 	}
     }
 
     close(IN);
 }
 
 #
 # Parsers for the various processing states.
 #
 # STATE_NORMAL: looking for the /** to begin everything.
 #
 sub process_normal() {
     if (/$doc_start/o) {
 	$state = STATE_NAME;	# next line is always the function name
 	$in_doc_sect = 0;
 	$declaration_start_line = $. + 1;
     }
 }
 
 #
 # STATE_NAME: Looking for the "name - description" line
 #
 sub process_name($$) {
     my $file = shift;
-    my $identifier;
     my $descr;
 
     if (/$doc_block/o) {
 	$state = STATE_DOCBLOCK;
 	$contents = "";
 	$new_start_line = $.;
 
 	if ( $1 eq "" ) {
 	    $section = $section_intro;
 	} else {
 	    $section = $1;
 	}
-    }
-    elsif (/$doc_decl/o) {
+    } elsif (/$doc_decl/o) {
 	$identifier = $1;
-	if (/\s*([\w\s]+?)(\(\))?\s*-/) {
+	if (/\s*([\w\s]+?)(\(\))?\s*([-:].*)?$/) {
 	    $identifier = $1;
 	}
+	if ($identifier =~ m/^(struct|union|enum|typedef)\b\s*(\S*)/) {
+	    $decl_type = $1;
+	    $identifier = $2;
+	} else {
+	    $decl_type = 'function';
+	    $identifier =~ s/^define\s+//;
+	}
+	$identifier =~ s/\s+$//;
 
 	$state = STATE_BODY;
 	# if there's no @param blocks need to set up default section
 	# here
 	$contents = "";
 	$section = $section_default;
 	$new_start_line = $. + 1;
-	if (/-(.*)/) {
+	if (/[-:](.*)/) {
 	    # strip leading/trailing/multiple spaces
 	    $descr= $1;
 	    $descr =~ s/^\s*//;
 	    $descr =~ s/\s*$//;
 	    $descr =~ s/\s+/ /g;
 	    $declaration_purpose = $descr;
 	    $state = STATE_BODY_MAYBE;
 	} else {
 	    $declaration_purpose = "";
 	}
 
 	if (($declaration_purpose eq "") && $verbose) {
 	    print STDERR "${file}:$.: warning: missing initial short description on line:\n";
 	    print STDERR $_;
 	    ++$warnings;
 	}
 
-	if ($identifier =~ m/^struct\b/) {
-	    $decl_type = 'struct';
-	} elsif ($identifier =~ m/^union\b/) {
-	    $decl_type = 'union';
-	} elsif ($identifier =~ m/^enum\b/) {
-	    $decl_type = 'enum';
-	} elsif ($identifier =~ m/^typedef\b/) {
-	    $decl_type = 'typedef';
-	} else {
-	    $decl_type = 'function';
+	if ($identifier eq "") {
+	    print STDERR "${file}:$.: warning: wrong kernel-doc identifier on line:\n";
+	    print STDERR $_;
+	    ++$warnings;
+	    $state = STATE_NORMAL;
 	}
 
 	if ($verbose) {
-	    print STDERR "${file}:$.: info: Scanning doc for $identifier\n";
+	    print STDERR "${file}:$.: info: Scanning doc for $decl_type $identifier\n";
 	}
     } else {
 	print STDERR "${file}:$.: warning: Cannot understand $_ on line $.",
 	    " - I thought it was a doc line\n";
 	++$warnings;
 	$state = STATE_NORMAL;
     }
 }
 
 
 #
 # STATE_BODY and STATE_BODY_MAYBE: the bulk of a kerneldoc comment.
 #
 sub process_body($$) {
     my $file = shift;
 
     # Until all named variable macro parameters are
     # documented using the bare name (`x`) rather than with
     # dots (`x...`), strip the dots:
     if ($section =~ /\w\.\.\.$/) {
 	$section =~ s/\.\.\.$//;
 
 	if ($verbose) {
 	    print STDERR "${file}:$.: warning: Variable macro arguments should be documented without dots\n";
 	    ++$warnings;
 	}
     }
 
     if ($state == STATE_BODY_WITH_BLANK_LINE && /^\s*\*\s?\S/) {
 	dump_section($file, $section, $contents);
 	$section = $section_default;
 	$new_start_line = $.;