Skip to content

Commit d98ccfc

Browse files
dgerlachrafaeljw
authored andcommitted
cpufreq: ti-cpufreq: Only register platform_device when supported
Currently the ti-cpufreq driver blindly registers a 'ti-cpufreq' to force the driver to probe on any platforms where the driver is built in. However, this should only happen on platforms that actually can make use of the driver. There is already functionality in place to match the SoC compatible so let's factor this out into a separate call and make sure we find a match before creating the ti-cpufreq platform device. Reviewed-by: Johan Hovold <johan@kernel.org> Signed-off-by: Dave Gerlach <d-gerlach@ti.com> Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 9ff0119 commit d98ccfc

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

drivers/cpufreq/ti-cpufreq.c

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -201,19 +201,28 @@ static const struct of_device_id ti_cpufreq_of_match[] = {
201201
{},
202202
};
203203

204+
static const struct of_device_id *ti_cpufreq_match_node(void)
205+
{
206+
struct device_node *np;
207+
const struct of_device_id *match;
208+
209+
np = of_find_node_by_path("/");
210+
match = of_match_node(ti_cpufreq_of_match, np);
211+
of_node_put(np);
212+
213+
return match;
214+
}
215+
204216
static int ti_cpufreq_probe(struct platform_device *pdev)
205217
{
206218
u32 version[VERSION_COUNT];
207-
struct device_node *np;
208219
const struct of_device_id *match;
209220
struct opp_table *ti_opp_table;
210221
struct ti_cpufreq_data *opp_data;
211222
const char * const reg_names[] = {"vdd", "vbb"};
212223
int ret;
213224

214-
np = of_find_node_by_path("/");
215-
match = of_match_node(ti_cpufreq_of_match, np);
216-
of_node_put(np);
225+
match = dev_get_platdata(&pdev->dev);
217226
if (!match)
218227
return -ENODEV;
219228

@@ -290,7 +299,14 @@ static int ti_cpufreq_probe(struct platform_device *pdev)
290299

291300
static int ti_cpufreq_init(void)
292301
{
293-
platform_device_register_simple("ti-cpufreq", -1, NULL, 0);
302+
const struct of_device_id *match;
303+
304+
/* Check to ensure we are on a compatible platform */
305+
match = ti_cpufreq_match_node();
306+
if (match)
307+
platform_device_register_data(NULL, "ti-cpufreq", -1, match,
308+
sizeof(*match));
309+
294310
return 0;
295311
}
296312
module_init(ti_cpufreq_init);

0 commit comments

Comments
 (0)