Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mmc: core: Re-factor code for sending CID

Instead of having the caller to check for SPI mode, let's leave that to
internals of mmc_send_cid(). In this way the code gets cleaner and it
becomes clear what is specific to SPI and non-SPI mode.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com>

+12 -12
+1 -4
drivers/mmc/core/mmc.c
··· 1556 1556 /* 1557 1557 * Fetch CID from card. 1558 1558 */ 1559 - if (mmc_host_is_spi(host)) 1560 - err = mmc_send_cid(host, cid); 1561 - else 1562 - err = mmc_all_send_cid(host, cid); 1559 + err = mmc_send_cid(host, cid); 1563 1560 if (err) 1564 1561 goto err; 1565 1562
+10 -2
drivers/mmc/core/mmc_ops.c
··· 207 207 return err; 208 208 } 209 209 210 - int mmc_all_send_cid(struct mmc_host *host, u32 *cid) 210 + static int mmc_all_send_cid(struct mmc_host *host, u32 *cid) 211 211 { 212 212 int err; 213 213 struct mmc_command cmd = {}; ··· 334 334 return ret; 335 335 } 336 336 337 - int mmc_send_cid(struct mmc_host *host, u32 *cid) 337 + static int mmc_spi_send_cid(struct mmc_host *host, u32 *cid) 338 338 { 339 339 int ret, i; 340 340 __be32 *cid_tmp; ··· 353 353 err: 354 354 kfree(cid_tmp); 355 355 return ret; 356 + } 357 + 358 + int mmc_send_cid(struct mmc_host *host, u32 *cid) 359 + { 360 + if (mmc_host_is_spi(host)) 361 + return mmc_spi_send_cid(host, cid); 362 + 363 + return mmc_all_send_cid(host, cid); 356 364 } 357 365 358 366 int mmc_get_ext_csd(struct mmc_card *card, u8 **new_ext_csd)
-1
drivers/mmc/core/mmc_ops.h
··· 22 22 int mmc_set_dsr(struct mmc_host *host); 23 23 int mmc_go_idle(struct mmc_host *host); 24 24 int mmc_send_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr); 25 - int mmc_all_send_cid(struct mmc_host *host, u32 *cid); 26 25 int mmc_set_relative_addr(struct mmc_card *card); 27 26 int mmc_send_csd(struct mmc_card *card, u32 *csd); 28 27 int __mmc_send_status(struct mmc_card *card, u32 *status, unsigned int retries);
+1 -5
drivers/mmc/core/sd.c
··· 788 788 } 789 789 } 790 790 791 - if (mmc_host_is_spi(host)) 792 - err = mmc_send_cid(host, cid); 793 - else 794 - err = mmc_all_send_cid(host, cid); 795 - 791 + err = mmc_send_cid(host, cid); 796 792 return err; 797 793 } 798 794