Skip to contentSkip to conversation

mmc: omap_hsmmc: convert to use devm_* and fixes

PATCH In review Balaji T K 3 participants 20 messages May 9, 2014 – May 21, 2014

Subsystems (2)
lore
Share & tools
lore

Balaji T K

author
#0 lore raw

v2 cover mmc: omap_hsmmc: convert to use devm_* and fixes

v2:
use devm_ioremap_resource
add cmd23 multiblock read/write fix

Balaji T K (6):
mmc: omap_hsmmc: use devm_clk_get
mmc: omap_hsmmc: use devm_request_irq
mmc: omap_hsmmc: use devm_request_threaded_irq
mmc: omap_hsmmc: use devm_ioremap_resource
mmc: omap_hsmmc: fix cmd23 multiblock read/write
mmc: omap_hsmmc: split omap-dma header file

 drivers/mmc/host/omap_hsmmc.c  |   57 ++++++++++++---------------------------
 include/linux/omap-dma.h       |   19 +------------
 include/linux/omap-dmaengine.h |   21 ++++++++++++++
 3 files changed, 40 insertions(+), 57 deletions(-)
 create mode 100644 include/linux/omap-dmaengine.h
Signature · 1 line
1.7.5.4
author
#1 lore raw

PATCH v2 1/6 mmc: omap_hsmmc: use devm_clk_get

With devm_clk_get conversion clk_put can be removed in clean up path

---
 drivers/mmc/host/omap_hsmmc.c |   15 ++++-----------
 1 files changed, 4 insertions(+), 11 deletions(-)
drivers/mmc/host/omap_hsmmc.c +4 -11
index b4de63b..b8ae7ee 100644
@@ -1922,7 +1922,7 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
 
 	spin_lock_init(&host->irq_lock);
 
-	host->fclk = clk_get(&pdev->dev, "fck");
+	host->fclk = devm_clk_get(&pdev->dev, "fck");
 	if (IS_ERR(host->fclk)) {
 		ret = PTR_ERR(host->fclk);
 		host->fclk = NULL;
@@ -1941,7 +1941,7 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
 
 	omap_hsmmc_context_save(host);
 
-	host->dbclk = clk_get(&pdev->dev, "mmchsdb_fck");
+	host->dbclk = devm_clk_get(&pdev->dev, "mmchsdb_fck");
 	/*
 	 * MMC can still work without debounce clock.
 	 */
@@ -1949,7 +1949,6 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
 		host->dbclk = NULL;
 	} else if (clk_prepare_enable(host->dbclk) != 0) {
 		dev_warn(mmc_dev(host->mmc), "Failed to enable debounce clk\n");
-		clk_put(host->dbclk);
 		host->dbclk = NULL;
 	}
 
@@ -2105,11 +2104,8 @@ err_irq:
 		dma_release_channel(host->rx_chan);
 	pm_runtime_put_sync(host->dev);
 	pm_runtime_disable(host->dev);
-	clk_put(host->fclk);
-	if (host->dbclk) {
+	if (host->dbclk)
 		clk_disable_unprepare(host->dbclk);
-		clk_put(host->dbclk);
-	}
 err1:
 	iounmap(host->base);
 	mmc_free_host(mmc);
@@ -2144,11 +2140,8 @@ static int omap_hsmmc_remove(struct platform_device *pdev)
 
 	pm_runtime_put_sync(host->dev);
 	pm_runtime_disable(host->dev);
-	clk_put(host->fclk);
-	if (host->dbclk) {
+	if (host->dbclk)
 		clk_disable_unprepare(host->dbclk);
-		clk_put(host->dbclk);
-	}
 
 	omap_hsmmc_gpio_free(host->pdata);
 	iounmap(host->base);
Signature · 1 line
1.7.5.4
author
#8 lore raw

PATCH v2 2/6 mmc: omap_hsmmc: use devm_request_irq

In reply to Balaji T K

With devm_request_irq conversion free_irq can be removed in clean up path

---
 drivers/mmc/host/omap_hsmmc.c |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)
drivers/mmc/host/omap_hsmmc.c +2 -5
index b8ae7ee..ef7e48a 100644
@@ -2017,7 +2017,7 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
 	}
 
 	/* Request IRQ for MMC operations */
-	ret = request_irq(host->irq, omap_hsmmc_irq, 0,
+	ret = devm_request_irq(&pdev->dev, host->irq, omap_hsmmc_irq, 0,
 			mmc_hostname(mmc), host);
 	if (ret) {
 		dev_err(mmc_dev(host->mmc), "Unable to grab HSMMC IRQ\n");
@@ -2028,7 +2028,7 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
 		if (pdata->init(&pdev->dev) != 0) {
 			dev_err(mmc_dev(host->mmc),
 				"Unable to configure MMC IRQs\n");
-			goto err_irq_cd_init;
+			goto err_irq;
 		}
 	}
 
@@ -2095,8 +2095,6 @@ err_irq_cd:
 err_reg:
 	if (host->pdata->cleanup)
 		host->pdata->cleanup(&pdev->dev);
-err_irq_cd_init:
-	free_irq(host->irq, host);
 err_irq:
 	if (host->tx_chan)
 		dma_release_channel(host->tx_chan);
@@ -2129,7 +2127,6 @@ static int omap_hsmmc_remove(struct platform_device *pdev)
 		omap_hsmmc_reg_put(host);
 	if (host->pdata->cleanup)
 		host->pdata->cleanup(&pdev->dev);
-	free_irq(host->irq, host);
 	if (mmc_slot(host).card_detect_irq)
 		free_irq(mmc_slot(host).card_detect_irq, host);
 
Signature · 1 line
1.7.5.4
author
#9 lore raw

PATCH v2 3/6 mmc: omap_hsmmc: use devm_request_threaded_irq

In reply to Balaji T K

With devm_request_threaded_irq conversion free_irq can be removed in clean up path

---
 drivers/mmc/host/omap_hsmmc.c |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)
drivers/mmc/host/omap_hsmmc.c +3 -6
index ef7e48a..6179fe3 100644
@@ -2043,9 +2043,9 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
 
 	/* Request IRQ for card detect */
 	if ((mmc_slot(host).card_detect_irq)) {
-		ret = request_threaded_irq(mmc_slot(host).card_detect_irq,
-					   NULL,
-					   omap_hsmmc_detect,
+		ret = devm_request_threaded_irq(&pdev->dev,
+						mmc_slot(host).card_detect_irq,
+						NULL, omap_hsmmc_detect,
 					   IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
 					   mmc_hostname(mmc), host);
 		if (ret) {
@@ -2088,7 +2088,6 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
 
 err_slot_name:
 	mmc_remove_host(mmc);
-	free_irq(mmc_slot(host).card_detect_irq, host);
 err_irq_cd:
 	if (host->use_reg)
 		omap_hsmmc_reg_put(host);
@@ -2127,8 +2126,6 @@ static int omap_hsmmc_remove(struct platform_device *pdev)
 		omap_hsmmc_reg_put(host);
 	if (host->pdata->cleanup)
 		host->pdata->cleanup(&pdev->dev);
-	if (mmc_slot(host).card_detect_irq)
-		free_irq(mmc_slot(host).card_detect_irq, host);
 
 	if (host->tx_chan)
 		dma_release_channel(host->tx_chan);
Signature · 1 line
1.7.5.4
author
#10 lore raw

PATCH v2 4/6 mmc: omap_hsmmc: use devm_ioremap_resource

In reply to Balaji T K

With devm_ioremap_resource conversion release_mem_region, iounmap can be removed in clean up path

---
 drivers/mmc/host/omap_hsmmc.c |   19 +++++--------------
 1 files changed, 5 insertions(+), 14 deletions(-)
drivers/mmc/host/omap_hsmmc.c +5 -14
index 6179fe3..140425c 100644
@@ -1851,6 +1851,7 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
 	unsigned tx_req, rx_req;
 	struct pinctrl *pinctrl;
 	const struct omap_mmc_of_data *data;
+	void __iomem *base;
 
 	match = of_match_device(of_match_ptr(omap_mmc_of_match), &pdev->dev);
 	if (match) {
@@ -1881,9 +1882,9 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
 	if (res == NULL || irq < 0)
 		return -ENXIO;
 
-	res = request_mem_region(res->start, resource_size(res), pdev->name);
-	if (res == NULL)
-		return -EBUSY;
+	base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(base))
+		return PTR_ERR(base);
 
 	ret = omap_hsmmc_gpio_init(pdata);
 	if (ret)
@@ -1904,7 +1905,7 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
 	host->irq	= irq;
 	host->slot_id	= 0;
 	host->mapbase	= res->start + pdata->reg_offset;
-	host->base	= ioremap(host->mapbase, SZ_4K);
+	host->base	= base + pdata->reg_offset;
 	host->power_mode = MMC_POWER_OFF;
 	host->next_data.cookie = 1;
 	host->pbias_enabled = 0;
@@ -2104,21 +2105,16 @@ err_irq:
 	if (host->dbclk)
 		clk_disable_unprepare(host->dbclk);
 err1:
-	iounmap(host->base);
 	mmc_free_host(mmc);
 err_alloc:
 	omap_hsmmc_gpio_free(pdata);
 err:
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (res)
-		release_mem_region(res->start, resource_size(res));
 	return ret;
 }
 
 static int omap_hsmmc_remove(struct platform_device *pdev)
 {
 	struct omap_hsmmc_host *host = platform_get_drvdata(pdev);
-	struct resource *res;
 
 	pm_runtime_get_sync(host->dev);
 	mmc_remove_host(host->mmc);
@@ -2138,13 +2134,8 @@ static int omap_hsmmc_remove(struct platform_device *pdev)
 		clk_disable_unprepare(host->dbclk);
 
 	omap_hsmmc_gpio_free(host->pdata);
-	iounmap(host->base);
 	mmc_free_host(host->mmc);
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (res)
-		release_mem_region(res->start, resource_size(res));
-
 	return 0;
 }
 
Signature · 1 line
1.7.5.4
author
#11 lore raw

PATCH v2 5/6 mmc: omap_hsmmc: fix cmd23 multiblock read/write

In reply to Balaji T K

Check for set block count command fails always since host->cmd is set to NULL in the same function incorrectly. Correct host->cmd usage properly.

---
 drivers/mmc/host/omap_hsmmc.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/mmc/host/omap_hsmmc.c +3 -2
index 140425c..cba71d6 100644
@@ -920,16 +920,17 @@ omap_hsmmc_xfer_done(struct omap_hsmmc_host *host, struct mmc_data *data)
 static void
 omap_hsmmc_cmd_done(struct omap_hsmmc_host *host, struct mmc_command *cmd)
 {
-	host->cmd = NULL;
-
 	if (host->mrq->sbc && (host->cmd == host->mrq->sbc) &&
 	    !host->mrq->sbc->error && !(host->flags & AUTO_CMD23)) {
+		host->cmd = NULL;
 		omap_hsmmc_start_dma_transfer(host);
 		omap_hsmmc_start_command(host, host->mrq->cmd,
 						host->mrq->data);
 		return;
 	}
 
+	host->cmd = NULL;
+
 	if (cmd->flags & MMC_RSP_PRESENT) {
 		if (cmd->flags & MMC_RSP_136) {
 			/* response type 2 */
Signature · 1 line
1.7.5.4
author
#12 lore raw

PATCH v2 6/6 mmc: omap_hsmmc: split omap-dma header file

In reply to Balaji T K

moving dmaengine consumer specific function to omap-dmaengine.h
to Resolve build failure seen with sh-allmodconfig:
include/linux/omap-dma.h:171:8: error: expected identifier before numeric constant make[4]: *** [drivers/mmc/host/omap_hsmmc.o] Error 1

Cc Russell King - ARM Linux <[email protected]>
Cc Tony Lindgren <[email protected]>
---
 drivers/mmc/host/omap_hsmmc.c  |    2 +-
 include/linux/omap-dma.h       |   19 +------------------
 include/linux/omap-dmaengine.h |   21 +++++++++++++++++++++
 3 files changed, 23 insertions(+), 19 deletions(-)
 create mode 100644 include/linux/omap-dmaengine.h
drivers/mmc/host/omap_hsmmc.c +1 -1
index cba71d6..6b7b755 100644
@@ -31,7 +31,7 @@
 #include <linux/of.h>
 #include <linux/of_gpio.h>
 #include <linux/of_device.h>
-#include <linux/omap-dma.h>
+#include <linux/omap-dmaengine.h>
 #include <linux/mmc/host.h>
 #include <linux/mmc/core.h>
 #include <linux/mmc/mmc.h>
include/linux/omap-dma.h +1 -18
index 41a13e7..999f52d 100644
@@ -1,23 +1,6 @@
-/*
- * OMAP DMA Engine support
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
 #ifndef __LINUX_OMAP_DMA_H
 #define __LINUX_OMAP_DMA_H
-
-struct dma_chan;
-
-#if defined(CONFIG_DMA_OMAP) || defined(CONFIG_DMA_OMAP_MODULE)
-bool omap_dma_filter_fn(struct dma_chan *, void *);
-#else
-static inline bool omap_dma_filter_fn(struct dma_chan *c, void *d)
-{
-	return false;
-}
-#endif
+#include <linux/omap-dmaengine.h>
 
 /*
  *  Legacy OMAP DMA handling defines and functions
include/linux/omap-dmaengine.h new file +21 -0
new file mode 100644
index 0000000..2b0b6aa
@@ -0,0 +1,21 @@
+/*
+ * OMAP DMA Engine support
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#ifndef __LINUX_OMAP_DMAENGINE_H
+#define __LINUX_OMAP_DMAENGINE_H
+
+struct dma_chan;
+
+#if defined(CONFIG_DMA_OMAP) || defined(CONFIG_DMA_OMAP_MODULE)
+bool omap_dma_filter_fn(struct dma_chan *, void *);
+#else
+static inline bool omap_dma_filter_fn(struct dma_chan *c, void *d)
+{
+	return false;
+}
+#endif
+#endif /* __LINUX_OMAP_DMAENGINE_H */
Signature · 1 line
1.7.5.4
#2 lore raw

Re: [PATCH v2 1/6] mmc: omap_hsmmc: use devm_clk_get

In reply to Balaji T K
Quoted 30 lines · Balaji T K

With devm_clk_get conversion clk_put can be removed in clean up path

---
 drivers/mmc/host/omap_hsmmc.c |   15 ++++-----------
 1 files changed, 4 insertions(+), 11 deletions(-)
drivers/mmc/host/omap_hsmmc.c +2 -2
index b4de63b..b8ae7ee 100644
@@ -1922,7 +1922,7 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
 
        spin_lock_init(&host->irq_lock);
 
-       host->fclk = clk_get(&pdev->dev, "fck");
+       host->fclk = devm_clk_get(&pdev->dev, "fck");
        if (IS_ERR(host->fclk)) {
                ret = PTR_ERR(host->fclk);
                host->fclk = NULL;
@@ -1941,7 +1941,7 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
 
        omap_hsmmc_context_save(host);
 
-       host->dbclk = clk_get(&pdev->dev, "mmchsdb_fck");
+       host->dbclk = devm_clk_get(&pdev->dev, "mmchsdb_fck");
        /*
         * MMC can still work without debounce clock.
         */

drivers/mmc/host/omap_hsmmc.c static int omap_hsmmc_probe(struct platform_device *pdev) · line 1952

Quoted 5 lines
drivers/mmc/host/omap_hsmmc.c +0 -1
@@ -1949,7 +1949,6 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
                host->dbclk = NULL;
        } else if (clk_prepare_enable(host->dbclk) != 0) {
                dev_warn(mmc_dev(host->mmc), "Failed to enable debounce clk\n");
-               clk_put(host->dbclk);
                host->dbclk = NULL;

You should use the IS_ERR macro, no need to reset dbclk to NULL.

drivers/mmc/host/omap_hsmmc.c err_irq: · line 2107

Quoted 9 lines
drivers/mmc/host/omap_hsmmc.c +1 -2
        }
 
@@ -2105,11 +2104,8 @@ err_irq:
                dma_release_channel(host->rx_chan);
        pm_runtime_put_sync(host->dev);
        pm_runtime_disable(host->dev);
-       clk_put(host->fclk);
-       if (host->dbclk) {
+       if (host->dbclk)

Use IS_ERR instead.

drivers/mmc/host/omap_hsmmc.c static int omap_hsmmc_remove(struct platform_device *pdev) · line 2143

Quoted 13 lines
drivers/mmc/host/omap_hsmmc.c +1 -4
                clk_disable_unprepare(host->dbclk);
-               clk_put(host->dbclk);
-       }
 err1:
        iounmap(host->base);
        mmc_free_host(mmc);
@@ -2144,11 +2140,8 @@ static int omap_hsmmc_remove(struct platform_device *pdev)
 
        pm_runtime_put_sync(host->dev);
        pm_runtime_disable(host->dev);
-       clk_put(host->fclk);
-       if (host->dbclk) {
+       if (host->dbclk)

Use IS_ERR instead.

Quoted 9 lines
drivers/mmc/host/omap_hsmmc.c +0 -3
                clk_disable_unprepare(host->dbclk);
-               clk_put(host->dbclk);
-       }
 
        omap_hsmmc_gpio_free(host->pdata);
        iounmap(host->base);
--

1.7.5.4

Kind regards
Ulf Hansson

author
#3 lore raw

Re: [PATCH v2 1/6] mmc: omap_hsmmc: use devm_clk_get

Quoted 25 lines · Ulf Hansson
Quoted 24 lines · Balaji T K

With devm_clk_get conversion clk_put can be removed in clean up path

---
  drivers/mmc/host/omap_hsmmc.c |   15 ++++-----------
  1 files changed, 4 insertions(+), 11 deletions(-)
drivers/mmc/host/omap_hsmmc.c +1 -1
index b4de63b..b8ae7ee 100644
@@ -1922,7 +1922,7 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
 
         spin_lock_init(&host->irq_lock);
 
-       host->fclk = clk_get(&pdev->dev, "fck");
+       host->fclk = devm_clk_get(&pdev->dev, "fck");
         if (IS_ERR(host->fclk)) {
                 ret = PTR_ERR(host->fclk);
                 host->fclk = NULL;
@@ -1941,7 +1941,7 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
 
         omap_hsmmc_context_save(host);
 
Quoted 14 lines

drivers/mmc/host/omap_hsmmc.c static int omap_hsmmc_probe(struct platform_device *pdev) · line 1952

Quoted 11 lines
drivers/mmc/host/omap_hsmmc.c +1 -2
-       host->dbclk = clk_get(&pdev->dev, "mmchsdb_fck");
+       host->dbclk = devm_clk_get(&pdev->dev, "mmchsdb_fck");
         /*
          * MMC can still work without debounce clock.
          */
@@ -1949,7 +1949,6 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
                 host->dbclk = NULL;
         } else if (clk_prepare_enable(host->dbclk) != 0) {
                 dev_warn(mmc_dev(host->mmc), "Failed to enable debounce clk\n");
-               clk_put(host->dbclk);
                 host->dbclk = NULL;

You should use the IS_ERR macro, no need to reset dbclk to NULL.

Agreed, IS_ERR macro usage deserves patch on its own. will create separate patch on top of this series.

Thanks and Regards
Balaji T K

Quoted 41 lines

drivers/mmc/host/omap_hsmmc.c err_irq: · line 2107

Quoted 9 lines
drivers/mmc/host/omap_hsmmc.c +1 -2
         }
 
@@ -2105,11 +2104,8 @@ err_irq:
                 dma_release_channel(host->rx_chan);
         pm_runtime_put_sync(host->dev);
         pm_runtime_disable(host->dev);
-       clk_put(host->fclk);
-       if (host->dbclk) {
+       if (host->dbclk)

Use IS_ERR instead.

drivers/mmc/host/omap_hsmmc.c static int omap_hsmmc_remove(struct platform_device *pdev) · line 2143

Quoted 13 lines
drivers/mmc/host/omap_hsmmc.c +1 -4
                 clk_disable_unprepare(host->dbclk);
-               clk_put(host->dbclk);
-       }
  err1:
         iounmap(host->base);
         mmc_free_host(mmc);
@@ -2144,11 +2140,8 @@ static int omap_hsmmc_remove(struct platform_device *pdev)
 
         pm_runtime_put_sync(host->dev);
         pm_runtime_disable(host->dev);
-       clk_put(host->fclk);
-       if (host->dbclk) {
+       if (host->dbclk)

Use IS_ERR instead.

Quoted 9 lines
drivers/mmc/host/omap_hsmmc.c +0 -3
                 clk_disable_unprepare(host->dbclk);
-               clk_put(host->dbclk);
-       }
 
         omap_hsmmc_gpio_free(host->pdata);
         iounmap(host->base);
--

1.7.5.4

Kind regards
Ulf Hansson

#4 lore raw

Re: [PATCH v2 1/6] mmc: omap_hsmmc: use devm_clk_get

Quoted 49 lines · Balaji T K
Quoted 30 lines · Ulf Hansson
Quoted 28 lines · Balaji T K

With devm_clk_get conversion clk_put can be removed in clean up path

---
  drivers/mmc/host/omap_hsmmc.c |   15 ++++-----------
  1 files changed, 4 insertions(+), 11 deletions(-)
drivers/mmc/host/omap_hsmmc.c +1 -1
index b4de63b..b8ae7ee 100644
@@ -1922,7 +1922,7 @@ static int omap_hsmmc_probe(struct platform_device
 *pdev)
 
         spin_lock_init(&host->irq_lock);
 
-       host->fclk = clk_get(&pdev->dev, "fck");
+       host->fclk = devm_clk_get(&pdev->dev, "fck");
         if (IS_ERR(host->fclk)) {
                 ret = PTR_ERR(host->fclk);
                 host->fclk = NULL;
drivers/mmc/host/omap_hsmmc.c +0 -0
@@ -1941,7 +1941,7 @@ static int omap_hsmmc_probe(struct platform_device
 *pdev)
 
         omap_hsmmc_context_save(host);
 
Quoted 17 lines

drivers/mmc/host/omap_hsmmc.c static int omap_hsmmc_probe(struct platform_device · line 1954

Quoted 13 lines
drivers/mmc/host/omap_hsmmc.c +1 -1
-       host->dbclk = clk_get(&pdev->dev, "mmchsdb_fck");
+       host->dbclk = devm_clk_get(&pdev->dev, "mmchsdb_fck");
         /*
          * MMC can still work without debounce clock.
          */
drivers/mmc/host/omap_hsmmc.c +0 -1
@@ -1949,7 +1949,6 @@ static int omap_hsmmc_probe(struct platform_device
 *pdev)
                 host->dbclk = NULL;
         } else if (clk_prepare_enable(host->dbclk) != 0) {
                 dev_warn(mmc_dev(host->mmc), "Failed to enable debounce
 clk\n");
-               clk_put(host->dbclk);
                 host->dbclk = NULL;

You should use the IS_ERR macro, no need to reset dbclk to NULL.

Quoted 2 lines

Agreed, IS_ERR macro usage deserves patch on its own. will create separate patch on top of this series.

Or you just update this patch, since it would touch there very same piece of code. :-)

Kind regards
Ulf Hansson

author
#5 lore raw

PATCH 1/1 mmc: omap_hsmmc: use IS_ERR macro for error checking

Debounce clock is optional, use IS_ERR macro instead of NULL pointer check.

---
 drivers/mmc/host/omap_hsmmc.c |   18 +++++++-----------
 1 files changed, 7 insertions(+), 11 deletions(-)
drivers/mmc/host/omap_hsmmc.c +7 -11
index 6b7b755..521eec3 100644
@@ -1155,7 +1155,7 @@ static int omap_hsmmc_switch_opcond(struct omap_hsmmc_host *host, int vdd)
 
 	/* Disable the clocks */
 	pm_runtime_put_sync(host->dev);
-	if (host->dbclk)
+	if (!IS_ERR(host->dbclk))
 		clk_disable_unprepare(host->dbclk);
 
 	/* Turn the power off */
@@ -1166,7 +1166,7 @@ static int omap_hsmmc_switch_opcond(struct omap_hsmmc_host *host, int vdd)
 		ret = mmc_slot(host).set_power(host->dev, host->slot_id, 1,
 					       vdd);
 	pm_runtime_get_sync(host->dev);
-	if (host->dbclk)
+	if (!IS_ERR(host->dbclk))
 		clk_prepare_enable(host->dbclk);
 
 	if (ret != 0)
@@ -1947,12 +1947,8 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
 	/*
 	 * MMC can still work without debounce clock.
 	 */
-	if (IS_ERR(host->dbclk)) {
-		host->dbclk = NULL;
-	} else if (clk_prepare_enable(host->dbclk) != 0) {
+	if (!IS_ERR(host->dbclk) && clk_prepare_enable(host->dbclk))
 		dev_warn(mmc_dev(host->mmc), "Failed to enable debounce clk\n");
-		host->dbclk = NULL;
-	}
 
 	/* Since we do only SG emulation, we can have as many segs
 	 * as we want. */
@@ -2103,7 +2099,7 @@ err_irq:
 		dma_release_channel(host->rx_chan);
 	pm_runtime_put_sync(host->dev);
 	pm_runtime_disable(host->dev);
-	if (host->dbclk)
+	if (!IS_ERR(host->dbclk))
 		clk_disable_unprepare(host->dbclk);
 err1:
 	mmc_free_host(mmc);
@@ -2131,7 +2127,7 @@ static int omap_hsmmc_remove(struct platform_device *pdev)
 
 	pm_runtime_put_sync(host->dev);
 	pm_runtime_disable(host->dev);
-	if (host->dbclk)
+	if (!IS_ERR(host->dbclk))
 		clk_disable_unprepare(host->dbclk);
 
 	omap_hsmmc_gpio_free(host->pdata);
@@ -2175,7 +2171,7 @@ static int omap_hsmmc_suspend(struct device *dev)
 				OMAP_HSMMC_READ(host->base, HCTL) & ~SDBP);
 	}
 
-	if (host->dbclk)
+	if (!IS_ERR(host->dbclk))
 		clk_disable_unprepare(host->dbclk);
 
 	pm_runtime_put_sync(host->dev);
@@ -2192,7 +2188,7 @@ static int omap_hsmmc_resume(struct device *dev)
 
 	pm_runtime_get_sync(host->dev);
 
-	if (host->dbclk)
+	if (!IS_ERR(host->dbclk))
 		clk_prepare_enable(host->dbclk);
 
 	if (!(host->mmc->pm_flags & MMC_PM_KEEP_POWER))
Signature · 1 line
1.7.5.4
author
#7 lore raw

Re: [PATCH v2 1/6] mmc: omap_hsmmc: use devm_clk_get

In reply to Ulf Hansson
Quoted 50 lines · Ulf Hansson
Quoted 49 lines · Balaji T K
Quoted 47 lines · Ulf Hansson
Quoted 34 lines · Balaji T K

With devm_clk_get conversion clk_put can be removed in clean up path

---
   drivers/mmc/host/omap_hsmmc.c |   15 ++++-----------
   1 files changed, 4 insertions(+), 11 deletions(-)
drivers/mmc/host/omap_hsmmc.c +1 -1
index b4de63b..b8ae7ee 100644
@@ -1922,7 +1922,7 @@ static int omap_hsmmc_probe(struct platform_device
 *pdev)
 
          spin_lock_init(&host->irq_lock);
 
-       host->fclk = clk_get(&pdev->dev, "fck");
+       host->fclk = devm_clk_get(&pdev->dev, "fck");
          if (IS_ERR(host->fclk)) {
                  ret = PTR_ERR(host->fclk);
                  host->fclk = NULL;
drivers/mmc/host/omap_hsmmc.c +1 -1
@@ -1941,7 +1941,7 @@ static int omap_hsmmc_probe(struct platform_device
 *pdev)
 
          omap_hsmmc_context_save(host);
 
-       host->dbclk = clk_get(&pdev->dev, "mmchsdb_fck");
+       host->dbclk = devm_clk_get(&pdev->dev, "mmchsdb_fck");
          /*
           * MMC can still work without debounce clock.
           */

drivers/mmc/host/omap_hsmmc.c static int omap_hsmmc_probe(struct platform_device · line 1954

Quoted 7 lines
drivers/mmc/host/omap_hsmmc.c +0 -1
@@ -1949,7 +1949,6 @@ static int omap_hsmmc_probe(struct platform_device
 *pdev)
                  host->dbclk = NULL;
          } else if (clk_prepare_enable(host->dbclk) != 0) {
                  dev_warn(mmc_dev(host->mmc), "Failed to enable debounce
 clk\n");
-               clk_put(host->dbclk);
                  host->dbclk = NULL;

You should use the IS_ERR macro, no need to reset dbclk to NULL.

Quoted 5 lines
Quoted 2 lines

Agreed, IS_ERR macro usage deserves patch on its own. will create separate patch on top of this series.

Or you just update this patch, since it would touch there very same piece of code. :-)

plus few more code additionally, since these are two different logical changes, have sent a separate patch. But feel free to squash them if needed.

Thanks and Regards,
Balaji T K

author
#13 lore raw

Re: [PATCH v2 6/6] mmc: omap_hsmmc: split omap-dma header file

In reply to Balaji T K
Quoted 8 lines · Balaji T K

moving dmaengine consumer specific function to omap-dmaengine.h
to Resolve build failure seen with sh-allmodconfig:
include/linux/omap-dma.h:171:8: error: expected identifier before numeric constant make[4]: *** [drivers/mmc/host/omap_hsmmc.o] Error 1

Cc Russell King - ARM Linux <[email protected]>
Cc Tony Lindgren <[email protected]>

Hi Russell, Tony,

Since this patches touches omap dma header file, can you provide your comments / ack if it looks ok ?

Quoted 77 lines
---
  drivers/mmc/host/omap_hsmmc.c  |    2 +-
  include/linux/omap-dma.h       |   19 +------------------
  include/linux/omap-dmaengine.h |   21 +++++++++++++++++++++
  3 files changed, 23 insertions(+), 19 deletions(-)

create mode 100644 include/linux/omap-dmaengine.h

drivers/mmc/host/omap_hsmmc.c +1 -1
index cba71d6..6b7b755 100644
@@ -31,7 +31,7 @@
  #include <linux/of.h>
  #include <linux/of_gpio.h>
  #include <linux/of_device.h>
-#include <linux/omap-dma.h>
+#include <linux/omap-dmaengine.h>
  #include <linux/mmc/host.h>
  #include <linux/mmc/core.h>
  #include <linux/mmc/mmc.h>
include/linux/omap-dma.h +1 -18
index 41a13e7..999f52d 100644
@@ -1,23 +1,6 @@
-/*
- * OMAP DMA Engine support
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
  #ifndef __LINUX_OMAP_DMA_H
  #define __LINUX_OMAP_DMA_H
-
-struct dma_chan;
-
-#if defined(CONFIG_DMA_OMAP) || defined(CONFIG_DMA_OMAP_MODULE)
-bool omap_dma_filter_fn(struct dma_chan *, void *);
-#else
-static inline bool omap_dma_filter_fn(struct dma_chan *c, void *d)
-{
-	return false;
-}
-#endif
+#include <linux/omap-dmaengine.h>
 
  /*
   *  Legacy OMAP DMA handling defines and functions
include/linux/omap-dmaengine.h new file +21 -0
new file mode 100644
index 0000000..2b0b6aa
@@ -0,0 +1,21 @@
+/*
+ * OMAP DMA Engine support
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#ifndef __LINUX_OMAP_DMAENGINE_H
+#define __LINUX_OMAP_DMAENGINE_H
+
+struct dma_chan;
+
+#if defined(CONFIG_DMA_OMAP) || defined(CONFIG_DMA_OMAP_MODULE)
+bool omap_dma_filter_fn(struct dma_chan *, void *);
+#else
+static inline bool omap_dma_filter_fn(struct dma_chan *c, void *d)
+{
+	return false;
+}
+#endif
+#endif /* __LINUX_OMAP_DMAENGINE_H */
#14 lore raw

Re: [PATCH v2 6/6] mmc: omap_hsmmc: split omap-dma header file

In reply to Balaji T K
Quoted 44 lines · Balaji T K

moving dmaengine consumer specific function to omap-dmaengine.h
to Resolve build failure seen with sh-allmodconfig:
include/linux/omap-dma.h:171:8: error: expected identifier before numeric constant make[4]: *** [drivers/mmc/host/omap_hsmmc.o] Error 1

Cc Russell King - ARM Linux <[email protected]>
Cc Tony Lindgren <[email protected]>
---
 drivers/mmc/host/omap_hsmmc.c  |    2 +-
 include/linux/omap-dma.h       |   19 +------------------
 include/linux/omap-dmaengine.h |   21 +++++++++++++++++++++
 3 files changed, 23 insertions(+), 19 deletions(-)
 create mode 100644 include/linux/omap-dmaengine.h
drivers/mmc/host/omap_hsmmc.c +1 -1
index cba71d6..6b7b755 100644
@@ -31,7 +31,7 @@
 #include <linux/of.h>
 #include <linux/of_gpio.h>
 #include <linux/of_device.h>
-#include <linux/omap-dma.h>
+#include <linux/omap-dmaengine.h>
 #include <linux/mmc/host.h>
 #include <linux/mmc/core.h>
 #include <linux/mmc/mmc.h>
include/linux/omap-dma.h +0 -9
index 41a13e7..999f52d 100644
@@ -1,23 +1,6 @@
-/*
- * OMAP DMA Engine support
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
 #ifndef __LINUX_OMAP_DMA_H
 #define __LINUX_OMAP_DMA_H
-
-struct dma_chan;

include/linux/omap-dma.h line 3

Quoted 10 lines
include/linux/omap-dma.h +1 -9
-
-#if defined(CONFIG_DMA_OMAP) || defined(CONFIG_DMA_OMAP_MODULE)
-bool omap_dma_filter_fn(struct dma_chan *, void *);
-#else
-static inline bool omap_dma_filter_fn(struct dma_chan *c, void *d)
-{
-	return false;
-}
-#endif
+#include <linux/omap-dmaengine.h>

Can't the drivers needing this include it directly?

Also, has this been tested with make randconfig? Changes like this can easily cause problems elsewhere..

Regards,

Tony

Quoted 32 lines
include/linux/omap-dma.h +0 -0
 /*
  *  Legacy OMAP DMA handling defines and functions
include/linux/omap-dmaengine.h new file +21 -0
new file mode 100644
index 0000000..2b0b6aa
@@ -0,0 +1,21 @@
+/*
+ * OMAP DMA Engine support
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#ifndef __LINUX_OMAP_DMAENGINE_H
+#define __LINUX_OMAP_DMAENGINE_H
+
+struct dma_chan;
+
+#if defined(CONFIG_DMA_OMAP) || defined(CONFIG_DMA_OMAP_MODULE)
+bool omap_dma_filter_fn(struct dma_chan *, void *);
+#else
+static inline bool omap_dma_filter_fn(struct dma_chan *c, void *d)
+{
+	return false;
+}
+#endif
+#endif /* __LINUX_OMAP_DMAENGINE_H */
Signature · 1 line
1.7.5.4
author
#15 lore raw

Re: [PATCH v2 6/6] mmc: omap_hsmmc: split omap-dma header file

Quoted 49 lines · Tony Lindgren
Quoted 48 lines · Balaji T K

moving dmaengine consumer specific function to omap-dmaengine.h
to Resolve build failure seen with sh-allmodconfig:
include/linux/omap-dma.h:171:8: error: expected identifier before numeric constant make[4]: *** [drivers/mmc/host/omap_hsmmc.o] Error 1

Cc Russell King - ARM Linux <[email protected]>
Cc Tony Lindgren <[email protected]>
---
  drivers/mmc/host/omap_hsmmc.c  |    2 +-
  include/linux/omap-dma.h       |   19 +------------------
  include/linux/omap-dmaengine.h |   21 +++++++++++++++++++++
  3 files changed, 23 insertions(+), 19 deletions(-)

create mode 100644 include/linux/omap-dmaengine.h

drivers/mmc/host/omap_hsmmc.c +1 -1
index cba71d6..6b7b755 100644
@@ -31,7 +31,7 @@
  #include <linux/of.h>
  #include <linux/of_gpio.h>
  #include <linux/of_device.h>
-#include <linux/omap-dma.h>
+#include <linux/omap-dmaengine.h>
  #include <linux/mmc/host.h>
  #include <linux/mmc/core.h>
  #include <linux/mmc/mmc.h>
include/linux/omap-dma.h +0 -13
index 41a13e7..999f52d 100644
@@ -1,23 +1,6 @@
-/*
- * OMAP DMA Engine support
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
  #ifndef __LINUX_OMAP_DMA_H
  #define __LINUX_OMAP_DMA_H
-
-struct dma_chan;
-
-#if defined(CONFIG_DMA_OMAP) || defined(CONFIG_DMA_OMAP_MODULE)
-bool omap_dma_filter_fn(struct dma_chan *, void *);
-#else
Quoted 9 lines

include/linux/omap-dma.h line 3

Quoted 6 lines
include/linux/omap-dma.h +1 -5
-static inline bool omap_dma_filter_fn(struct dma_chan *c, void *d)
-{
-	return false;
-}
-#endif
+#include <linux/omap-dmaengine.h>

Can't the drivers needing this include it directly?

Yes, I have converted omap_hsmmc as part of this patch.
Due to lack of bandwidth, I haven't touched upon all other drivers that include omap-dma.h. Once that is done in other subsystem after this patch gets merged, this include can then be removed from omap-dma.h

Quoted 2 lines

Also, has this been tested with make randconfig? Changes like this can easily cause problems elsewhere..

May be I am missing something, Can you please elaborate ? This patch is based on the discussion [1]
I just moved the dma consumer specific things needed by users to a separate file and include the same file in place so that other users can be converted one at a time.

[1]
https://lkml.org/lkml/2014/1/19/16

Quoted 37 lines

Regards,

Tony

Quoted 32 lines
include/linux/omap-dma.h +0 -0
  /*
   *  Legacy OMAP DMA handling defines and functions
include/linux/omap-dmaengine.h new file +21 -1
new file mode 100644
index 0000000..2b0b6aa
@@ -0,0 +1,21 @@
+/*
+ * OMAP DMA Engine support
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#ifndef __LINUX_OMAP_DMAENGINE_H
+#define __LINUX_OMAP_DMAENGINE_H
+
+struct dma_chan;
+
+#if defined(CONFIG_DMA_OMAP) || defined(CONFIG_DMA_OMAP_MODULE)
+bool omap_dma_filter_fn(struct dma_chan *, void *);
+#else
+static inline bool omap_dma_filter_fn(struct dma_chan *c, void *d)
+{
+	return false;
+}
+#endif
+#endif /* __LINUX_OMAP_DMAENGINE_H */
--

1.7.5.4

#16 lore raw

Re: [PATCH v2 6/6] mmc: omap_hsmmc: split omap-dma header file

Quoted 15 lines · Balaji T K
Quoted 4 lines · Tony Lindgren
Quoted 4 lines
include/linux/omap-dma.h +0 -4
-
-#if defined(CONFIG_DMA_OMAP) || defined(CONFIG_DMA_OMAP_MODULE)
-bool omap_dma_filter_fn(struct dma_chan *, void *);
-#else
Quoted 9 lines

include/linux/omap-dma.h line 3

Quoted 6 lines
include/linux/omap-dma.h +1 -5
-static inline bool omap_dma_filter_fn(struct dma_chan *c, void *d)
-{
-	return false;
-}
-#endif
+#include <linux/omap-dmaengine.h>

Can't the drivers needing this include it directly?

Quoted 4 lines

Yes, I have converted omap_hsmmc as part of this patch.
Due to lack of bandwidth, I haven't touched upon all other drivers that include omap-dma.h. Once that is done in other subsystem after this patch gets merged, this include can then be removed from omap-dma.h

OK

Quoted 4 lines
Quoted 2 lines

Also, has this been tested with make randconfig? Changes like this can easily cause problems elsewhere..

May be I am missing something, Can you please elaborate ?

You're touching a header included in many places, so you need to make sure you're not accidentally breaking anything.

There's an option that allows you to specify some selected options like CONFIG_ARCH_OMAP2PLUS=y with KCONFIG_ALLCONFIG and then run make randconfig. This should expose quite fast if there are some issues for the other drivers.

Also, have you compile tested this with omap1_defconfig?

Regards,

Tony

author
#17 lore raw

Re: [PATCH v2 6/6] mmc: omap_hsmmc: split omap-dma header file

Quoted 23 lines · Tony Lindgren
Quoted 15 lines · Balaji T K
Quoted 4 lines · Tony Lindgren
Quoted 4 lines
include/linux/omap-dma.h +0 -4
-
-#if defined(CONFIG_DMA_OMAP) || defined(CONFIG_DMA_OMAP_MODULE)
-bool omap_dma_filter_fn(struct dma_chan *, void *);
-#else
Quoted 9 lines

include/linux/omap-dma.h line 3

Quoted 6 lines
include/linux/omap-dma.h +1 -5
-static inline bool omap_dma_filter_fn(struct dma_chan *c, void *d)
-{
-	return false;
-}
-#endif
+#include <linux/omap-dmaengine.h>

Can't the drivers needing this include it directly?

Quoted 4 lines

Yes, I have converted omap_hsmmc as part of this patch.
Due to lack of bandwidth, I haven't touched upon all other drivers that include omap-dma.h. Once that is done in other subsystem after this patch gets merged, this include can then be removed from omap-dma.h

OK

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

Also, has this been tested with make randconfig? Changes like this can easily cause problems elsewhere..

May be I am missing something, Can you please elaborate ?

You're touching a header included in many places, so you need to make sure you're not accidentally breaking anything.

True

Quoted 7 lines

There's an option that allows you to specify some selected options like CONFIG_ARCH_OMAP2PLUS=y with KCONFIG_ALLCONFIG and then run make randconfig. This should expose quite fast if there are some issues for the other drivers.

Also, have you compile tested this with omap1_defconfig?

checked omap1_defconfig and randconfig's, both are OK.

Thanks and Regards,
Balaji T K

Acked-by
#18 lore raw

Re: [PATCH v2 6/6] mmc: omap_hsmmc: split omap-dma header file

Quoted 40 lines · Balaji T K
Quoted 23 lines · Tony Lindgren
Quoted 15 lines · Balaji T K
Quoted 4 lines · Tony Lindgren
Quoted 4 lines
include/linux/omap-dma.h +0 -4
-
-#if defined(CONFIG_DMA_OMAP) || defined(CONFIG_DMA_OMAP_MODULE)
-bool omap_dma_filter_fn(struct dma_chan *, void *);
-#else
Quoted 9 lines

include/linux/omap-dma.h line 3

Quoted 6 lines
include/linux/omap-dma.h +1 -5
-static inline bool omap_dma_filter_fn(struct dma_chan *c, void *d)
-{
-	return false;
-}
-#endif
+#include <linux/omap-dmaengine.h>

Can't the drivers needing this include it directly?

Quoted 4 lines

Yes, I have converted omap_hsmmc as part of this patch.
Due to lack of bandwidth, I haven't touched upon all other drivers that include omap-dma.h. Once that is done in other subsystem after this patch gets merged, this include can then be removed from omap-dma.h

OK

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

Also, has this been tested with make randconfig? Changes like this can easily cause problems elsewhere..

May be I am missing something, Can you please elaborate ?

You're touching a header included in many places, so you need to make sure you're not accidentally breaking anything.

True

Quoted 5 lines

There's an option that allows you to specify some selected options like CONFIG_ARCH_OMAP2PLUS=y with KCONFIG_ALLCONFIG and then run make randconfig. This should expose quite fast if there are some issues for the other drivers.

Quoted 4 lines
Quoted 2 lines

Also, have you compile tested this with omap1_defconfig?

checked omap1_defconfig and randconfig's, both are OK.

OK thanks:

#19 lore raw
In reply to Balaji T K
Quoted 12 lines · Balaji T K

v2:
use devm_ioremap_resource
add cmd23 multiblock read/write fix

Balaji T K (6):
mmc: omap_hsmmc: use devm_clk_get
mmc: omap_hsmmc: use devm_request_irq
mmc: omap_hsmmc: use devm_request_threaded_irq
mmc: omap_hsmmc: use devm_ioremap_resource
mmc: omap_hsmmc: fix cmd23 multiblock read/write
mmc: omap_hsmmc: split omap-dma header file

Quoted 6 lines
 drivers/mmc/host/omap_hsmmc.c  |   57 ++++++++++++---------------------------
 include/linux/omap-dma.h       |   19 +------------
 include/linux/omap-dmaengine.h |   21 ++++++++++++++
 3 files changed, 40 insertions(+), 57 deletions(-)
 create mode 100644 include/linux/omap-dmaengine.h

Thanks Balaji,

I will include this patchset in the next PR I send to Chris.

Kind regards
Ulf Hansson

Quoted 3 lines

--
1.7.5.4

#6 lore raw

Re: [PATCH] mmc: omap_hsmmc: use IS_ERR macro for error checking

In reply to Balaji T K
Quoted 3 lines · Balaji T K

Debounce clock is optional, use IS_ERR macro instead of NULL pointer check.

Thanks Balaji,

I will include this in the next PR I send to Chris.

Kind regards
Ulf Hansson