[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <YbDhbLnZVUhw/mz4@errol.ini.cmu.edu>
Date: Wed, 8 Dec 2021 11:46:36 -0500
From: "Gabriel L. Somlo" <gsomlo@...il.com>
To: Joel Stanley <joel@....id.au>
Cc: Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Rob Herring <robh+dt@...nel.org>,
devicetree <devicetree@...r.kernel.org>,
Ulf Hansson <ulf.hansson@...aro.org>,
linux-mmc <linux-mmc@...r.kernel.org>,
Karol Gugala <kgugala@...micro.com>,
Mateusz Holenko <mholenko@...micro.com>, krakoczy@...micro.com,
mdudek@...ernships.antmicro.com,
Paul Mackerras <paulus@...abs.org>,
Stafford Horne <shorne@...il.com>,
Geert Uytterhoeven <geert@...ux-m68k.org>,
david.abdurachmanov@...ive.com,
Florent Kermarrec <florent@...oy-digital.fr>
Subject: Re: [PATCH v1 3/3] mmc: Add driver for LiteX's LiteSDCard interface
Hi Joel,
On Mon, Dec 06, 2021 at 10:53:17AM +0000, Joel Stanley wrote:
> On Fri, 3 Dec 2021 at 23:42, Gabriel Somlo <gsomlo@...il.com> wrote:
> > +static void
> litex_request> +litex_request(struct mmc_host *mmc, struct mmc_request *mrq)
> > +{
> > + struct litex_mmc_host *host = mmc_priv(mmc);
> > + struct platform_device *pdev = to_platform_device(mmc->parent);
> > + struct device *dev = &pdev->dev;
> > + struct mmc_data *data = mrq->data;
> > + struct mmc_command *sbc = mrq->sbc;
> > + struct mmc_command *cmd = mrq->cmd;
> > + struct mmc_command *stop = mrq->stop;
> > + unsigned int retries = cmd->retries;
> > + int status;
> > + int sg_count;
> > + enum dma_data_direction dir = DMA_TO_DEVICE;
> > + bool direct = false;
> > + dma_addr_t dma;
> > + unsigned int len = 0;
> > +
> > + u32 response_len = litex_response_len(cmd);
> > + u32 transfer = SDCARD_CTRL_DATA_TRANSFER_NONE;
> > +
> > + /* First check that the card is still there */
> > + if (!litex_get_cd(mmc)) {
> > + cmd->error = -ENOMEDIUM;
> > + mmc_request_done(mmc, mrq);
> > + return;
> > + }
> > +
> > + /* Send set-block-count command if needed */
> > + if (sbc) {
> > + status = send_cmd(host, sbc->opcode, sbc->arg,
> > + litex_response_len(sbc),
> > + SDCARD_CTRL_DATA_TRANSFER_NONE);
> > + sbc->error = litex_map_status(status);
> > + if (status != SD_OK) {
> > + host->is_bus_width_set = false;
> > + mmc_request_done(mmc, mrq);
> > + return;
> > + }
> > + }
> > +
> > + if (data) {
>
> This is a big ol' if(). Consider splitting it (or some of it?) out
> into some other functions to make it easier to read.
>
I can factor out the dma transfer portion into a dedicated helper
function:
static void litex_mmc_data_dma_transfer(struct litex_mmc_host *host,
struct mmc_data *data,
unsigned int *len,
bool *direct,
u8 *transfer)
where `len`, `direct`, and `transfer` are passed in as pointers,
because the helper function modifies their values and the caller
(i.e., `litex_[mmc_]request()`) is subsequently using those
potentially modified-by-the-callee values.
If you still feel the extra call overhead is worth the tradeoff in
improved legibility and code grouping, let me know and I can have it
out in version 4 (I sent out v3 earlier this morning without changing
this part).
Thanks,
--Gabriel
Powered by blists - more mailing lists