int_sqrt() adjustments
Subsystems (8)
PATCH v3 1/1 int_sqrt() adjustments
Add __attribute_const__ and adjust to use (signed) int for the right param of "<<". Change the return value of int_sqrt() from "unsigned long" to u32 to be the same as int_sqrt64() and adjust some calling functions.
Signed-off-by Florian La Roche <[email protected]>
--- drivers/gpu/drm/i915/selftests/i915_gem_gtt.c | 8 ++++---- drivers/media/pci/cx88/cx88-dsp.c | 2 +- include/linux/kernel.h | 4 ++-- lib/int_sqrt.c | 8 ++++---- lib/prime_numbers.c | 2 +- mm/vmscan.c | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-)
drivers/gpu/drm/i915/selftests/i915_gem_gtt.c +4 -4
@@ -348,7 +348,7 @@ static int fill_hole(struct drm_i915_private *i915,struct drm_i915_gem_object *obj;const unsigned long max_pages =min_t (u64,ULONG_MAX -1 , hole_size/2 >>PAGE_SHIFT ); -const unsigned long max_step =max (int_sqrt (max_pages),2UL ); +const u32 max_step =max (int_sqrt (max_pages),2UL );unsigned long npages, prime, flags;struct i915_vma *vma;LIST_HEAD (objects);
@@ -400,7 +400,7 @@ static int fill_hole(struct drm_i915_private *i915, err =i915_vma_pin (vma,0 ,0 , offset | flags);if (err) { -pr_err ("%s(%s) pin (forward) failed with err=%d on size=%lu pages (prime=%lu), offset=%llx\n" , +pr_err ("%s(%s) pin (forward) failed with err=%d on size=%lu pages (prime=%u), offset=%llx\n" , __func__, p->name, err, npages, prime, offset); goto err; }
@@ -473,7 +473,7 @@ static int fill_hole(struct drm_i915_private *i915, err =i915_vma_pin (vma,0 ,0 , offset | flags);if (err) { -pr_err ("%s(%s) pin (backward) failed with err=%d on size=%lu pages (prime=%lu), offset=%llx\n" , +pr_err ("%s(%s) pin (backward) failed with err=%d on size=%lu pages (prime=%u), offset=%llx\n" , __func__, p->name, err, npages, prime, offset); goto err; }
@@ -533,7 +533,7 @@ static int fill_hole(struct drm_i915_private *i915, } } -if (igt_timeout (end_time,"%s timed out (npages=%lu, prime=%lu)\n" , +if (igt_timeout (end_time,"%s timed out (npages=%lu, prime=%u)\n" , __func__, npages, prime)) { err = -EINTR ; goto err;
drivers/media/pci/cx88/cx88-dsp.c +1 -1
@@ -137,7 +137,7 @@ static u32 freq_magnitude(s16 x[], u32 N, u32 freq) {u32 sum =int_goertzel (x,N , freq); -return (u32 )int_sqrt (sum); +return int_sqrt (sum); }static u32 noise_magnitude (s16 x[],u32 N ,u32 freq_start,u32 freq_end)
include/linux/kernel.h +2 -2
@@ -513,10 +513,10 @@ extern int __kernel_text_address(unsigned long addr);extern int kernel_text_address (unsigned long addr);extern int func_ptr_is_kernel_text (void *ptr); -unsigned long int_sqrt (unsigned long ); +__attribute_const__ u32 int_sqrt(unsigned long);#if BITS_PER_LONG <64 -u32 int_sqrt64 (u64 x); +__attribute_const__ u32 int_sqrt64(u64 x);#else static inline u32 int_sqrt64 (u64 x) {
lib/int_sqrt.c +4 -4
@@ -16,14 +16,14 @@* * Computes: floor(sqrt(x)) */ -unsigned long int_sqrt (unsigned long x) +__attribute_const__ u32 int_sqrt(unsigned long x) {unsigned long b, m, y =0 ;if (x <=1 )return x; - m =1UL << (__fls (x) & ~1UL ); + m =1UL << (__fls (x) & ~1 );while (m !=0 ) { b = y + m; y >>=1 ;
@@ -45,14 +45,14 @@ EXPORT_SYMBOL(int_sqrt);* is expected. * @x: 64bit integer of which to calculate the sqrt */ -u32 int_sqrt64 (u64 x) +__attribute_const__ u32 int_sqrt64(u64 x) {u64 b, m, y =0 ;if (x <=ULONG_MAX )return int_sqrt ((unsigned long ) x); - m =1ULL << ((fls64 (x) -1 ) & ~1ULL ); + m =1ULL << ((fls64 (x) -1 ) & ~1 );while (m !=0 ) { b = y + m; y >>=1 ;
lib/prime_numbers.c +1 -1
@@ -67,7 +67,7 @@ static unsigned long selftest_max;static bool slow_is_prime_number (unsigned long x) { -unsigned long y =int_sqrt (x); +u32 y =int_sqrt (x);while (y >1 ) {if ((x % y) ==0 )
mm/vmscan.c +1 -1
@@ -2216,7 +2216,7 @@ static bool inactive_list_is_low(struct lruvec *lruvec, bool file,struct pglist_data *pgdat =lruvec_pgdat (lruvec);enum lru_list inactive_lru = file *LRU_FILE ;unsigned long inactive, active; -unsigned long inactive_ratio; +u32 inactive_ratio;unsigned long refaults;unsigned long gb;
Signature · 1 line
2.17.1