Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1307277

Re: [PATCH RESEND v4 4/4] cpufreq: powernv: Add sysfs attributes to show throttle stats

From Gautham R Shenoy <ego@linux.vnet.ibm.com>
Newsgroups linux.kernel
Subject Re: [PATCH RESEND v4 4/4] cpufreq: powernv: Add sysfs attributes to show throttle stats
Date 2016-01-12 12:20 +0100
Message-ID <qQ59v-8S-7@gated-at.bofh.it> (permalink)
References <qQ4n8-81P-19@gated-at.bofh.it> <qQ4n8-81P-25@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Hi Shilpa,

On Tue, Jan 12, 2016 at 04:24:27AM -0600, Shilpasri G Bhat wrote:

> +static inline int get_chip_index(struct kobject *kobj)

Probably have "get_chip_index(int id)". See the reason below.
> +{
> +	int i, id;
> +
> +	i = kstrtoint(kobj->name + 4, 0, &id);
> +	if (i)
> +		return i;
> +
> +	for (i = 0; i < nr_chips; i++)
> +		if (chips[i].id == id)
> +			return i;

This pattern to obtain a chip index from the chip id is repeated in
multiple place inside this file. Might be worthwhile to move this to a
helper function, i.e get_chip_index(id)!

> +	return -EINVAL;
> +}
> +
> +static ssize_t throttle_freq_show(struct kobject *kobj,
> +				  struct kobj_attribute *attr, char *buf)
> +{
> +	int i, count = 0, id;
> + 
        We obtain the id from kobj here and then obtain the index from
	id via the function below.
	

> +	id = get_chip_index(kobj);


> +	if (id < 0)
> +		return id;
> +
> +	for (i = 0; i < powernv_pstate_info.nr_pstates; i++)
> +		count += sprintf(&buf[count], "%d %d\n",
> +			       powernv_freqs[i].frequency,
> +			       chips[id].pstate_stat[i]);
> +
> +	return count;
> +}
> +
> +static struct kobj_attribute attr_throttle_frequencies =
> +__ATTR(throttle_frequencies, 0444, throttle_freq_show, NULL);
> +
--
Thanks and Regards
gautham.

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH RESEND v4 4/4] cpufreq: powernv: Add sysfs attributes to show throttle stats Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com> - 2016-01-12 11:30 +0100
  Re: [PATCH RESEND v4 4/4] cpufreq: powernv: Add sysfs attributes to  show throttle stats Gautham R Shenoy <ego@linux.vnet.ibm.com> - 2016-01-12 12:20 +0100

csiph-web