From e1b5bffc445a7d3d0025bc3a784404296f9b0bfa Mon Sep 17 00:00:00 2001 From: Stephen Boyd Date: Wed, 16 Jan 2019 20:14:46 -0800 Subject: [PATCH] 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 [avajid@codeaurora.org: resolved trivial merge conflict] Signed-off-by: Amir Vajid --- drivers/devfreq/bimc-bwmon.c | 63 +++++++++++++++++++++++------------- 1 file changed, 40 insertions(+), 23 deletions(-) diff --git a/drivers/devfreq/bimc-bwmon.c b/drivers/devfreq/bimc-bwmon.c index b93ad308057f..6b9df0478b1f 100644 --- a/drivers/devfreq/bimc-bwmon.c +++ b/drivers/devfreq/bimc-bwmon.c @@ -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);