linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 0/5] mmc: atmel-mci: Get rid of leftovers and clean up
@ 2024-04-17 16:55 Andy Shevchenko
  2024-04-17 16:55 ` [PATCH v1 1/5] mmc: atmel-mci: Get rid of platform data leftovers Andy Shevchenko
                   ` (5 more replies)
  0 siblings, 6 replies; 9+ messages in thread
From: Andy Shevchenko @ 2024-04-17 16:55 UTC (permalink / raw)
  To: Andy Shevchenko, linux-mmc, linux-arm-kernel, linux-kernel
  Cc: Aubin Constans, Ulf Hansson, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea

I used to have some patches against the driver, but it appears that part
of it has been applied (in different form as done by someone else).
However, there is still room to improve, hence this spring cleanup series.

Andy Shevchenko (5):
  mmc: atmel-mci: Get rid of platform data leftovers
  mmc: atmel-mci: Use temporary variable for struct device
  mmc: atmel-mci: Replace platform device pointer by generic one
  mmc: atmel-mci: Incapsulate used to be a platform data into host
    structure
  mmc: atmel-mci: Switch to use dev_err_probe()

 drivers/mmc/host/atmel-mci.c | 308 +++++++++++++++--------------------
 1 file changed, 131 insertions(+), 177 deletions(-)

-- 
2.43.0.rc1.1336.g36b5255a03ac


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v1 1/5] mmc: atmel-mci: Get rid of platform data leftovers
  2024-04-17 16:55 [PATCH v1 0/5] mmc: atmel-mci: Get rid of leftovers and clean up Andy Shevchenko
@ 2024-04-17 16:55 ` Andy Shevchenko
  2024-04-17 16:55 ` [PATCH v1 2/5] mmc: atmel-mci: Use temporary variable for struct device Andy Shevchenko
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Andy Shevchenko @ 2024-04-17 16:55 UTC (permalink / raw)
  To: Andy Shevchenko, linux-mmc, linux-arm-kernel, linux-kernel
  Cc: Aubin Constans, Ulf Hansson, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea

The commit d2c6d518c21d ("mmc: atmel-mci: move atmel MCI header file")
made sure that there is no in-kernel user of the platform data. But
at the same time it hadn't removed the code around that data structure.
Finish the job here and remove a dead code.

Fixes: d2c6d518c21d ("mmc: atmel-mci: move atmel MCI header file")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/mmc/host/atmel-mci.c | 43 +++++-------------------------------
 1 file changed, 6 insertions(+), 37 deletions(-)

diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
index dba826db739a..87c2855f64c2 100644
--- a/drivers/mmc/host/atmel-mci.c
+++ b/drivers/mmc/host/atmel-mci.c
@@ -226,13 +226,9 @@ struct mci_slot_pdata {
 
 /**
  * struct mci_platform_data - board-specific MMC/SDcard configuration
- * @dma_slave: DMA slave interface to use in data transfers.
- * @dma_filter: Filtering function to filter the DMA channel
  * @slot: Per-slot configuration data.
  */
 struct mci_platform_data {
-	void			*dma_slave;
-	dma_filter_fn		dma_filter;
 	struct mci_slot_pdata	slot[ATMCI_MAX_NR_SLOTS];
 };
 
@@ -626,7 +622,6 @@ static void atmci_init_debugfs(struct atmel_mci_slot *slot)
 			   &host->completed_events);
 }
 
-#if defined(CONFIG_OF)
 static const struct of_device_id atmci_dt_ids[] = {
 	{ .compatible = "atmel,hsmci" },
 	{ /* sentinel */ }
@@ -700,13 +695,6 @@ atmci_of_init(struct platform_device *pdev)
 
 	return pdata;
 }
-#else /* CONFIG_OF */
-static inline struct mci_platform_data*
-atmci_of_init(struct platform_device *dev)
-{
-	return ERR_PTR(-EINVAL);
-}
-#endif
 
 static inline unsigned int atmci_get_version(struct atmel_mci *host)
 {
@@ -2388,23 +2376,6 @@ static void atmci_cleanup_slot(struct atmel_mci_slot *slot,
 static int atmci_configure_dma(struct atmel_mci *host)
 {
 	host->dma.chan = dma_request_chan(&host->pdev->dev, "rxtx");
-
-	if (PTR_ERR(host->dma.chan) == -ENODEV) {
-		struct mci_platform_data *pdata = host->pdev->dev.platform_data;
-		dma_cap_mask_t mask;
-
-		if (!pdata || !pdata->dma_filter)
-			return -ENODEV;
-
-		dma_cap_zero(mask);
-		dma_cap_set(DMA_SLAVE, mask);
-
-		host->dma.chan = dma_request_channel(mask, pdata->dma_filter,
-						     pdata->dma_slave);
-		if (!host->dma.chan)
-			host->dma.chan = ERR_PTR(-ENODEV);
-	}
-
 	if (IS_ERR(host->dma.chan))
 		return PTR_ERR(host->dma.chan);
 
@@ -2492,13 +2463,11 @@ static int atmci_probe(struct platform_device *pdev)
 	regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!regs)
 		return -ENXIO;
-	pdata = pdev->dev.platform_data;
-	if (!pdata) {
-		pdata = atmci_of_init(pdev);
-		if (IS_ERR(pdata)) {
-			dev_err(&pdev->dev, "platform data not available\n");
-			return PTR_ERR(pdata);
-		}
+
+	pdata = atmci_of_init(pdev);
+	if (IS_ERR(pdata)) {
+		dev_err(&pdev->dev, "platform data not available\n");
+		return PTR_ERR(pdata);
 	}
 
 	irq = platform_get_irq(pdev, 0);
@@ -2701,7 +2670,7 @@ static struct platform_driver atmci_driver = {
 	.driver		= {
 		.name		= "atmel_mci",
 		.probe_type	= PROBE_PREFER_ASYNCHRONOUS,
-		.of_match_table	= of_match_ptr(atmci_dt_ids),
+		.of_match_table	= atmci_dt_ids,
 		.pm		= &atmci_dev_pm_ops,
 	},
 };
-- 
2.43.0.rc1.1336.g36b5255a03ac


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v1 2/5] mmc: atmel-mci: Use temporary variable for struct device
  2024-04-17 16:55 [PATCH v1 0/5] mmc: atmel-mci: Get rid of leftovers and clean up Andy Shevchenko
  2024-04-17 16:55 ` [PATCH v1 1/5] mmc: atmel-mci: Get rid of platform data leftovers Andy Shevchenko
@ 2024-04-17 16:55 ` Andy Shevchenko
  2024-04-17 16:55 ` [PATCH v1 3/5] mmc: atmel-mci: Replace platform device pointer by generic one Andy Shevchenko
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Andy Shevchenko @ 2024-04-17 16:55 UTC (permalink / raw)
  To: Andy Shevchenko, linux-mmc, linux-arm-kernel, linux-kernel
  Cc: Aubin Constans, Ulf Hansson, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea

Use temporary variable for struct device to make code neater.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/mmc/host/atmel-mci.c | 214 ++++++++++++++++++-----------------
 1 file changed, 108 insertions(+), 106 deletions(-)

diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
index 87c2855f64c2..c4dfd4c7785f 100644
--- a/drivers/mmc/host/atmel-mci.c
+++ b/drivers/mmc/host/atmel-mci.c
@@ -526,6 +526,7 @@ static void atmci_show_status_reg(struct seq_file *s,
 static int atmci_regs_show(struct seq_file *s, void *v)
 {
 	struct atmel_mci	*host = s->private;
+	struct device		*dev = &host->pdev->dev;
 	u32			*buf;
 	int			ret = 0;
 
@@ -534,7 +535,7 @@ static int atmci_regs_show(struct seq_file *s, void *v)
 	if (!buf)
 		return -ENOMEM;
 
-	pm_runtime_get_sync(&host->pdev->dev);
+	pm_runtime_get_sync(dev);
 
 	/*
 	 * Grab a more or less consistent snapshot. Note that we're
@@ -545,8 +546,8 @@ 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(&host->pdev->dev);
-	pm_runtime_put_autosuspend(&host->pdev->dev);
+	pm_runtime_mark_last_busy(dev);
+	pm_runtime_put_autosuspend(dev);
 
 	seq_printf(s, "MR:\t0x%08x%s%s ",
 			buf[ATMCI_MR / 4],
@@ -629,33 +630,31 @@ static const struct of_device_id atmci_dt_ids[] = {
 
 MODULE_DEVICE_TABLE(of, atmci_dt_ids);
 
-static struct mci_platform_data*
-atmci_of_init(struct platform_device *pdev)
+static struct mci_platform_data *atmci_of_init(struct device *dev)
 {
-	struct device_node *np = pdev->dev.of_node;
+	struct device_node *np = dev->of_node;
 	struct device_node *cnp;
 	struct mci_platform_data *pdata;
 	u32 slot_id;
 	int err;
 
 	if (!np) {
-		dev_err(&pdev->dev, "device node not found\n");
+		dev_err(dev, "device node not found\n");
 		return ERR_PTR(-EINVAL);
 	}
 
-	pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
+	pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
 	if (!pdata)
 		return ERR_PTR(-ENOMEM);
 
 	for_each_child_of_node(np, cnp) {
 		if (of_property_read_u32(cnp, "reg", &slot_id)) {
-			dev_warn(&pdev->dev, "reg property is missing for %pOF\n",
-				 cnp);
+			dev_warn(dev, "reg property is missing for %pOF\n", cnp);
 			continue;
 		}
 
 		if (slot_id >= ATMCI_MAX_NR_SLOTS) {
-			dev_warn(&pdev->dev, "can't have more than %d slots\n",
+			dev_warn(dev, "can't have more than %d slots\n",
 			         ATMCI_MAX_NR_SLOTS);
 			of_node_put(cnp);
 			break;
@@ -666,7 +665,7 @@ atmci_of_init(struct platform_device *pdev)
 			pdata->slot[slot_id].bus_width = 1;
 
 		pdata->slot[slot_id].detect_pin =
-			devm_fwnode_gpiod_get(&pdev->dev, of_fwnode_handle(cnp),
+			devm_fwnode_gpiod_get(dev, of_fwnode_handle(cnp),
 					      "cd", GPIOD_IN, "cd-gpios");
 		err = PTR_ERR_OR_ZERO(pdata->slot[slot_id].detect_pin);
 		if (err) {
@@ -681,7 +680,7 @@ atmci_of_init(struct platform_device *pdev)
 			of_property_read_bool(cnp, "non-removable");
 
 		pdata->slot[slot_id].wp_pin =
-			devm_fwnode_gpiod_get(&pdev->dev, of_fwnode_handle(cnp),
+			devm_fwnode_gpiod_get(dev, of_fwnode_handle(cnp),
 					      "wp", GPIOD_IN, "wp-gpios");
 		err = PTR_ERR_OR_ZERO(pdata->slot[slot_id].wp_pin);
 		if (err) {
@@ -726,11 +725,10 @@ static inline unsigned int atmci_convert_chksize(struct atmel_mci *host,
 
 static void atmci_timeout_timer(struct timer_list *t)
 {
-	struct atmel_mci *host;
+	struct atmel_mci *host = from_timer(host, t, timer);
+	struct device *dev = &host->pdev->dev;
 
-	host = from_timer(host, t, timer);
-
-	dev_dbg(&host->pdev->dev, "software timeout\n");
+	dev_dbg(dev, "software timeout\n");
 
 	if (host->mrq->cmd->data) {
 		host->mrq->cmd->data->error = -ETIMEDOUT;
@@ -848,15 +846,14 @@ static u32 atmci_prepare_command(struct mmc_host *mmc,
 static void atmci_send_command(struct atmel_mci *host,
 		struct mmc_command *cmd, u32 cmd_flags)
 {
+	struct device *dev = &host->pdev->dev;
 	unsigned int timeout_ms = cmd->busy_timeout ? cmd->busy_timeout :
 		ATMCI_CMD_TIMEOUT_MS;
 
 	WARN_ON(host->cmd);
 	host->cmd = cmd;
 
-	dev_vdbg(&host->pdev->dev,
-			"start command: ARGR=0x%08x CMDR=0x%08x\n",
-			cmd->arg, cmd_flags);
+	dev_vdbg(dev, "start command: ARGR=0x%08x CMDR=0x%08x\n", cmd->arg, cmd_flags);
 
 	atmci_writel(host, ATMCI_ARGR, cmd->arg);
 	atmci_writel(host, ATMCI_CMDR, cmd_flags);
@@ -866,7 +863,9 @@ static void atmci_send_command(struct atmel_mci *host,
 
 static void atmci_send_stop_cmd(struct atmel_mci *host, struct mmc_data *data)
 {
-	dev_dbg(&host->pdev->dev, "send stop command\n");
+	struct device *dev = &host->pdev->dev;
+
+	dev_dbg(dev, "send stop command\n");
 	atmci_send_command(host, data->stop, host->stop_cmdr);
 	atmci_writel(host, ATMCI_IER, ATMCI_CMDRDY);
 }
@@ -938,12 +937,11 @@ static void atmci_pdc_set_both_buf(struct atmel_mci *host, int dir)
  */
 static void atmci_pdc_cleanup(struct atmel_mci *host)
 {
+	struct device		*dev = &host->pdev->dev;
 	struct mmc_data         *data = host->data;
 
 	if (data)
-		dma_unmap_sg(&host->pdev->dev,
-				data->sg, data->sg_len,
-				mmc_get_dma_dir(data));
+		dma_unmap_sg(dev, data->sg, data->sg_len, mmc_get_dma_dir(data));
 }
 
 /*
@@ -953,6 +951,7 @@ static void atmci_pdc_cleanup(struct atmel_mci *host)
  */
 static void atmci_pdc_complete(struct atmel_mci *host)
 {
+	struct device *dev = &host->pdev->dev;
 	int transfer_size = host->data->blocks * host->data->blksz;
 	int i;
 
@@ -969,7 +968,7 @@ static void atmci_pdc_complete(struct atmel_mci *host)
 
 	atmci_pdc_cleanup(host);
 
-	dev_dbg(&host->pdev->dev, "(%s) set pending xfer complete\n", __func__);
+	dev_dbg(dev, "(%s) set pending xfer complete\n", __func__);
 	atmci_set_pending(host, EVENT_XFER_COMPLETE);
 	tasklet_schedule(&host->tasklet);
 }
@@ -990,9 +989,10 @@ static void atmci_dma_cleanup(struct atmel_mci *host)
 static void atmci_dma_complete(void *arg)
 {
 	struct atmel_mci	*host = arg;
+	struct device		*dev = &host->pdev->dev;
 	struct mmc_data		*data = host->data;
 
-	dev_vdbg(&host->pdev->dev, "DMA complete\n");
+	dev_vdbg(dev, "DMA complete\n");
 
 	if (host->caps.has_dma_conf_reg)
 		/* Disable DMA hardware handshaking on MCI */
@@ -1005,8 +1005,7 @@ static void atmci_dma_complete(void *arg)
 	 * to send the stop command or waiting for NBUSY in this case.
 	 */
 	if (data) {
-		dev_dbg(&host->pdev->dev,
-		        "(%s) set pending xfer complete\n", __func__);
+		dev_dbg(dev, "(%s) set pending xfer complete\n", __func__);
 		atmci_set_pending(host, EVENT_XFER_COMPLETE);
 		tasklet_schedule(&host->tasklet);
 
@@ -1080,6 +1079,7 @@ static u32 atmci_prepare_data(struct atmel_mci *host, struct mmc_data *data)
 static u32
 atmci_prepare_data_pdc(struct atmel_mci *host, struct mmc_data *data)
 {
+	struct device *dev = &host->pdev->dev;
 	u32 iflags, tmp;
 	int i;
 
@@ -1105,8 +1105,7 @@ atmci_prepare_data_pdc(struct atmel_mci *host, struct mmc_data *data)
 
 	/* Configure PDC */
 	host->data_size = data->blocks * data->blksz;
-	dma_map_sg(&host->pdev->dev, data->sg, data->sg_len,
-		   mmc_get_dma_dir(data));
+	dma_map_sg(dev, data->sg, data->sg_len, mmc_get_dma_dir(data));
 
 	if ((!host->caps.has_rwproof)
 	    && (host->data->flags & MMC_DATA_WRITE)) {
@@ -1232,8 +1231,9 @@ atmci_submit_data_dma(struct atmel_mci *host, struct mmc_data *data)
 
 static void atmci_stop_transfer(struct atmel_mci *host)
 {
-	dev_dbg(&host->pdev->dev,
-	        "(%s) set pending xfer complete\n", __func__);
+	struct device *dev = &host->pdev->dev;
+
+	dev_dbg(dev, "(%s) set pending xfer complete\n", __func__);
 	atmci_set_pending(host, EVENT_XFER_COMPLETE);
 	atmci_writel(host, ATMCI_IER, ATMCI_NOTBUSY);
 }
@@ -1249,14 +1249,14 @@ static void atmci_stop_transfer_pdc(struct atmel_mci *host)
 static void atmci_stop_transfer_dma(struct atmel_mci *host)
 {
 	struct dma_chan *chan = host->data_chan;
+	struct device *dev = &host->pdev->dev;
 
 	if (chan) {
 		dmaengine_terminate_all(chan);
 		atmci_dma_cleanup(host);
 	} else {
 		/* Data transfer was stopped by the interrupt handler */
-		dev_dbg(&host->pdev->dev,
-		        "(%s) set pending xfer complete\n", __func__);
+		dev_dbg(dev, "(%s) set pending xfer complete\n", __func__);
 		atmci_set_pending(host, EVENT_XFER_COMPLETE);
 		atmci_writel(host, ATMCI_IER, ATMCI_NOTBUSY);
 	}
@@ -1269,6 +1269,7 @@ static void atmci_stop_transfer_dma(struct atmel_mci *host)
 static void atmci_start_request(struct atmel_mci *host,
 		struct atmel_mci_slot *slot)
 {
+	struct device		*dev = &host->pdev->dev;
 	struct mmc_request	*mrq;
 	struct mmc_command	*cmd;
 	struct mmc_data		*data;
@@ -1284,7 +1285,7 @@ static void atmci_start_request(struct atmel_mci *host,
 	host->cmd_status = 0;
 	host->data_status = 0;
 
-	dev_dbg(&host->pdev->dev, "start request: cmd %u\n", mrq->cmd->opcode);
+	dev_dbg(dev, "start request: cmd %u\n", mrq->cmd->opcode);
 
 	if (host->need_reset || host->caps.need_reset_after_xfer) {
 		iflags = atmci_readl(host, ATMCI_IMR);
@@ -1363,6 +1364,8 @@ static void atmci_start_request(struct atmel_mci *host,
 static void atmci_queue_request(struct atmel_mci *host,
 		struct atmel_mci_slot *slot, struct mmc_request *mrq)
 {
+	struct device *dev = &host->pdev->dev;
+
 	dev_vdbg(&slot->mmc->class_dev, "queue request: state=%d\n",
 			host->state);
 
@@ -1372,7 +1375,7 @@ static void atmci_queue_request(struct atmel_mci *host,
 		host->state = STATE_SENDING_CMD;
 		atmci_start_request(host, slot);
 	} else {
-		dev_dbg(&host->pdev->dev, "queue request\n");
+		dev_dbg(dev, "queue request\n");
 		list_add_tail(&slot->queue_node, &host->queue);
 	}
 	spin_unlock_bh(&host->lock);
@@ -1382,10 +1385,11 @@ static void atmci_request(struct mmc_host *mmc, struct mmc_request *mrq)
 {
 	struct atmel_mci_slot	*slot = mmc_priv(mmc);
 	struct atmel_mci	*host = slot->host;
+	struct device		*dev = &host->pdev->dev;
 	struct mmc_data		*data;
 
 	WARN_ON(slot->mrq);
-	dev_dbg(&host->pdev->dev, "MRQ: cmd %u\n", mrq->cmd->opcode);
+	dev_dbg(dev, "MRQ: cmd %u\n", mrq->cmd->opcode);
 
 	/*
 	 * We may "know" the card is gone even though there's still an
@@ -1595,6 +1599,7 @@ static void atmci_request_end(struct atmel_mci *host, struct mmc_request *mrq)
 {
 	struct atmel_mci_slot	*slot = NULL;
 	struct mmc_host		*prev_mmc = host->cur_slot->mmc;
+	struct device		*dev = &host->pdev->dev;
 
 	WARN_ON(host->cmd || host->data);
 
@@ -1617,12 +1622,11 @@ static void atmci_request_end(struct atmel_mci *host, struct mmc_request *mrq)
 		slot = list_entry(host->queue.next,
 				struct atmel_mci_slot, queue_node);
 		list_del(&slot->queue_node);
-		dev_vdbg(&host->pdev->dev, "list not empty: %s is next\n",
-				mmc_hostname(slot->mmc));
+		dev_vdbg(dev, "list not empty: %s is next\n", mmc_hostname(slot->mmc));
 		host->state = STATE_SENDING_CMD;
 		atmci_start_request(host, slot);
 	} else {
-		dev_vdbg(&host->pdev->dev, "list empty\n");
+		dev_vdbg(dev, "list empty\n");
 		host->state = STATE_IDLE;
 	}
 
@@ -1756,6 +1760,7 @@ static void atmci_detect_change(struct timer_list *t)
 static void atmci_tasklet_func(struct tasklet_struct *t)
 {
 	struct atmel_mci        *host = from_tasklet(host, t, tasklet);
+	struct device		*dev = &host->pdev->dev;
 	struct mmc_request	*mrq = host->mrq;
 	struct mmc_data		*data = host->data;
 	enum atmel_mci_state	state = host->state;
@@ -1766,14 +1771,13 @@ static void atmci_tasklet_func(struct tasklet_struct *t)
 
 	state = host->state;
 
-	dev_vdbg(&host->pdev->dev,
-		"tasklet: state %u pending/completed/mask %lx/%lx/%x\n",
+	dev_vdbg(dev, "tasklet: state %u pending/completed/mask %lx/%lx/%x\n",
 		state, host->pending_events, host->completed_events,
 		atmci_readl(host, ATMCI_IMR));
 
 	do {
 		prev_state = state;
-		dev_dbg(&host->pdev->dev, "FSM: state=%d\n", state);
+		dev_dbg(dev, "FSM: state=%d\n", state);
 
 		switch (state) {
 		case STATE_IDLE:
@@ -1786,18 +1790,17 @@ static void atmci_tasklet_func(struct tasklet_struct *t)
 			 * END_REQUEST by default, WAITING_NOTBUSY if it's a
 			 * command needing it or DATA_XFER if there is data.
 			 */
-			dev_dbg(&host->pdev->dev, "FSM: cmd ready?\n");
+			dev_dbg(dev, "FSM: cmd ready?\n");
 			if (!atmci_test_and_clear_pending(host,
 						EVENT_CMD_RDY))
 				break;
 
-			dev_dbg(&host->pdev->dev, "set completed cmd ready\n");
+			dev_dbg(dev, "set completed cmd ready\n");
 			host->cmd = NULL;
 			atmci_set_completed(host, EVENT_CMD_RDY);
 			atmci_command_complete(host, mrq->cmd);
 			if (mrq->data) {
-				dev_dbg(&host->pdev->dev,
-				        "command with data transfer");
+				dev_dbg(dev, "command with data transfer\n");
 				/*
 				 * If there is a command error don't start
 				 * data transfer.
@@ -1812,8 +1815,7 @@ static void atmci_tasklet_func(struct tasklet_struct *t)
 				} else
 					state = STATE_DATA_XFER;
 			} else if ((!mrq->data) && (mrq->cmd->flags & MMC_RSP_BUSY)) {
-				dev_dbg(&host->pdev->dev,
-				        "command response need waiting notbusy");
+				dev_dbg(dev, "command response need waiting notbusy\n");
 				atmci_writel(host, ATMCI_IER, ATMCI_NOTBUSY);
 				state = STATE_WAITING_NOTBUSY;
 			} else
@@ -1824,7 +1826,7 @@ static void atmci_tasklet_func(struct tasklet_struct *t)
 		case STATE_DATA_XFER:
 			if (atmci_test_and_clear_pending(host,
 						EVENT_DATA_ERROR)) {
-				dev_dbg(&host->pdev->dev, "set completed data error\n");
+				dev_dbg(dev, "set completed data error\n");
 				atmci_set_completed(host, EVENT_DATA_ERROR);
 				state = STATE_END_REQUEST;
 				break;
@@ -1837,14 +1839,12 @@ static void atmci_tasklet_func(struct tasklet_struct *t)
 			 * to the next step which is WAITING_NOTBUSY in write
 			 * case and directly SENDING_STOP in read case.
 			 */
-			dev_dbg(&host->pdev->dev, "FSM: xfer complete?\n");
+			dev_dbg(dev, "FSM: xfer complete?\n");
 			if (!atmci_test_and_clear_pending(host,
 						EVENT_XFER_COMPLETE))
 				break;
 
-			dev_dbg(&host->pdev->dev,
-			        "(%s) set completed xfer complete\n",
-				__func__);
+			dev_dbg(dev, "(%s) set completed xfer complete\n", __func__);
 			atmci_set_completed(host, EVENT_XFER_COMPLETE);
 
 			if (host->caps.need_notbusy_for_read_ops ||
@@ -1869,12 +1869,12 @@ static void atmci_tasklet_func(struct tasklet_struct *t)
 			 * included) or a write operation. In the latest case,
 			 * we need to send a stop command.
 			 */
-			dev_dbg(&host->pdev->dev, "FSM: not busy?\n");
+			dev_dbg(dev, "FSM: not busy?\n");
 			if (!atmci_test_and_clear_pending(host,
 						EVENT_NOTBUSY))
 				break;
 
-			dev_dbg(&host->pdev->dev, "set completed not busy\n");
+			dev_dbg(dev, "set completed not busy\n");
 			atmci_set_completed(host, EVENT_NOTBUSY);
 
 			if (host->data) {
@@ -1904,12 +1904,12 @@ static void atmci_tasklet_func(struct tasklet_struct *t)
 			 * in order to go to the end request state instead of
 			 * sending stop again.
 			 */
-			dev_dbg(&host->pdev->dev, "FSM: cmd ready?\n");
+			dev_dbg(dev, "FSM: cmd ready?\n");
 			if (!atmci_test_and_clear_pending(host,
 						EVENT_CMD_RDY))
 				break;
 
-			dev_dbg(&host->pdev->dev, "FSM: cmd ready\n");
+			dev_dbg(dev, "FSM: cmd ready\n");
 			host->cmd = NULL;
 			data->bytes_xfered = data->blocks * data->blksz;
 			data->error = 0;
@@ -2108,6 +2108,7 @@ static void atmci_sdio_interrupt(struct atmel_mci *host, u32 status)
 static irqreturn_t atmci_interrupt(int irq, void *dev_id)
 {
 	struct atmel_mci	*host = dev_id;
+	struct device		*dev = &host->pdev->dev;
 	u32			status, mask, pending;
 	unsigned int		pass_count = 0;
 
@@ -2119,21 +2120,21 @@ static irqreturn_t atmci_interrupt(int irq, void *dev_id)
 			break;
 
 		if (pending & ATMCI_DATA_ERROR_FLAGS) {
-			dev_dbg(&host->pdev->dev, "IRQ: data error\n");
+			dev_dbg(dev, "IRQ: data error\n");
 			atmci_writel(host, ATMCI_IDR, ATMCI_DATA_ERROR_FLAGS
 					| ATMCI_RXRDY | ATMCI_TXRDY
 					| ATMCI_ENDRX | ATMCI_ENDTX
 					| ATMCI_RXBUFF | ATMCI_TXBUFE);
 
 			host->data_status = status;
-			dev_dbg(&host->pdev->dev, "set pending data error\n");
+			dev_dbg(dev, "set pending data error\n");
 			smp_wmb();
 			atmci_set_pending(host, EVENT_DATA_ERROR);
 			tasklet_schedule(&host->tasklet);
 		}
 
 		if (pending & ATMCI_TXBUFE) {
-			dev_dbg(&host->pdev->dev, "IRQ: tx buffer empty\n");
+			dev_dbg(dev, "IRQ: tx buffer empty\n");
 			atmci_writel(host, ATMCI_IDR, ATMCI_TXBUFE);
 			atmci_writel(host, ATMCI_IDR, ATMCI_ENDTX);
 			/*
@@ -2149,7 +2150,7 @@ static irqreturn_t atmci_interrupt(int irq, void *dev_id)
 				atmci_pdc_complete(host);
 			}
 		} else if (pending & ATMCI_ENDTX) {
-			dev_dbg(&host->pdev->dev, "IRQ: end of tx buffer\n");
+			dev_dbg(dev, "IRQ: end of tx buffer\n");
 			atmci_writel(host, ATMCI_IDR, ATMCI_ENDTX);
 
 			if (host->data_size) {
@@ -2160,7 +2161,7 @@ static irqreturn_t atmci_interrupt(int irq, void *dev_id)
 		}
 
 		if (pending & ATMCI_RXBUFF) {
-			dev_dbg(&host->pdev->dev, "IRQ: rx buffer full\n");
+			dev_dbg(dev, "IRQ: rx buffer full\n");
 			atmci_writel(host, ATMCI_IDR, ATMCI_RXBUFF);
 			atmci_writel(host, ATMCI_IDR, ATMCI_ENDRX);
 			/*
@@ -2176,7 +2177,7 @@ static irqreturn_t atmci_interrupt(int irq, void *dev_id)
 				atmci_pdc_complete(host);
 			}
 		} else if (pending & ATMCI_ENDRX) {
-			dev_dbg(&host->pdev->dev, "IRQ: end of rx buffer\n");
+			dev_dbg(dev, "IRQ: end of rx buffer\n");
 			atmci_writel(host, ATMCI_IDR, ATMCI_ENDRX);
 
 			if (host->data_size) {
@@ -2193,19 +2194,19 @@ static irqreturn_t atmci_interrupt(int irq, void *dev_id)
 		 * The appropriate workaround is to use the BLKE signal.
 		 */
 		if (pending & ATMCI_BLKE) {
-			dev_dbg(&host->pdev->dev, "IRQ: blke\n");
+			dev_dbg(dev, "IRQ: blke\n");
 			atmci_writel(host, ATMCI_IDR, ATMCI_BLKE);
 			smp_wmb();
-			dev_dbg(&host->pdev->dev, "set pending notbusy\n");
+			dev_dbg(dev, "set pending notbusy\n");
 			atmci_set_pending(host, EVENT_NOTBUSY);
 			tasklet_schedule(&host->tasklet);
 		}
 
 		if (pending & ATMCI_NOTBUSY) {
-			dev_dbg(&host->pdev->dev, "IRQ: not_busy\n");
+			dev_dbg(dev, "IRQ: not_busy\n");
 			atmci_writel(host, ATMCI_IDR, ATMCI_NOTBUSY);
 			smp_wmb();
-			dev_dbg(&host->pdev->dev, "set pending notbusy\n");
+			dev_dbg(dev, "set pending notbusy\n");
 			atmci_set_pending(host, EVENT_NOTBUSY);
 			tasklet_schedule(&host->tasklet);
 		}
@@ -2216,11 +2217,11 @@ static irqreturn_t atmci_interrupt(int irq, void *dev_id)
 			atmci_write_data_pio(host);
 
 		if (pending & ATMCI_CMDRDY) {
-			dev_dbg(&host->pdev->dev, "IRQ: cmd ready\n");
+			dev_dbg(dev, "IRQ: cmd ready\n");
 			atmci_writel(host, ATMCI_IDR, ATMCI_CMDRDY);
 			host->cmd_status = status;
 			smp_wmb();
-			dev_dbg(&host->pdev->dev, "set pending cmd rdy\n");
+			dev_dbg(dev, "set pending cmd rdy\n");
 			atmci_set_pending(host, EVENT_CMD_RDY);
 			tasklet_schedule(&host->tasklet);
 		}
@@ -2252,11 +2253,12 @@ static int atmci_init_slot(struct atmel_mci *host,
 		struct mci_slot_pdata *slot_data, unsigned int id,
 		u32 sdc_reg, u32 sdio_irq)
 {
+	struct device			*dev = &host->pdev->dev;
 	struct mmc_host			*mmc;
 	struct atmel_mci_slot		*slot;
 	int ret;
 
-	mmc = mmc_alloc_host(sizeof(struct atmel_mci_slot), &host->pdev->dev);
+	mmc = mmc_alloc_host(sizeof(struct atmel_mci_slot), dev);
 	if (!mmc)
 		return -ENOMEM;
 
@@ -2375,12 +2377,13 @@ static void atmci_cleanup_slot(struct atmel_mci_slot *slot,
 
 static int atmci_configure_dma(struct atmel_mci *host)
 {
-	host->dma.chan = dma_request_chan(&host->pdev->dev, "rxtx");
+	struct device *dev = &host->pdev->dev;
+
+	host->dma.chan = dma_request_chan(dev, "rxtx");
 	if (IS_ERR(host->dma.chan))
 		return PTR_ERR(host->dma.chan);
 
-	dev_info(&host->pdev->dev, "using %s for DMA transfers\n",
-		 dma_chan_name(host->dma.chan));
+	dev_info(dev, "using %s for DMA transfers\n", dma_chan_name(host->dma.chan));
 
 	host->dma_conf.src_addr = host->mapbase + ATMCI_RDR;
 	host->dma_conf.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
@@ -2400,11 +2403,11 @@ static int atmci_configure_dma(struct atmel_mci *host)
  */
 static void atmci_get_cap(struct atmel_mci *host)
 {
+	struct device *dev = &host->pdev->dev;
 	unsigned int version;
 
 	version = atmci_get_version(host);
-	dev_info(&host->pdev->dev,
-			"version: 0x%x\n", version);
+	dev_info(dev, "version: 0x%x\n", version);
 
 	host->caps.has_dma_conf_reg = false;
 	host->caps.has_pdc = true;
@@ -2445,14 +2448,14 @@ static void atmci_get_cap(struct atmel_mci *host)
 		break;
 	default:
 		host->caps.has_pdc = false;
-		dev_warn(&host->pdev->dev,
-				"Unmanaged mci version, set minimum capabilities\n");
+		dev_warn(dev, "Unmanaged mci version, set minimum capabilities\n");
 		break;
 	}
 }
 
 static int atmci_probe(struct platform_device *pdev)
 {
+	struct device			*dev = &pdev->dev;
 	struct mci_platform_data	*pdata;
 	struct atmel_mci		*host;
 	struct resource			*regs;
@@ -2464,9 +2467,9 @@ static int atmci_probe(struct platform_device *pdev)
 	if (!regs)
 		return -ENXIO;
 
-	pdata = atmci_of_init(pdev);
+	pdata = atmci_of_init(dev);
 	if (IS_ERR(pdata)) {
-		dev_err(&pdev->dev, "platform data not available\n");
+		dev_err(dev, "platform data not available\n");
 		return PTR_ERR(pdata);
 	}
 
@@ -2474,7 +2477,7 @@ static int atmci_probe(struct platform_device *pdev)
 	if (irq < 0)
 		return irq;
 
-	host = devm_kzalloc(&pdev->dev, sizeof(*host), GFP_KERNEL);
+	host = devm_kzalloc(dev, sizeof(*host), GFP_KERNEL);
 	if (!host)
 		return -ENOMEM;
 
@@ -2482,11 +2485,11 @@ static int atmci_probe(struct platform_device *pdev)
 	spin_lock_init(&host->lock);
 	INIT_LIST_HEAD(&host->queue);
 
-	host->mck = devm_clk_get(&pdev->dev, "mci_clk");
+	host->mck = devm_clk_get(dev, "mci_clk");
 	if (IS_ERR(host->mck))
 		return PTR_ERR(host->mck);
 
-	host->regs = devm_ioremap(&pdev->dev, regs->start, resource_size(regs));
+	host->regs = devm_ioremap(dev, regs->start, resource_size(regs));
 	if (!host->regs)
 		return -ENOMEM;
 
@@ -2501,7 +2504,7 @@ static int atmci_probe(struct platform_device *pdev)
 
 	tasklet_setup(&host->tasklet, atmci_tasklet_func);
 
-	ret = request_irq(irq, atmci_interrupt, 0, dev_name(&pdev->dev), host);
+	ret = request_irq(irq, atmci_interrupt, 0, dev_name(dev), host);
 	if (ret) {
 		clk_disable_unprepare(host->mck);
 		return ret;
@@ -2517,12 +2520,12 @@ static int atmci_probe(struct platform_device *pdev)
 		host->submit_data = &atmci_submit_data_dma;
 		host->stop_transfer = &atmci_stop_transfer_dma;
 	} else if (host->caps.has_pdc) {
-		dev_info(&pdev->dev, "using PDC\n");
+		dev_info(dev, "using PDC\n");
 		host->prepare_data = &atmci_prepare_data_pdc;
 		host->submit_data = &atmci_submit_data_pdc;
 		host->stop_transfer = &atmci_stop_transfer_pdc;
 	} else {
-		dev_info(&pdev->dev, "using PIO\n");
+		dev_info(dev, "using PIO\n");
 		host->prepare_data = &atmci_prepare_data;
 		host->submit_data = &atmci_submit_data;
 		host->stop_transfer = &atmci_stop_transfer;
@@ -2532,11 +2535,11 @@ static int atmci_probe(struct platform_device *pdev)
 
 	timer_setup(&host->timer, atmci_timeout_timer, 0);
 
-	pm_runtime_get_noresume(&pdev->dev);
-	pm_runtime_set_active(&pdev->dev);
-	pm_runtime_set_autosuspend_delay(&pdev->dev, AUTOSUSPEND_DELAY);
-	pm_runtime_use_autosuspend(&pdev->dev);
-	pm_runtime_enable(&pdev->dev);
+	pm_runtime_get_noresume(dev);
+	pm_runtime_set_active(dev);
+	pm_runtime_set_autosuspend_delay(dev, AUTOSUSPEND_DELAY);
+	pm_runtime_use_autosuspend(dev);
+	pm_runtime_enable(dev);
 
 	/* We need at least one slot to succeed */
 	nr_slots = 0;
@@ -2561,27 +2564,26 @@ static int atmci_probe(struct platform_device *pdev)
 	}
 
 	if (!nr_slots) {
-		dev_err(&pdev->dev, "init failed: no slot defined\n");
+		dev_err(dev, "init failed: no slot defined\n");
 		goto err_init_slot;
 	}
 
 	if (!host->caps.has_rwproof) {
-		host->buffer = dma_alloc_coherent(&pdev->dev, host->buf_size,
+		host->buffer = dma_alloc_coherent(dev, host->buf_size,
 		                                  &host->buf_phys_addr,
 						  GFP_KERNEL);
 		if (!host->buffer) {
 			ret = -ENOMEM;
-			dev_err(&pdev->dev, "buffer allocation failed\n");
+			dev_err(dev, "buffer allocation failed\n");
 			goto err_dma_alloc;
 		}
 	}
 
-	dev_info(&pdev->dev,
-			"Atmel MCI controller at 0x%08lx irq %d, %u slots\n",
-			host->mapbase, irq, nr_slots);
+	dev_info(dev, "Atmel MCI controller at 0x%08lx irq %d, %u slots\n",
+		 host->mapbase, irq, nr_slots);
 
-	pm_runtime_mark_last_busy(&host->pdev->dev);
-	pm_runtime_put_autosuspend(&pdev->dev);
+	pm_runtime_mark_last_busy(dev);
+	pm_runtime_put_autosuspend(dev);
 
 	return 0;
 
@@ -2593,8 +2595,8 @@ static int atmci_probe(struct platform_device *pdev)
 err_init_slot:
 	clk_disable_unprepare(host->mck);
 
-	pm_runtime_disable(&pdev->dev);
-	pm_runtime_put_noidle(&pdev->dev);
+	pm_runtime_disable(dev);
+	pm_runtime_put_noidle(dev);
 
 	del_timer_sync(&host->timer);
 	if (!IS_ERR(host->dma.chan))
@@ -2607,13 +2609,13 @@ static int atmci_probe(struct platform_device *pdev)
 static void atmci_remove(struct platform_device *pdev)
 {
 	struct atmel_mci	*host = platform_get_drvdata(pdev);
+	struct device		*dev = &pdev->dev;
 	unsigned int		i;
 
-	pm_runtime_get_sync(&pdev->dev);
+	pm_runtime_get_sync(dev);
 
 	if (host->buffer)
-		dma_free_coherent(&pdev->dev, host->buf_size,
-		                  host->buffer, host->buf_phys_addr);
+		dma_free_coherent(dev, host->buf_size, host->buffer, host->buf_phys_addr);
 
 	for (i = 0; i < ATMCI_MAX_NR_SLOTS; i++) {
 		if (host->slot[i])
@@ -2632,8 +2634,8 @@ static void atmci_remove(struct platform_device *pdev)
 
 	clk_disable_unprepare(host->mck);
 
-	pm_runtime_disable(&pdev->dev);
-	pm_runtime_put_noidle(&pdev->dev);
+	pm_runtime_disable(dev);
+	pm_runtime_put_noidle(dev);
 }
 
 #ifdef CONFIG_PM
-- 
2.43.0.rc1.1336.g36b5255a03ac


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v1 3/5] mmc: atmel-mci: Replace platform device pointer by generic one
  2024-04-17 16:55 [PATCH v1 0/5] mmc: atmel-mci: Get rid of leftovers and clean up Andy Shevchenko
  2024-04-17 16:55 ` [PATCH v1 1/5] mmc: atmel-mci: Get rid of platform data leftovers Andy Shevchenko
  2024-04-17 16:55 ` [PATCH v1 2/5] mmc: atmel-mci: Use temporary variable for struct device Andy Shevchenko
@ 2024-04-17 16:55 ` Andy Shevchenko
  2024-04-17 16:55 ` [PATCH v1 4/5] mmc: atmel-mci: Incapsulate used to be a platform data into host structure Andy Shevchenko
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Andy Shevchenko @ 2024-04-17 16:55 UTC (permalink / raw)
  To: Andy Shevchenko, linux-mmc, linux-arm-kernel, linux-kernel
  Cc: Aubin Constans, Ulf Hansson, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea

There no need to keep a pointer to a platform device as it's not
used outside of ->probe() and ->remove() callbacks.

Replace platform device pointer by generic one in host structure.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/mmc/host/atmel-mci.c | 44 ++++++++++++++++++------------------
 1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
index c4dfd4c7785f..3aed57c392fa 100644
--- a/drivers/mmc/host/atmel-mci.c
+++ b/drivers/mmc/host/atmel-mci.c
@@ -296,7 +296,7 @@ struct atmel_mci_dma {
  *	rate and timeout calculations.
  * @mapbase: Physical address of the MMIO registers.
  * @mck: The peripheral bus clock hooked up to the MMC controller.
- * @pdev: Platform device associated with the MMC controller.
+ * @dev: Device associated with the MMC controller.
  * @slot: Slots sharing this MMC controller.
  * @caps: MCI capabilities depending on MCI version.
  * @prepare_data: function to setup MCI before data transfer which
@@ -373,7 +373,7 @@ struct atmel_mci {
 	unsigned long		bus_hz;
 	unsigned long		mapbase;
 	struct clk		*mck;
-	struct platform_device	*pdev;
+	struct device		*dev;
 
 	struct atmel_mci_slot	*slot[ATMCI_MAX_NR_SLOTS];
 
@@ -526,7 +526,7 @@ static void atmci_show_status_reg(struct seq_file *s,
 static int atmci_regs_show(struct seq_file *s, void *v)
 {
 	struct atmel_mci	*host = s->private;
-	struct device		*dev = &host->pdev->dev;
+	struct device		*dev = host->dev;
 	u32			*buf;
 	int			ret = 0;
 
@@ -726,7 +726,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 device *dev = &host->pdev->dev;
+	struct device *dev = host->dev;
 
 	dev_dbg(dev, "software timeout\n");
 
@@ -846,7 +846,7 @@ static u32 atmci_prepare_command(struct mmc_host *mmc,
 static void atmci_send_command(struct atmel_mci *host,
 		struct mmc_command *cmd, u32 cmd_flags)
 {
-	struct device *dev = &host->pdev->dev;
+	struct device *dev = host->dev;
 	unsigned int timeout_ms = cmd->busy_timeout ? cmd->busy_timeout :
 		ATMCI_CMD_TIMEOUT_MS;
 
@@ -863,7 +863,7 @@ static void atmci_send_command(struct atmel_mci *host,
 
 static void atmci_send_stop_cmd(struct atmel_mci *host, struct mmc_data *data)
 {
-	struct device *dev = &host->pdev->dev;
+	struct device *dev = host->dev;
 
 	dev_dbg(dev, "send stop command\n");
 	atmci_send_command(host, data->stop, host->stop_cmdr);
@@ -937,8 +937,8 @@ static void atmci_pdc_set_both_buf(struct atmel_mci *host, int dir)
  */
 static void atmci_pdc_cleanup(struct atmel_mci *host)
 {
-	struct device		*dev = &host->pdev->dev;
 	struct mmc_data         *data = host->data;
+	struct device		*dev = host->dev;
 
 	if (data)
 		dma_unmap_sg(dev, data->sg, data->sg_len, mmc_get_dma_dir(data));
@@ -951,7 +951,7 @@ static void atmci_pdc_cleanup(struct atmel_mci *host)
  */
 static void atmci_pdc_complete(struct atmel_mci *host)
 {
-	struct device *dev = &host->pdev->dev;
+	struct device *dev = host->dev;
 	int transfer_size = host->data->blocks * host->data->blksz;
 	int i;
 
@@ -989,8 +989,8 @@ static void atmci_dma_cleanup(struct atmel_mci *host)
 static void atmci_dma_complete(void *arg)
 {
 	struct atmel_mci	*host = arg;
-	struct device		*dev = &host->pdev->dev;
 	struct mmc_data		*data = host->data;
+	struct device		*dev = host->dev;
 
 	dev_vdbg(dev, "DMA complete\n");
 
@@ -1079,7 +1079,7 @@ static u32 atmci_prepare_data(struct atmel_mci *host, struct mmc_data *data)
 static u32
 atmci_prepare_data_pdc(struct atmel_mci *host, struct mmc_data *data)
 {
-	struct device *dev = &host->pdev->dev;
+	struct device *dev = host->dev;
 	u32 iflags, tmp;
 	int i;
 
@@ -1231,7 +1231,7 @@ atmci_submit_data_dma(struct atmel_mci *host, struct mmc_data *data)
 
 static void atmci_stop_transfer(struct atmel_mci *host)
 {
-	struct device *dev = &host->pdev->dev;
+	struct device *dev = host->dev;
 
 	dev_dbg(dev, "(%s) set pending xfer complete\n", __func__);
 	atmci_set_pending(host, EVENT_XFER_COMPLETE);
@@ -1249,7 +1249,7 @@ static void atmci_stop_transfer_pdc(struct atmel_mci *host)
 static void atmci_stop_transfer_dma(struct atmel_mci *host)
 {
 	struct dma_chan *chan = host->data_chan;
-	struct device *dev = &host->pdev->dev;
+	struct device *dev = host->dev;
 
 	if (chan) {
 		dmaengine_terminate_all(chan);
@@ -1269,7 +1269,7 @@ static void atmci_stop_transfer_dma(struct atmel_mci *host)
 static void atmci_start_request(struct atmel_mci *host,
 		struct atmel_mci_slot *slot)
 {
-	struct device		*dev = &host->pdev->dev;
+	struct device		*dev = host->dev;
 	struct mmc_request	*mrq;
 	struct mmc_command	*cmd;
 	struct mmc_data		*data;
@@ -1364,7 +1364,7 @@ static void atmci_start_request(struct atmel_mci *host,
 static void atmci_queue_request(struct atmel_mci *host,
 		struct atmel_mci_slot *slot, struct mmc_request *mrq)
 {
-	struct device *dev = &host->pdev->dev;
+	struct device *dev = host->dev;
 
 	dev_vdbg(&slot->mmc->class_dev, "queue request: state=%d\n",
 			host->state);
@@ -1385,7 +1385,7 @@ static void atmci_request(struct mmc_host *mmc, struct mmc_request *mrq)
 {
 	struct atmel_mci_slot	*slot = mmc_priv(mmc);
 	struct atmel_mci	*host = slot->host;
-	struct device		*dev = &host->pdev->dev;
+	struct device		*dev = host->dev;
 	struct mmc_data		*data;
 
 	WARN_ON(slot->mrq);
@@ -1599,7 +1599,7 @@ static void atmci_request_end(struct atmel_mci *host, struct mmc_request *mrq)
 {
 	struct atmel_mci_slot	*slot = NULL;
 	struct mmc_host		*prev_mmc = host->cur_slot->mmc;
-	struct device		*dev = &host->pdev->dev;
+	struct device		*dev = host->dev;
 
 	WARN_ON(host->cmd || host->data);
 
@@ -1760,9 +1760,9 @@ static void atmci_detect_change(struct timer_list *t)
 static void atmci_tasklet_func(struct tasklet_struct *t)
 {
 	struct atmel_mci        *host = from_tasklet(host, t, tasklet);
-	struct device		*dev = &host->pdev->dev;
 	struct mmc_request	*mrq = host->mrq;
 	struct mmc_data		*data = host->data;
+	struct device		*dev = host->dev;
 	enum atmel_mci_state	state = host->state;
 	enum atmel_mci_state	prev_state;
 	u32			status;
@@ -2108,7 +2108,7 @@ static void atmci_sdio_interrupt(struct atmel_mci *host, u32 status)
 static irqreturn_t atmci_interrupt(int irq, void *dev_id)
 {
 	struct atmel_mci	*host = dev_id;
-	struct device		*dev = &host->pdev->dev;
+	struct device		*dev = host->dev;
 	u32			status, mask, pending;
 	unsigned int		pass_count = 0;
 
@@ -2253,7 +2253,7 @@ static int atmci_init_slot(struct atmel_mci *host,
 		struct mci_slot_pdata *slot_data, unsigned int id,
 		u32 sdc_reg, u32 sdio_irq)
 {
-	struct device			*dev = &host->pdev->dev;
+	struct device			*dev = host->dev;
 	struct mmc_host			*mmc;
 	struct atmel_mci_slot		*slot;
 	int ret;
@@ -2377,7 +2377,7 @@ static void atmci_cleanup_slot(struct atmel_mci_slot *slot,
 
 static int atmci_configure_dma(struct atmel_mci *host)
 {
-	struct device *dev = &host->pdev->dev;
+	struct device *dev = host->dev;
 
 	host->dma.chan = dma_request_chan(dev, "rxtx");
 	if (IS_ERR(host->dma.chan))
@@ -2403,7 +2403,7 @@ static int atmci_configure_dma(struct atmel_mci *host)
  */
 static void atmci_get_cap(struct atmel_mci *host)
 {
-	struct device *dev = &host->pdev->dev;
+	struct device *dev = host->dev;
 	unsigned int version;
 
 	version = atmci_get_version(host);
@@ -2481,7 +2481,7 @@ static int atmci_probe(struct platform_device *pdev)
 	if (!host)
 		return -ENOMEM;
 
-	host->pdev = pdev;
+	host->dev = dev;
 	spin_lock_init(&host->lock);
 	INIT_LIST_HEAD(&host->queue);
 
-- 
2.43.0.rc1.1336.g36b5255a03ac


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v1 4/5] mmc: atmel-mci: Incapsulate used to be a platform data into host structure
  2024-04-17 16:55 [PATCH v1 0/5] mmc: atmel-mci: Get rid of leftovers and clean up Andy Shevchenko
                   ` (2 preceding siblings ...)
  2024-04-17 16:55 ` [PATCH v1 3/5] mmc: atmel-mci: Replace platform device pointer by generic one Andy Shevchenko
@ 2024-04-17 16:55 ` Andy Shevchenko
  2024-04-17 20:42   ` kernel test robot
  2024-04-17 16:55 ` [PATCH v1 5/5] mmc: atmel-mci: Switch to use dev_err_probe() Andy Shevchenko
  2024-04-25 16:22 ` [PATCH v1 0/5] mmc: atmel-mci: Get rid of leftovers and clean up Ulf Hansson
  5 siblings, 1 reply; 9+ messages in thread
From: Andy Shevchenko @ 2024-04-17 16:55 UTC (permalink / raw)
  To: Andy Shevchenko, linux-mmc, linux-arm-kernel, linux-kernel
  Cc: Aubin Constans, Ulf Hansson, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea

After platform data is gone, we always allocate memory for the slot
information. Incapsulate the array of the latter into the host structure,
so we allocate memory only once. This makes code simpler.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/mmc/host/atmel-mci.c | 66 ++++++++++++++----------------------
 1 file changed, 25 insertions(+), 41 deletions(-)

diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
index 3aed57c392fa..3ae17b8584a2 100644
--- a/drivers/mmc/host/atmel-mci.c
+++ b/drivers/mmc/host/atmel-mci.c
@@ -224,14 +224,6 @@ struct mci_slot_pdata {
 	bool			non_removable;
 };
 
-/**
- * struct mci_platform_data - board-specific MMC/SDcard configuration
- * @slot: Per-slot configuration data.
- */
-struct mci_platform_data {
-	struct mci_slot_pdata	slot[ATMCI_MAX_NR_SLOTS];
-};
-
 struct atmel_mci_caps {
 	bool    has_dma_conf_reg;
 	bool    has_pdc;
@@ -375,6 +367,7 @@ struct atmel_mci {
 	struct clk		*mck;
 	struct device		*dev;
 
+	struct mci_slot_pdata	pdata[ATMCI_MAX_NR_SLOTS];
 	struct atmel_mci_slot	*slot[ATMCI_MAX_NR_SLOTS];
 
 	struct atmel_mci_caps   caps;
@@ -630,22 +623,16 @@ static const struct of_device_id atmci_dt_ids[] = {
 
 MODULE_DEVICE_TABLE(of, atmci_dt_ids);
 
-static struct mci_platform_data *atmci_of_init(struct device *dev)
+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;
-	struct mci_platform_data *pdata;
 	u32 slot_id;
 	int err;
 
-	if (!np) {
-		dev_err(dev, "device node not found\n");
-		return ERR_PTR(-EINVAL);
-	}
-
-	pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
-	if (!pdata)
-		return ERR_PTR(-ENOMEM);
+	if (!np)
+		return dev_err_probe(dev, -EINVAL, "device node not found\n");
 
 	for_each_child_of_node(np, cnp) {
 		if (of_property_read_u32(cnp, "reg", &slot_id)) {
@@ -661,38 +648,38 @@ static struct mci_platform_data *atmci_of_init(struct device *dev)
 		}
 
 		if (of_property_read_u32(cnp, "bus-width",
-		                         &pdata->slot[slot_id].bus_width))
-			pdata->slot[slot_id].bus_width = 1;
+					 &host->pdata[slot_id].bus_width))
+			host->pdata[slot_id].bus_width = 1;
 
-		pdata->slot[slot_id].detect_pin =
+		host->pdata[slot_id].detect_pin =
 			devm_fwnode_gpiod_get(dev, of_fwnode_handle(cnp),
 					      "cd", GPIOD_IN, "cd-gpios");
-		err = PTR_ERR_OR_ZERO(pdata->slot[slot_id].detect_pin);
+		err = PTR_ERR_OR_ZERO(host->pdata[slot_id].detect_pin);
 		if (err) {
 			if (err != -ENOENT) {
 				of_node_put(cnp);
-				return ERR_PTR(err);
+				return err;
 			}
-			pdata->slot[slot_id].detect_pin = NULL;
+			host->pdata[slot_id].detect_pin = NULL;
 		}
 
-		pdata->slot[slot_id].non_removable =
+		host->pdata[slot_id].non_removable =
 			of_property_read_bool(cnp, "non-removable");
 
-		pdata->slot[slot_id].wp_pin =
+		host->pdata[slot_id].wp_pin =
 			devm_fwnode_gpiod_get(dev, of_fwnode_handle(cnp),
 					      "wp", GPIOD_IN, "wp-gpios");
-		err = PTR_ERR_OR_ZERO(pdata->slot[slot_id].wp_pin);
+		err = PTR_ERR_OR_ZERO(host->pdata[slot_id].wp_pin);
 		if (err) {
 			if (err != -ENOENT) {
 				of_node_put(cnp);
-				return ERR_PTR(err);
+				return err;
 			}
-			pdata->slot[slot_id].wp_pin = NULL;
+			host->pdata[slot_id].wp_pin = NULL;
 		}
 	}
 
-	return pdata;
+	return 0;
 }
 
 static inline unsigned int atmci_get_version(struct atmel_mci *host)
@@ -2456,7 +2443,6 @@ static void atmci_get_cap(struct atmel_mci *host)
 static int atmci_probe(struct platform_device *pdev)
 {
 	struct device			*dev = &pdev->dev;
-	struct mci_platform_data	*pdata;
 	struct atmel_mci		*host;
 	struct resource			*regs;
 	unsigned int			nr_slots;
@@ -2467,12 +2453,6 @@ static int atmci_probe(struct platform_device *pdev)
 	if (!regs)
 		return -ENXIO;
 
-	pdata = atmci_of_init(dev);
-	if (IS_ERR(pdata)) {
-		dev_err(dev, "platform data not available\n");
-		return PTR_ERR(pdata);
-	}
-
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0)
 		return irq;
@@ -2485,6 +2465,10 @@ static int atmci_probe(struct platform_device *pdev)
 	spin_lock_init(&host->lock);
 	INIT_LIST_HEAD(&host->queue);
 
+	ret = atmci_of_init(host);
+	if (ret)
+		return dev_err_probe(dev, ret, "Slot information not available\n");
+
 	host->mck = devm_clk_get(dev, "mci_clk");
 	if (IS_ERR(host->mck))
 		return PTR_ERR(host->mck);
@@ -2544,16 +2528,16 @@ static int atmci_probe(struct platform_device *pdev)
 	/* We need at least one slot to succeed */
 	nr_slots = 0;
 	ret = -ENODEV;
-	if (pdata->slot[0].bus_width) {
-		ret = atmci_init_slot(host, &pdata->slot[0],
+	if (host->pdata[0].bus_width) {
+		ret = atmci_init_slot(host, &host->pdata[0],
 				0, ATMCI_SDCSEL_SLOT_A, ATMCI_SDIOIRQA);
 		if (!ret) {
 			nr_slots++;
 			host->buf_size = host->slot[0]->mmc->max_req_size;
 		}
 	}
-	if (pdata->slot[1].bus_width) {
-		ret = atmci_init_slot(host, &pdata->slot[1],
+	if (host->pdata[1].bus_width) {
+		ret = atmci_init_slot(host, &host->pdata[1],
 				1, ATMCI_SDCSEL_SLOT_B, ATMCI_SDIOIRQB);
 		if (!ret) {
 			nr_slots++;
-- 
2.43.0.rc1.1336.g36b5255a03ac


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v1 5/5] mmc: atmel-mci: Switch to use dev_err_probe()
  2024-04-17 16:55 [PATCH v1 0/5] mmc: atmel-mci: Get rid of leftovers and clean up Andy Shevchenko
                   ` (3 preceding siblings ...)
  2024-04-17 16:55 ` [PATCH v1 4/5] mmc: atmel-mci: Incapsulate used to be a platform data into host structure Andy Shevchenko
@ 2024-04-17 16:55 ` Andy Shevchenko
  2024-04-25 16:22 ` [PATCH v1 0/5] mmc: atmel-mci: Get rid of leftovers and clean up Ulf Hansson
  5 siblings, 0 replies; 9+ messages in thread
From: Andy Shevchenko @ 2024-04-17 16:55 UTC (permalink / raw)
  To: Andy Shevchenko, linux-mmc, linux-arm-kernel, linux-kernel
  Cc: Aubin Constans, Ulf Hansson, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea

Switch to use dev_err_probe() to simplify the error path and
unify a message template.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/mmc/host/atmel-mci.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
index 3ae17b8584a2..c4502482d967 100644
--- a/drivers/mmc/host/atmel-mci.c
+++ b/drivers/mmc/host/atmel-mci.c
@@ -2548,7 +2548,7 @@ static int atmci_probe(struct platform_device *pdev)
 	}
 
 	if (!nr_slots) {
-		dev_err(dev, "init failed: no slot defined\n");
+		dev_err_probe(dev, ret, "init failed: no slot defined\n");
 		goto err_init_slot;
 	}
 
@@ -2557,8 +2557,7 @@ static int atmci_probe(struct platform_device *pdev)
 		                                  &host->buf_phys_addr,
 						  GFP_KERNEL);
 		if (!host->buffer) {
-			ret = -ENOMEM;
-			dev_err(dev, "buffer allocation failed\n");
+			ret = dev_err_probe(dev, -ENOMEM, "buffer allocation failed\n");
 			goto err_dma_alloc;
 		}
 	}
-- 
2.43.0.rc1.1336.g36b5255a03ac


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v1 4/5] mmc: atmel-mci: Incapsulate used to be a platform data into host structure
  2024-04-17 16:55 ` [PATCH v1 4/5] mmc: atmel-mci: Incapsulate used to be a platform data into host structure Andy Shevchenko
@ 2024-04-17 20:42   ` kernel test robot
  2024-04-18  9:33     ` Andy Shevchenko
  0 siblings, 1 reply; 9+ messages in thread
From: kernel test robot @ 2024-04-17 20:42 UTC (permalink / raw)
  To: Andy Shevchenko, linux-mmc, linux-arm-kernel, linux-kernel
  Cc: llvm, oe-kbuild-all, Aubin Constans, Ulf Hansson, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea

Hi Andy,

kernel test robot noticed the following build warnings:

[auto build test WARNING on soc/for-next]
[also build test WARNING on linus/master v6.9-rc4 next-20240417]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/mmc-atmel-mci-Get-rid-of-platform-data-leftovers/20240418-005915
base:   https://git.kernel.org/pub/scm/linux/kernel/git/soc/soc.git for-next
patch link:    https://lore.kernel.org/r/20240417165708.2965612-5-andriy.shevchenko%40linux.intel.com
patch subject: [PATCH v1 4/5] mmc: atmel-mci: Incapsulate used to be a platform data into host structure
config: arm-defconfig (https://download.01.org/0day-ci/archive/20240418/202404180428.bZDYDFAE-lkp@intel.com/config)
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project.git f28c006a5895fc0e329fe15fead81e37457cb1d1)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240418/202404180428.bZDYDFAE-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202404180428.bZDYDFAE-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/mmc/host/atmel-mci.c:378: warning: Function parameter or struct member 'pdata' not described in 'atmel_mci'


vim +378 drivers/mmc/host/atmel-mci.c

65e8b083fc8ec3 Haavard Skinnemoen 2008-07-30  245  
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  246  /**
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  247   * struct atmel_mci - MMC controller state shared between all slots
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  248   * @lock: Spinlock protecting the queue and associated data.
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  249   * @regs: Pointer to MMIO registers.
796211b7953bd1 Ludovic Desroches  2011-08-11  250   * @sg: Scatterlist entry currently being processed by PIO or PDC code.
f51874b7ec92cb Lee Jones          2020-07-01  251   * @sg_len: Size of the scatterlist
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  252   * @pio_offset: Offset into the current scatterlist entry.
7a90dcc2d7ceb6 Ludovic Desroches  2012-05-16  253   * @buffer: Buffer used if we don't have the r/w proof capability. We
7a90dcc2d7ceb6 Ludovic Desroches  2012-05-16  254   *      don't have the time to switch pdc buffers so we have to use only
7a90dcc2d7ceb6 Ludovic Desroches  2012-05-16  255   *      one buffer for the full transaction.
7a90dcc2d7ceb6 Ludovic Desroches  2012-05-16  256   * @buf_size: size of the buffer.
f51874b7ec92cb Lee Jones          2020-07-01  257   * @buf_phys_addr: buffer address needed for pdc.
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  258   * @cur_slot: The slot which is currently using the controller.
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  259   * @mrq: The request currently being processed on @cur_slot,
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  260   *	or NULL if the controller is idle.
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  261   * @cmd: The command currently being sent to the card, or NULL.
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  262   * @data: The data currently being transferred, or NULL if no data
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  263   *	transfer is in progress.
796211b7953bd1 Ludovic Desroches  2011-08-11  264   * @data_size: just data->blocks * data->blksz.
65e8b083fc8ec3 Haavard Skinnemoen 2008-07-30  265   * @dma: DMA client state.
65e8b083fc8ec3 Haavard Skinnemoen 2008-07-30  266   * @data_chan: DMA channel being used for the current data transfer.
f51874b7ec92cb Lee Jones          2020-07-01  267   * @dma_conf: Configuration for the DMA slave
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  268   * @cmd_status: Snapshot of SR taken upon completion of the current
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  269   *	command. Only valid when EVENT_CMD_COMPLETE is pending.
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  270   * @data_status: Snapshot of SR taken upon completion of the current
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  271   *	data transfer. Only valid when EVENT_DATA_COMPLETE or
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  272   *	EVENT_DATA_ERROR is pending.
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  273   * @stop_cmdr: Value to be loaded into CMDR when the stop command is
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  274   *	to be sent.
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  275   * @tasklet: Tasklet running the request state machine.
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  276   * @pending_events: Bitmask of events flagged by the interrupt handler
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  277   *	to be processed by the tasklet.
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  278   * @completed_events: Bitmask of events which the state machine has
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  279   *	processed.
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  280   * @state: Tasklet state.
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  281   * @queue: List of slots waiting for access to the controller.
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  282   * @need_clock_update: Update the clock rate before the next request.
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  283   * @need_reset: Reset controller before next request.
24011f346471f7 Ludovic Desroches  2012-05-16  284   * @timer: Timer to balance the data timeout error flag which cannot rise.
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  285   * @mode_reg: Value of the MR register.
74791a2dc8dc2a Nicolas Ferre      2009-12-14  286   * @cfg_reg: Value of the CFG register.
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  287   * @bus_hz: The rate of @mck in Hz. This forms the basis for MMC bus
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  288   *	rate and timeout calculations.
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  289   * @mapbase: Physical address of the MMIO registers.
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  290   * @mck: The peripheral bus clock hooked up to the MMC controller.
d9faa6e8381c3a Andy Shevchenko    2024-04-17  291   * @dev: Device associated with the MMC controller.
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  292   * @slot: Slots sharing this MMC controller.
796211b7953bd1 Ludovic Desroches  2011-08-11  293   * @caps: MCI capabilities depending on MCI version.
796211b7953bd1 Ludovic Desroches  2011-08-11  294   * @prepare_data: function to setup MCI before data transfer which
796211b7953bd1 Ludovic Desroches  2011-08-11  295   * depends on MCI capabilities.
796211b7953bd1 Ludovic Desroches  2011-08-11  296   * @submit_data: function to start data transfer which depends on MCI
796211b7953bd1 Ludovic Desroches  2011-08-11  297   * capabilities.
796211b7953bd1 Ludovic Desroches  2011-08-11  298   * @stop_transfer: function to stop data transfer which depends on MCI
796211b7953bd1 Ludovic Desroches  2011-08-11  299   * capabilities.
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  300   *
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  301   * Locking
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  302   * =======
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  303   *
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  304   * @lock is a softirq-safe spinlock protecting @queue as well as
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  305   * @cur_slot, @mrq and @state. These must always be updated
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  306   * at the same time while holding @lock.
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  307   *
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  308   * @lock also protects mode_reg and need_clock_update since these are
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  309   * used to synchronize mode register updates with the queue
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  310   * processing.
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  311   *
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  312   * The @mrq field of struct atmel_mci_slot is also protected by @lock,
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  313   * and must always be written at the same time as the slot is added to
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  314   * @queue.
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  315   *
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  316   * @pending_events and @completed_events are accessed using atomic bit
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  317   * operations, so they don't need any locking.
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  318   *
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  319   * None of the fields touched by the interrupt handler need any
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  320   * locking. However, ordering is important: Before EVENT_DATA_ERROR or
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  321   * EVENT_DATA_COMPLETE is set in @pending_events, all data-related
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  322   * interrupts must be disabled and @data_status updated with a
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  323   * snapshot of SR. Similarly, before EVENT_CMD_COMPLETE is set, the
25985edcedea63 Lucas De Marchi    2011-03-30  324   * CMDRDY interrupt must be disabled and @cmd_status updated with a
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  325   * snapshot of SR, and before EVENT_XFER_COMPLETE can be set, the
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  326   * bytes_xfered field of @data must be written. This is ensured by
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  327   * using barriers.
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  328   */
7d2be0749a5909 Haavard Skinnemoen 2008-06-30  329  struct atmel_mci {
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  330  	spinlock_t		lock;
7d2be0749a5909 Haavard Skinnemoen 2008-06-30  331  	void __iomem		*regs;
7d2be0749a5909 Haavard Skinnemoen 2008-06-30  332  
7d2be0749a5909 Haavard Skinnemoen 2008-06-30  333  	struct scatterlist	*sg;
bdbc5d0c60f3e9 Terry Barnaby      2013-04-08  334  	unsigned int		sg_len;
7d2be0749a5909 Haavard Skinnemoen 2008-06-30  335  	unsigned int		pio_offset;
7a90dcc2d7ceb6 Ludovic Desroches  2012-05-16  336  	unsigned int		*buffer;
7a90dcc2d7ceb6 Ludovic Desroches  2012-05-16  337  	unsigned int		buf_size;
7a90dcc2d7ceb6 Ludovic Desroches  2012-05-16  338  	dma_addr_t		buf_phys_addr;
7d2be0749a5909 Haavard Skinnemoen 2008-06-30  339  
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  340  	struct atmel_mci_slot	*cur_slot;
7d2be0749a5909 Haavard Skinnemoen 2008-06-30  341  	struct mmc_request	*mrq;
7d2be0749a5909 Haavard Skinnemoen 2008-06-30  342  	struct mmc_command	*cmd;
7d2be0749a5909 Haavard Skinnemoen 2008-06-30  343  	struct mmc_data		*data;
796211b7953bd1 Ludovic Desroches  2011-08-11  344  	unsigned int		data_size;
7d2be0749a5909 Haavard Skinnemoen 2008-06-30  345  
65e8b083fc8ec3 Haavard Skinnemoen 2008-07-30  346  	struct atmel_mci_dma	dma;
65e8b083fc8ec3 Haavard Skinnemoen 2008-07-30  347  	struct dma_chan		*data_chan;
e2b35f3dbfc080 Viresh Kumar       2012-02-01  348  	struct dma_slave_config	dma_conf;
65e8b083fc8ec3 Haavard Skinnemoen 2008-07-30  349  
7d2be0749a5909 Haavard Skinnemoen 2008-06-30  350  	u32			cmd_status;
7d2be0749a5909 Haavard Skinnemoen 2008-06-30  351  	u32			data_status;
7d2be0749a5909 Haavard Skinnemoen 2008-06-30  352  	u32			stop_cmdr;
7d2be0749a5909 Haavard Skinnemoen 2008-06-30  353  
7d2be0749a5909 Haavard Skinnemoen 2008-06-30  354  	struct tasklet_struct	tasklet;
7d2be0749a5909 Haavard Skinnemoen 2008-06-30  355  	unsigned long		pending_events;
7d2be0749a5909 Haavard Skinnemoen 2008-06-30  356  	unsigned long		completed_events;
c06ad2580dca4e Haavard Skinnemoen 2008-07-31  357  	enum atmel_mci_state	state;
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  358  	struct list_head	queue;
7d2be0749a5909 Haavard Skinnemoen 2008-06-30  359  
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  360  	bool			need_clock_update;
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  361  	bool			need_reset;
24011f346471f7 Ludovic Desroches  2012-05-16  362  	struct timer_list	timer;
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  363  	u32			mode_reg;
74791a2dc8dc2a Nicolas Ferre      2009-12-14  364  	u32			cfg_reg;
7d2be0749a5909 Haavard Skinnemoen 2008-06-30  365  	unsigned long		bus_hz;
7d2be0749a5909 Haavard Skinnemoen 2008-06-30  366  	unsigned long		mapbase;
7d2be0749a5909 Haavard Skinnemoen 2008-06-30  367  	struct clk		*mck;
d9faa6e8381c3a Andy Shevchenko    2024-04-17  368  	struct device		*dev;
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  369  
e20b1c52f08695 Andy Shevchenko    2024-04-17  370  	struct mci_slot_pdata	pdata[ATMCI_MAX_NR_SLOTS];
2c96a293bbd6b3 Ludovic Desroches  2011-08-11  371  	struct atmel_mci_slot	*slot[ATMCI_MAX_NR_SLOTS];
796211b7953bd1 Ludovic Desroches  2011-08-11  372  
796211b7953bd1 Ludovic Desroches  2011-08-11  373  	struct atmel_mci_caps   caps;
796211b7953bd1 Ludovic Desroches  2011-08-11  374  
796211b7953bd1 Ludovic Desroches  2011-08-11  375  	u32 (*prepare_data)(struct atmel_mci *host, struct mmc_data *data);
796211b7953bd1 Ludovic Desroches  2011-08-11  376  	void (*submit_data)(struct atmel_mci *host, struct mmc_data *data);
796211b7953bd1 Ludovic Desroches  2011-08-11  377  	void (*stop_transfer)(struct atmel_mci *host);
965ebf33ea5afb Haavard Skinnemoen 2008-09-17 @378  };
965ebf33ea5afb Haavard Skinnemoen 2008-09-17  379  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v1 4/5] mmc: atmel-mci: Incapsulate used to be a platform data into host structure
  2024-04-17 20:42   ` kernel test robot
@ 2024-04-18  9:33     ` Andy Shevchenko
  0 siblings, 0 replies; 9+ messages in thread
From: Andy Shevchenko @ 2024-04-18  9:33 UTC (permalink / raw)
  To: kernel test robot
  Cc: linux-mmc, linux-arm-kernel, linux-kernel, llvm, oe-kbuild-all,
	Aubin Constans, Ulf Hansson, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea

On Thu, Apr 18, 2024 at 04:42:07AM +0800, kernel test robot wrote:
> Hi Andy,
> 
> kernel test robot noticed the following build warnings:
> 
> [auto build test WARNING on soc/for-next]
> [also build test WARNING on linus/master v6.9-rc4 next-20240417]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch#_base_tree_information]
> 
> url:    https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/mmc-atmel-mci-Get-rid-of-platform-data-leftovers/20240418-005915
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/soc/soc.git for-next
> patch link:    https://lore.kernel.org/r/20240417165708.2965612-5-andriy.shevchenko%40linux.intel.com
> patch subject: [PATCH v1 4/5] mmc: atmel-mci: Incapsulate used to be a platform data into host structure
> config: arm-defconfig (https://download.01.org/0day-ci/archive/20240418/202404180428.bZDYDFAE-lkp@intel.com/config)
> compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project.git f28c006a5895fc0e329fe15fead81e37457cb1d1)
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240418/202404180428.bZDYDFAE-lkp@intel.com/reproduce)
> 
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202404180428.bZDYDFAE-lkp@intel.com/
> 
> All warnings (new ones prefixed by >>):
> 
> >> drivers/mmc/host/atmel-mci.c:378: warning: Function parameter or struct member 'pdata' not described in 'atmel_mci'

Indeed. I'll fix this in next version, but will wait for others to comment on
the real code and approach in general.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v1 0/5] mmc: atmel-mci: Get rid of leftovers and clean up
  2024-04-17 16:55 [PATCH v1 0/5] mmc: atmel-mci: Get rid of leftovers and clean up Andy Shevchenko
                   ` (4 preceding siblings ...)
  2024-04-17 16:55 ` [PATCH v1 5/5] mmc: atmel-mci: Switch to use dev_err_probe() Andy Shevchenko
@ 2024-04-25 16:22 ` Ulf Hansson
  5 siblings, 0 replies; 9+ messages in thread
From: Ulf Hansson @ 2024-04-25 16:22 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: linux-mmc, linux-arm-kernel, linux-kernel, Aubin Constans,
	Nicolas Ferre, Alexandre Belloni, Claudiu Beznea

On Wed, 17 Apr 2024 at 18:57, Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> I used to have some patches against the driver, but it appears that part
> of it has been applied (in different form as done by someone else).
> However, there is still room to improve, hence this spring cleanup series.
>
> Andy Shevchenko (5):
>   mmc: atmel-mci: Get rid of platform data leftovers
>   mmc: atmel-mci: Use temporary variable for struct device
>   mmc: atmel-mci: Replace platform device pointer by generic one
>   mmc: atmel-mci: Incapsulate used to be a platform data into host
>     structure
>   mmc: atmel-mci: Switch to use dev_err_probe()
>
>  drivers/mmc/host/atmel-mci.c | 308 +++++++++++++++--------------------
>  1 file changed, 131 insertions(+), 177 deletions(-)
>

I decided to pick patch 1->3 for next, leaving the remaining patch4
and patch5 for you to re-spin, thanks!

Kind regards
Uffe

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-04-25 16:22 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-17 16:55 [PATCH v1 0/5] mmc: atmel-mci: Get rid of leftovers and clean up Andy Shevchenko
2024-04-17 16:55 ` [PATCH v1 1/5] mmc: atmel-mci: Get rid of platform data leftovers Andy Shevchenko
2024-04-17 16:55 ` [PATCH v1 2/5] mmc: atmel-mci: Use temporary variable for struct device Andy Shevchenko
2024-04-17 16:55 ` [PATCH v1 3/5] mmc: atmel-mci: Replace platform device pointer by generic one Andy Shevchenko
2024-04-17 16:55 ` [PATCH v1 4/5] mmc: atmel-mci: Incapsulate used to be a platform data into host structure Andy Shevchenko
2024-04-17 20:42   ` kernel test robot
2024-04-18  9:33     ` Andy Shevchenko
2024-04-17 16:55 ` [PATCH v1 5/5] mmc: atmel-mci: Switch to use dev_err_probe() Andy Shevchenko
2024-04-25 16:22 ` [PATCH v1 0/5] mmc: atmel-mci: Get rid of leftovers and clean up Ulf Hansson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).