[Skiboot] [PATCH V7 2/3] occ: Fix Pstate ordering for P9

Vaidyanathan Srinivasan svaidy at linux.vnet.ibm.com
Fri May 26 18:34:08 AEST 2017


* Michael Neuling <mikey at neuling.org> [2017-05-22 11:13:38]:

> On Tue, 2017-02-14 at 02:01 +0530, Shilpasri G Bhat wrote:

[snip]

> > + * cmp_pstates: Compares the given two pstates and determines which
> > + *              among them is associated with a higher pstate.
> > + *
> > + * @a, at b: The pstate ids of the pstates being compared.
> > + *
> > + * Returns: -1 : If pstate associated with @a is smaller than
> > + *               the pstate associated with @b.
> > + *	     0 : If pstates associated with @a and @b are equal.
> > + *	     1 : If pstate associated with @a is greater than
> > + *               the pstate associated with @b.
> > + */
> > +static int (*cmp_pstates)(int a, int b);
> > +
> > +static int cmp_positive_pstates(int a, int b)
> > +{
> > +	if (a > b)
> > +		return -1;
> > +	else if (a < b)
> > +		return 1;
> > +
> > +	return 0;
> > +}
> > +
> > +static int cmp_negative_pstates(int a, int b)
> > +{
> > +	if (a < b)
> > +		return -1;
> > +	else if (a > b)
> > +		return 1;
> > +
> > +	return 0;
> > +}
> > +
> 
> Can these just return a bool?  The callers only care about > 0.

I tried converting to bool, but the validation checks become
inaccurate.  We really need to skip the equal case and check for
greater or less.

I tried to change like this:

/**
 * cmp_pstates: Compares the given two pstates and determines which
 *              among them is associated with a higher pstate.
 *
 * @a, at b: The pstate ids of the pstates being compared.
 *
 * Returns: false: If pstate associated with @a is smaller than
 *                 or equal to the pstate associated with @b.
 *	    true: If pstate associated with @a is greater than
 *               the pstate associated with @b.
 */

Merging the equal condition with true or false is not very obvious to
the caller.  So I decided to keep the current " < 0", " = 0", "> 0"
condition similar to other string compare routines.

--Vaidy



More information about the Skiboot mailing list