summaryrefslogtreecommitdiff
path: root/drivers/mmc/host/atmel-mci.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mmc/host/atmel-mci.c')
-rw-r--r--drivers/mmc/host/atmel-mci.c56
1 files changed, 22 insertions, 34 deletions
diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
index 24fffc702a94..3b4928f5b9b2 100644
--- a/drivers/mmc/host/atmel-mci.c
+++ b/drivers/mmc/host/atmel-mci.c
@@ -38,6 +38,7 @@
#include <asm/cacheflush.h>
#include <asm/io.h>
#include <linux/unaligned.h>
+#include <linux/string_choices.h>
#define ATMCI_MAX_NR_SLOTS 2
@@ -541,7 +542,6 @@ static int atmci_regs_show(struct seq_file *s, void *v)
memcpy_fromio(buf, host->regs, ATMCI_REGS_SIZE);
spin_unlock_bh(&host->lock);
- pm_runtime_mark_last_busy(dev);
pm_runtime_put_autosuspend(dev);
seq_printf(s, "MR:\t0x%08x%s%s ",
@@ -609,12 +609,12 @@ static void atmci_init_debugfs(struct atmel_mci_slot *slot)
if (!root)
return;
- debugfs_create_file("regs", S_IRUSR, root, host, &atmci_regs_fops);
- debugfs_create_file("req", S_IRUSR, root, slot, &atmci_req_fops);
- debugfs_create_u32("state", S_IRUSR, root, &host->state);
- debugfs_create_xul("pending_events", S_IRUSR, root,
+ debugfs_create_file("regs", 0400, root, host, &atmci_regs_fops);
+ debugfs_create_file("req", 0400, root, slot, &atmci_req_fops);
+ debugfs_create_u32("state", 0400, root, &host->state);
+ debugfs_create_xul("pending_events", 0400, root,
&host->pending_events);
- debugfs_create_xul("completed_events", S_IRUSR, root,
+ debugfs_create_xul("completed_events", 0400, root,
&host->completed_events);
}
@@ -629,14 +629,13 @@ static int atmci_of_init(struct atmel_mci *host)
{
struct device *dev = host->dev;
struct device_node *np = dev->of_node;
- struct device_node *cnp;
u32 slot_id;
int err;
if (!np)
return dev_err_probe(dev, -EINVAL, "device node not found\n");
- for_each_child_of_node(np, cnp) {
+ for_each_child_of_node_scoped(np, cnp) {
if (of_property_read_u32(cnp, "reg", &slot_id)) {
dev_warn(dev, "reg property is missing for %pOF\n", cnp);
continue;
@@ -645,7 +644,6 @@ static int atmci_of_init(struct atmel_mci *host)
if (slot_id >= ATMCI_MAX_NR_SLOTS) {
dev_warn(dev, "can't have more than %d slots\n",
ATMCI_MAX_NR_SLOTS);
- of_node_put(cnp);
break;
}
@@ -658,10 +656,8 @@ static int atmci_of_init(struct atmel_mci *host)
"cd", GPIOD_IN, "cd-gpios");
err = PTR_ERR_OR_ZERO(host->pdata[slot_id].detect_pin);
if (err) {
- if (err != -ENOENT) {
- of_node_put(cnp);
+ if (err != -ENOENT)
return err;
- }
host->pdata[slot_id].detect_pin = NULL;
}
@@ -673,10 +669,8 @@ static int atmci_of_init(struct atmel_mci *host)
"wp", GPIOD_IN, "wp-gpios");
err = PTR_ERR_OR_ZERO(host->pdata[slot_id].wp_pin);
if (err) {
- if (err != -ENOENT) {
- of_node_put(cnp);
+ if (err != -ENOENT)
return err;
- }
host->pdata[slot_id].wp_pin = NULL;
}
}
@@ -714,7 +708,7 @@ static inline unsigned int atmci_convert_chksize(struct atmel_mci *host,
static void atmci_timeout_timer(struct timer_list *t)
{
- struct atmel_mci *host = from_timer(host, t, timer);
+ struct atmel_mci *host = timer_container_of(host, t, timer);
struct device *dev = host->dev;
dev_dbg(dev, "software timeout\n");
@@ -1592,7 +1586,7 @@ static void atmci_request_end(struct atmel_mci *host, struct mmc_request *mrq)
WARN_ON(host->cmd || host->data);
- del_timer(&host->timer);
+ timer_delete(&host->timer);
/*
* Update the MMC clock rate if necessary. This may be
@@ -1652,7 +1646,8 @@ static void atmci_command_complete(struct atmel_mci *host,
static void atmci_detect_change(struct timer_list *t)
{
- struct atmel_mci_slot *slot = from_timer(slot, t, detect_timer);
+ struct atmel_mci_slot *slot = timer_container_of(slot, t,
+ detect_timer);
bool present;
bool present_old;
@@ -2247,7 +2242,7 @@ static int atmci_init_slot(struct atmel_mci *host,
struct atmel_mci_slot *slot;
int ret;
- mmc = mmc_alloc_host(sizeof(struct atmel_mci_slot), dev);
+ mmc = devm_mmc_alloc_host(dev, sizeof(*slot));
if (!mmc)
return -ENOMEM;
@@ -2263,7 +2258,7 @@ static int atmci_init_slot(struct atmel_mci *host,
"slot[%u]: bus_width=%u, detect_pin=%d, "
"detect_is_active_high=%s, wp_pin=%d\n",
id, slot_data->bus_width, desc_to_gpio(slot_data->detect_pin),
- !gpiod_is_active_low(slot_data->detect_pin) ? "true" : "false",
+ str_true_false(!gpiod_is_active_low(slot_data->detect_pin)),
desc_to_gpio(slot_data->wp_pin));
mmc->ops = &atmci_ops;
@@ -2320,10 +2315,8 @@ static int atmci_init_slot(struct atmel_mci *host,
host->slot[id] = slot;
mmc_regulator_get_supply(mmc);
ret = mmc_add_host(mmc);
- if (ret) {
- mmc_free_host(mmc);
+ if (ret)
return ret;
- }
if (slot->detect_pin) {
timer_setup(&slot->detect_timer, atmci_detect_change, 0);
@@ -2357,11 +2350,10 @@ static void atmci_cleanup_slot(struct atmel_mci_slot *slot,
if (slot->detect_pin) {
free_irq(gpiod_to_irq(slot->detect_pin), slot);
- del_timer_sync(&slot->detect_timer);
+ timer_delete_sync(&slot->detect_timer);
}
slot->host->slot[id] = NULL;
- mmc_free_host(slot->mmc);
}
static int atmci_configure_dma(struct atmel_mci *host)
@@ -2569,7 +2561,6 @@ static int atmci_probe(struct platform_device *pdev)
dev_info(dev, "Atmel MCI controller at 0x%08lx irq %d, %u slots\n",
host->mapbase, irq, nr_slots);
- pm_runtime_mark_last_busy(dev);
pm_runtime_put_autosuspend(dev);
return 0;
@@ -2585,7 +2576,7 @@ err_init_slot:
pm_runtime_disable(dev);
pm_runtime_put_noidle(dev);
- del_timer_sync(&host->timer);
+ timer_delete_sync(&host->timer);
if (!IS_ERR(host->dma.chan))
dma_release_channel(host->dma.chan);
err_dma_probe_defer:
@@ -2613,7 +2604,7 @@ static void atmci_remove(struct platform_device *pdev)
atmci_writel(host, ATMCI_CR, ATMCI_CR_MCIDIS);
atmci_readl(host, ATMCI_SR);
- del_timer_sync(&host->timer);
+ timer_delete_sync(&host->timer);
if (!IS_ERR(host->dma.chan))
dma_release_channel(host->dma.chan);
@@ -2625,7 +2616,6 @@ static void atmci_remove(struct platform_device *pdev)
pm_runtime_put_noidle(dev);
}
-#ifdef CONFIG_PM
static int atmci_runtime_suspend(struct device *dev)
{
struct atmel_mci *host = dev_get_drvdata(dev);
@@ -2645,12 +2635,10 @@ static int atmci_runtime_resume(struct device *dev)
return clk_prepare_enable(host->mck);
}
-#endif
static const struct dev_pm_ops atmci_dev_pm_ops = {
- SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
- pm_runtime_force_resume)
- SET_RUNTIME_PM_OPS(atmci_runtime_suspend, atmci_runtime_resume, NULL)
+ SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume)
+ RUNTIME_PM_OPS(atmci_runtime_suspend, atmci_runtime_resume, NULL)
};
static struct platform_driver atmci_driver = {
@@ -2660,7 +2648,7 @@ static struct platform_driver atmci_driver = {
.name = "atmel_mci",
.probe_type = PROBE_PREFER_ASYNCHRONOUS,
.of_match_table = atmci_dt_ids,
- .pm = &atmci_dev_pm_ops,
+ .pm = pm_ptr(&atmci_dev_pm_ops),
},
};
module_platform_driver(atmci_driver);