Skip to contentSkip to conversation

rtc: armada38x: remove unneeded call to platform_set_drvdata()

PATCH In review Andrei Coardos 3 participants 3 messages Aug 7, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rtc: armada38x: remove unneeded call to platform_set_drvdata()

This function call was found to be unnecessary as there is no equivalent platform_get_drvdata() call to access the private data of the driver. Also, the private data is defined in this driver, so there is no risk of it being accessed outside of this driver file.

---
 drivers/rtc/rtc-armada38x.c | 1 -
 1 file changed, 1 deletion(-)
drivers/rtc/rtc-armada38x.c +0 -1
index b4139c200676..5ed028429565 100644
@@ -527,7 +527,6 @@ static __init int armada38x_rtc_probe(struct platform_device *pdev)
 		dev_warn(&pdev->dev, "Interrupt not available.\n");
 		rtc->irq = -1;
 	}
-	platform_set_drvdata(pdev, rtc);
 
 	if (rtc->irq != -1)
 		device_init_wakeup(&pdev->dev, 1);
Signature · 1 line
2.34.1
#1 lore raw
Quoted 6 lines · Andrei Coardos

This function call was found to be unnecessary as there is no equivalent platform_get_drvdata() call to access the private data of the driver. Also, the private data is defined in this driver, so there is no risk of it being accessed outside of this driver file.

NAK on this.
This still calls dev_get_drvdata() in PM routines to access the private data.

Quoted 20 lines
---
 drivers/rtc/rtc-armada38x.c | 1 -
 1 file changed, 1 deletion(-)
drivers/rtc/rtc-armada38x.c +0 -2
index b4139c200676..5ed028429565 100644
@@ -527,7 +527,6 @@ static __init int armada38x_rtc_probe(struct platform_device *pdev)
                dev_warn(&pdev->dev, "Interrupt not available.\n");
                rtc->irq = -1;
        }
-       platform_set_drvdata(pdev, rtc);
 
        if (rtc->irq != -1)
                device_init_wakeup(&pdev->dev, 1);
--

2.34.1

#2 lore raw
In reply to Andrei Coardos
Quoted 4 lines · Andrei Coardos

This function call was found to be unnecessary as there is no equivalent platform_get_drvdata() call to access the private data of the driver. Also, the private data is defined in this driver, so there is no risk of it being accessed outside of this driver file.

I hope you're not going about doing this _broken_ thing and thinking "if there's no platform_get_drvdata(), then there shouldn't be any platform_set_drvdata()" because that is WRONG. Wrong wrong wrong wrong wrong.

	platform_set_drvdata(pdev, foo);

sets the driver data on dev, and is basically implemented as:

	dev_set_drvdata(&pdev->dev, foo);

So, to access the driver data, one can either use:

platform_get_drvdata(pdev)

or:

dev_get_drvdata(dev)

where one is dealing with a "struct device" pointer. So, the lack of any platform_get_drvdata() does *NOT* mean that platform_set_drvdata() can be removed.

If that's what you've been doing, you are *creating* bugs - and you need to stop until you properly understand what you are doing.

Thanks anyway, but... your change is totally wrong and will wreck the driver, causing it to oops the kernel.

Strong and definite NAK.

I do *NOT* expect to ever see a patch like this again for this driver.

Thanks.

Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!