From: Jassi Brar <jassisinghbrar@gmail.com>
To: conor.dooley@microchip.com
Cc: Rob Herring <robh+dt@kernel.org>,
damien.lemoal@wdc.com, aou@eecs.berkeley.edu,
paul.walmsley@sifive.com, Palmer Dabbelt <palmer@dabbelt.com>,
Devicetree List <devicetree@vger.kernel.org>,
linux-riscv@lists.infradead.org, j.neuschaefer@gmx.net,
lewis.hanly@microchip.com, cyril.jean@microchip.com,
daire.mcnamara@microchip.com, atish.patra@wdc.com,
anup.patel@wdc.com, david.abdurachmanov@gmail.com
Subject: Re: [PATCH v5 2/5] mbox: add polarfire soc system controller mailbox
Date: Mon, 12 Apr 2021 12:20:56 -0500 [thread overview]
Message-ID: <CABb+yY1D4Z_vCXMYqHMhisJFZ9F8RPzaKUnTPhkFW=o5BEWfNg@mail.gmail.com> (raw)
In-Reply-To: <20210412160402.19394-1-conor.dooley@microchip.com>
On Mon, Apr 12, 2021 at 11:04 AM <conor.dooley@microchip.com> wrote:
> diff --git a/drivers/mailbox/mailbox-mpfs.c b/drivers/mailbox/mailbox-mpfs.c
> +
> +struct mpfs_mbox {
> + struct mbox_controller controller;
> + struct device *dev;
> + int irq;
> + void __iomem *mbox_base;
> + void __iomem *int_reg;
> + struct mbox_chan *chans;
>
As I said previously .... struct mbox_chan chans[1] ?
> +static bool mpfs_mbox_busy(struct mpfs_mbox *mbox)
> +{
> + u32 status;
> +
> + status = readl_relaxed(mbox->mbox_base + SERVICES_SR_OFFSET);
> +
> + return status & SCB_STATUS_BUSY_MASK;
> +}
> +
> +static struct mpfs_mbox *mbox_chan_to_mpfs_mbox(struct mbox_chan *chan)
> +{
> + if (!chan)
> + return NULL;
> +
The return value is not always checked before use in the caller.
And I don't see how could 'chan' ever be null. So, maybe just discard
this function ?
> + return (struct mpfs_mbox *)chan->con_priv;
> +}
> +
> +static int mpfs_mbox_send_data(struct mbox_chan *chan, void *data)
> +{
> + u32 val = 0u;
> + u16 opt_sel;
> + u32 tx_trigger;
> + struct mpfs_mss_msg *msg = data;
> + struct mpfs_mbox *mbox = mbox_chan_to_mpfs_mbox(chan);
> +
> + mbox->response = msg->response;
> + mbox->resp_offset = msg->resp_offset;
> +
> + if (mpfs_mbox_busy(mbox))
> + return -EBUSY;
> +
This check should be unnecessary because the api won't call
send_data() unless the last one is done.
> +static inline bool mpfs_mbox_pending(struct mpfs_mbox *mbox)
> +{
> + u32 status;
> +
> + status = readl_relaxed(mbox->mbox_base + SERVICES_SR_OFFSET);
> +
> + return !(status & SCB_STATUS_BUSY_MASK);
> +}
> +
Isn't this !mpfs_mbox_busy() ?
> +static void mpfs_mbox_rx_data(struct mbox_chan *chan)
> +{
> + struct mpfs_mbox *mbox = mbox_chan_to_mpfs_mbox(chan);
> + u32 i;
> + u16 num_words = ALIGN((mbox->response->resp_size), (4)) / 4U;
> + struct mpfs_mss_response *response = mbox->response;
> +
Usually the decs are in ascending or descending order. Please choose one.
> +
> +static int mpfs_mbox_startup(struct mbox_chan *chan)
> +{
> + struct mpfs_mbox *mbox = mbox_chan_to_mpfs_mbox(chan);
> + int ret = 0;
> +
> + if (!mbox)
> + return -EINVAL;
> + ret = devm_request_irq(mbox->dev, mbox->irq, mpfs_mbox_inbox_isr, 0, "mpfs-mailbox", chan);
>
scripts/checkpatch should catch missing newline before "ret =" ?
cheers.
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2021-04-12 17:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-12 16:04 [PATCH v5 2/5] mbox: add polarfire soc system controller mailbox conor.dooley
2021-04-12 17:20 ` Jassi Brar [this message]
2021-04-13 14:16 ` Conor.Dooley
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='CABb+yY1D4Z_vCXMYqHMhisJFZ9F8RPzaKUnTPhkFW=o5BEWfNg@mail.gmail.com' \
--to=jassisinghbrar@gmail.com \
--cc=anup.patel@wdc.com \
--cc=aou@eecs.berkeley.edu \
--cc=atish.patra@wdc.com \
--cc=conor.dooley@microchip.com \
--cc=cyril.jean@microchip.com \
--cc=daire.mcnamara@microchip.com \
--cc=damien.lemoal@wdc.com \
--cc=david.abdurachmanov@gmail.com \
--cc=devicetree@vger.kernel.org \
--cc=j.neuschaefer@gmx.net \
--cc=lewis.hanly@microchip.com \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=robh+dt@kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).