Thread (88 messages) 88 messages, 4 authors, 2021-09-05

Re: [PATCH 12/40] mfd: ti_am335x_tscadc: Move the driver structure allocation earlier

flat view

From: Jonathan Cameron <jic23@kernel.org>
Date: 2021-08-30 14:22:08
Also in: linux-clk, linux-devicetree, linux-iio, linux-omap

On Wed, 25 Aug 2021 17:24:50 +0200
Miquel Raynal [off-list ref] wrote:
Allocating the driver structure should be done earlier in the probe so
that we can used its members from the beginning.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
No problem with this, but I would expect either this patch or the one
immediately after it to actually take advantage of this being
available earlier in probe().
As things stand it's not clear to a reviewer that this is actually
a useful bit of refactoring.
quoted hunk ↗ jump to hunk
---
 drivers/mfd/ti_am335x_tscadc.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
index 8e86b766b619..0fef35e1e64b 100644
--- a/drivers/mfd/ti_am335x_tscadc.c
+++ b/drivers/mfd/ti_am335x_tscadc.c
@@ -124,6 +124,13 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
 	int tsc_wires = 0, adc_channels = 0, readouts = 0;
 	int total_channels, clock_rate, ctrl, err;
 
+	/* Allocate memory for device */
+	tscadc = devm_kzalloc(&pdev->dev, sizeof(*tscadc), GFP_KERNEL);
+	if (!tscadc)
+		return -ENOMEM;
+
+	tscadc->dev = &pdev->dev;
+
 	if (!pdev->dev.of_node) {
 		dev_err(&pdev->dev, "Could not find valid DT data.\n");
 		return -EINVAL;
@@ -159,13 +166,6 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
-	/* Allocate memory for device */
-	tscadc = devm_kzalloc(&pdev->dev, sizeof(*tscadc), GFP_KERNEL);
-	if (!tscadc)
-		return -ENOMEM;
-
-	tscadc->dev = &pdev->dev;
-
 	err = platform_get_irq(pdev, 0);
 	if (err < 0) {
 		dev_err(&pdev->dev, "no irq ID is specified.\n");
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help