From: Jerome Pouiller <Jerome.Pouiller@silabs.com>
To: "driverdev-devel@linuxdriverproject.org"
<driverdev-devel@linuxdriverproject.org>
Cc: Dan Carpenter <dan.carpenter@oracle.com>,
Jules Irenge <jbi.octave@gmail.com>,
"devel@driverdev.osuosl.org" <devel@driverdev.osuosl.org>,
"outreachy-kernel@googlegroups.com"
<outreachy-kernel@googlegroups.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>
Subject: Re: [PATCH v1 1/5] staging: wfx: fix warnings of no space is necessary
Date: Mon, 21 Oct 2019 08:21:45 +0000 [thread overview]
Message-ID: <4583183.OhVBZdlllx@pc-42> (raw)
In-Reply-To: <20191019142443.GH24678@kadam>
On Saturday 19 October 2019 16:24:43 CEST Dan Carpenter wrote:
> On Sat, Oct 19, 2019 at 03:07:15PM +0100, Jules Irenge wrote:
> > diff --git a/drivers/staging/wfx/bh.c b/drivers/staging/wfx/bh.c
> > index 3355183fc86c..573216b08042 100644
> > --- a/drivers/staging/wfx/bh.c
> > +++ b/drivers/staging/wfx/bh.c
> > @@ -69,13 +69,13 @@ static int rx_helper(struct wfx_dev *wdev, size_t read_len, int *is_cnf)
> > if (wfx_data_read(wdev, skb->data, alloc_len))
> > goto err;
> >
> > - piggyback = le16_to_cpup((u16 *) (skb->data + alloc_len - 2));
> > + piggyback = le16_to_cpup((u16 *)(skb->data + alloc_len - 2));
> > _trace_piggyback(piggyback, false);
> >
> > - hif = (struct hif_msg *) skb->data;
> > + hif = (struct hif_msg *)skb->data;
> > WARN(hif->encrypted & 0x1, "unsupported encryption type");
> > if (hif->encrypted == 0x2) {
> > - if (wfx_sl_decode(wdev, (void *) hif)) {
> > + if (wfx_sl_decode(wdev, (void *)hif)) {
>
> In the future you may want to go through and remove the (void *) casts.
> It's not required here.
>
> > diff --git a/drivers/staging/wfx/bus_spi.c b/drivers/staging/wfx/bus_spi.c
> > index f65f7d75e731..effd07957753 100644
> > --- a/drivers/staging/wfx/bus_spi.c
> > +++ b/drivers/staging/wfx/bus_spi.c
> > @@ -90,7 +90,7 @@ static int wfx_spi_copy_to_io(void *priv, unsigned int addr,
> > struct wfx_spi_priv *bus = priv;
> > u16 regaddr = (addr << 12) | (count / 2);
> > // FIXME: use a bounce buffer
> > - u16 *src16 = (void *) src;
> > + u16 *src16 = (void *)src;
>
> Here we are just getting rid of the constness. Apparently we are doing
> that so we can modify it without GCC pointing out the bug!! I don't
> know the code but this seems very wrong.
Hello Dan, Jules,
Indeed, this code should be improved.
Each u16 from src is byte-swapped before to be sent to SPI and restored
before to return from the function:
for (i = 0; i < count / 2; i++)
swab16s(&src16[i]);
[...]
spi_sync(bus->func, &m);
[...]
for (i = 0; i < count / 2; i++)
swab16s(&src16[i]);
So, src is same than original, but it is not const.
This is exactly the purpose of the FIXME just before the cast: "use a
bounce buffer". However, I did not yet make this change because I worry
about a possible performance penalty.
--
Jérôme Pouiller
next prev parent reply other threads:[~2019-10-21 13:07 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-19 14:07 [PATCH v1 0/5] staging: wfx: fix checkpatch warnings Jules Irenge
2019-10-19 14:07 ` [PATCH v1 1/5] staging: wfx: fix warnings of no space is necessary Jules Irenge
2019-10-19 14:24 ` Dan Carpenter
2019-10-19 15:09 ` Jules Irenge
2019-10-19 15:17 ` [Outreachy kernel] " Julia Lawall
2019-10-19 18:05 ` Dan Carpenter
2019-10-19 20:02 ` Joe Perches
2019-10-20 19:17 ` Dan Carpenter
2019-10-20 19:29 ` [Outreachy kernel] " Julia Lawall
2019-10-20 19:36 ` Joe Perches
2019-10-20 19:48 ` [Outreachy kernel] " Julia Lawall
2019-10-20 19:52 ` Julia Lawall
2019-10-20 20:16 ` Joe Perches
2019-10-20 20:29 ` Julia Lawall
2019-10-21 6:52 ` Julia Lawall
2019-10-21 8:54 ` Joe Perches
2019-10-22 8:57 ` Dan Carpenter
2019-10-21 8:21 ` Jerome Pouiller [this message]
2019-10-19 14:07 ` [PATCH v1 2/5] staging: wfx: fix warning of line over 80 characters Jules Irenge
2019-10-19 14:07 ` [PATCH v1 3/5] staging: wfx: fix warnings of logical continuation Jules Irenge
2019-10-19 14:07 ` [PATCH v1 4/5] staging: wfx: correct misspelled words Jules Irenge
2019-10-19 14:07 ` [PATCH v1 5/5] staging: wfx: fix warnings of alignment should match open parenthesis Jules Irenge
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=4583183.OhVBZdlllx@pc-42 \
--to=jerome.pouiller@silabs.com \
--cc=dan.carpenter@oracle.com \
--cc=devel@driverdev.osuosl.org \
--cc=driverdev-devel@linuxdriverproject.org \
--cc=gregkh@linuxfoundation.org \
--cc=jbi.octave@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=outreachy-kernel@googlegroups.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.