aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin K. Petersen <martin.petersen@oracle.com>2010-09-10 14:07:38 -0400
committerJens Axboe <axboe@carl.home.kernel.dk>2010-09-10 14:07:38 -0400
commitc8bf1336824ebd698d37b71763e1c43190f2229a (patch)
tree19948b3c686ba71bb2e85883a5325cec069015b7
parent76be97c1fc945db08aae1f1b746012662d643e97 (diff)
Consolidate min_not_zero
We have several users of min_not_zero, each of them using their own definition. Move the define to kernel.h. Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Jens Axboe <axboe@carl.home.kernel.dk>
-rw-r--r--block/blk-settings.c5
-rw-r--r--drivers/block/drbd/drbd_receiver.c1
-rw-r--r--drivers/md/dm-snap.c2
-rw-r--r--drivers/md/dm-table.c5
-rw-r--r--include/linux/kernel.h10
5 files changed, 10 insertions, 13 deletions
diff --git a/block/blk-settings.c b/block/blk-settings.c
index a234f4bf1d6..8d592b559bd 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -455,11 +455,6 @@ void blk_queue_io_opt(struct request_queue *q, unsigned int opt)
455} 455}
456EXPORT_SYMBOL(blk_queue_io_opt); 456EXPORT_SYMBOL(blk_queue_io_opt);
457 457
458/*
459 * Returns the minimum that is _not_ zero, unless both are zero.
460 */
461#define min_not_zero(l, r) (l == 0) ? r : ((r == 0) ? l : min(l, r))
462
463/** 458/**
464 * blk_queue_stack_limits - inherit underlying queue limits for stacked drivers 459 * blk_queue_stack_limits - inherit underlying queue limits for stacked drivers
465 * @t: the stacking driver (top) 460 * @t: the stacking driver (top)
diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
index 081522d3c74..484ecbb6b77 100644
--- a/drivers/block/drbd/drbd_receiver.c
+++ b/drivers/block/drbd/drbd_receiver.c
@@ -2972,7 +2972,6 @@ static int receive_sizes(struct drbd_conf *mdev, struct p_header *h)
2972 * we still need to figure out whether we accept that. */ 2972 * we still need to figure out whether we accept that. */
2973 mdev->p_size = p_size; 2973 mdev->p_size = p_size;
2974 2974
2975#define min_not_zero(l, r) (l == 0) ? r : ((r == 0) ? l : min(l, r))
2976 if (get_ldev(mdev)) { 2975 if (get_ldev(mdev)) {
2977 warn_if_differ_considerably(mdev, "lower level device sizes", 2976 warn_if_differ_considerably(mdev, "lower level device sizes",
2978 p_size, drbd_get_max_capacity(mdev->ldev)); 2977 p_size, drbd_get_max_capacity(mdev->ldev));
diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
index 5974d3094d9..f30f6e8d594 100644
--- a/drivers/md/dm-snap.c
+++ b/drivers/md/dm-snap.c
@@ -706,8 +706,6 @@ static int dm_add_exception(void *context, chunk_t old, chunk_t new)
706 return 0; 706 return 0;
707} 707}
708 708
709#define min_not_zero(l, r) (((l) == 0) ? (r) : (((r) == 0) ? (l) : min(l, r)))
710
711/* 709/*
712 * Return a minimum chunk size of all snapshots that have the specified origin. 710 * Return a minimum chunk size of all snapshots that have the specified origin.
713 * Return zero if the origin has no snapshots. 711 * Return zero if the origin has no snapshots.
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index f9fc07d7a4b..90267f8d64e 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -486,11 +486,6 @@ static int __table_get_device(struct dm_table *t, struct dm_target *ti,
486 return 0; 486 return 0;
487} 487}
488 488
489/*
490 * Returns the minimum that is _not_ zero, unless both are zero.
491 */
492#define min_not_zero(l, r) (l == 0) ? r : ((r == 0) ? l : min(l, r))
493
494int dm_set_device_limits(struct dm_target *ti, struct dm_dev *dev, 489int dm_set_device_limits(struct dm_target *ti, struct dm_dev *dev,
495 sector_t start, sector_t len, void *data) 490 sector_t start, sector_t len, void *data)
496{ 491{
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 2b0a35e6bc6..f5df2f4acb0 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -641,6 +641,16 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }
641 _max1 > _max2 ? _max1 : _max2; }) 641 _max1 > _max2 ? _max1 : _max2; })
642 642
643/** 643/**
644 * min_not_zero - return the minimum that is _not_ zero, unless both are zero
645 * @x: value1
646 * @y: value2
647 */
648#define min_not_zero(x, y) ({ \
649 typeof(x) __x = (x); \
650 typeof(y) __y = (y); \
651 __x == 0 ? __y : ((__y == 0) ? __x : min(__x, __y)); })
652
653/**
644 * clamp - return a value clamped to a given range with strict typechecking 654 * clamp - return a value clamped to a given range with strict typechecking
645 * @val: current value 655 * @val: current value
646 * @min: minimum allowable value 656 * @min: minimum allowable value