Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 58b0a943 authored by Stephen Boyd's avatar Stephen Boyd
Browse files

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: default avatarStephen Boyd <sboyd@codeaurora.org>
parent eee45088
Loading
Loading
Loading
Loading
+40 −23
Original line number Diff line number Diff line
@@ -554,14 +554,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[] = {
@@ -577,7 +593,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;

@@ -593,16 +608,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) {
			dev_err(dev, "HW sampling rate not specified!\n");
			return ret;
@@ -641,17 +655,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);