]> git.baikalelectronics.ru Git - kernel.git/commitdiff
mmc: sdricoh_cs: Move MMC_APP_CMD handling to sdricoh_mmc_cmd()
authorUlf Hansson <ulf.hansson@linaro.org>
Tue, 14 Apr 2020 16:14:04 +0000 (18:14 +0200)
committerUlf Hansson <ulf.hansson@linaro.org>
Thu, 28 May 2020 09:21:01 +0000 (11:21 +0200)
Move MMC_APP_CMD specific handling to be managed by sdricoh_mmc_cmd(), as
this makes the code a bit cleaner.

Cc: Sascha Sommer <saschasommer@freenet.de>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Link: https://lore.kernel.org/r/20200414161413.3036-11-ulf.hansson@linaro.org
drivers/mmc/host/sdricoh_cs.c

index a41c0660abbf83124aba224b5fa4a9d238e2dd7e..e7d74db95b57c09e02a5f073f29d47d1d5e2faa2 100644 (file)
@@ -149,16 +149,25 @@ static int sdricoh_query_status(struct sdricoh_host *host, unsigned int wanted,
 
 }
 
-static int sdricoh_mmc_cmd(struct sdricoh_host *host, unsigned char opcode,
-                          unsigned int arg)
+static int sdricoh_mmc_cmd(struct sdricoh_host *host, struct mmc_command *cmd)
 {
        unsigned int status;
        int result = 0;
        unsigned int loop = 0;
+       unsigned char opcode = cmd->opcode;
+
        /* reset status reg? */
        sdricoh_writel(host, R21C_STATUS, 0x18);
+
+       /* MMC_APP_CMDs need some special handling */
+       if (host->app_cmd) {
+               opcode |= 64;
+               host->app_cmd = 0;
+       } else if (opcode == MMC_APP_CMD)
+               host->app_cmd = 1;
+
        /* fill parameters */
-       sdricoh_writel(host, R204_CMD_ARG, arg);
+       sdricoh_writel(host, R204_CMD_ARG, cmd->arg);
        sdricoh_writel(host, R200_CMD, (0x10000 << 8) | opcode);
        /* wait for command completion */
        if (opcode) {
@@ -250,28 +259,20 @@ static void sdricoh_request(struct mmc_host *mmc, struct mmc_request *mrq)
        struct mmc_command *cmd = mrq->cmd;
        struct mmc_data *data = cmd->data;
        struct device *dev = host->dev;
-       unsigned char opcode = cmd->opcode;
        int i;
 
        dev_dbg(dev, "=============================\n");
-       dev_dbg(dev, "sdricoh_request opcode=%i\n", opcode);
+       dev_dbg(dev, "sdricoh_request opcode=%i\n", cmd->opcode);
 
        sdricoh_writel(host, R21C_STATUS, 0x18);
 
-       /* MMC_APP_CMDs need some special handling */
-       if (host->app_cmd) {
-               opcode |= 64;
-               host->app_cmd = 0;
-       } else if (opcode == MMC_APP_CMD)
-               host->app_cmd = 1;
-
        /* read/write commands seem to require this */
        if (data) {
                sdricoh_writew(host, R226_BLOCKSIZE, data->blksz);
                sdricoh_writel(host, R208_DATAIO, 0);
        }
 
-       cmd->error = sdricoh_mmc_cmd(host, opcode, cmd->arg);
+       cmd->error = sdricoh_mmc_cmd(host, cmd);
 
        /* read response buffer */
        if (cmd->flags & MMC_RSP_PRESENT) {