From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Gabriel Somlo <gsomlo@gmail.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Rob Herring <robh+dt@kernel.org>,
devicetree <devicetree@vger.kernel.org>,
Ulf Hansson <ulf.hansson@linaro.org>,
linux-mmc <linux-mmc@vger.kernel.org>,
Karol Gugala <kgugala@antmicro.com>,
Mateusz Holenko <mholenko@antmicro.com>,
Kamil Rakoczy <krakoczy@antmicro.com>,
mdudek@internships.antmicro.com,
Paul Mackerras <paulus@ozlabs.org>, Joel Stanley <joel@jms.id.au>,
Stafford Horne <shorne@gmail.com>,
Geert Uytterhoeven <geert@linux-m68k.org>,
david.abdurachmanov@sifive.com,
Florent Kermarrec <florent@enjoy-digital.fr>,
Randy Dunlap <rdunlap@infradead.org>
Subject: Re: [PATCH v9 3/3] mmc: Add driver for LiteX's LiteSDCard interface
Date: Sat, 8 Jan 2022 19:43:19 +0200 [thread overview]
Message-ID: <CAHp75VeEvT-_47gKFAYdz-BR9y=KLEw2uMbRxYKo1rLQSQEfyg@mail.gmail.com> (raw)
In-Reply-To: <20220108161134.2419279-4-gsomlo@gmail.com>
On Sat, Jan 8, 2022 at 6:11 PM Gabriel Somlo <gsomlo@gmail.com> wrote:
>
> LiteX (https://github.com/enjoy-digital/litex) is a SoC framework
> that targets FPGAs. LiteSDCard is a small footprint, configurable
> SDCard core commonly used in LiteX designs.
>
> The driver was first written in May 2020 and has been maintained
> cooperatively by the LiteX community. Thanks to all contributors!
Thanks for an update, my comments below.
...
> +#include <linux/bits.h>
> +#include <linux/clk.h>
> +#include <linux/delay.h>
> +#include <linux/dma-mapping.h>
> +#include <linux/interrupt.h>
> +#include <linux/iopoll.h>
> +#include <linux/litex.h>
> +#include <linux/mod_devicetable.h>
> +#include <linux/module.h>
> +#include <linux/mmc/host.h>
> +#include <linux/mmc/mmc.h>
> +#include <linux/mmc/sd.h>
I would move this group of headers...
> +#include <linux/platform_device.h>
> +
...somewhere here to show that this driver belongs to the MMC subsystem.
...
> +#define LITEX_MMC_OCR (MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_29_30 | \
> + MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 | \
> + MMC_VDD_33_34 | MMC_VDD_34_35 | MMC_VDD_35_36)
Seems to me this is identical to
https://elixir.bootlin.com/linux/latest/source/drivers/mmc/host/au1xmmc.c#L72
And may be reused in
https://elixir.bootlin.com/linux/latest/source/drivers/mmc/host/vub300.c#L2168.
Perhaps it makes sense to have
#define MMC_VDD_27_36 ...
in mmc.h?
In any case, it can be postponed, just a side note for the future improvements.
...
> + /* Ensure bus width will be set (again) upon card (re)insertion */
> + if (ret == 0)
> + host->is_bus_width_set = false;
> +
> + return ret;
Please, switch to standard pattern, i.e.
if (ret)
return ret;
...
return 0;
...
> + u32 div;
> +
> + div = freq ? host->ref_clk / freq : 256U;
> + div = roundup_pow_of_two(div);
> + div = clamp(div, 2U, 256U);
Not sure why it becomes two lines again.
...
> + ret = devm_add_action_or_reset(dev,
> + (void(*)(void *))mmc_free_host, mmc);
One line?
An actually preferable way is to define a separate wrapper function
and use it here without any casting.
> + if (ret) {
> + dev_err(dev, "Failed to register mmc_free_host action\n");
> + return ret;
return dev_err_probe(...);
> + }
...
> + clk = devm_clk_get(dev, NULL);
> + if (IS_ERR(clk)) {
> + ret = dev_err_probe(dev, PTR_ERR(clk), "can't get clock\n");
> + return ret;
return dev_err_probe(...);
> + }
...
> + ret = mmc_add_host(mmc);
> +
> + return ret;
It's now
return mmc_add_host(...);
> +}
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2022-01-08 17:43 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-08 16:11 [PATCH v9 0/3] mmc: Add LiteSDCard mmc driver Gabriel Somlo
2022-01-08 16:11 ` [PATCH v9 1/3] MAINTAINERS: co-maintain LiteX platform Gabriel Somlo
2022-01-08 16:11 ` [PATCH v9 2/3] dt-bindings: mmc: Add bindings for LiteSDCard Gabriel Somlo
2022-01-08 16:11 ` [PATCH v9 3/3] mmc: Add driver for LiteX's LiteSDCard interface Gabriel Somlo
2022-01-08 17:43 ` Andy Shevchenko [this message]
2022-01-09 0:26 ` Gabriel L. Somlo
2022-01-09 11:43 ` Andy Shevchenko
2022-01-10 8:25 ` Geert Uytterhoeven
[not found] ` <20220109025042.1537-1-hdanton@sina.com>
2022-01-09 4:19 ` Gabriel L. Somlo
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='CAHp75VeEvT-_47gKFAYdz-BR9y=KLEw2uMbRxYKo1rLQSQEfyg@mail.gmail.com' \
--to=andy.shevchenko@gmail.com \
--cc=david.abdurachmanov@sifive.com \
--cc=devicetree@vger.kernel.org \
--cc=florent@enjoy-digital.fr \
--cc=geert@linux-m68k.org \
--cc=gsomlo@gmail.com \
--cc=joel@jms.id.au \
--cc=kgugala@antmicro.com \
--cc=krakoczy@antmicro.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=mdudek@internships.antmicro.com \
--cc=mholenko@antmicro.com \
--cc=paulus@ozlabs.org \
--cc=rdunlap@infradead.org \
--cc=robh+dt@kernel.org \
--cc=shorne@gmail.com \
--cc=ulf.hansson@linaro.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).