lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Tue, 15 Apr 2014 16:47:19 -0700
From:	Randy Dunlap <rdunlap@...radead.org>
To:	Stratos Karafotis <stratosk@...aphore.gr>,
	"Rafael J. Wysocki" <rjw@...ysocki.net>,
	Viresh Kumar <viresh.kumar@...aro.org>
CC:	"David S. Miller" <davem@...emloft.net>,
	Hans-Christian Egtvedt <egtvedt@...fundet.no>,
	Linus Walleij <linus.walleij@...aro.org>,
	Dirk Brandewie <dirk.j.brandewie@...el.com>,
	linux-doc@...r.kernel.org,
	"cpufreq@...r.kernel.org" <cpufreq@...r.kernel.org>,
	linux-pm@...r.kernel.org, LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2 1/8] cpufreq: Introduce macros for cpufreq_frequency_table
 iteration

On 04/15/2014 03:25 PM, Stratos Karafotis wrote:
> Many cpufreq drivers need to iterate over the cpufreq_frequency_table
> for various tasks.
> 
> This patch introduces two macros which can be used for iteration over
> cpufreq_frequency_table keeping a common coding style across drivers:
> 
> - cpufreq_for_each_entry: iterate over each entry of the table
> - cpufreq_for_each_valid_entry: iterate over each entry that contains
> a valid frequency.
> 
> It should have no functional changes.
> 
> Signed-off-by: Stratos Karafotis <stratosk@...aphore.gr>
> ---
>  Documentation/cpu-freq/cpu-drivers.txt | 16 ++++++++++++++++
>  drivers/cpufreq/cpufreq.c              | 11 +++++++++++
>  include/linux/cpufreq.h                | 21 +++++++++++++++++++++
>  3 files changed, 48 insertions(+)
> 
> diff --git a/Documentation/cpu-freq/cpu-drivers.txt b/Documentation/cpu-freq/cpu-drivers.txt
> index 48da5fd..2c9156a 100644
> --- a/Documentation/cpu-freq/cpu-drivers.txt
> +++ b/Documentation/cpu-freq/cpu-drivers.txt
> @@ -228,3 +228,19 @@ is the corresponding frequency table helper for the ->target
>  stage. Just pass the values to this function, and the unsigned int
>  index returns the number of the frequency table entry which contains
>  the frequency the CPU shall be set to.
> +
> +The following macros can be used as iterators over cpufreq_frequency_table:

<insert blank line>

> +cpufreq_for_each_entry(pos, table) - iterates over all entries of frequency
> +table.

<insert blank line>

> +cpufreq-for_each_valid_entry(pos, table) - iterates over all entries,
> +excluding CPUFREQ_ENTRY_INVALID frequencies.
> +Use arguments "pos" - a cpufreq_frequency_table * as a loop cursor and
> +"table" - the cpufreq_frequency_table * you want to iterate over.

<insert blank line>

> +For example:
> +
> +	struct cpufreq_frequency_table *pos, *driver_freq_table;
> +
> +	cpufreq_for_each_entry(pos, driver_freq_table) {
> +		/* Do something with pos */
> +		pos->frequency = ...
> +	}

> diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
> index 5ae5100..4f913b5 100644
> --- a/include/linux/cpufreq.h
> +++ b/include/linux/cpufreq.h
> @@ -468,6 +468,27 @@ struct cpufreq_frequency_table {
>  				    * order */
>  };
>  
> +bool cpufreq_next_valid(struct cpufreq_frequency_table **pos);
> +
> +/*
> + * cpufreq_for_each_entry -	iterate over a cpufreq_frequency_table
> + * @pos:	the cpufreq_frequency_table * to use as a loop cursor.
> + * @table:	the cpufreq_frequency_table * to iterate over.
> + */
> +
> +#define cpufreq_for_each_entry(pos, table)	\
> +	for (pos = table; pos->frequency != CPUFREQ_TABLE_END; pos++)
> +
> +/*
> + * cpufreq_for_each_valid_entry -     iterate over a cpufreq_frequency_table
> + *	exluding CPUFREQ_ENTRY_INVALID frequencies.

        excluding

> + * @pos:        the cpufreq_frequency_table * to use as a loop cursor.
> + * @table:      the cpufreq_frequency_table * to iterate over.
> + */
> +
> +#define cpufreq_for_each_valid_entry(pos, table)	\
> +	for (pos = table; cpufreq_next_valid(&pos); pos++)
> +
>  int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy,
>  				    struct cpufreq_frequency_table *table);
>  
> 


-- 
~Randy
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ