Skip to content

Commit aacb99d

Browse files
mszyprowbebarino
authored andcommitted
clk: samsung: Revert "clk: Use device_get_match_data()"
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 2bc5feb ("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 409c39e. Cc: <[email protected]> Fixes: 409c39e ("clk: Use device_get_match_data()") Signed-off-by: Marek Szyprowski <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Krzysztof Kozlowski <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Stephen Boyd <[email protected]>
1 parent a225493 commit aacb99d

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

drivers/clk/samsung/clk-exynos-clkout.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
#include <linux/io.h>
1414
#include <linux/of.h>
1515
#include <linux/of_address.h>
16+
#include <linux/of_device.h>
1617
#include <linux/platform_device.h>
1718
#include <linux/pm.h>
18-
#include <linux/property.h>
1919

2020
#define EXYNOS_CLKOUT_NR_CLKS 1
2121
#define EXYNOS_CLKOUT_PARENTS 32
@@ -84,17 +84,24 @@ MODULE_DEVICE_TABLE(of, exynos_clkout_ids);
8484
static int exynos_clkout_match_parent_dev(struct device *dev, u32 *mux_mask)
8585
{
8686
const struct exynos_clkout_variant *variant;
87+
const struct of_device_id *match;
8788

8889
if (!dev->parent) {
8990
dev_err(dev, "not instantiated from MFD\n");
9091
return -EINVAL;
9192
}
9293

93-
variant = device_get_match_data(dev->parent);
94-
if (!variant) {
94+
/*
95+
* 'exynos_clkout_ids' arrays is not the ids array matched by
96+
* the dev->parent driver, so of_device_get_match_data() or
97+
* device_get_match_data() cannot be used here.
98+
*/
99+
match = of_match_device(exynos_clkout_ids, dev->parent);
100+
if (!match) {
95101
dev_err(dev, "cannot match parent device\n");
96102
return -EINVAL;
97103
}
104+
variant = match->data;
98105

99106
*mux_mask = variant->mux_mask;
100107

0 commit comments

Comments
 (0)