aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd
diff options
context:
space:
mode:
authorMiquel Raynal <miquel.raynal@bootlin.com>2021-10-15 10:14:34 +0200
committerLee Jones <lee.jones@linaro.org>2021-10-20 17:26:04 +0100
commit6147947922fc8e4d15296ed69bf886fbe139042a (patch)
treeab073502636eddfdceed649d2066e1c5baf6a1ff /drivers/mfd
parentmfd: ti_am335x_tscadc: Simplify divisor calculation (diff)
downloadlinux-dev-6147947922fc8e4d15296ed69bf886fbe139042a.tar.xz
linux-dev-6147947922fc8e4d15296ed69bf886fbe139042a.zip
mfd: ti_am335x_tscadc: Move the driver structure allocation earlier
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> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Link: https://lore.kernel.org/r/20211015081506.933180-17-miquel.raynal@bootlin.com
Diffstat (limited to 'drivers/mfd')
-rw-r--r--drivers/mfd/ti_am335x_tscadc.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
index 20d8ddee27fe..ba821109e98b 100644
--- a/drivers/mfd/ti_am335x_tscadc.c
+++ b/drivers/mfd/ti_am335x_tscadc.c
@@ -125,6 +125,13 @@ static int ti_tscadc_probe(struct platform_device *pdev)
int tsc_wires = 0, adc_channels = 0, total_channels;
int readouts = 0;
+ /* 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;
@@ -164,13 +171,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)
return err;