From: Soumya Negi <soumya.negi97@gmail.com>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Micky Ching <micky_ching@realsil.com.cn>,
outreachy@lists.linux.dev, linux-staging@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: rts5208: Parenthesize macro arguments
Date: Thu, 12 Oct 2023 00:48:38 -0700 [thread overview]
Message-ID: <20231012074837.GE16374@Negi> (raw)
In-Reply-To: <81d6e283-fd87-4fd6-964f-22cbf420cdaa@kadam.mountain>
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:
/*
* 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.
Thanks,
Soumya
> regards,
> dan carpenter
>
next prev parent reply other threads:[~2023-10-12 7:48 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-12 5:02 [PATCH] staging: rts5208: Parenthesize macro arguments Soumya Negi
2023-10-12 6:33 ` Dan Carpenter
2023-10-12 7:48 ` Soumya Negi [this message]
2023-10-12 7:51 ` Julia Lawall
2023-10-12 12:49 ` Soumya Negi
2023-10-12 13:03 ` Soumya Negi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231012074837.GE16374@Negi \
--to=soumya.negi97@gmail.com \
--cc=dan.carpenter@linaro.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=micky_ching@realsil.com.cn \
--cc=outreachy@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox