Blame view

lib/lcm.c 441 Bytes
6016daed5   Rasmus Villemoes   lib/lcm.c: replac...
1
  #include <linux/compiler.h>
2cda2728a   Martin K. Petersen   block: Fix overru...
2
  #include <linux/gcd.h>
8bc3bcc93   Paul Gortmaker   lib: reduce the u...
3
  #include <linux/export.h>
72d39508e   H Hartley Sweeten   lib/lcm.c: quiet ...
4
  #include <linux/lcm.h>
2cda2728a   Martin K. Petersen   block: Fix overru...
5
6
7
8
9
  
  /* Lowest common multiple */
  unsigned long lcm(unsigned long a, unsigned long b)
  {
  	if (a && b)
74a5fef7c   Rasmus Villemoes   lib/lcm.c: ensure...
10
  		return (a / gcd(a, b)) * b;
69c953c85   Rasmus Villemoes   lib/lcm.c: lcm(n,...
11
12
  	else
  		return 0;
2cda2728a   Martin K. Petersen   block: Fix overru...
13
14
  }
  EXPORT_SYMBOL_GPL(lcm);
e9637415a   Mike Snitzer   block: fix blk_st...
15
16
17
18
19
20
21
22
23
24
25
  
  unsigned long lcm_not_zero(unsigned long a, unsigned long b)
  {
  	unsigned long l = lcm(a, b);
  
  	if (l)
  		return l;
  
  	return (b ? : a);
  }
  EXPORT_SYMBOL_GPL(lcm_not_zero);