+/**
+ * mmc_send_cmd_retry() - send a command to the mmc device, retrying on error
+ *
+ * @dev: device to receive the command
+ * @cmd: command to send
+ * @data: additional data to send/receive
+ * @retries: how many times to retry; mmc_send_cmd is always called at least
+ * once
+ * @return 0 if ok, -ve on error
+ */
+static int mmc_send_cmd_retry(struct mmc *mmc, struct mmc_cmd *cmd,
+ struct mmc_data *data, uint retries)
+{
+ int ret;
+
+ do {
+ ret = mmc_send_cmd(mmc, cmd, data);
+ } while (ret && retries--);
+
+ return ret;
+}
+
+/**
+ * mmc_send_cmd_quirks() - send a command to the mmc device, retrying if a
+ * specific quirk is enabled
+ *
+ * @dev: device to receive the command
+ * @cmd: command to send
+ * @data: additional data to send/receive
+ * @quirk: retry only if this quirk is enabled
+ * @retries: how many times to retry; mmc_send_cmd is always called at least
+ * once
+ * @return 0 if ok, -ve on error
+ */
+static int mmc_send_cmd_quirks(struct mmc *mmc, struct mmc_cmd *cmd,
+ struct mmc_data *data, u32 quirk, uint retries)
+{
+ if (CONFIG_IS_ENABLED(MMC_QUIRKS) && mmc->quirks & quirk)
+ return mmc_send_cmd_retry(mmc, cmd, data, retries);
+ else
+ return mmc_send_cmd(mmc, cmd, data);
+}
+