diff options
author | Stefan Richter <stefanr@s5r6.in-berlin.de> | 2011-09-18 18:20:48 -0400 |
---|---|---|
committer | Stefan Richter <stefanr@s5r6.in-berlin.de> | 2011-10-09 11:00:18 -0400 |
commit | 4ec4a67aa100268b4ac5ae32b54843d975969969 (patch) | |
tree | 0cb2413784e788939edd625c2b163c7f410f2c61 | |
parent | b810e4ae111cb8b4c0ccbbe7ff4ea0a23c671e4f (diff) |
firewire: use clamp and min3 macros
Use kernel.h's convenience macros. Also omit a printk that should never
happen and won't matter much if it ever happened.
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
-rw-r--r-- | drivers/firewire/core-transaction.c | 4 | ||||
-rw-r--r-- | drivers/firewire/net.c | 6 | ||||
-rw-r--r-- | drivers/firewire/sbp2.c | 4 |
3 files changed, 5 insertions, 9 deletions
diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c index 334b82a3542c..855ab3f5936f 100644 --- a/drivers/firewire/core-transaction.c +++ b/drivers/firewire/core-transaction.c | |||
@@ -1046,8 +1046,8 @@ static void update_split_timeout(struct fw_card *card) | |||
1046 | 1046 | ||
1047 | cycles = card->split_timeout_hi * 8000 + (card->split_timeout_lo >> 19); | 1047 | cycles = card->split_timeout_hi * 8000 + (card->split_timeout_lo >> 19); |
1048 | 1048 | ||
1049 | cycles = max(cycles, 800u); /* minimum as per the spec */ | 1049 | /* minimum per IEEE 1394, maximum which doesn't overflow OHCI */ |
1050 | cycles = min(cycles, 3u * 8000u); /* maximum OHCI timeout */ | 1050 | cycles = clamp(cycles, 800u, 3u * 8000u); |
1051 | 1051 | ||
1052 | card->split_timeout_cycles = cycles; | 1052 | card->split_timeout_cycles = cycles; |
1053 | card->split_timeout_jiffies = DIV_ROUND_UP(cycles * HZ, 8000); | 1053 | card->split_timeout_jiffies = DIV_ROUND_UP(cycles * HZ, 8000); |
diff --git a/drivers/firewire/net.c b/drivers/firewire/net.c index 03a7a85d0424..d1fad1fb17e2 100644 --- a/drivers/firewire/net.c +++ b/drivers/firewire/net.c | |||
@@ -502,11 +502,7 @@ static struct fwnet_peer *fwnet_peer_find_by_node_id(struct fwnet_device *dev, | |||
502 | static unsigned fwnet_max_payload(unsigned max_rec, unsigned speed) | 502 | static unsigned fwnet_max_payload(unsigned max_rec, unsigned speed) |
503 | { | 503 | { |
504 | max_rec = min(max_rec, speed + 8); | 504 | max_rec = min(max_rec, speed + 8); |
505 | max_rec = min(max_rec, 0xbU); /* <= 4096 */ | 505 | max_rec = clamp(max_rec, 8U, 11U); /* 512...4096 */ |
506 | if (max_rec < 8) { | ||
507 | fw_notify("max_rec %x out of range\n", max_rec); | ||
508 | max_rec = 8; | ||
509 | } | ||
510 | 506 | ||
511 | return (1 << (max_rec + 1)) - RFC2374_FRAG_HDR_SIZE; | 507 | return (1 << (max_rec + 1)) - RFC2374_FRAG_HDR_SIZE; |
512 | } | 508 | } |
diff --git a/drivers/firewire/sbp2.c b/drivers/firewire/sbp2.c index 8a8047db6980..68375bc3aef6 100644 --- a/drivers/firewire/sbp2.c +++ b/drivers/firewire/sbp2.c | |||
@@ -1164,8 +1164,8 @@ static int sbp2_probe(struct device *dev) | |||
1164 | * specifies the max payload size as 2 ^ (max_payload + 2), so | 1164 | * specifies the max payload size as 2 ^ (max_payload + 2), so |
1165 | * if we set this to max_speed + 7, we get the right value. | 1165 | * if we set this to max_speed + 7, we get the right value. |
1166 | */ | 1166 | */ |
1167 | tgt->max_payload = min(device->max_speed + 7, 10U); | 1167 | tgt->max_payload = min3(device->max_speed + 7, 10U, |
1168 | tgt->max_payload = min(tgt->max_payload, device->card->max_receive - 1); | 1168 | device->card->max_receive - 1); |
1169 | 1169 | ||
1170 | /* Do the login in a workqueue so we can easily reschedule retries. */ | 1170 | /* Do the login in a workqueue so we can easily reschedule retries. */ |
1171 | list_for_each_entry(lu, &tgt->lu_list, link) | 1171 | list_for_each_entry(lu, &tgt->lu_list, link) |