PM / devfreq: bw_hwmon: Reflow some code

Fix up style in this driver probe routine to use newer mechanisms
like of_device_get_match_data() and to not use things like
addresses of functions to assign function pointers. This makes
the code more readable.

Change-Id: Ib07edc0051fe9319e9a40cda7ba79646ce59b7e4
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
[avajid@codeaurora.org: resolved trivial merge conflict]
Signed-off-by: Amir Vajid <avajid@codeaurora.org>
This commit is contained in:
Stephen Boyd 2019-01-16 20:14:46 -08:00 • committed by Amir Vajid
commit e1b5bffc44

View file

@ -548,14 +548,30 @@ static int resume_bw_hwmon(struct bw_hwmon *hw)
/*************************************************************************/
static const struct bwmon_spec spec[] = {
{ .wrap_on_thres = true, .overflow = false, .throt_adj = false,
.hw_sampling = false},
{ .wrap_on_thres = false, .overflow = true, .throt_adj = false,
.hw_sampling = false},
{ .wrap_on_thres = false, .overflow = true, .throt_adj = true,
.hw_sampling = false},
{ .wrap_on_thres = false, .overflow = true, .throt_adj = true,
.hw_sampling = true},
[0] = {
.wrap_on_thres = true,
.overflow = false,
.throt_adj = false,
.hw_sampling = false
},
[1] = {
.wrap_on_thres = false,
.overflow = true,
.throt_adj = false,
.hw_sampling = false
},
[2] = {
.wrap_on_thres = false,
.overflow = true,
.throt_adj = true,
.hw_sampling = false
},
[3] = {
.wrap_on_thres = false,
.overflow = true,
.throt_adj = true,
.hw_sampling = true
},
};
static const struct of_device_id bimc_bwmon_match_table[] = {
@ -571,7 +587,6 @@ static int bimc_bwmon_driver_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
struct resource *res;
struct bwmon *m;
const struct of_device_id *id;
int ret;
u32 data;
@ -587,16 +602,15 @@ static int bimc_bwmon_driver_probe(struct platform_device *pdev)
}
m->mport = data;
id = of_match_device(bimc_bwmon_match_table, dev);
if (!id) {
m->spec = of_device_get_match_data(dev);
if (!m->spec) {
dev_err(dev, "Unknown device type!\n");
return -ENODEV;
}
m->spec = id->data;
if (has_hw_sampling(m)) {
ret = of_property_read_u32(dev->of_node,
"qcom,hw-timer-hz", &data);
ret = of_property_read_u32(dev->of_node, "qcom,hw-timer-hz",
&data);
if (ret < 0) {
dev_err(dev, "HW sampling rate not specified! (%d)\n",
ret);
@ -636,17 +650,20 @@ static int bimc_bwmon_driver_probe(struct platform_device *pdev)
m->hw.of_node = of_parse_phandle(dev->of_node, "qcom,target-dev", 0);
if (!m->hw.of_node)
return -EINVAL;
m->hw.start_hwmon = &start_bw_hwmon;
m->hw.stop_hwmon = &stop_bw_hwmon;
m->hw.suspend_hwmon = &suspend_bw_hwmon;
m->hw.resume_hwmon = &resume_bw_hwmon;
m->hw.get_bytes_and_clear = &get_bytes_and_clear;
m->hw.set_thres = &set_thres;
m->hw.start_hwmon = start_bw_hwmon;
m->hw.stop_hwmon = stop_bw_hwmon;
m->hw.suspend_hwmon = suspend_bw_hwmon;
m->hw.resume_hwmon = resume_bw_hwmon;
m->hw.get_bytes_and_clear = get_bytes_and_clear;
m->hw.set_thres = set_thres;
if (has_hw_sampling(m))
m->hw.set_hw_events = &set_hw_events;
m->hw.set_hw_events = set_hw_events;
if (m->spec->throt_adj) {
m->hw.set_throttle_adj = &mon_set_throttle_adj;
m->hw.get_throttle_adj = &mon_get_throttle_adj;
m->hw.set_throttle_adj = mon_set_throttle_adj;
m->hw.get_throttle_adj = mon_get_throttle_adj;
}
ret = register_bw_hwmon(dev, &m->hw);