Skip to content

Commit 7f52421

Browse files
lyakhcjb
authored andcommitted
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>
1 parent e82b4ac commit 7f52421

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

‎drivers/mmc/host/sh_mobile_sdhi.c‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,15 @@ static int sh_mobile_sdhi_write16_hook(struct tmio_mmc_host *host, int addr)
9090
return 0;
9191
}
9292

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+
93102
static int __devinit sh_mobile_sdhi_probe(struct platform_device *pdev)
94103
{
95104
struct sh_mobile_sdhi *priv;
@@ -110,7 +119,7 @@ static int __devinit sh_mobile_sdhi_probe(struct platform_device *pdev)
110119
p->pdata = mmc_data;
111120

112121
if (p->init) {
113-
ret = p->init(pdev);
122+
ret = p->init(pdev, &sdhi_ops);
114123
if (ret)
115124
goto einit;
116125
}

‎include/linux/mmc/sh_mobile_sdhi.h‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ struct tmio_mmc_data;
1010
#define SH_MOBILE_SDHI_IRQ_SDCARD "sdcard"
1111
#define SH_MOBILE_SDHI_IRQ_SDIO "sdio"
1212

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+
1321
struct sh_mobile_sdhi_info {
1422
int dma_slave_tx;
1523
int dma_slave_rx;
@@ -22,7 +30,8 @@ struct sh_mobile_sdhi_info {
2230
int (*get_cd)(struct platform_device *pdev);
2331

2432
/* callbacks for board specific setup code */
25-
int (*init)(struct platform_device *pdev);
33+
int (*init)(struct platform_device *pdev,
34+
const struct sh_mobile_sdhi_ops *ops);
2635
void (*cleanup)(struct platform_device *pdev);
2736
};
2837

0 commit comments

Comments
 (0)