Skip to content

Commit 7838a8d

Browse files
linuswstorulf
authored andcommitted
mmc: omap_hsmmc: Kill off cover detection
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> Acked-by: Tony Lindgren <tony@atomide.com> Acked-by: Kishon Vijay Abraham I <kishon@ti.com> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent ac379b7 commit 7838a8d

File tree

2 files changed

+2
-120
lines changed

2 files changed

+2
-120
lines changed

drivers/mmc/host/omap_hsmmc.c

Lines changed: 2 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ struct omap_hsmmc_host {
198198
struct dma_chan *rx_chan;
199199
int response_busy;
200200
int context_loss;
201-
int protect_card;
202201
int reqs_blocked;
203202
int req_in_progress;
204203
unsigned long clk_rate;
@@ -207,15 +206,6 @@ struct omap_hsmmc_host {
207206
#define HSMMC_SDIO_IRQ_ENABLED (1 << 1) /* SDIO irq enabled */
208207
struct omap_hsmmc_next next_data;
209208
struct omap_hsmmc_platform_data *pdata;
210-
211-
/* return MMC cover switch state, can be NULL if not supported.
212-
*
213-
* possible return values:
214-
* 0 - closed
215-
* 1 - open
216-
*/
217-
int (*get_cover_state)(struct device *dev);
218-
219209
int (*card_detect)(struct device *dev);
220210
};
221211

@@ -233,13 +223,6 @@ static int omap_hsmmc_card_detect(struct device *dev)
233223
return mmc_gpio_get_cd(host->mmc);
234224
}
235225

236-
static int omap_hsmmc_get_cover_state(struct device *dev)
237-
{
238-
struct omap_hsmmc_host *host = dev_get_drvdata(dev);
239-
240-
return mmc_gpio_get_cd(host->mmc);
241-
}
242-
243226
static int omap_hsmmc_enable_supply(struct mmc_host *mmc)
244227
{
245228
int ret;
@@ -484,22 +467,13 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
484467
return 0;
485468
}
486469

487-
static irqreturn_t omap_hsmmc_cover_irq(int irq, void *dev_id);
488-
489470
static int omap_hsmmc_gpio_init(struct mmc_host *mmc,
490471
struct omap_hsmmc_host *host,
491472
struct omap_hsmmc_platform_data *pdata)
492473
{
493474
int ret;
494475

495-
if (gpio_is_valid(pdata->gpio_cod)) {
496-
ret = mmc_gpio_request_cd(mmc, pdata->gpio_cod, 0);
497-
if (ret)
498-
return ret;
499-
500-
host->get_cover_state = omap_hsmmc_get_cover_state;
501-
mmc_gpio_set_cd_isr(mmc, omap_hsmmc_cover_irq);
502-
} else if (gpio_is_valid(pdata->gpio_cd)) {
476+
if (gpio_is_valid(pdata->gpio_cd)) {
503477
ret = mmc_gpio_request_cd(mmc, pdata->gpio_cd, 0);
504478
if (ret)
505479
return ret;
@@ -781,9 +755,6 @@ static void send_init_stream(struct omap_hsmmc_host *host)
781755
int reg = 0;
782756
unsigned long timeout;
783757

784-
if (host->protect_card)
785-
return;
786-
787758
disable_irq(host->irq);
788759

789760
OMAP_HSMMC_WRITE(host->base, IE, INT_EN_MASK);
@@ -804,29 +775,6 @@ static void send_init_stream(struct omap_hsmmc_host *host)
804775
enable_irq(host->irq);
805776
}
806777

807-
static inline
808-
int omap_hsmmc_cover_is_closed(struct omap_hsmmc_host *host)
809-
{
810-
int r = 1;
811-
812-
if (host->get_cover_state)
813-
r = host->get_cover_state(host->dev);
814-
return r;
815-
}
816-
817-
static ssize_t
818-
omap_hsmmc_show_cover_switch(struct device *dev, struct device_attribute *attr,
819-
char *buf)
820-
{
821-
struct mmc_host *mmc = container_of(dev, struct mmc_host, class_dev);
822-
struct omap_hsmmc_host *host = mmc_priv(mmc);
823-
824-
return sprintf(buf, "%s\n",
825-
omap_hsmmc_cover_is_closed(host) ? "closed" : "open");
826-
}
827-
828-
static DEVICE_ATTR(cover_switch, S_IRUGO, omap_hsmmc_show_cover_switch, NULL);
829-
830778
static ssize_t
831779
omap_hsmmc_show_slot_name(struct device *dev, struct device_attribute *attr,
832780
char *buf)
@@ -1247,44 +1195,6 @@ static int omap_hsmmc_switch_opcond(struct omap_hsmmc_host *host, int vdd)
12471195
return ret;
12481196
}
12491197

1250-
/* Protect the card while the cover is open */
1251-
static void omap_hsmmc_protect_card(struct omap_hsmmc_host *host)
1252-
{
1253-
if (!host->get_cover_state)
1254-
return;
1255-
1256-
host->reqs_blocked = 0;
1257-
if (host->get_cover_state(host->dev)) {
1258-
if (host->protect_card) {
1259-
dev_info(host->dev, "%s: cover is closed, "
1260-
"card is now accessible\n",
1261-
mmc_hostname(host->mmc));
1262-
host->protect_card = 0;
1263-
}
1264-
} else {
1265-
if (!host->protect_card) {
1266-
dev_info(host->dev, "%s: cover is open, "
1267-
"card is now inaccessible\n",
1268-
mmc_hostname(host->mmc));
1269-
host->protect_card = 1;
1270-
}
1271-
}
1272-
}
1273-
1274-
/*
1275-
* irq handler when (cell-phone) cover is mounted/removed
1276-
*/
1277-
static irqreturn_t omap_hsmmc_cover_irq(int irq, void *dev_id)
1278-
{
1279-
struct omap_hsmmc_host *host = dev_id;
1280-
1281-
sysfs_notify(&host->mmc->class_dev.kobj, NULL, "cover_switch");
1282-
1283-
omap_hsmmc_protect_card(host);
1284-
mmc_detect_change(host->mmc, (HZ * 200) / 1000);
1285-
return IRQ_HANDLED;
1286-
}
1287-
12881198
static void omap_hsmmc_dma_callback(void *param)
12891199
{
12901200
struct omap_hsmmc_host *host = param;
@@ -1555,24 +1465,7 @@ static void omap_hsmmc_request(struct mmc_host *mmc, struct mmc_request *req)
15551465

15561466
BUG_ON(host->req_in_progress);
15571467
BUG_ON(host->dma_ch != -1);
1558-
if (host->protect_card) {
1559-
if (host->reqs_blocked < 3) {
1560-
/*
1561-
* Ensure the controller is left in a consistent
1562-
* state by resetting the command and data state
1563-
* machines.
1564-
*/
1565-
omap_hsmmc_reset_controller_fsm(host, SRD);
1566-
omap_hsmmc_reset_controller_fsm(host, SRC);
1567-
host->reqs_blocked += 1;
1568-
}
1569-
req->cmd->error = -EBADF;
1570-
if (req->data)
1571-
req->data->error = -EBADF;
1572-
req->cmd->retries = 0;
1573-
mmc_request_done(mmc, req);
1574-
return;
1575-
} else if (host->reqs_blocked)
1468+
if (host->reqs_blocked)
15761469
host->reqs_blocked = 0;
15771470
WARN_ON(host->mrq != NULL);
15781471
host->mrq = req;
@@ -1921,7 +1814,6 @@ static struct omap_hsmmc_platform_data *of_get_hsmmc_pdata(struct device *dev)
19211814
pdata->controller_flags |= OMAP_HSMMC_SUPPORTS_DUAL_VOLT;
19221815

19231816
pdata->gpio_cd = -EINVAL;
1924-
pdata->gpio_cod = -EINVAL;
19251817
pdata->gpio_wp = -EINVAL;
19261818

19271819
if (of_find_property(np, "ti,non-removable", NULL)) {
@@ -2125,21 +2017,13 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
21252017
if (!ret)
21262018
mmc->caps |= MMC_CAP_SDIO_IRQ;
21272019

2128-
omap_hsmmc_protect_card(host);
2129-
21302020
mmc_add_host(mmc);
21312021

21322022
if (mmc_pdata(host)->name != NULL) {
21332023
ret = device_create_file(&mmc->class_dev, &dev_attr_slot_name);
21342024
if (ret < 0)
21352025
goto err_slot_name;
21362026
}
2137-
if (host->get_cover_state) {
2138-
ret = device_create_file(&mmc->class_dev,
2139-
&dev_attr_cover_switch);
2140-
if (ret < 0)
2141-
goto err_slot_name;
2142-
}
21432027

21442028
omap_hsmmc_debugfs(mmc);
21452029
pm_runtime_mark_last_busy(host->dev);
@@ -2231,7 +2115,6 @@ static int omap_hsmmc_resume(struct device *dev)
22312115
if (!(host->mmc->pm_flags & MMC_PM_KEEP_POWER))
22322116
omap_hsmmc_conf_bus_power(host);
22332117

2234-
omap_hsmmc_protect_card(host);
22352118
pm_runtime_mark_last_busy(host->dev);
22362119
pm_runtime_put_autosuspend(host->dev);
22372120
return 0;

include/linux/platform_data/hsmmc-omap.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ struct omap_hsmmc_platform_data {
7171
char *version;
7272

7373
int gpio_cd; /* gpio (card detect) */
74-
int gpio_cod; /* gpio (cover detect) */
7574
int gpio_wp; /* gpio (write protect) */
7675
/* if we have special card, init it using this callback */
7776
void (*init_card)(struct mmc_card *card);

0 commit comments

Comments
 (0)