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

mmc: sh_mobile_sdhi: support modular mmc-core with non-standard hotplug

Currently if a platform wants to implement a non-standard card-detection
method, it would need to call tmio_mmc_cd_wakeup(), which is an inline
function, calling mmc_detect_change(). For this the platform would have
to link mmc_core statically into the kernel, losing the ability to build
it as a module. This patch adds a callback to the sh_mobile_sdhi driver,
which eliminates this dependency.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Acked-by: Magnus Damm <damm@opensource.se>
Signed-off-by: Chris Ball <cjb@laptop.org>

authored by

Guennadi Liakhovetski and committed by
Chris Ball
7f524217 e82b4ac9

+20 -2
+10 -1
drivers/mmc/host/sh_mobile_sdhi.c
··· 90 90 return 0; 91 91 } 92 92 93 + static void sh_mobile_sdhi_cd_wakeup(const struct platform_device *pdev) 94 + { 95 + mmc_detect_change(dev_get_drvdata(&pdev->dev), msecs_to_jiffies(100)); 96 + } 97 + 98 + static const struct sh_mobile_sdhi_ops sdhi_ops = { 99 + .cd_wakeup = sh_mobile_sdhi_cd_wakeup, 100 + }; 101 + 93 102 static int __devinit sh_mobile_sdhi_probe(struct platform_device *pdev) 94 103 { 95 104 struct sh_mobile_sdhi *priv; ··· 119 110 p->pdata = mmc_data; 120 111 121 112 if (p->init) { 122 - ret = p->init(pdev); 113 + ret = p->init(pdev, &sdhi_ops); 123 114 if (ret) 124 115 goto einit; 125 116 }
+10 -1
include/linux/mmc/sh_mobile_sdhi.h
··· 10 10 #define SH_MOBILE_SDHI_IRQ_SDCARD "sdcard" 11 11 #define SH_MOBILE_SDHI_IRQ_SDIO "sdio" 12 12 13 + /** 14 + * struct sh_mobile_sdhi_ops - SDHI driver callbacks 15 + * @cd_wakeup: trigger a card-detection run 16 + */ 17 + struct sh_mobile_sdhi_ops { 18 + void (*cd_wakeup)(const struct platform_device *pdev); 19 + }; 20 + 13 21 struct sh_mobile_sdhi_info { 14 22 int dma_slave_tx; 15 23 int dma_slave_rx; ··· 30 22 int (*get_cd)(struct platform_device *pdev); 31 23 32 24 /* callbacks for board specific setup code */ 33 - int (*init)(struct platform_device *pdev); 25 + int (*init)(struct platform_device *pdev, 26 + const struct sh_mobile_sdhi_ops *ops); 34 27 void (*cleanup)(struct platform_device *pdev); 35 28 }; 36 29