All of lore.kernel.org
 help / color / mirror / Atom feed
From: Linus Walleij <linus.walleij@linaro.org>
To: Dmitry Osipenko <digetx@gmail.com>
Cc: Arend van Spriel <aspriel@gmail.com>,
	Franky Lin <franky.lin@broadcom.com>,
	Hante Meuleman <hante.meuleman@broadcom.com>,
	Chi-hsien Lin <chi-hsien.lin@infineon.com>,
	Wright Feng <wright.feng@infineon.com>,
	Chung-hsien Hsu <chung-hsien.hsu@infineon.com>,
	Kalle Valo <kvalo@codeaurora.org>,
	linux-wireless <linux-wireless@vger.kernel.org>,
	Stefan Hansson <newbyte@disroot.org>,
	Arend van Spriel <arend.vanspriel@broadcom.com>
Subject: Re: [PATCH v2] brcmfmac: firmware: Fix firmware loading
Date: Thu, 5 Aug 2021 11:27:30 +0200	[thread overview]
Message-ID: <CACRpkdY_PrEus+DQ7PKH=1E5eMsDAS=M6ObB97TKUeP-vzeFZg@mail.gmail.com> (raw)
In-Reply-To: <0f439074-83ea-087d-7eec-aa6d4d3d4689@gmail.com>

On Thu, Aug 5, 2021 at 3:44 AM Dmitry Osipenko <digetx@gmail.com> wrote:

> 04.08.2021 18:34, Linus Walleij пишет:
> > +             fwctx->tested_board_variant = false;
>
> This shouldn't be really needed, isn't it?

It is true in the sense that fwctx is allocated with kzalloc.

But it is done in a different function brcmf_fw_alloc_request()
and it is not entirely clear that the allocated struct is not reused,
and if someone refactors the code they could reuse it, so I add
this just to be 100% sure that this gets set to false.

Usually in the kernel when we have functions named *alloc*
it is allocating objects that can later be reused several times
(see the block layer for example), so I try to follow that pattern
here and assume that fwctx can be reused.

The only time I really rely on fields being zero is when the
allocation is in the same base block, e.g. inside probe() or
so.

> > +     } else {
> > +             fwctx->tested_board_variant = true;
> >               ret = request_firmware_nowait(THIS_MODULE, true, first->path,
> >                                             fwctx->dev, GFP_KERNEL, fwctx,
> > -                                           brcmf_fw_request_done);
> > +                                           brcmf_fw_request_done_first);
> >       }
> >       if (ret < 0)
> > -             brcmf_fw_request_done(NULL, fwctx);
> > +             brcmf_fw_request_done_first(NULL, fwctx);
>
> This "else" can be replaced with:
>
> if (!alt_path || ret < 0)
>         brcmf_fw_request_done(NULL, fwctx);

Sorry I don't quite get this... both branches of the if/else clause will
assign ret also if alt_path is set request_firmware_nowait() can return
nonzero and then brcmf_fw_request_done() needs to get
called?

Yours,
Linus Walleij

  reply	other threads:[~2021-08-05  9:27 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-04 15:34 [PATCH v2] brcmfmac: firmware: Fix firmware loading Linus Walleij
2021-08-05  1:22 ` Dmitry Osipenko
2021-08-05  9:14   ` Linus Walleij
2021-08-05 10:01     ` Dmitry Osipenko
2021-08-05  1:35 ` Dmitry Osipenko
2021-08-05  9:17   ` Linus Walleij
2021-08-05 10:06     ` Dmitry Osipenko
2021-08-05  1:44 ` Dmitry Osipenko
2021-08-05  9:27   ` Linus Walleij [this message]
2021-08-05 10:10     ` Dmitry Osipenko

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='CACRpkdY_PrEus+DQ7PKH=1E5eMsDAS=M6ObB97TKUeP-vzeFZg@mail.gmail.com' \
    --to=linus.walleij@linaro.org \
    --cc=arend.vanspriel@broadcom.com \
    --cc=aspriel@gmail.com \
    --cc=chi-hsien.lin@infineon.com \
    --cc=chung-hsien.hsu@infineon.com \
    --cc=digetx@gmail.com \
    --cc=franky.lin@broadcom.com \
    --cc=hante.meuleman@broadcom.com \
    --cc=kvalo@codeaurora.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=newbyte@disroot.org \
    --cc=wright.feng@infineon.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.