Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp336086pxm; Wed, 2 Mar 2022 16:42:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJwv1MVAr3Mr+QHR4IPAxyNdKbdJ5RsOF0R7nZlfF6+ErCvbOQ5HNTC+8EsbgP3ub83kGnVK X-Received: by 2002:a65:6d0a:0:b0:373:9242:3a13 with SMTP id bf10-20020a656d0a000000b0037392423a13mr28552751pgb.452.1646268122630; Wed, 02 Mar 2022 16:42:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646268122; cv=none; d=google.com; s=arc-20160816; b=M1gcwLBtaVLLckS+Ewx3HexqMxR7Exa4vkSHCREVxhoNSheNWuNcU14TL5VZgWI47V q+ax+88zClq9liAG0hHMpBtOSTwdwHFLGy+azaoF4s3r7KCu5kfUnBUffEXob3bBYVVl I0lChBTV/jbrRyp3wO+h7taPO4bbRk4ZOdytmFG9MTZQqAmZhuegrZSpVjwQPejV6tNh ZTpI1a/vki/bcvn9ny/Xjavhi27Ga/yHuhNxQ8kSJumJAX6+tKQ1/zNwH9DsJvG2+PMP Lor/+r2fO4TEPwL+RawR2OPzbviP0NPTnU2cB4bw+1XmzCG8+7priMFkjSma8CuFr4DR JclA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:accept-language:in-reply-to:references:message-id:date :thread-index:thread-topic:subject:cc:to:from; bh=224A4KiqBu8ZmMkCFZiz4xzi5aXf1dSH/zSnxhi+EGw=; b=TCA0EU7N5Qg2fk4KXnEJu158SxJdfKkkJUGT6I6umXsCtCSkhAk74PHfa+wUy3LAO0 Nbf1vuYEdYO0zn5wl87i0vBYjFdNz2IBlMUmktyoanAtHf7mUFuxAqAnDz3zVxhxf1IR dVnX66dl2VqgWdk5jbbmz9PcfxHosPc/ukCGYr9kFImulrXt0ds5EhT7fe28iIguffli 0lC9aiOafCGCa/xC8GJhimYuHf/dX/bNPn9W+gjDLYB4Qy7hYw0aGf+NTrP8hCiNhAGx x7mp6ppVfWKWhWq8vv7ATAJD22lmufZVuu8UPSmMoa7ByI6FNzjCwaYkq9PFdFFjhoh5 JeaA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id c34-20020a631c22000000b0036c238deae9si563692pgc.383.2022.03.02.16.42.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Mar 2022 16:42:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 17669580E5; Wed, 2 Mar 2022 15:58:01 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229836AbiCBX6g convert rfc822-to-8bit (ORCPT + 99 others); Wed, 2 Mar 2022 18:58:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229796AbiCBX6e (ORCPT ); Wed, 2 Mar 2022 18:58:34 -0500 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.85.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C7DD0659D for ; Wed, 2 Mar 2022 15:57:49 -0800 (PST) Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-214-E8EQuzy4Px6_ZuHM3Sq0SA-1; Wed, 02 Mar 2022 23:57:46 +0000 X-MC-Unique: E8EQuzy4Px6_ZuHM3Sq0SA-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) by AcuMS.aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) with Microsoft SMTP Server (TLS) id 15.0.1497.28; Wed, 2 Mar 2022 23:57:44 +0000 Received: from AcuMS.Aculab.com ([fe80::994c:f5c2:35d6:9b65]) by AcuMS.aculab.com ([fe80::994c:f5c2:35d6:9b65%12]) with mapi id 15.00.1497.028; Wed, 2 Mar 2022 23:57:44 +0000 From: David Laight To: =?iso-8859-1?Q?=27Uwe_Kleine-K=F6nig=27?= , Jiri Slaby CC: "gregkh@linuxfoundation.org" , "Alexandre Belloni" , Mateusz Holenko , Neil Armstrong , "Benjamin Herrenschmidt" , Liviu Dudau , Baruch Siach , "linux-kernel@vger.kernel.org" , Paul Cercueil , "Paul Mackerras" , Michael Ellerman , "Michal Simek" , Karol Gugala , Jerome Brunet , Peter Korsgaard , Florian Fainelli , "Alexander Shiyan" , Krzysztof Kozlowski , Alexandre Torgue , Fabio Estevam , "Russell King" , Ludovic Desroches , Andy Gross , "bcm-kernel-feedback-list@broadcom.com" , NXP Linux Team , "linux-serial@vger.kernel.org" , Vineet Gupta , Orson Zhai , Tobias Klauser , Patrice Chotard , "Albert Ou" , Maxime Coquelin , Manivannan Sadhasivam , Martin Blumenstingl , Sascha Hauer , Takao Orito , Vladimir Zapolskiy , Lorenzo Pieralisi , Paul Walmsley , Bjorn Andersson , Sudeep Holla , Richard Genoud , Chunyan Zhang , "Nicolas Ferre" , "David S. Miller" , Taichi Sugaya , "Palmer Dabbelt" , Pengutronix Kernel Team , Kevin Hilman , Baolin Wang , Shawn Guo , =?iso-8859-1?Q?Andreas_F=E4rber?= , "Maciej W. Rozycki" Subject: RE: [PATCH v3] serial: make uart_console_write->putchar()'s character an unsigned char Thread-Topic: [PATCH v3] serial: make uart_console_write->putchar()'s character an unsigned char Thread-Index: AQHYLl5tVpWrjMz0S0GPyaCV/1nc9aysw9yA Date: Wed, 2 Mar 2022 23:57:44 +0000 Message-ID: <5c7045c1910143e08ced432d938b5825@AcuMS.aculab.com> References: <20220302072732.1916-1-jslaby@suse.cz> <20220302175242.ejiaf36vszr4xvou@pengutronix.de> In-Reply-To: <20220302175242.ejiaf36vszr4xvou@pengutronix.de> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=C51A453 smtp.mailfrom=david.laight@aculab.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 From: Uwe Kleine-König > Sent: 02 March 2022 17:53 > > On Wed, Mar 02, 2022 at 08:27:32AM +0100, Jiri Slaby wrote: > > Currently, uart_console_write->putchar's second parameter (the > > character) is of type int. It makes little sense, provided uart_console_write() > > accepts the input string as "const char *s" and passes its content -- the > > characters -- to putchar(). So switch the character's type to unsigned > > char. > > > > We don't use char as that is signed on some platforms. That would cause > > troubles for drivers which (implicitly) cast the char to u16 when > > writing to the device. Sign extension would happen in that case and the > > value written would be completely different to the provided char. DZ is > > an example of such a driver -- on MIPS, it uses u16 for dz_out in > > dz_console_putchar(). > > I always thought this was bigger than 8bit for hardware that supports > wider characters. But if that's the case that's completely unsupported, > there isn't even CS9. The real problem is that using char (or short) for a function parameter or result is very likely to require the compile add code to mask the value to 8 (or 16) bits. Remember that almost every time you do anything with a signed or unsigned char/short variable the compiler has to use the integer promotion rules to convert the value to int. You'll almost certainly get better code if the value is left in an int (or unsigned int) variable until the low 8 bits get written to a buffer (or hardware register). David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)