diff mbox series

[v2,1/3] drivers: serial: earlycon: Correct argument name

Message ID 20220806163255.10404-2-markuss.broks@gmail.com (mailing list archive)
State New, archived
Headers show
Series Add generic framebuffer support to EFI earlycon driver | expand

Commit Message

Markuss Broks Aug. 6, 2022, 4:32 p.m. UTC
The "node" argument is actually an offset, and it's also
an "int", and not "unsigned long". Correct the of_setup_earlycon
function.

Signed-off-by: Markuss Broks <markuss.broks@gmail.com>
---
 drivers/tty/serial/earlycon.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

Comments

Andy Shevchenko Aug. 6, 2022, 4:56 p.m. UTC | #1
On Sat, Aug 6, 2022 at 6:37 PM Markuss Broks <markuss.broks@gmail.com> wrote:
>
> The "node" argument is actually an offset, and it's also
> an "int", and not "unsigned long". Correct the of_setup_earlycon
> function.

Suggested-by: Greg KH?

> Signed-off-by: Markuss Broks <markuss.broks@gmail.com>
Chen, Rong A Aug. 8, 2022, 1:28 a.m. UTC | #2
Hi Markuss,

I love your patch! Yet something to improve:

[auto build test ERROR on tty/tty-testing]
[also build test ERROR on efi/next staging/staging-testing usb/usb-testing linus/master v5.19 next-20220805]
[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/Markuss-Broks/Add-generic-framebuffer-support-to-EFI-earlycon-driver/20220807-003646
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git tty-testing
config: x86_64-randconfig-a012 (https://download.01.org/0day-ci/archive/20220807/202208071111.oWn8uZfx-lkp@intel.com/config)
compiler: clang version 16.0.0 (https://github.com/llvm/llvm-project 5f1c7e2cc5a3c07cbc2412e851a7283c1841f520)
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/dedd7c138e9492439eeda05fa75a18bf19883a08
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Markuss-Broks/Add-generic-framebuffer-support-to-EFI-earlycon-driver/20220807-003646
        git checkout dedd7c138e9492439eeda05fa75a18bf19883a08
        # 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

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

All errors (new ones prefixed by >>):

>> drivers/tty/serial/earlycon.c:246:12: error: conflicting types for 'of_setup_earlycon'
   int __init of_setup_earlycon(const struct earlycon_id *match,
              ^
   include/linux/serial_core.h:708:12: note: previous declaration is here
   extern int of_setup_earlycon(const struct earlycon_id *match,
              ^
   1 error generated.


vim +/of_setup_earlycon +246 drivers/tty/serial/earlycon.c

8477614d9f7c5c Peter Hurley       2016-01-16  245  
c90fe9c0394b06 Peter Hurley       2016-01-16 @246  int __init of_setup_earlycon(const struct earlycon_id *match,
dedd7c138e9492 Markuss Broks      2022-08-06  247  			     int offset,
4d118c9a866590 Peter Hurley       2016-01-16  248  			     const char *options)
b0b6abd34c1b50 Rob Herring        2014-03-27  249  {
b0b6abd34c1b50 Rob Herring        2014-03-27  250  	int err;
b0b6abd34c1b50 Rob Herring        2014-03-27  251  	struct uart_port *port = &early_console_dev.port;
088da2a17619cf Peter Hurley       2016-01-16  252  	const __be32 *val;
088da2a17619cf Peter Hurley       2016-01-16  253  	bool big_endian;
c90fe9c0394b06 Peter Hurley       2016-01-16  254  	u64 addr;
b0b6abd34c1b50 Rob Herring        2014-03-27  255  
65e20e8cbbccaf Michael Walle      2022-06-28  256  	if (early_con.flags & CON_ENABLED)
65e20e8cbbccaf Michael Walle      2022-06-28  257  		return -EALREADY;
65e20e8cbbccaf Michael Walle      2022-06-28  258  
e1dd3bef6d03c9 Geert Uytterhoeven 2015-11-27  259  	spin_lock_init(&port->lock);
b0b6abd34c1b50 Rob Herring        2014-03-27  260  	port->iotype = UPIO_MEM;
dedd7c138e9492 Markuss Broks      2022-08-06  261  	addr = of_flat_dt_translate_address(offset);
c90fe9c0394b06 Peter Hurley       2016-01-16  262  	if (addr == OF_BAD_ADDR) {
c90fe9c0394b06 Peter Hurley       2016-01-16  263  		pr_warn("[%s] bad address\n", match->name);
c90fe9c0394b06 Peter Hurley       2016-01-16  264  		return -ENXIO;
c90fe9c0394b06 Peter Hurley       2016-01-16  265  	}
b0b6abd34c1b50 Rob Herring        2014-03-27  266  	port->mapbase = addr;
b0b6abd34c1b50 Rob Herring        2014-03-27  267  
dedd7c138e9492 Markuss Broks      2022-08-06  268  	val = of_get_flat_dt_prop(offset, "reg-offset", NULL);
088da2a17619cf Peter Hurley       2016-01-16  269  	if (val)
088da2a17619cf Peter Hurley       2016-01-16  270  		port->mapbase += be32_to_cpu(*val);
1f66dd36bb1843 Greentime Hu       2018-02-13  271  	port->membase = earlycon_map(port->mapbase, SZ_4K);
1f66dd36bb1843 Greentime Hu       2018-02-13  272  
dedd7c138e9492 Markuss Broks      2022-08-06  273  	val = of_get_flat_dt_prop(offset, "reg-shift", NULL);
088da2a17619cf Peter Hurley       2016-01-16  274  	if (val)
088da2a17619cf Peter Hurley       2016-01-16  275  		port->regshift = be32_to_cpu(*val);
dedd7c138e9492 Markuss Broks      2022-08-06  276  	big_endian = of_get_flat_dt_prop(offset, "big-endian", NULL) != NULL ||
088da2a17619cf Peter Hurley       2016-01-16  277  		(IS_ENABLED(CONFIG_CPU_BIG_ENDIAN) &&
dedd7c138e9492 Markuss Broks      2022-08-06  278  		 of_get_flat_dt_prop(offset, "native-endian", NULL) != NULL);
dedd7c138e9492 Markuss Broks      2022-08-06  279  	val = of_get_flat_dt_prop(offset, "reg-io-width", NULL);
088da2a17619cf Peter Hurley       2016-01-16  280  	if (val) {
088da2a17619cf Peter Hurley       2016-01-16  281  		switch (be32_to_cpu(*val)) {
088da2a17619cf Peter Hurley       2016-01-16  282  		case 1:
088da2a17619cf Peter Hurley       2016-01-16  283  			port->iotype = UPIO_MEM;
088da2a17619cf Peter Hurley       2016-01-16  284  			break;
088da2a17619cf Peter Hurley       2016-01-16  285  		case 2:
088da2a17619cf Peter Hurley       2016-01-16  286  			port->iotype = UPIO_MEM16;
088da2a17619cf Peter Hurley       2016-01-16  287  			break;
088da2a17619cf Peter Hurley       2016-01-16  288  		case 4:
088da2a17619cf Peter Hurley       2016-01-16  289  			port->iotype = (big_endian) ? UPIO_MEM32BE : UPIO_MEM32;
088da2a17619cf Peter Hurley       2016-01-16  290  			break;
088da2a17619cf Peter Hurley       2016-01-16  291  		default:
088da2a17619cf Peter Hurley       2016-01-16  292  			pr_warn("[%s] unsupported reg-io-width\n", match->name);
088da2a17619cf Peter Hurley       2016-01-16  293  			return -EINVAL;
088da2a17619cf Peter Hurley       2016-01-16  294  		}
088da2a17619cf Peter Hurley       2016-01-16  295  	}
088da2a17619cf Peter Hurley       2016-01-16  296  
dedd7c138e9492 Markuss Broks      2022-08-06  297  	val = of_get_flat_dt_prop(offset, "current-speed", NULL);
31cb9a8575ca04 Eugeniy Paltsev    2017-08-21  298  	if (val)
31cb9a8575ca04 Eugeniy Paltsev    2017-08-21  299  		early_console_dev.baud = be32_to_cpu(*val);
31cb9a8575ca04 Eugeniy Paltsev    2017-08-21  300  
dedd7c138e9492 Markuss Broks      2022-08-06  301  	val = of_get_flat_dt_prop(offset, "clock-frequency", NULL);
814453adea7d08 Michal Simek       2018-04-10  302  	if (val)
814453adea7d08 Michal Simek       2018-04-10  303  		port->uartclk = be32_to_cpu(*val);
814453adea7d08 Michal Simek       2018-04-10  304  
4d118c9a866590 Peter Hurley       2016-01-16  305  	if (options) {
31cb9a8575ca04 Eugeniy Paltsev    2017-08-21  306  		early_console_dev.baud = simple_strtoul(options, NULL, 0);
4d118c9a866590 Peter Hurley       2016-01-16  307  		strlcpy(early_console_dev.options, options,
4d118c9a866590 Peter Hurley       2016-01-16  308  			sizeof(early_console_dev.options));
4d118c9a866590 Peter Hurley       2016-01-16  309  	}
05d961320ba624 Peter Hurley       2016-01-16  310  	earlycon_init(&early_console_dev, match->name);
4d118c9a866590 Peter Hurley       2016-01-16  311  	err = match->setup(&early_console_dev, options);
f28295cc8ce14b Hsin-Yi Wang       2020-09-15  312  	earlycon_print_info(&early_console_dev);
b0b6abd34c1b50 Rob Herring        2014-03-27  313  	if (err < 0)
b0b6abd34c1b50 Rob Herring        2014-03-27  314  		return err;
b0b6abd34c1b50 Rob Herring        2014-03-27  315  	if (!early_console_dev.con->write)
b0b6abd34c1b50 Rob Herring        2014-03-27  316  		return -ENODEV;
b0b6abd34c1b50 Rob Herring        2014-03-27  317  
b0b6abd34c1b50 Rob Herring        2014-03-27  318  
b0b6abd34c1b50 Rob Herring        2014-03-27  319  	register_console(early_console_dev.con);
b0b6abd34c1b50 Rob Herring        2014-03-27  320  	return 0;
b0b6abd34c1b50 Rob Herring        2014-03-27  321  }
8477614d9f7c5c Peter Hurley       2016-01-16  322
Rob Herring (Arm) Aug. 8, 2022, 3:55 p.m. UTC | #3
On Sat, Aug 6, 2022 at 10:34 AM Markuss Broks <markuss.broks@gmail.com> wrote:
>
> The "node" argument is actually an offset,

It's an offset to a node in the FDT. The fact that it is an offset is
an internal implementation detail of the FDT format. So really, it's a
handle to a node. 'node' is more descriptive to its purpose.

> and it's also an "int", and not "unsigned long".

Uh, no it's not. of_flat_dt_*() functions all take an unsigned long.

Rob
diff mbox series

Patch

diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index 57c70851f22a0e78805f34d1a7700708104b6f6a..bc210ae8173d97d5ef422468acf2755a853cb943 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -244,7 +244,7 @@  early_param("earlycon", param_setup_earlycon);
 #ifdef CONFIG_OF_EARLY_FLATTREE
 
 int __init of_setup_earlycon(const struct earlycon_id *match,
-			     unsigned long node,
+			     int offset,
 			     const char *options)
 {
 	int err;
@@ -255,25 +255,25 @@  int __init of_setup_earlycon(const struct earlycon_id *match,
 
 	spin_lock_init(&port->lock);
 	port->iotype = UPIO_MEM;
-	addr = of_flat_dt_translate_address(node);
+	addr = of_flat_dt_translate_address(offset);
 	if (addr == OF_BAD_ADDR) {
 		pr_warn("[%s] bad address\n", match->name);
 		return -ENXIO;
 	}
 	port->mapbase = addr;
 
-	val = of_get_flat_dt_prop(node, "reg-offset", NULL);
+	val = of_get_flat_dt_prop(offset, "reg-offset", NULL);
 	if (val)
 		port->mapbase += be32_to_cpu(*val);
 	port->membase = earlycon_map(port->mapbase, SZ_4K);
 
-	val = of_get_flat_dt_prop(node, "reg-shift", NULL);
+	val = of_get_flat_dt_prop(offset, "reg-shift", NULL);
 	if (val)
 		port->regshift = be32_to_cpu(*val);
-	big_endian = of_get_flat_dt_prop(node, "big-endian", NULL) != NULL ||
+	big_endian = of_get_flat_dt_prop(offset, "big-endian", NULL) != NULL ||
 		(IS_ENABLED(CONFIG_CPU_BIG_ENDIAN) &&
-		 of_get_flat_dt_prop(node, "native-endian", NULL) != NULL);
-	val = of_get_flat_dt_prop(node, "reg-io-width", NULL);
+		 of_get_flat_dt_prop(offset, "native-endian", NULL) != NULL);
+	val = of_get_flat_dt_prop(offset, "reg-io-width", NULL);
 	if (val) {
 		switch (be32_to_cpu(*val)) {
 		case 1:
@@ -291,11 +291,11 @@  int __init of_setup_earlycon(const struct earlycon_id *match,
 		}
 	}
 
-	val = of_get_flat_dt_prop(node, "current-speed", NULL);
+	val = of_get_flat_dt_prop(offset, "current-speed", NULL);
 	if (val)
 		early_console_dev.baud = be32_to_cpu(*val);
 
-	val = of_get_flat_dt_prop(node, "clock-frequency", NULL);
+	val = of_get_flat_dt_prop(offset, "clock-frequency", NULL);
 	if (val)
 		port->uartclk = be32_to_cpu(*val);