mmc: omap_hsmmc: Kill off cover detection

Message ID 20180924091959.8587-1-linus.walleij@linaro.org
State New
Headers show
Series
  • mmc: omap_hsmmc: Kill off cover detection
Related show

Commit Message

Linus Walleij Sept. 24, 2018, 9:19 a.m.
Cover detection appears to be a feature protecting the SD
card on mobile phones with a slide-cover, such as some Nokia
phones. The idea seems to be to not allow access to the
SD card when the cover is open.

It is only usable with platform data from board files, but
no board file in the kernel is using it, yet it takes up
a sizeable chunk of code in the OMAP HSMMC driver.

Since we do not add new board files for the OMAPs any target
that need this should anyway reimplement it properly using
the device tree, so delete this legacy code.

The driver is marked as orphan in MAINTAINERS by the way.

Cc: Tony Lindgren <tony@atomide.com>
Cc: linux-omap@vger.kernel.org
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

---
 drivers/mmc/host/omap_hsmmc.c            | 120 +----------------------
 include/linux/platform_data/hsmmc-omap.h |   1 -
 2 files changed, 2 insertions(+), 119 deletions(-)

-- 
2.17.1

Comments

kbuild test robot Sept. 25, 2018, 6:44 a.m. | #1
Hi Linus,

I love your patch! Yet something to improve:

[auto build test ERROR on ulf.hansson-mmc/next]
[also build test ERROR on v4.19-rc5 next-20180925]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Linus-Walleij/mmc-omap_hsmmc-Kill-off-cover-detection/20180925-092420
base:   git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc.git next
config: i386-allmodconfig (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All errors (new ones prefixed by >>):

   drivers/mmc/host/omap_hsmmc.c: In function 'omap_hsmmc_resume':
>> drivers/mmc/host/omap_hsmmc.c:2118:2: error: implicit declaration of function 'omap_hsmmc_protect_card'; did you mean 'omap_hsmmc_init_card'? [-Werror=implicit-function-declaration]

     omap_hsmmc_protect_card(host);
     ^~~~~~~~~~~~~~~~~~~~~~~
     omap_hsmmc_init_card
   cc1: some warnings being treated as errors

vim +2118 drivers/mmc/host/omap_hsmmc.c

a45c6cb81 Madhusudhan Chikkature 2009-01-23  2101  
a45c6cb81 Madhusudhan Chikkature 2009-01-23  2102  /* Routine to resume the MMC device */
a791daa15 Kevin Hilman           2010-05-26  2103  static int omap_hsmmc_resume(struct device *dev)
a45c6cb81 Madhusudhan Chikkature 2009-01-23  2104  {
927ce944a Felipe Balbi           2012-03-14  2105  	struct omap_hsmmc_host *host = dev_get_drvdata(dev);
927ce944a Felipe Balbi           2012-03-14  2106  
927ce944a Felipe Balbi           2012-03-14  2107  	if (!host)
927ce944a Felipe Balbi           2012-03-14  2108  		return 0;
a45c6cb81 Madhusudhan Chikkature 2009-01-23  2109  
fa4aa2d48 Balaji T K             2011-07-01  2110  	pm_runtime_get_sync(host->dev);
11dd62a74 Denis Karpov           2009-09-22  2111  
cd03d9a85 Rajendra Nayak         2012-04-09  2112  	if (host->dbclk)
94c181494 Rajendra Nayak         2012-06-27  2113  		clk_prepare_enable(host->dbclk);
2bec08937 Adrian Hunter          2009-09-22  2114  
31f9d4635 Eliad Peller           2011-11-22  2115  	if (!(host->mmc->pm_flags & MMC_PM_KEEP_POWER))
70a3341a7 Denis Karpov           2009-09-22  2116  		omap_hsmmc_conf_bus_power(host);
1b331e69a Kim Kyuwon             2009-02-20  2117  
b62f62281 Adrian Hunter          2009-09-22 @2118  	omap_hsmmc_protect_card(host);
fa4aa2d48 Balaji T K             2011-07-01  2119  	pm_runtime_mark_last_busy(host->dev);
fa4aa2d48 Balaji T K             2011-07-01  2120  	pm_runtime_put_autosuspend(host->dev);
3932afd51 Ulf Hansson            2013-09-25  2121  	return 0;
a45c6cb81 Madhusudhan Chikkature 2009-01-23  2122  }
a45c6cb81 Madhusudhan Chikkature 2009-01-23  2123  #endif
a45c6cb81 Madhusudhan Chikkature 2009-01-23  2124  

:::::: The code at line 2118 was first introduced by commit
:::::: b62f622812c5aaacad217fd8f4445562b917df6d omap_hsmmc: protect the card when the cover is open

:::::: TO: Adrian Hunter <adrian.hunter@nokia.com>
:::::: CC: Linus Torvalds <torvalds@linux-foundation.org>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
Linus Walleij Sept. 25, 2018, 6:50 a.m. | #2
On Tue, Sep 25, 2018 at 8:47 AM kbuild test robot <lkp@intel.com> wrote:

> I love your patch! Yet something to improve:

(...)
>    drivers/mmc/host/omap_hsmmc.c: In function 'omap_hsmmc_resume':

> >> drivers/mmc/host/omap_hsmmc.c:2118:2: error: implicit declaration of function 'omap_hsmmc_protect_card'; did you mean 'omap_hsmmc_init_card'? [-Werror=implicit-function-declaration]

>      omap_hsmmc_protect_card(host);

>      ^~~~~~~~~~~~~~~~~~~~~~~


Already fixed in the v2 patch.

Yours,
Linus Walleij

Patch

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 071693ebfe18..bfa803d337a4 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -198,7 +198,6 @@  struct omap_hsmmc_host {
 	struct dma_chan		*rx_chan;
 	int			response_busy;
 	int			context_loss;
-	int			protect_card;
 	int			reqs_blocked;
 	int			req_in_progress;
 	unsigned long		clk_rate;
@@ -207,15 +206,6 @@  struct omap_hsmmc_host {
 #define HSMMC_SDIO_IRQ_ENABLED	(1 << 1)        /* SDIO irq enabled */
 	struct omap_hsmmc_next	next_data;
 	struct	omap_hsmmc_platform_data	*pdata;
-
-	/* return MMC cover switch state, can be NULL if not supported.
-	 *
-	 * possible return values:
-	 *   0 - closed
-	 *   1 - open
-	 */
-	int (*get_cover_state)(struct device *dev);
-
 	int (*card_detect)(struct device *dev);
 };
 
@@ -233,13 +223,6 @@  static int omap_hsmmc_card_detect(struct device *dev)
 	return mmc_gpio_get_cd(host->mmc);
 }
 
-static int omap_hsmmc_get_cover_state(struct device *dev)
-{
-	struct omap_hsmmc_host *host = dev_get_drvdata(dev);
-
-	return mmc_gpio_get_cd(host->mmc);
-}
-
 static int omap_hsmmc_enable_supply(struct mmc_host *mmc)
 {
 	int ret;
@@ -484,22 +467,13 @@  static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
 	return 0;
 }
 
-static irqreturn_t omap_hsmmc_cover_irq(int irq, void *dev_id);
-
 static int omap_hsmmc_gpio_init(struct mmc_host *mmc,
 				struct omap_hsmmc_host *host,
 				struct omap_hsmmc_platform_data *pdata)
 {
 	int ret;
 
-	if (gpio_is_valid(pdata->gpio_cod)) {
-		ret = mmc_gpio_request_cd(mmc, pdata->gpio_cod, 0);
-		if (ret)
-			return ret;
-
-		host->get_cover_state = omap_hsmmc_get_cover_state;
-		mmc_gpio_set_cd_isr(mmc, omap_hsmmc_cover_irq);
-	} else if (gpio_is_valid(pdata->gpio_cd)) {
+	if (gpio_is_valid(pdata->gpio_cd)) {
 		ret = mmc_gpio_request_cd(mmc, pdata->gpio_cd, 0);
 		if (ret)
 			return ret;
@@ -781,9 +755,6 @@  static void send_init_stream(struct omap_hsmmc_host *host)
 	int reg = 0;
 	unsigned long timeout;
 
-	if (host->protect_card)
-		return;
-
 	disable_irq(host->irq);
 
 	OMAP_HSMMC_WRITE(host->base, IE, INT_EN_MASK);
@@ -804,29 +775,6 @@  static void send_init_stream(struct omap_hsmmc_host *host)
 	enable_irq(host->irq);
 }
 
-static inline
-int omap_hsmmc_cover_is_closed(struct omap_hsmmc_host *host)
-{
-	int r = 1;
-
-	if (host->get_cover_state)
-		r = host->get_cover_state(host->dev);
-	return r;
-}
-
-static ssize_t
-omap_hsmmc_show_cover_switch(struct device *dev, struct device_attribute *attr,
-			   char *buf)
-{
-	struct mmc_host *mmc = container_of(dev, struct mmc_host, class_dev);
-	struct omap_hsmmc_host *host = mmc_priv(mmc);
-
-	return sprintf(buf, "%s\n",
-			omap_hsmmc_cover_is_closed(host) ? "closed" : "open");
-}
-
-static DEVICE_ATTR(cover_switch, S_IRUGO, omap_hsmmc_show_cover_switch, NULL);
-
 static ssize_t
 omap_hsmmc_show_slot_name(struct device *dev, struct device_attribute *attr,
 			char *buf)
@@ -1247,44 +1195,6 @@  static int omap_hsmmc_switch_opcond(struct omap_hsmmc_host *host, int vdd)
 	return ret;
 }
 
-/* Protect the card while the cover is open */
-static void omap_hsmmc_protect_card(struct omap_hsmmc_host *host)
-{
-	if (!host->get_cover_state)
-		return;
-
-	host->reqs_blocked = 0;
-	if (host->get_cover_state(host->dev)) {
-		if (host->protect_card) {
-			dev_info(host->dev, "%s: cover is closed, "
-					 "card is now accessible\n",
-					 mmc_hostname(host->mmc));
-			host->protect_card = 0;
-		}
-	} else {
-		if (!host->protect_card) {
-			dev_info(host->dev, "%s: cover is open, "
-					 "card is now inaccessible\n",
-					 mmc_hostname(host->mmc));
-			host->protect_card = 1;
-		}
-	}
-}
-
-/*
- * irq handler when (cell-phone) cover is mounted/removed
- */
-static irqreturn_t omap_hsmmc_cover_irq(int irq, void *dev_id)
-{
-	struct omap_hsmmc_host *host = dev_id;
-
-	sysfs_notify(&host->mmc->class_dev.kobj, NULL, "cover_switch");
-
-	omap_hsmmc_protect_card(host);
-	mmc_detect_change(host->mmc, (HZ * 200) / 1000);
-	return IRQ_HANDLED;
-}
-
 static void omap_hsmmc_dma_callback(void *param)
 {
 	struct omap_hsmmc_host *host = param;
@@ -1555,24 +1465,7 @@  static void omap_hsmmc_request(struct mmc_host *mmc, struct mmc_request *req)
 
 	BUG_ON(host->req_in_progress);
 	BUG_ON(host->dma_ch != -1);
-	if (host->protect_card) {
-		if (host->reqs_blocked < 3) {
-			/*
-			 * Ensure the controller is left in a consistent
-			 * state by resetting the command and data state
-			 * machines.
-			 */
-			omap_hsmmc_reset_controller_fsm(host, SRD);
-			omap_hsmmc_reset_controller_fsm(host, SRC);
-			host->reqs_blocked += 1;
-		}
-		req->cmd->error = -EBADF;
-		if (req->data)
-			req->data->error = -EBADF;
-		req->cmd->retries = 0;
-		mmc_request_done(mmc, req);
-		return;
-	} else if (host->reqs_blocked)
+	if (host->reqs_blocked)
 		host->reqs_blocked = 0;
 	WARN_ON(host->mrq != NULL);
 	host->mrq = req;
@@ -1921,7 +1814,6 @@  static struct omap_hsmmc_platform_data *of_get_hsmmc_pdata(struct device *dev)
 		pdata->controller_flags |= OMAP_HSMMC_SUPPORTS_DUAL_VOLT;
 
 	pdata->gpio_cd = -EINVAL;
-	pdata->gpio_cod = -EINVAL;
 	pdata->gpio_wp = -EINVAL;
 
 	if (of_find_property(np, "ti,non-removable", NULL)) {
@@ -2125,8 +2017,6 @@  static int omap_hsmmc_probe(struct platform_device *pdev)
 	if (!ret)
 		mmc->caps |= MMC_CAP_SDIO_IRQ;
 
-	omap_hsmmc_protect_card(host);
-
 	mmc_add_host(mmc);
 
 	if (mmc_pdata(host)->name != NULL) {
@@ -2134,12 +2024,6 @@  static int omap_hsmmc_probe(struct platform_device *pdev)
 		if (ret < 0)
 			goto err_slot_name;
 	}
-	if (host->get_cover_state) {
-		ret = device_create_file(&mmc->class_dev,
-					 &dev_attr_cover_switch);
-		if (ret < 0)
-			goto err_slot_name;
-	}
 
 	omap_hsmmc_debugfs(mmc);
 	pm_runtime_mark_last_busy(host->dev);
diff --git a/include/linux/platform_data/hsmmc-omap.h b/include/linux/platform_data/hsmmc-omap.h
index 73d9098ada2d..c055d7eda085 100644
--- a/include/linux/platform_data/hsmmc-omap.h
+++ b/include/linux/platform_data/hsmmc-omap.h
@@ -71,7 +71,6 @@  struct omap_hsmmc_platform_data {
 	char *version;
 
 	int gpio_cd;			/* gpio (card detect) */
-	int gpio_cod;			/* gpio (cover detect) */
 	int gpio_wp;			/* gpio (write protect) */
 	/* if we have special card, init it using this callback */
 	void (*init_card)(struct mmc_card *card);