Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp108397lqj; Sat, 1 Jun 2024 09:53:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX3O5w+k8qNx6u2rxhlR0dWOSjsDK0KKM6sn/kQvpFJHd9vXigcuuAzprrM/AEt0ZF4RtGQuWsdPpTQZWoevT2/q4wGQi3bg/eSsvxmIw== X-Google-Smtp-Source: AGHT+IGqHgWBMVtZxROLJL9fOQjvsGcXawZvtizLGEzZIgGnbrB4tI5cDT4I9LV6+KXGcfzj74bU X-Received: by 2002:a05:6808:199c:b0:3c8:6551:8125 with SMTP id 5614622812f47-3d1e3475f9amr6257337b6e.6.1717260835548; Sat, 01 Jun 2024 09:53:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717260835; cv=pass; d=google.com; s=arc-20160816; b=LnovJxe0IoH+5axwujRiMkwCZjulqG7if8Rkx8yCjNXWqWhI63r0MB1a4sIutcVfLa qSu1pziAe2w3yQBtrUteH6nBQXyCAUPj65wCFR6IObeVgEk6iJu8av5YdUb0+LamtSW5 d7OqlSs35dWnwox7Em5AUCyTTpaoni2zyTfkCEp41/sswR7rV8bXvtWtH/ktsOCwFZev uId599AegML5iSaZhw+WQyS6yFmVhwz/3Jie9zpZKT1TOIiqhaZok5iOjKT/7PJb11MJ 41FEdlJOXE+VCcuApbXtChi0dP+kCxso0IAHwHz0frodwx/fQOvneAoCzchmsjlpwuIK t1IQ== 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=Zu2ELriqifa64vKYAW2lUJdtW26VDgmol875O/k7qgQ=; fh=gcJNzPovi9xBsOlK27IAPWqDhUbqbmsDbCqA17pW1wk=; b=LqZq8DYp8DvFWk6OqAhbOOC3nlHVdKJqJzX1RjkSQioaNlVL0WKfVbSWwMTS7XGYaU X4HlLM/WxDLicyFY8e5GYX1KweysypcrM/inwtf2BvLDnLFjOwx40McehNdKKmrP1usb THkAcMg044xBQXT+6ezw7ht3Z1FoCOLRhNBQYjsNGg164Bb6vRL+8BJ8PTWY1vXMnK0Y lCBLtgtXvx69u698cnSAgtpld858zHDY90rgYjKchA+LSw8jUgndvhVssmdGQPbn05D5 ret0Mn8HVw2Ts3U7zk+yUu9BnZeBBR3Fk99Wv3SASNrHBmgRzONDUVBNLbesRRDkjFPA +Ciw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=vGTgOKaq; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-197956-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-197956-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 6a1803df08f44-6ae4b43918fsi52082606d6.545.2024.06.01.09.53.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Jun 2024 09:53:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-197956-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=vGTgOKaq; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-197956-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-197956-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 438421C20F61 for ; Sat, 1 Jun 2024 16:53:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3A83F153565; Sat, 1 Jun 2024 16:53:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="vGTgOKaq" 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 58E3A54650; Sat, 1 Jun 2024 16:53:48 +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=1717260828; cv=none; b=FsnRMjzCaWKXkPMRmzLIQt/9IYrTqjcrC8Hsx4xqE5ZcJ2/FH+QXnCidd1XaIbwI80gryeBe0o7WiGN7EZ6V61UTBNSozaS8/UoD1b4mXl3+IHadJwL3lOWxcO6PjA2/EZfjCnEe2zjyLrEkZ6DvZlXaSFs+URQB6DAKVCkmEos= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717260828; c=relaxed/simple; bh=5+heAb7w9OghR5Rbj6S0QhipYZU0tDVGNTFIVXQlkWM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=jfgN2nWmfdGp8bKw89+6qJnntprAVd5/+4hUwT2+5DCeDfSoC45Kb+pF083ALkQgJZtWhv0ZmV9asnHaiD6Lgx1vT04ry8TVyyXiBE7KgEOCuoYLNcWKMJD+I6khCJrVvucJVEcXGuPdcI60We/BtL52JU7hAHSttj7BAfPBE30= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=vGTgOKaq; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 05DFBC116B1; Sat, 1 Jun 2024 16:53:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717260827; bh=5+heAb7w9OghR5Rbj6S0QhipYZU0tDVGNTFIVXQlkWM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=vGTgOKaqJtvaEtlvsYjd9Gnc4dwsk2TBsdU8/VmHb8BsT1AaWldaFA1f5FP3Cc6ae uQRdCguUXjbn9i77mqk2sXPY8RxZSJQ9uM822PZ8zppCb0eb6oQvKbHYQD1FW99mH+ B47BVCpLXtQSQZ+3DCvrVaf/Gx86wMWdMjUv24tXeteD+BqqOWpwZCYu6TqBO6Q0nV EBSCnmzqBdtHGyta1pCSZ6x0DIT8otTpbvkeW+QK2zs/sKyBSdZwn094QkewV2A1fT Ys++UlyR5kDBvIDowL6+gOUwQIh+ClYJ7d6K+1MQsygRLBxWfMAYF8m+WW7IikjFeV nz2LLaTStturw== Date: Sat, 1 Jun 2024 17:53:42 +0100 From: Simon Horman To: Thorsten Blum Cc: Nicolas Pitre , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Breno Leitao , Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= , John Paul Adrian Glaubitz , Andrew Lunn , Arnd Bergmann , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net-next v2] net: smc91x: Refactor SMC_* macros Message-ID: <20240601165342.GS491852@kernel.org> References: <20240531120103.565490-2-thorsten.blum@toblux.com> 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: <20240531120103.565490-2-thorsten.blum@toblux.com> On Fri, May 31, 2024 at 02:01:04PM +0200, Thorsten Blum wrote: > Use the macro parameter lp directly instead of relying on ioaddr being > defined in the surrounding scope. > > The macros SMC_CURRENT_BANK(), SMC_SELECT_BANK(), SMC_GET_BASE(), and > SMC_GET_REV() take an additional parameter ioaddr to use a different > address if necessary (e.g., as in smc_probe()). > > Relying on implicitly defined variable names in C macros is generally > considered bad practice and can be avoided by using explicit parameters. > > Compile-tested only. > > Suggested-by: Andrew Lunn > Signed-off-by: Thorsten Blum > --- > Changes in v2: > - Add macro parameter ioaddr where necessary to fix smc_probe() after > feedback from Jakub Kicinski > - Update patch description > - Link to v1: https://lore.kernel.org/linux-kernel/20240528104421.399885-3-thorsten.blum@toblux.com/ > --- > drivers/net/ethernet/smsc/smc91x.c | 132 +++++++++++-------------- > drivers/net/ethernet/smsc/smc91x.h | 152 ++++++++++++++--------------- > 2 files changed, 131 insertions(+), 153 deletions(-) Hi Thorsten, This is a large and repetitive patch, which makes it hard to spot any errors (I couldn't see any :) I'm not sure if it is worth doing at this point, but it might have been worth splitting the patch up, f.e. by addressing one MACRO at a time, removing local ioaddr variables as they become unused. As highlighted bellow, checkpatch flags a lot of issues with the code updated by this patch. Perhaps they could be addressed as the lines with issues are updated. Or by patch(es) before those that make the changes made by this patch. Or some combination of the two. ... > diff --git a/drivers/net/ethernet/smsc/smc91x.h b/drivers/net/ethernet/smsc/smc91x.h ... > @@ -839,64 +839,64 @@ static const char * chip_ids[ 16 ] = { > #define SMC_MUST_ALIGN_WRITE(lp) SMC_32BIT(lp) > > #define SMC_GET_PN(lp) \ > - (SMC_8BIT(lp) ? (SMC_inb(ioaddr, PN_REG(lp))) \ > - : (SMC_inw(ioaddr, PN_REG(lp)) & 0xFF)) > + (SMC_8BIT(lp) ? (SMC_inb(lp->base, PN_REG(lp))) \ > + : (SMC_inw(lp->base, PN_REG(lp)) & 0xFF)) > > #define SMC_SET_PN(lp, x) \ > do { \ > if (SMC_MUST_ALIGN_WRITE(lp)) \ > - SMC_outl((x)<<16, ioaddr, SMC_REG(lp, 0, 2)); \ > + SMC_outl((x)<<16, lp->base, SMC_REG(lp, 0, 2)); \ While we are here, I think we can address the whitespace issues flagged by checkpatch - there should be spaces around '<<'. Likewise elsewhere. ... > -#define SMC_CURRENT_BANK(lp) SMC_inw(ioaddr, BANK_SELECT) > +#define SMC_CURRENT_BANK(lp, ioaddr) SMC_inw(ioaddr, BANK_SELECT) lp is not used in this macro, can it be removed? Possibly as a follow-up? Flagged by checkpatch. > > -#define SMC_SELECT_BANK(lp, x) \ > +#define SMC_SELECT_BANK(lp, x, ioaddr) \ > do { \ > if (SMC_MUST_ALIGN_WRITE(lp)) \ > SMC_outl((x)<<16, ioaddr, 12< @@ -904,125 +904,125 @@ static const char * chip_ids[ 16 ] = { > SMC_outw(lp, x, ioaddr, BANK_SELECT); \ > } while (0) > > -#define SMC_GET_BASE(lp) SMC_inw(ioaddr, BASE_REG(lp)) > +#define SMC_GET_BASE(lp, ioaddr) SMC_inw(ioaddr, BASE_REG(lp)) > > -#define SMC_SET_BASE(lp, x) SMC_outw(lp, x, ioaddr, BASE_REG(lp)) > +#define SMC_SET_BASE(lp, x) SMC_outw(lp, x, lp->base, BASE_REG(lp)) lp is now evaluated twice in this macro. As the motivation of this patch seems to be about good practice, perhaps we should avoid introducing a bad one? Likewise in several other macros. Flagged by checkpatch. ... > -#define SMC_GET_CTL(lp) SMC_inw(ioaddr, CTL_REG(lp)) > +#define SMC_GET_CTL(lp) SMC_inw(lp->base, CTL_REG(lp)) I don't think this is introduced by this patch, but perhaps it could be addressed. Checkpatch says: Macro argument 'lp' may be better as '(lp)' to avoid precedence issues Likewise elsewhere. ...