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);