Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp140162rdg; Thu, 12 Oct 2023 00:51:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEKhVmYpRM5SmBbunhNa+wbac0zSHEBeDHw+jMCIgmcAIPLnGSWm8oYRoMht0nuNMFc9r32 X-Received: by 2002:a05:6a00:cc1:b0:68b:bf33:2957 with SMTP id b1-20020a056a000cc100b0068bbf332957mr23155854pfv.22.1697097119654; Thu, 12 Oct 2023 00:51:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697097119; cv=none; d=google.com; s=arc-20160816; b=HBxctuNr2k6y876bS2FpCS/svbK2CBmP6SEqdBAqHD9d7bcAJ6RjiY/TDa2DZcs2bU eIGJyCGqAAtYOMNyldOoCPY4rJkYo2GdPvDM/ea5C2PSSaBf8khCRnHA9ED38GNIsSoG eWnQ6voqgIqnRwD3jY2lE7MTfdqRQlrFXQXpMEqihG78rmWm6HUKHYsw37z7EoMvOBB4 Hx7dvMUQibGUXssurMCzzl/CDf5d8mhRxYjPcWX1bzsxnu32eQG9f6+BeNRSBZ8Lc6BX eeGZ9Pqy1USUofmaNWNgomPTOOM05vYaYO1FFd8DYtJhGbd7HJyIUOYxsJCWojTU8YWD +t4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=Es7QN2GEuzhlQdl0k2scO4nnsg4P8+3YcCL5L8h6RlA=; fh=qztBtHCdI9rJg2ZFkb8k6K8YgAOM3MnuxCjF15+7skM=; b=osK9No4/RlRpuQWGFz7NMZ54zJlyMf8lUYNuZZG6IxqZ/81eMyGlat8Ictz7LIY2vh c8W1y7prf3OG9nscjSfzhTUO17C9hlJzsIPINJ/rZZozt80dwsjxuuNZI4etLo1LBaHE 9SJGXwtLtMjHv+vfAVUKFYEehAhTuSiLOJfHRpvLOdye3bNrjzqQlqJXGyIo3B1hwvfx NT3urSyeCFQpGVdkEvt6v59ZiN2cRYBdxZR7G5no7+b/Ecpi7xfrKt2F9uNypRBraxrl FUKQVgdIIXNvABjwF8pbpidqv20damzfhHdK4yi8IysdO7q03i8Sze3COggg5yoOzY7e PgWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=UGcSCDh2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id fj33-20020a056a003a2100b006910070695fsi13991805pfb.31.2023.10.12.00.51.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 00:51:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=UGcSCDh2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id CAC198115457; Thu, 12 Oct 2023 00:51:56 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347085AbjJLHvc (ORCPT + 99 others); Thu, 12 Oct 2023 03:51:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343708AbjJLHvb (ORCPT ); Thu, 12 Oct 2023 03:51:31 -0400 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 944A7C0 for ; Thu, 12 Oct 2023 00:51:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=Es7QN2GEuzhlQdl0k2scO4nnsg4P8+3YcCL5L8h6RlA=; b=UGcSCDh23Bz2f36LsEoJPPGkcVvqGmN678hSB70f31nwLBZmObbvWSv1 tcpWdZ6m6/un2kLdQLhD3OgAJF9WSxUM4uI+JZ0U8/IvLMae3CTqKCKjE iYHAu3SzTvS75yUa+7q8QGmgKnr3TNSkwg+7L6EizcRYgFKkgsNV+zqbe k=; Authentication-Results: mail3-relais-sop.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=julia.lawall@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="6.03,218,1694728800"; d="scan'208";a="68479733" Received: from dt-lawall.paris.inria.fr ([128.93.67.65]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Oct 2023 09:51:27 +0200 Date: Thu, 12 Oct 2023 09:51:27 +0200 (CEST) From: Julia Lawall To: Soumya Negi cc: Dan Carpenter , Greg Kroah-Hartman , Micky Ching , outreachy@lists.linux.dev, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH] staging: rts5208: Parenthesize macro arguments In-Reply-To: <20231012074837.GE16374@Negi> Message-ID: References: <20231012050240.20378-1-soumya.negi97@gmail.com> <81d6e283-fd87-4fd6-964f-22cbf420cdaa@kadam.mountain> <20231012074837.GE16374@Negi> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Thu, 12 Oct 2023 00:51:57 -0700 (PDT) On Thu, 12 Oct 2023, Soumya Negi wrote: > Hi Dan, > > On Thu, Oct 12, 2023 at 09:33:07AM +0300, Dan Carpenter wrote: > > On Wed, Oct 11, 2023 at 10:02:40PM -0700, Soumya Negi wrote: > > > Use parenthesis with macro arguments to avoid possible precedence > ... > > > */ > > > #define rtsx_writel(chip, reg, value) \ > > > - iowrite32(value, (chip)->rtsx->remap_addr + reg) > > > + iowrite32(value, (chip)->rtsx->remap_addr + (reg)) > > > > These would be better as functions instead of defines. > > There are actually more macros in the code. Should all of > them be redefined as functions? The original code looks like this: You should make a static inline function if you can. That would require that the parameter types are the same at all call sites and that all of the arguments are used as values, not eg as the left side of an assignment (looks fine here). > > /* > * macros for easy use > */ > #define rtsx_writel(chip, reg, value) \ > iowrite32(value, (chip)->rtsx->remap_addr + reg) > #define rtsx_readl(chip, reg) \ > ioread32((chip)->rtsx->remap_addr + reg) > #define rtsx_writew(chip, reg, value) \ > iowrite16(value, (chip)->rtsx->remap_addr + reg) > #define rtsx_readw(chip, reg) \ > ioread16((chip)->rtsx->remap_addr + reg) > #define rtsx_writeb(chip, reg, value) \ > iowrite8(value, (chip)->rtsx->remap_addr + reg) > #define rtsx_readb(chip, reg) \ > ioread8((chip)->rtsx->remap_addr + reg) > > #define rtsx_read_config_byte(chip, where, val) \ > pci_read_config_byte((chip)->rtsx->pci, where, val) > > #define rtsx_write_config_byte(chip, where, val) \ > pci_write_config_byte((chip)->rtsx->pci, where, val) > > #define wait_timeout_x(task_state, msecs) \ > do { \ > set_current_state((task_state)); \ > schedule_timeout((msecs) * HZ / 1000); \ > } while (0) > #define wait_timeout(msecs) wait_timeout_x(TASK_INTERRUPTIBLE, (msecs)) > > > > pci_read_config_byte((chip)->rtsx->pci, where, val) > > > @@ -131,8 +131,8 @@ static inline struct rtsx_dev *host_to_rtsx(struct Scsi_Host *host) > > > * The scsi_lock() and scsi_unlock() macros protect the sm_state and the > > > * single queue element srb for write access > > > */ > > > -#define scsi_unlock(host) spin_unlock_irq(host->host_lock) > > > -#define scsi_lock(host) spin_lock_irq(host->host_lock) > > > +#define scsi_unlock(host) spin_unlock_irq((host)->host_lock) > > > +#define scsi_lock(host) spin_lock_irq((host)->host_lock) > > > > For these ones, the name is too generic. probably the right thing is > > to just get rid of them completely and call spin_lock/unlock_irq() > > directly. > > I understand that there should be 2 different patches, one for the > macro-to-function rewrites & one for replacing the scsi lock/unlock macros with > direct spinlock calls. But, should these be in a patchset(they are vaguely > related since the patches together would get rid of the checkpatch warnings)? > I'm not sure. Patch set, since they affect the same file. Otherwise, Greg doesn't know in what order to apply them. julia