From patchwork Fri Oct 28 13:23:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jason A. Donenfeld" X-Patchwork-Id: 12270 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp835172wru; Fri, 28 Oct 2022 06:35:41 -0700 (PDT) X-Google-Smtp-Source: AMsMyM40NTXMky6RHMo+VjdKx7l1CwVX0eByfI/d2YqyOOp0ly44UtWdo2UnRU5XGjefJQW8l9Di X-Received: by 2002:a17:907:272a:b0:791:994d:fb6a with SMTP id d10-20020a170907272a00b00791994dfb6amr47626148ejl.337.1666964141523; Fri, 28 Oct 2022 06:35:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666964141; cv=none; d=google.com; s=arc-20160816; b=bN5twMhKEZ2hC96+gVE3jOkl0a3QBqSEThUQtj7TMzyRPIogKwD/3qUSqwfaQ1+PKw WKTPBB3xTrLyHhNdr6ftp0Y8LJLwoKrNJ6yuLtNrbXlTSTenaBY59IedgXuULqO6aR1L AAIHHaNRIm0gaN+8M2yJeY+vNEhZt5yrFpZ29ha3axOCjQZV+76XJkB9K8Nv4elhYCym tsVe+zjsZrtbVg/RbHIfPmLCO5dq9dL0G5VzqQmTX6GqxAfAmWkWTETUv3ljzmZCpuVo P3xHEefUCgBOP+omhVG1k1Jxcw4GVQwScIOinD6dC2j7itWCWOQQxinIY034G2/kIO7z arcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=3V/khMusm/hSqNmRbev9Tdtgp+q6rmjc1eRz5Ap8HSo=; b=VUYvxrHZhoxI62ixal1eMixCS/MaBXAsN0Nb85E/ahWfKIylNwgarbLUeSU837rlwo EhqldjYm9kxuD07PknFRj/L0LH8e+9iVD3jiEa1Mz8/3763eKMxrypP2MqlnF1vNQPVf S0XcTArcRm1WHUqC2aySEVhak7FIlkaLFvdnaXSb/Dy0+048j5GC9MMG4rm8AS9W8SVU ZkR3vTq8mXf5CQeV5kbIBbAKXMPhR8cnXQds3/0zG4lJFzYF7EcHfli+g/dY52Mr4x3j RhsvbpeM11Bsq4T02R7ctRe9a6SzCUgpCZPzbNmw/cuFtlkVxpPCX6qckHlYsctDjU3H tb4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b=D3aSOOA2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=zx2c4.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k13-20020a50c8cd000000b0045d4015cdcesi4521396edh.51.2022.10.28.06.35.17; Fri, 28 Oct 2022 06:35:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b=D3aSOOA2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=zx2c4.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230409AbiJ1NYG (ORCPT + 99 others); Fri, 28 Oct 2022 09:24:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230478AbiJ1NYB (ORCPT ); Fri, 28 Oct 2022 09:24:01 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 270FD1D3749; Fri, 28 Oct 2022 06:24:00 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id CFE31B829BA; Fri, 28 Oct 2022 13:23:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B1B05C433D6; Fri, 28 Oct 2022 13:23:56 +0000 (UTC) Authentication-Results: smtp.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="D3aSOOA2" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1666963433; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=3V/khMusm/hSqNmRbev9Tdtgp+q6rmjc1eRz5Ap8HSo=; b=D3aSOOA2v7cfEEDLORURmLWXY4m5LmYosFqMZBrUYO7/8BIIVyMaQpFofGfS6PbAGGghEM N1mnlGqOeYY22ijnyYwhQ3n/qUuXvRCLGCptqU6tkIPskhVdyfwl5etql2JDZZmwhGpqmJ wsQLLdbonz62yIm0k0VQf0ULxaVlkW0= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id ae7675f7 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Fri, 28 Oct 2022 13:23:53 +0000 (UTC) From: "Jason A. Donenfeld" To: linux-mips@vger.kernel.org, tsbogend@alpha.franken.de, linux-kernel@vger.kernel.org Cc: "Jason A. Donenfeld" Subject: [PATCH] MIPS: pic32: treat port as signed integer Date: Fri, 28 Oct 2022 15:23:44 +0200 Message-Id: <20221028132344.1993934-1-Jason@zx2c4.com> MIME-Version: 1.0 X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747938591398967919?= X-GMAIL-MSGID: =?utf-8?q?1747938591398967919?= get_port_from_cmdline() returns an int, yet is assigned to a char, which is wrong in its own right, but also, with char becoming unsigned, this poses problems, because -1 is used as an error value. Further complicating things, fw_init_early_console() is only ever called with a -1 argument. Fix this up by removing the unused argument from fw_init_early_console() and treating port as a proper signed integer. Cc: Thomas Bogendoerfer Signed-off-by: Jason A. Donenfeld --- Thomas - this is part of the -funsigned-char work I've been accumulating in my unsigned-char branch. If you want to take this as a fix for 6.1, go ahead. Otherwise, Linus asked me to keep the 6.2 unsigned-char patches together in my branch, so I'll take this, pending your Ack. -Jason arch/mips/include/asm/fw/fw.h | 2 +- arch/mips/pic32/pic32mzda/early_console.c | 13 ++++++------- arch/mips/pic32/pic32mzda/init.c | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/arch/mips/include/asm/fw/fw.h b/arch/mips/include/asm/fw/fw.h index d0ef8b4892bb..d0494ce4b337 100644 --- a/arch/mips/include/asm/fw/fw.h +++ b/arch/mips/include/asm/fw/fw.h @@ -26,6 +26,6 @@ extern char *fw_getcmdline(void); extern void fw_meminit(void); extern char *fw_getenv(char *name); extern unsigned long fw_getenvl(char *name); -extern void fw_init_early_console(char port); +extern void fw_init_early_console(void); #endif /* __ASM_FW_H_ */ diff --git a/arch/mips/pic32/pic32mzda/early_console.c b/arch/mips/pic32/pic32mzda/early_console.c index 25372e62783b..3cd1b408fa1c 100644 --- a/arch/mips/pic32/pic32mzda/early_console.c +++ b/arch/mips/pic32/pic32mzda/early_console.c @@ -27,7 +27,7 @@ #define U_BRG(x) (UART_BASE(x) + 0x40) static void __iomem *uart_base; -static char console_port = -1; +static int console_port = -1; static int __init configure_uart_pins(int port) { @@ -47,7 +47,7 @@ static int __init configure_uart_pins(int port) return 0; } -static void __init configure_uart(char port, int baud) +static void __init configure_uart(int port, int baud) { u32 pbclk; @@ -60,7 +60,7 @@ static void __init configure_uart(char port, int baud) uart_base + PIC32_SET(U_STA(port))); } -static void __init setup_early_console(char port, int baud) +static void __init setup_early_console(int port, int baud) { if (configure_uart_pins(port)) return; @@ -130,16 +130,15 @@ static int __init get_baud_from_cmdline(char *arch_cmdline) return baud; } -void __init fw_init_early_console(char port) +void __init fw_init_early_console(void) { char *arch_cmdline = pic32_getcmdline(); - int baud = -1; + int baud, port; uart_base = ioremap(PIC32_BASE_UART, 0xc00); baud = get_baud_from_cmdline(arch_cmdline); - if (port == -1) - port = get_port_from_cmdline(arch_cmdline); + port = get_port_from_cmdline(arch_cmdline); if (port == -1) port = EARLY_CONSOLE_PORT; diff --git a/arch/mips/pic32/pic32mzda/init.c b/arch/mips/pic32/pic32mzda/init.c index 08c46cf122d7..53b227a9074c 100644 --- a/arch/mips/pic32/pic32mzda/init.c +++ b/arch/mips/pic32/pic32mzda/init.c @@ -47,7 +47,7 @@ void __init plat_mem_setup(void) strscpy(arcs_cmdline, boot_command_line, COMMAND_LINE_SIZE); #ifdef CONFIG_EARLY_PRINTK - fw_init_early_console(-1); + fw_init_early_console(); #endif pic32_config_init(); }