[PATCH v2 1/6] platform/x86: dell-smo8800: Change probe() ordering a bit

Hans de Goede
2024-01-06T16:09:52Z

Retrieve the IRQ number from the platform_device a bit earlier
and only call platform_set_drvdata() on successful probe
(the drvdata is only used from the remove() callback).

This is a preparation patch for moving the lis3lv02d i2c_client
instantiation from the i2c-i801 driver to dell-smo8800.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
drivers/platform/x86/dell/dell-smo8800.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/platform/x86/dell/dell-smo8800.c b/drivers/platform/x86/dell/dell-smo8800.c
index f7ec17c56833..87339cc78880 100644
--- a/drivers/platform/x86/dell/dell-smo8800.c
+++ b/drivers/platform/x86/dell/dell-smo8800.c
@@ -121,19 +121,17 @@ static int smo8800_probe(struct platform_device *device)

init_waitqueue_head(&smo8800->misc_wait);

+ err = platform_get_irq(device, 0);
+ if (err < 0)
+ return err;
+ smo8800->irq = err;
+
err = misc_register(&smo8800->miscdev);
if (err) {
dev_err(&device->dev, "failed to register misc dev: %d\n", err);
return err;
}

- platform_set_drvdata(device, smo8800);
-
- err = platform_get_irq(device, 0);
- if (err < 0)
- goto error;
- smo8800->irq = err;
-
err = request_threaded_irq(smo8800->irq, smo8800_interrupt_quick,
smo8800_interrupt_thread,
IRQF_TRIGGER_RISING | IRQF_ONESHOT,
@@ -147,6 +145,7 @@ static int smo8800_probe(struct platform_device *device)

dev_dbg(&device->dev, "device /dev/freefall registered with IRQ %d\n",
smo8800->irq);
+ platform_set_drvdata(device, smo8800);
return 0;

error:
--
2.43.0