Received: by 2002:ab2:7407:0:b0:1f4:b336:87c4 with SMTP id e7csp234412lqn; Thu, 11 Apr 2024 22:27:00 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUgW6Dghy+XumP0mWcQwBBgYfAfYXv4Mc5pUBeOEmdTE4gNfeBE1EH2gHKVPm4Km4Edscfk7BaHyftvEatik5GI4HKOor77GIbHuuNB+w== X-Google-Smtp-Source: AGHT+IFdEImQxjSXjF2kLGaV2t3C0b8ylIMO9cll8r/l/uG1ZUywBapBVRqWTz8LNAO1zJrB7dW5 X-Received: by 2002:a50:8d5e:0:b0:567:e0e:dda5 with SMTP id t30-20020a508d5e000000b005670e0edda5mr1365475edt.17.1712899620754; Thu, 11 Apr 2024 22:27:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712899620; cv=pass; d=google.com; s=arc-20160816; b=uYR7FyUPw5BEPU7KbEsZILwawEbIiT098lhol8c78u+R8PnNhcrVyybcI1pwEL/IZi 80no6HjLlAvMVbRXHKJ8dYsT4YSVPTe+/+B4stbgrEXbBAjWCgGgryPu6f3w3Z+A6xYl rwYsTyGeiDAEEN9FOLEzzU2u+8lSDPqoRtGtyVkDAO9iyl3sEDmg7V1DxeY7GVKNTJ1W FJh6PLiFisir555QFDGLBFkP1LVt/7ty5hbgeStOuLcrz00DJO2q81riBRjd4/PgnNMo vAWonjpGHT+8GqVBPXLM51bnFIbzdCaB2aRS69CjOK1rRCw/w/ROqirPvvunXQU1HKKE W46Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=5KTndT1NnupxjhpxphqRuMEwROwNhONoDhrHl2uIh3c=; fh=mehENiMxpY3hOzKd5ODE/hNQNjXofB5S1cM3GfomyCA=; b=MMXW0+rtvPo2FnRdan0afXMkDB/cIq6A/ho9y9x3R05wKjYXdlJgo1bC6a04hOEDzs zR+Sqz512mfUjv7ClVM32QAwkf6uPGTiXImYoY3d7KSw/8H91lsQDLOfr9bTKvRPCZX/ +JcA/fT+hsxpdL9xHYb2SCTSjEt65vsvXtxZNbOUpiOmGNMy7jDnwODwpYSDMQy0IpSA iMPaMeEriyjlk3IVv5D6AJVLkybB6E/RFUzfiluXNEsxG8Q+kwlDj+0miGr0cov+/fko x891n0P5A5WDbTpirHeZbLVNGgDzQ35QL6yW1+tm8M7v+bCf1ZNU5EERosxtU2I0ZSp1 3nEA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=N5w9h6zK; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-141978-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-141978-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id g12-20020a0564021ecc00b0057000ee9f9dsi63599edg.54.2024.04.11.22.27.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 22:27:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-141978-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=N5w9h6zK; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-141978-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-141978-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 7BBBC1F22B82 for ; Fri, 12 Apr 2024 05:27:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AC4F51B95B; Fri, 12 Apr 2024 05:26:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="N5w9h6zK" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D21878C13; Fri, 12 Apr 2024 05:26:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712899612; cv=none; b=qW23aO07sFNU7pK1+PQHYMjG+GEx3uiBUDCWh/i3unZEfX6mb91gGpRwzc/BPkA/EAdoSYw8eWfApF2wrDI9ymTg8G3atdisXT2xmJ5jNaOn5AHY2GgE2mgeXUFV7+vMnMtbwew0Un1DMdMxnUlLx9Y3w8BWZ2TLTh7tmvh5qcM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712899612; c=relaxed/simple; bh=x71PJqK49LwuCjl9CvP6DX6KHdBlBM5DQb98t1OTDOc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=N35w3AaZ/wSsRJMbX79gMMZdQMkDmKyA/gIt2jVWqPaF2uaIFdgI5Oa4xkAOxQPXOqDS77aXWlDdIE1b6cf2PE2NTD+wGN6cwnPk/uQKuSzzrdtAfJcaxOw2zhgjO1cw7Se9wF4Qo/AK3dEll/VQT6X9k641U3NC0uXqliTRyM0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=N5w9h6zK; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id DAE8CC2BBFC; Fri, 12 Apr 2024 05:26:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1712899612; bh=x71PJqK49LwuCjl9CvP6DX6KHdBlBM5DQb98t1OTDOc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=N5w9h6zKeKatlQlfgqtYDpbeOdqzpSRYTHo92ZZgaJu8IvfvnOMl5blm/j1XoKmTQ OMDTEuWf6po62x+FWyvJCKW7cHWCOw+0jl9Fw+20tG071H0Zc626EvYe+h73XrfFl8 UleWX2/QZLS/trJVLEVnXao9jOT2/a2MROG3YMlY= Date: Fri, 12 Apr 2024 07:26:49 +0200 From: Greg Kroah-Hartman To: parker@finest.io Cc: Jiri Slaby , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, Parker Newman Subject: Re: [PATCH v2 2/7] serial: exar: add support for reading from Exar EEPROM Message-ID: <2024041247-clamor-bottom-ae36@gregkh> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Thu, Apr 11, 2024 at 04:25:40PM -0400, parker@finest.io wrote: > From: Parker Newman > > - Adds support for reading a word from the Exar EEPROM. > - Adds exar_write_reg/exar_read_reg for reading and writing to the UART's > config registers. First off, thanks for splitting this up, looks much better. Some minor nits here: > > Signed-off-by: Parker Newman > --- > drivers/tty/serial/8250/8250_exar.c | 110 ++++++++++++++++++++++++++++ > 1 file changed, 110 insertions(+) > > diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c > index 4d1e07343d0b..49d690344e65 100644 > --- a/drivers/tty/serial/8250/8250_exar.c > +++ b/drivers/tty/serial/8250/8250_exar.c > @@ -128,6 +128,16 @@ > #define UART_EXAR_DLD 0x02 /* Divisor Fractional */ > #define UART_EXAR_DLD_485_POLARITY 0x80 /* RS-485 Enable Signal Polarity */ > > +/* EEPROM registers */ > +#define UART_EXAR_REGB 0x8e > +#define UART_EXAR_REGB_EECK BIT(4) > +#define UART_EXAR_REGB_EECS BIT(5) > +#define UART_EXAR_REGB_EEDI BIT(6) > +#define UART_EXAR_REGB_EEDO BIT(7) > +#define UART_EXAR_REGB_EE_ADDR_SIZE 6 > +#define UART_EXAR_REGB_EE_DATA_SIZE 16 Use tabs after the define name and before the value? > + > + > /* > * IOT2040 MPIO wiring semantics: > * > @@ -195,6 +205,106 @@ struct exar8250 { > int line[]; > }; > > +static inline void exar_write_reg(struct exar8250 *priv, > + unsigned int reg, uint8_t value) > +{ > + if (!priv || !priv->virt) > + return; > + > + writeb(value, priv->virt + reg); > +} > + > +static inline uint8_t exar_read_reg(struct exar8250 *priv, unsigned int reg) > +{ > + if (!priv || !priv->virt) > + return 0; How can either of these ever happen? You control when this is called, right? So just make sure that isn't an issue. > + > + return readb(priv->virt + reg); > +} > + > +static inline void exar_ee_select(struct exar8250 *priv, bool enable) > +{ > + uint8_t value = 0x00; This is the kernel, please use kernel types, not userspace types (i.e. u8 not uint8_t). Yes, there are lots of places in the kernel that have userspace types, but let's not add to the mess please. > + > + if (enable) > + value |= UART_EXAR_REGB_EECS; > + > + exar_write_reg(priv, UART_EXAR_REGB, value); > + udelay(2); Why wait this amount of time? A comment would be nice. Why not just do a read to ensure the write happened instead? > +} > + > +static inline void exar_ee_write_bit(struct exar8250 *priv, int bit) > +{ > + uint8_t value = UART_EXAR_REGB_EECS; Same comment about the type, here and everywhere else. > + > + if (bit) > + value |= UART_EXAR_REGB_EEDI; > + > + //Clock out the bit on the i2c interface Comments using // are fine, but please put a space after the "//" to make them readable > + exar_write_reg(priv, UART_EXAR_REGB, value); > + udelay(2); Same commment about the time value, here and everywhere else. Why slow things down if you don't have to? thanks, greg k-h