Skip to contentSkip to conversation

mmc: sh_mobile_sdhi: add a callback for board specific init code

PATCH In review Bastian Hecht 2 participants 2 messages Mar 16, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mmc: sh_mobile_sdhi: add a callback for board specific init code

Some boards need a preliminary setup stage to prepare the sdhi controller.

---
 drivers/mmc/host/sh_mobile_sdhi.c  |   13 +++++++++++++
 include/linux/mmc/sh_mobile_sdhi.h |    4 ++++
 2 files changed, 17 insertions(+), 0 deletions(-)
drivers/mmc/host/sh_mobile_sdhi.c +13 -0
index 0df69ab..1da31a4 100644
@@ -109,6 +109,12 @@ static int __devinit sh_mobile_sdhi_probe(struct platform_device *pdev)
 	mmc_data = &priv->mmc_data;
 	p->pdata = mmc_data;
 
+	if (p->init) {
+		ret = p->init(pdev);
+		if (ret)
+			goto einit;
+	}
+
 	snprintf(clk_name, sizeof(clk_name), "sdhi%d", pdev->id);
 	priv->clk = clk_get(&pdev->dev, clk_name);
 	if (IS_ERR(priv->clk)) {
@@ -242,6 +248,9 @@ eprobe:
 #endif
 	clk_put(priv->clk);
 eclkget:
+	if (p->cleanup)
+		p->cleanup(pdev);
+einit:
 	kfree(priv);
 	return ret;
 }
@@ -269,6 +278,10 @@ static int sh_mobile_sdhi_remove(struct platform_device *pdev)
 	clk_disable(priv->clk);
 #endif
 	clk_put(priv->clk);
+
+	if (p->cleanup)
+		p->cleanup(pdev);
+
 	kfree(priv);
 
 	return 0;
include/linux/mmc/sh_mobile_sdhi.h +4 -0
index 86347f6..9cad001 100644
@@ -22,6 +22,10 @@ struct sh_mobile_sdhi_info {
 	struct tmio_mmc_data *pdata;
 	void (*set_pwr)(struct platform_device *pdev, int state);
 	int (*get_cd)(struct platform_device *pdev);
+
+	/* callbacks for board specific setup code */
+	int (*init)(struct platform_device *pdev);
+	void (*cleanup)(struct platform_device *pdev);
 };
 
 #endif /* LINUX_MMC_SH_MOBILE_SDHI_H */
Signature · 1 line
1.7.5.4
#1 lore raw

Hi,

Quoted 52 lines · Bastian Hecht

Some boards need a preliminary setup stage to prepare the sdhi controller.

---
 drivers/mmc/host/sh_mobile_sdhi.c  |   13 +++++++++++++
 include/linux/mmc/sh_mobile_sdhi.h |    4 ++++
 2 files changed, 17 insertions(+), 0 deletions(-)
drivers/mmc/host/sh_mobile_sdhi.c +13 -0
index 0df69ab..1da31a4 100644
@@ -109,6 +109,12 @@ static int __devinit sh_mobile_sdhi_probe(struct platform_device *pdev)
 	mmc_data = &priv->mmc_data;
 	p->pdata = mmc_data;
 
+	if (p->init) {
+		ret = p->init(pdev);
+		if (ret)
+			goto einit;
+	}
+
 	snprintf(clk_name, sizeof(clk_name), "sdhi%d", pdev->id);
 	priv->clk = clk_get(&pdev->dev, clk_name);
 	if (IS_ERR(priv->clk)) {
@@ -242,6 +248,9 @@ eprobe:
 #endif
 	clk_put(priv->clk);
 eclkget:
+	if (p->cleanup)
+		p->cleanup(pdev);
+einit:
 	kfree(priv);
 	return ret;
 }
@@ -269,6 +278,10 @@ static int sh_mobile_sdhi_remove(struct platform_device *pdev)
 	clk_disable(priv->clk);
 #endif
 	clk_put(priv->clk);
+
+	if (p->cleanup)
+		p->cleanup(pdev);
+
 	kfree(priv);
 
 	return 0;
include/linux/mmc/sh_mobile_sdhi.h +0 -0
index 86347f6..9cad001 100644

include/linux/mmc/sh_mobile_sdhi.h struct sh_mobile_sdhi_info { · line 31

Quoted 10 lines
include/linux/mmc/sh_mobile_sdhi.h +4 -0
@@ -22,6 +22,10 @@ struct sh_mobile_sdhi_info {
 	struct tmio_mmc_data *pdata;
 	void (*set_pwr)(struct platform_device *pdev, int state);
 	int (*get_cd)(struct platform_device *pdev);
+
+	/* callbacks for board specific setup code */
+	int (*init)(struct platform_device *pdev);
+	void (*cleanup)(struct platform_device *pdev);
 };
 
 #endif /* LINUX_MMC_SH_MOBILE_SDHI_H */

Thanks, pushed to mmc-next for 3.4.

- Chris.

Signature · 2 lines
Chris Ball   <[email protected]>   <http://printf.net/>
One Laptop Per Child