Skip to content

Commit

Permalink
opp: ti: Use device_get_match_data()
Browse files Browse the repository at this point in the history
Use preferred device_get_match_data() instead of of_match_device() to
get the driver match data. With this, adjust the includes to explicitly
include the correct headers.

As this driver only does DT based matching, of_match_device() will never
return NULL if we've gotten to probe(). Therefore, the NULL check and
error return for it can be dropped.

Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
  • Loading branch information
Rob Herring authored and Viresh Kumar committed Nov 23, 2023
1 parent b85ea95 commit 4c58e9d
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions drivers/opp/ti-opp-supply.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/pm_opp.h>
#include <linux/property.h>
#include <linux/regulator/consumer.h>
#include <linux/slab.h>

Expand Down Expand Up @@ -373,23 +374,15 @@ static int ti_opp_supply_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct device *cpu_dev = get_cpu_device(0);
const struct of_device_id *match;
const struct ti_opp_supply_of_data *of_data;
int ret = 0;

match = of_match_device(ti_opp_supply_of_match, dev);
if (!match) {
/* We do not expect this to happen */
dev_err(dev, "%s: Unable to match device\n", __func__);
return -ENODEV;
}
if (!match->data) {
of_data = device_get_match_data(dev);
if (!of_data) {
/* Again, unlikely.. but mistakes do happen */
dev_err(dev, "%s: Bad data in match\n", __func__);
return -EINVAL;
}
of_data = match->data;

dev_set_drvdata(dev, (void *)of_data);

/* If we need optimized voltage */
Expand Down

0 comments on commit 4c58e9d

Please sign in to comment.