> +static int tmio_mmc_execute_tuning(struct mmc_host *mmc, u32 opcode)
> +{
> +     struct tmio_mmc_host *host = mmc_priv(mmc);
> +     unsigned int num;
> +     int i, ret = 0;
> +     bool *tap;
> +
> +     if (!host->init_tuning || !host->select_tuning)

Check host->prepare_tuning, too?

> +             /* Tuning is not supported */
> +             goto out;
> +
> +     num = host->init_tuning(host);
> +     if (!num)
> +             /* Tuning is not supported */
> +             goto out;
> +
> +     tap = kmalloc(num * 2 * sizeof(*tap), GFP_KERNEL);
> +     if (!tap) {
> +             ret = -ENOMEM;
> +             goto out;
> +     }
> +
> +     /* Issue CMD19 twice for each tap */
> +     for (i = 0; i < 2 * num; i++) {
> +             if (host->prepare_tuning)
> +                     host->prepare_tuning(host, i % num);
> +
> +             ret = mmc_send_tuning(mmc, opcode, NULL);
> +             if (ret && ret != -EILSEQ)
> +                     goto err_free;
> +             tap[i] = (ret != 0);
> +
> +             mdelay(1);
> +     }
> +
> +     ret = host->select_tuning(host, tap, num * 2);
> +
> +err_free:
> +     kfree(tap);
> +out:
> +     if (ret < 0) {
> +             dev_warn(&host->pdev->dev, "Tuning procedure failed\n");
> +             tmio_mmc_hw_reset(mmc);
> +     } else {
> +             host->mmc->retune_period = 0;
> +     }
> +
> +     return ret;
> +

Unnecessary blank line

Reply via email to