All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Philipp Hortmann <philipp.g.hortmann@gmail.com>
Cc: Forest Bond <forest@alittletooquiet.net>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 4/7] staging: vt6655: Replace VNSvOutPortB with iowrite8
Date: Tue, 12 Apr 2022 09:37:32 +0300	[thread overview]
Message-ID: <20220412063731.GA3293@kadam> (raw)
In-Reply-To: <3cac1ca7000a56e82b390ea0ddbab5aa549ee7ec.1649706687.git.philipp.g.hortmann@gmail.com>

On Mon, Apr 11, 2022 at 10:49:39PM +0200, Philipp Hortmann wrote:
> Replace macro VNSvOutPortB with iowrite8.
> The name of macro and the arguments use CamelCase which
> is not accepted by checkpatch.pl
> 
> For constants from 0 to below 0x80 the u8 cast was omitted.
> For variables which are defined as unsigned char the u8 is omitted.

I hate that GCC prints warnings for this.  Useless.  Horrible.  But I
understand that GCC does and we haven't figured out how to disable it
or who needs to approve that.

But even then I still don't understand the casting in this patch.

Shouldn't the rule be to do the minimum work arounds to silence GCC?
My understand is that the the casting is only needed when you're dealing
with a bitwise negated constant.  These are macros so the parameters
might be constant so basically any bitwise negate gets a cast.

>  #define MACvWordRegBitsOff(iobase, byRegOfs, wBits)			\
> @@ -578,37 +578,30 @@ do {									\
>  
>  #define MACvWriteBSSIDAddress(iobase, pbyEtherAddr)		\
>  do {								\
> -	VNSvOutPortB(iobase + MAC_REG_PAGE1SEL, 1);		\
> -	VNSvOutPortB(iobase + MAC_REG_BSSID0,			\
> -		     *(pbyEtherAddr));				\
> -	VNSvOutPortB(iobase + MAC_REG_BSSID0 + 1,		\
> -		     *(pbyEtherAddr + 1));			\
> -	VNSvOutPortB(iobase + MAC_REG_BSSID0 + 2,		\
> -		     *(pbyEtherAddr + 2));			\
> -	VNSvOutPortB(iobase + MAC_REG_BSSID0 + 3,		\
> -		     *(pbyEtherAddr + 3));			\
> -	VNSvOutPortB(iobase + MAC_REG_BSSID0 + 4,		\
> -		     *(pbyEtherAddr + 4));			\
> -	VNSvOutPortB(iobase + MAC_REG_BSSID0 + 5,		\
> -		     *(pbyEtherAddr + 5));			\
> -	VNSvOutPortB(iobase + MAC_REG_PAGE1SEL, 0);		\
> +	iowrite8(1, iobase + MAC_REG_PAGE1SEL);		\
> +	iowrite8((u8)*(pbyEtherAddr), iobase + MAC_REG_BSSID0);				\
> +	iowrite8((u8)*(pbyEtherAddr + 1), iobase + MAC_REG_BSSID0 + 1);			\
> +	iowrite8((u8)*(pbyEtherAddr + 2), iobase + MAC_REG_BSSID0 + 2);			\
> +	iowrite8((u8)*(pbyEtherAddr + 3), iobase + MAC_REG_BSSID0 + 3);			\
> +	iowrite8((u8)*(pbyEtherAddr + 4), iobase + MAC_REG_BSSID0 + 4);			\
> +	iowrite8((u8)*(pbyEtherAddr + 5), iobase + MAC_REG_BSSID0 + 5);			\
> +	iowrite8(0, iobase + MAC_REG_PAGE1SEL);		\
>  } while (0)


If these casts are required then the pointer math is wrong.  #SeriousBug
I looked at the caller and these casts are not required.  Just remove
the casts.

>  #define MACvClearStckDS(iobase)					\
>  do {									\
>  	unsigned char byOrgValue;					\
>  	byOrgValue = ioread8(iobase + MAC_REG_STICKHW);		\
>  	byOrgValue = byOrgValue & 0xFC;					\
> -	VNSvOutPortB(iobase + MAC_REG_STICKHW, byOrgValue);		\
> +	iowrite8((u8)byOrgValue, iobase + MAC_REG_STICKHW);		\
>  } while (0)

This cast is definitely not required.  byOrgValue is declared as local
to the block so we know it's unsigned char.

> diff --git a/drivers/staging/vt6655/srom.c b/drivers/staging/vt6655/srom.c
> index a0432bacb6a0..7feaa5138de0 100644
> --- a/drivers/staging/vt6655/srom.c
> +++ b/drivers/staging/vt6655/srom.c
> @@ -68,13 +68,13 @@ unsigned char SROMbyReadEmbedded(void __iomem *iobase,
>  	byData = 0xFF;
>  	byOrg = ioread8(iobase + MAC_REG_I2MCFG);
>  	/* turn off hardware retry for getting NACK */
> -	VNSvOutPortB(iobase + MAC_REG_I2MCFG, (byOrg & (~I2MCFG_NORETRY)));
> +	iowrite8((u8)(byOrg & (~I2MCFG_NORETRY)), iobase + MAC_REG_I2MCFG);

In this case we have a bitwise negate but it's ANDed with a u8 so there
is no cast required (hopefully 0_0).

regards,
dan carpenter


  reply	other threads:[~2022-04-12  6:38 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-11 20:49 [PATCH v3 0/7] staging: vt6655: Fix CamelCase in upc.h and started in mac.h Philipp Hortmann
2022-04-11 20:49 ` [PATCH v3 1/7] staging: vt6655: Replace VNSvInPortB with ioread8 Philipp Hortmann
2022-04-12 13:44   ` Greg Kroah-Hartman
2022-04-11 20:49 ` [PATCH v3 2/7] staging: vt6655: Replace VNSvInPortW with ioread16 Philipp Hortmann
2022-04-11 20:49 ` [PATCH v3 3/7] staging: vt6655: Replace VNSvInPortD with ioread32 Philipp Hortmann
2022-04-11 20:49 ` [PATCH v3 4/7] staging: vt6655: Replace VNSvOutPortB with iowrite8 Philipp Hortmann
2022-04-12  6:37   ` Dan Carpenter [this message]
2022-04-12  6:45     ` Philipp Hortmann
2022-04-12  6:56       ` Dan Carpenter
2022-04-12 13:40       ` Greg Kroah-Hartman
2022-04-11 20:49 ` [PATCH v3 5/7] staging: vt6655: Replace VNSvOutPortW with iowrite16 Philipp Hortmann
2022-04-11 20:49 ` [PATCH v3 6/7] staging: vt6655: Replace VNSvOutPortD with iowrite32 Philipp Hortmann
2022-04-11 20:49 ` [PATCH v3 7/7] staging: vt6655: Remove macro PCAvDelayByIO Philipp Hortmann

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=20220412063731.GA3293@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=forest@alittletooquiet.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=philipp.g.hortmann@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.