[PATCH] staging: sm750fb: replace twoToPowerOfx with shift operator

Michał Kępień kernel at kempniu.pl
Thu Sep 24 13:33:30 UTC 2015


> The function twoToPowerOfx that iteratively caclulates the power of 2
> may be replaced with shift operator

calculates

> -inline unsigned int twoToPowerOfx(unsigned long x)
> -{
> -	unsigned long i;
> -	unsigned long result = 1;
> -
> -	for (i = 1; i <= x; i++)
> -		result *= 2;
> -	return result;
> -}
> -
>  inline unsigned int calcPLL(pll_value_t *pPLL)
>  {
> -	return (pPLL->inputFreq * pPLL->M / pPLL->N / twoToPowerOfx(pPLL->OD) / twoToPowerOfx(pPLL->POD));
> +	return (pPLL->inputFreq * pPLL->M / pPLL->N / (1UL << pPLL->OD) / (1UL << pPLL->POD));

The original function returned an unsigned int.  Why did you use the UL
suffix here?

Also, this line still raises a checkpatch warning about it being over 80
characters.  AFAIK, if you change a line in a patch, you should make
sure it doesn't raise any checkpatch warnings afterwards.  Don't take my
word for it, though.

-- 
Best regards,
Michał Kępień


More information about the devel mailing list