* [PATCH] clk: samsung: Revert "clk: Use device_get_match_data()"
[not found] <CGME20240425075634eucas1p17bef12cf8ccafb6971f352d955e14fae@eucas1p1.samsung.com>
@ 2024-04-25 7:56 ` Marek Szyprowski
2024-04-25 8:04 ` Krzysztof Kozlowski
2024-04-29 17:30 ` Krzysztof Kozlowski
0 siblings, 2 replies; 3+ messages in thread
From: Marek Szyprowski @ 2024-04-25 7:56 UTC (permalink / raw)
To: linux-samsung-soc, linux-clk, linux-arm-kernel
Cc: Marek Szyprowski, Krzysztof Kozlowski, Sylwester Nawrocki,
Chanwoo Choi, Alim Akhtar, Michael Turquette, Stephen Boyd,
Rob Herring, David Lechner, Bjorn Andersson, Dmitry Baryshkov
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
original code matches the OF IDs on the PARENT device, so replacing it
with of_device_get_match_data() broke the driver.
This has been already pointed once in commit 2bc5febd05ab ("clk: samsung:
Revert "clk: samsung: exynos-clkout: Use of_device_get_match_data()"").
To avoid further confusion, add a comment about this special case, which
requires direct of_match_device() call to pass custom IDs array.
This partially reverts commit 409c39ec92a35e3708f5b5798c78eae78512cd71.
Fixes: 409c39ec92a3 ("clk: Use device_get_match_data()")
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
---
drivers/clk/samsung/clk-exynos-clkout.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/clk/samsung/clk-exynos-clkout.c b/drivers/clk/samsung/clk-exynos-clkout.c
index 3484e6cc80ad..503c6f5b20d5 100644
--- a/drivers/clk/samsung/clk-exynos-clkout.c
+++ b/drivers/clk/samsung/clk-exynos-clkout.c
@@ -13,9 +13,9 @@
#include <linux/io.h>
#include <linux/of.h>
#include <linux/of_address.h>
+#include <linux/of_device.h>
#include <linux/platform_device.h>
#include <linux/pm.h>
-#include <linux/property.h>
#define EXYNOS_CLKOUT_NR_CLKS 1
#define EXYNOS_CLKOUT_PARENTS 32
@@ -84,17 +84,24 @@ 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 = device_get_match_data(dev->parent);
- if (!variant) {
+ /*
+ * 'exynos_clkout_ids' arrays is not the ids array matched by
+ * the dev->parent driver, so of_device_get_match_data() or
+ * device_get_match_data() cannot be used here.
+ */
+ 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;
--
2.34.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] clk: samsung: Revert "clk: Use device_get_match_data()"
2024-04-25 7:56 ` [PATCH] clk: samsung: Revert "clk: Use device_get_match_data()" Marek Szyprowski
@ 2024-04-25 8:04 ` Krzysztof Kozlowski
2024-04-29 17:30 ` Krzysztof Kozlowski
1 sibling, 0 replies; 3+ messages in thread
From: Krzysztof Kozlowski @ 2024-04-25 8:04 UTC (permalink / raw)
To: Marek Szyprowski, linux-samsung-soc, linux-clk, linux-arm-kernel
Cc: Sylwester Nawrocki, Chanwoo Choi, Alim Akhtar, Michael Turquette,
Stephen Boyd, Rob Herring, David Lechner, Bjorn Andersson,
Dmitry Baryshkov
On 25/04/2024 09:56, Marek Szyprowski wrote:
> 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
> original code matches the OF IDs on the PARENT device, so replacing it
> with of_device_get_match_data() broke the driver.
>
> This has been already pointed once in commit 2bc5febd05ab ("clk: samsung:
> Revert "clk: samsung: exynos-clkout: Use of_device_get_match_data()"").
> To avoid further confusion, add a comment about this special case, which
> requires direct of_match_device() call to pass custom IDs array.
>
> This partially reverts commit 409c39ec92a35e3708f5b5798c78eae78512cd71.
D'oh! Again!
But to be honest, I think there misleading code is that exynos-clkout
(so the child) has:
.of_match_table = exynos_clkout_ids,
So one really can believe that this driver matches to exynos_clkout_ids,
which are the same as exynos-pmu (parent).
I think we should drop the of_match_table and rely on driver name
matching (MFD cell) or platform_device_id.
This patch is correct, so above solution could be added as 2 patch.
Thanks for noticing it.
Best regards,
Krzysztof
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] clk: samsung: Revert "clk: Use device_get_match_data()"
2024-04-25 7:56 ` [PATCH] clk: samsung: Revert "clk: Use device_get_match_data()" Marek Szyprowski
2024-04-25 8:04 ` Krzysztof Kozlowski
@ 2024-04-29 17:30 ` Krzysztof Kozlowski
1 sibling, 0 replies; 3+ messages in thread
From: Krzysztof Kozlowski @ 2024-04-29 17:30 UTC (permalink / raw)
To: linux-samsung-soc, linux-clk, linux-arm-kernel, Marek Szyprowski
Cc: Krzysztof Kozlowski, Sylwester Nawrocki, Chanwoo Choi,
Alim Akhtar, Michael Turquette, Stephen Boyd, Rob Herring,
David Lechner, Bjorn Andersson, Dmitry Baryshkov
On Thu, 25 Apr 2024 09:56:28 +0200, Marek Szyprowski wrote:
> 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
> original code matches the OF IDs on the PARENT device, so replacing it
> with of_device_get_match_data() broke the driver.
>
> This has been already pointed once in commit 2bc5febd05ab ("clk: samsung:
> Revert "clk: samsung: exynos-clkout: Use of_device_get_match_data()"").
> To avoid further confusion, add a comment about this special case, which
> requires direct of_match_device() call to pass custom IDs array.
>
> [...]
Applied, thanks!
[1/1] clk: samsung: Revert "clk: Use device_get_match_data()"
https://git.kernel.org/krzk/linux/c/da244c16ac58a3b1b7d8c54ec7780fd8326da2ff
Best regards,
--
Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-04-29 17:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CGME20240425075634eucas1p17bef12cf8ccafb6971f352d955e14fae@eucas1p1.samsung.com>
2024-04-25 7:56 ` [PATCH] clk: samsung: Revert "clk: Use device_get_match_data()" Marek Szyprowski
2024-04-25 8:04 ` Krzysztof Kozlowski
2024-04-29 17:30 ` Krzysztof Kozlowski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).