diff mbox series

tty: serial: mvebu-uart: Remove unused variable 'ret'

Message ID 20200930081459.1269-1-shipujin.t@gmail.com
State New
Headers show
Series tty: serial: mvebu-uart: Remove unused variable 'ret' | expand

Commit Message

Pujin Shi Sept. 30, 2020, 8:14 a.m. UTC
'ret' variable is now defined but not used in mvebu_uart_probe(),
causing this warning:

  drivers/tty/serial/mvebu-uart.c: In function ‘mvebu_uart_probe’:
  drivers/tty/serial/mvebu-uart.c:806:6: warning: unused variable ‘ret’ [-Wunused-variable]

Signed-off-by: Pujin Shi <shipujin.t@gmail.com>
---
 drivers/tty/serial/mvebu-uart.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jiri Slaby Sept. 30, 2020, 8:21 a.m. UTC | #1
On 30. 09. 20, 10:14, Pujin Shi wrote:
> 'ret' variable is now defined but not used in mvebu_uart_probe(),
> causing this warning:
> 
>   drivers/tty/serial/mvebu-uart.c: In function ‘mvebu_uart_probe’:
>   drivers/tty/serial/mvebu-uart.c:806:6: warning: unused variable ‘ret’ [-Wunused-variable]
> 
> Signed-off-by: Pujin Shi <shipujin.t@gmail.com>

Reviewed-by: Jiri Slaby <jirislaby@kernel.org>

> ---
>  drivers/tty/serial/mvebu-uart.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/tty/serial/mvebu-uart.c b/drivers/tty/serial/mvebu-uart.c
> index 7443c0506eb4..118b29912289 100644
> --- a/drivers/tty/serial/mvebu-uart.c
> +++ b/drivers/tty/serial/mvebu-uart.c
> @@ -803,7 +803,7 @@ static int mvebu_uart_probe(struct platform_device *pdev)
>  							   &pdev->dev);
>  	struct uart_port *port;
>  	struct mvebu_uart *mvuart;
> -	int ret, id, irq;
> +	int id, irq;
>  
>  	if (!reg) {
>  		dev_err(&pdev->dev, "no registers defined\n");
> 

thanks,
Greg Kroah-Hartman Sept. 30, 2020, 9:21 a.m. UTC | #2
On Wed, Sep 30, 2020 at 04:14:59PM +0800, Pujin Shi wrote:
> 'ret' variable is now defined but not used in mvebu_uart_probe(),

> causing this warning:

> 

>   drivers/tty/serial/mvebu-uart.c: In function ‘mvebu_uart_probe’:

>   drivers/tty/serial/mvebu-uart.c:806:6: warning: unused variable ‘ret’ [-Wunused-variable]

> 

> Signed-off-by: Pujin Shi <shipujin.t@gmail.com>


What commit caused this problem?

And are you sure it's not already fixed by:
	https://lore.kernel.org/r/20200929085651.158283-1-miaoqinglang@huawei.com

thanks,

greg k-h
kernel test robot Oct. 5, 2020, 11:51 p.m. UTC | #3
Hi Pujin,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on usb/usb-testing]
[also build test ERROR on v5.9-rc8]
[cannot apply to tty/tty-testing next-20201002]
[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/Pujin-Shi/tty-serial-mvebu-uart-Remove-unused-variable-ret/20200930-161555
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
config: powerpc-randconfig-r035-20201005 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project 39fc4a0b0af69772ee360b5f729b1ec453217793)
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
        # install powerpc cross compiling tool for clang build
        # apt-get install binutils-powerpc-linux-gnu
        # https://github.com/0day-ci/linux/commit/c2857134bbb1c0f004f4d026e62a2b90aa2015a0
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Pujin-Shi/tty-serial-mvebu-uart-Remove-unused-variable-ret/20200930-161555
        git checkout c2857134bbb1c0f004f4d026e62a2b90aa2015a0
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=powerpc 

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

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

>> drivers/tty/serial/mvebu-uart.c:915:2: error: use of undeclared identifier 'ret'; did you mean 'reg'?
           ret = uart_add_one_port(&mvebu_uart_driver, port);
           ^~~
           reg
   drivers/tty/serial/mvebu-uart.c:801:19: note: 'reg' declared here
           struct resource *reg = platform_get_resource(pdev, IORESOURCE_MEM, 0);
                            ^
>> drivers/tty/serial/mvebu-uart.c:915:6: warning: incompatible integer to pointer conversion assigning to 'struct resource *' from 'int' [-Wint-conversion]
           ret = uart_add_one_port(&mvebu_uart_driver, port);
               ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/tty/serial/mvebu-uart.c:916:6: error: use of undeclared identifier 'ret'; did you mean 'reg'?
           if (ret)
               ^~~
               reg
   drivers/tty/serial/mvebu-uart.c:801:19: note: 'reg' declared here
           struct resource *reg = platform_get_resource(pdev, IORESOURCE_MEM, 0);
                            ^
   drivers/tty/serial/mvebu-uart.c:917:10: error: use of undeclared identifier 'ret'; did you mean 'reg'?
                   return ret;
                          ^~~
                          reg
   drivers/tty/serial/mvebu-uart.c:801:19: note: 'reg' declared here
           struct resource *reg = platform_get_resource(pdev, IORESOURCE_MEM, 0);
                            ^
>> drivers/tty/serial/mvebu-uart.c:917:10: warning: incompatible pointer to integer conversion returning 'struct resource *' from a function with result type 'int' [-Wint-conversion]
                   return ret;
                          ^~~
   2 warnings and 3 errors generated.

vim +915 drivers/tty/serial/mvebu-uart.c

94228f9561bb6c Allen Yan     2017-10-13  798  
30530791a7a032 Wilson Ding   2016-02-16  799  static int mvebu_uart_probe(struct platform_device *pdev)
30530791a7a032 Wilson Ding   2016-02-16  800  {
30530791a7a032 Wilson Ding   2016-02-16  801  	struct resource *reg = platform_get_resource(pdev, IORESOURCE_MEM, 0);
5218d76958644a Miquel Raynal 2017-10-13  802  	const struct of_device_id *match = of_match_device(mvebu_uart_of_match,
5218d76958644a Miquel Raynal 2017-10-13  803  							   &pdev->dev);
30530791a7a032 Wilson Ding   2016-02-16  804  	struct uart_port *port;
5218d76958644a Miquel Raynal 2017-10-13  805  	struct mvebu_uart *mvuart;
c2857134bbb1c0 Pujin Shi     2020-09-30  806  	int id, irq;
30530791a7a032 Wilson Ding   2016-02-16  807  
95f787685a224e Miquel Raynal 2017-10-13  808  	if (!reg) {
95f787685a224e Miquel Raynal 2017-10-13  809  		dev_err(&pdev->dev, "no registers defined\n");
30530791a7a032 Wilson Ding   2016-02-16  810  		return -EINVAL;
30530791a7a032 Wilson Ding   2016-02-16  811  	}
30530791a7a032 Wilson Ding   2016-02-16  812  
32f47179833b63 Aditya Pakki  2019-03-18  813  	if (!match)
32f47179833b63 Aditya Pakki  2019-03-18  814  		return -ENODEV;
32f47179833b63 Aditya Pakki  2019-03-18  815  
94228f9561bb6c Allen Yan     2017-10-13  816  	/* Assume that all UART ports have a DT alias or none has */
94228f9561bb6c Allen Yan     2017-10-13  817  	id = of_alias_get_id(pdev->dev.of_node, "serial");
94228f9561bb6c Allen Yan     2017-10-13  818  	if (!pdev->dev.of_node || id < 0)
94228f9561bb6c Allen Yan     2017-10-13  819  		pdev->id = uart_num_counter++;
94228f9561bb6c Allen Yan     2017-10-13  820  	else
94228f9561bb6c Allen Yan     2017-10-13  821  		pdev->id = id;
94228f9561bb6c Allen Yan     2017-10-13  822  
94228f9561bb6c Allen Yan     2017-10-13  823  	if (pdev->id >= MVEBU_NR_UARTS) {
94228f9561bb6c Allen Yan     2017-10-13  824  		dev_err(&pdev->dev, "cannot have more than %d UART ports\n",
94228f9561bb6c Allen Yan     2017-10-13  825  			MVEBU_NR_UARTS);
94228f9561bb6c Allen Yan     2017-10-13  826  		return -EINVAL;
94228f9561bb6c Allen Yan     2017-10-13  827  	}
94228f9561bb6c Allen Yan     2017-10-13  828  
94228f9561bb6c Allen Yan     2017-10-13  829  	port = &mvebu_uart_ports[pdev->id];
30530791a7a032 Wilson Ding   2016-02-16  830  
30530791a7a032 Wilson Ding   2016-02-16  831  	spin_lock_init(&port->lock);
30530791a7a032 Wilson Ding   2016-02-16  832  
30530791a7a032 Wilson Ding   2016-02-16  833  	port->dev        = &pdev->dev;
30530791a7a032 Wilson Ding   2016-02-16  834  	port->type       = PORT_MVEBU;
30530791a7a032 Wilson Ding   2016-02-16  835  	port->ops        = &mvebu_uart_ops;
30530791a7a032 Wilson Ding   2016-02-16  836  	port->regshift   = 0;
30530791a7a032 Wilson Ding   2016-02-16  837  
30530791a7a032 Wilson Ding   2016-02-16  838  	port->fifosize   = 32;
30530791a7a032 Wilson Ding   2016-02-16  839  	port->iotype     = UPIO_MEM32;
30530791a7a032 Wilson Ding   2016-02-16  840  	port->flags      = UPF_FIXED_PORT;
94228f9561bb6c Allen Yan     2017-10-13  841  	port->line       = pdev->id;
30530791a7a032 Wilson Ding   2016-02-16  842  
95f787685a224e Miquel Raynal 2017-10-13  843  	/*
95f787685a224e Miquel Raynal 2017-10-13  844  	 * IRQ number is not stored in this structure because we may have two of
95f787685a224e Miquel Raynal 2017-10-13  845  	 * them per port (RX and TX). Instead, use the driver UART structure
95f787685a224e Miquel Raynal 2017-10-13  846  	 * array so called ->irq[].
95f787685a224e Miquel Raynal 2017-10-13  847  	 */
95f787685a224e Miquel Raynal 2017-10-13  848  	port->irq        = 0;
30530791a7a032 Wilson Ding   2016-02-16  849  	port->irqflags   = 0;
30530791a7a032 Wilson Ding   2016-02-16  850  	port->mapbase    = reg->start;
30530791a7a032 Wilson Ding   2016-02-16  851  
30530791a7a032 Wilson Ding   2016-02-16  852  	port->membase = devm_ioremap_resource(&pdev->dev, reg);
30530791a7a032 Wilson Ding   2016-02-16  853  	if (IS_ERR(port->membase))
4a3e208474204e tangbin       2020-03-05  854  		return PTR_ERR(port->membase);
30530791a7a032 Wilson Ding   2016-02-16  855  
5218d76958644a Miquel Raynal 2017-10-13  856  	mvuart = devm_kzalloc(&pdev->dev, sizeof(struct mvebu_uart),
30530791a7a032 Wilson Ding   2016-02-16  857  			      GFP_KERNEL);
5218d76958644a Miquel Raynal 2017-10-13  858  	if (!mvuart)
30530791a7a032 Wilson Ding   2016-02-16  859  		return -ENOMEM;
30530791a7a032 Wilson Ding   2016-02-16  860  
68a0db1d7da20f Allen Yan     2017-10-13  861  	/* Get controller data depending on the compatible string */
5218d76958644a Miquel Raynal 2017-10-13  862  	mvuart->data = (struct mvebu_uart_driver_data *)match->data;
5218d76958644a Miquel Raynal 2017-10-13  863  	mvuart->port = port;
30530791a7a032 Wilson Ding   2016-02-16  864  
5218d76958644a Miquel Raynal 2017-10-13  865  	port->private_data = mvuart;
5218d76958644a Miquel Raynal 2017-10-13  866  	platform_set_drvdata(pdev, mvuart);
30530791a7a032 Wilson Ding   2016-02-16  867  
68a0db1d7da20f Allen Yan     2017-10-13  868  	/* Get fixed clock frequency */
68a0db1d7da20f Allen Yan     2017-10-13  869  	mvuart->clk = devm_clk_get(&pdev->dev, NULL);
68a0db1d7da20f Allen Yan     2017-10-13  870  	if (IS_ERR(mvuart->clk)) {
68a0db1d7da20f Allen Yan     2017-10-13  871  		if (PTR_ERR(mvuart->clk) == -EPROBE_DEFER)
68a0db1d7da20f Allen Yan     2017-10-13  872  			return PTR_ERR(mvuart->clk);
68a0db1d7da20f Allen Yan     2017-10-13  873  
68a0db1d7da20f Allen Yan     2017-10-13  874  		if (IS_EXTENDED(port)) {
68a0db1d7da20f Allen Yan     2017-10-13  875  			dev_err(&pdev->dev, "unable to get UART clock\n");
68a0db1d7da20f Allen Yan     2017-10-13  876  			return PTR_ERR(mvuart->clk);
68a0db1d7da20f Allen Yan     2017-10-13  877  		}
68a0db1d7da20f Allen Yan     2017-10-13  878  	} else {
68a0db1d7da20f Allen Yan     2017-10-13  879  		if (!clk_prepare_enable(mvuart->clk))
68a0db1d7da20f Allen Yan     2017-10-13  880  			port->uartclk = clk_get_rate(mvuart->clk);
68a0db1d7da20f Allen Yan     2017-10-13  881  	}
68a0db1d7da20f Allen Yan     2017-10-13  882  
95f787685a224e Miquel Raynal 2017-10-13  883  	/* Manage interrupts */
95f787685a224e Miquel Raynal 2017-10-13  884  	if (platform_irq_count(pdev) == 1) {
95f787685a224e Miquel Raynal 2017-10-13  885  		/* Old bindings: no name on the single unamed UART0 IRQ */
95f787685a224e Miquel Raynal 2017-10-13  886  		irq = platform_get_irq(pdev, 0);
1df217868178bd Stephen Boyd  2019-07-30  887  		if (irq < 0)
95f787685a224e Miquel Raynal 2017-10-13  888  			return irq;
95f787685a224e Miquel Raynal 2017-10-13  889  
95f787685a224e Miquel Raynal 2017-10-13  890  		mvuart->irq[UART_IRQ_SUM] = irq;
95f787685a224e Miquel Raynal 2017-10-13  891  	} else {
95f787685a224e Miquel Raynal 2017-10-13  892  		/*
95f787685a224e Miquel Raynal 2017-10-13  893  		 * New bindings: named interrupts (RX, TX) for both UARTS,
95f787685a224e Miquel Raynal 2017-10-13  894  		 * only make use of uart-rx and uart-tx interrupts, do not use
95f787685a224e Miquel Raynal 2017-10-13  895  		 * uart-sum of UART0 port.
95f787685a224e Miquel Raynal 2017-10-13  896  		 */
95f787685a224e Miquel Raynal 2017-10-13  897  		irq = platform_get_irq_byname(pdev, "uart-rx");
1df217868178bd Stephen Boyd  2019-07-30  898  		if (irq < 0)
95f787685a224e Miquel Raynal 2017-10-13  899  			return irq;
95f787685a224e Miquel Raynal 2017-10-13  900  
95f787685a224e Miquel Raynal 2017-10-13  901  		mvuart->irq[UART_RX_IRQ] = irq;
95f787685a224e Miquel Raynal 2017-10-13  902  
95f787685a224e Miquel Raynal 2017-10-13  903  		irq = platform_get_irq_byname(pdev, "uart-tx");
1df217868178bd Stephen Boyd  2019-07-30  904  		if (irq < 0)
95f787685a224e Miquel Raynal 2017-10-13  905  			return irq;
95f787685a224e Miquel Raynal 2017-10-13  906  
95f787685a224e Miquel Raynal 2017-10-13  907  		mvuart->irq[UART_TX_IRQ] = irq;
95f787685a224e Miquel Raynal 2017-10-13  908  	}
95f787685a224e Miquel Raynal 2017-10-13  909  
9c3d3ee1239bab Allen Yan     2017-10-13  910  	/* UART Soft Reset*/
9c3d3ee1239bab Allen Yan     2017-10-13  911  	writel(CTRL_SOFT_RST, port->membase + UART_CTRL(port));
9c3d3ee1239bab Allen Yan     2017-10-13  912  	udelay(1);
9c3d3ee1239bab Allen Yan     2017-10-13  913  	writel(0, port->membase + UART_CTRL(port));
9c3d3ee1239bab Allen Yan     2017-10-13  914  
30530791a7a032 Wilson Ding   2016-02-16 @915  	ret = uart_add_one_port(&mvebu_uart_driver, port);
30530791a7a032 Wilson Ding   2016-02-16  916  	if (ret)
30530791a7a032 Wilson Ding   2016-02-16 @917  		return ret;
30530791a7a032 Wilson Ding   2016-02-16  918  	return 0;
30530791a7a032 Wilson Ding   2016-02-16  919  }
30530791a7a032 Wilson Ding   2016-02-16  920  

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

Patch

diff --git a/drivers/tty/serial/mvebu-uart.c b/drivers/tty/serial/mvebu-uart.c
index 7443c0506eb4..118b29912289 100644
--- a/drivers/tty/serial/mvebu-uart.c
+++ b/drivers/tty/serial/mvebu-uart.c
@@ -803,7 +803,7 @@  static int mvebu_uart_probe(struct platform_device *pdev)
 							   &pdev->dev);
 	struct uart_port *port;
 	struct mvebu_uart *mvuart;
-	int ret, id, irq;
+	int id, irq;
 
 	if (!reg) {
 		dev_err(&pdev->dev, "no registers defined\n");