diff mbox series

clk: samsung: Revert "clk: samsung: exynos-clkout: Use of_device_get_match_data()"

Message ID 20221108213718.32076-1-m.szyprowski@samsung.com
State New
Headers show
Series clk: samsung: Revert "clk: samsung: exynos-clkout: Use of_device_get_match_data()" | expand

Commit Message

Marek Szyprowski Nov. 8, 2022, 9:37 p.m. UTC
of_device_get_match_data() function should not be used on the device
other than the one matched to the given driver, because it always returns
the match_data of the matched driver. In case of exynos-clkout driver,
the code matched the OF IDs on the PARENT device, so replacing it with
of_device_get_match_data() broke the driver.

This reverts commit 777aaf3d1daf793461269b49c063aca1cee06a44.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
---
 drivers/clk/samsung/clk-exynos-clkout.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Krzysztof Kozlowski Nov. 15, 2022, 9:38 a.m. UTC | #1
On 09/11/2022 10:14, Krzysztof Kozlowski wrote:
> On 08/11/2022 23:53, Marek Szyprowski wrote:
>> On 08.11.2022 22:44, Krzysztof Kozlowski wrote:
>>> On 08/11/2022 22:37, Marek Szyprowski wrote:
>>>> of_device_get_match_data() function should not be used on the device
>>>> other than the one matched to the given driver, because it always returns
>>>> the match_data of the matched driver. In case of exynos-clkout driver,
>>>> the code matched the OF IDs on the PARENT device, so replacing it with
>>>> of_device_get_match_data() broke the driver.
>>>>
>>>> This reverts commit 777aaf3d1daf793461269b49c063aca1cee06a44.
>>> This was untested, automated commit and there were several other like
>>> that from Minghao. Other driver owners should check if they have the
>>> same issue. I made a quick look and seems fine, but it all depends what
>>> was the of_device_get_match_data() argument.
>>>
>>>> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
>>> Please add Cc-stable tag. Do reverts need a Fixes tag? I guess as well...
>>
>> Do we really need a CC-stable tag? v6.1-rc1 is the first release that 
>> contains that bug, so this revert imho should be simply applied as a fix 
>> for v6.1-rcX cycle.
> 
> No, then it's fine.
> 

I applied it.

Best regards,
Krzysztof
diff mbox series

Patch

diff --git a/drivers/clk/samsung/clk-exynos-clkout.c b/drivers/clk/samsung/clk-exynos-clkout.c
index 273f77d54dab..e6d6cbf8c4e6 100644
--- a/drivers/clk/samsung/clk-exynos-clkout.c
+++ b/drivers/clk/samsung/clk-exynos-clkout.c
@@ -81,17 +81,19 @@  MODULE_DEVICE_TABLE(of, exynos_clkout_ids);
 static int exynos_clkout_match_parent_dev(struct device *dev, u32 *mux_mask)
 {
 	const struct exynos_clkout_variant *variant;
+	const struct of_device_id *match;
 
 	if (!dev->parent) {
 		dev_err(dev, "not instantiated from MFD\n");
 		return -EINVAL;
 	}
 
-	variant = of_device_get_match_data(dev->parent);
-	if (!variant) {
+	match = of_match_device(exynos_clkout_ids, dev->parent);
+	if (!match) {
 		dev_err(dev, "cannot match parent device\n");
 		return -EINVAL;
 	}
+	variant = match->data;
 
 	*mux_mask = variant->mux_mask;