summaryrefslogtreecommitdiff
path: root/sys/dev/pci
diff options
context:
space:
mode:
authorDamien Bergamini <damien@cvs.openbsd.org>2008-06-16 18:43:07 +0000
committerDamien Bergamini <damien@cvs.openbsd.org>2008-06-16 18:43:07 +0000
commita72c40ca9787b2cb58d787b68493eeb21afca8d5 (patch)
tree7c024d5627d1ef0a7d49585bcb6c4831eb90e2e5 /sys/dev/pci
parentf142736e353a7928254ae9c7fdc03df0cc9a1413 (diff)
replace min() and max() function calls by MIN() and MAX().
MIN() and MAX() are macros that can evaluate their arguments twice but it is safe in this context. following a post from miod@ about the harmfulness of min() and max() in the kernel.
Diffstat (limited to 'sys/dev/pci')
-rw-r--r--sys/dev/pci/if_iwn.c28
-rw-r--r--sys/dev/pci/if_wpi.c4
2 files changed, 16 insertions, 16 deletions
diff --git a/sys/dev/pci/if_iwn.c b/sys/dev/pci/if_iwn.c
index 3fd3df146f1..dae2d7a4bb8 100644
--- a/sys/dev/pci/if_iwn.c
+++ b/sys/dev/pci/if_iwn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_iwn.c,v 1.19 2008/04/27 19:01:59 damien Exp $ */
+/* $OpenBSD: if_iwn.c,v 1.20 2008/06/16 18:43:06 damien Exp $ */
/*-
* Copyright (c) 2007,2008
@@ -2577,11 +2577,11 @@ iwn_get_rssi(const struct iwn_rx_stat *stat)
rssi = 0;
if (mask & (1 << 0)) /* Ant A */
- rssi = max(rssi, stat->rssi[0]);
+ rssi = MAX(rssi, stat->rssi[0]);
if (mask & (1 << 1)) /* Ant B */
- rssi = max(rssi, stat->rssi[2]);
+ rssi = MAX(rssi, stat->rssi[2]);
if (mask & (1 << 2)) /* Ant C */
- rssi = max(rssi, stat->rssi[4]);
+ rssi = MAX(rssi, stat->rssi[4]);
return rssi - agc - IWN_RSSI_TO_DBM;
}
@@ -2690,8 +2690,8 @@ iwn_compute_differential_gain(struct iwn_softc *sc,
return;
/* determine antenna with highest average RSSI */
- val = max(calib->rssi[0], calib->rssi[1]);
- val = max(calib->rssi[2], val);
+ val = MAX(calib->rssi[0], calib->rssi[1]);
+ val = MAX(calib->rssi[2], val);
/* determine which antennas are connected */
sc->antmsk = 0;
@@ -2706,7 +2706,7 @@ iwn_compute_differential_gain(struct iwn_softc *sc,
val = INT_MAX; /* ok, there's at least one */
for (i = 0; i < 3; i++)
if (sc->antmsk & (1 << i))
- val = min(calib->noise[i], val);
+ val = MIN(calib->noise[i], val);
memset(&cmd, 0, sizeof cmd);
cmd.code = IWN_SET_DIFF_GAIN;
@@ -2715,7 +2715,7 @@ iwn_compute_differential_gain(struct iwn_softc *sc,
if (sc->antmsk & (1 << i)) {
cmd.gain[i] = (calib->noise[i] - val) / 30;
/* limit differential gain to 3 */
- cmd.gain[i] = min(cmd.gain[i], 3);
+ cmd.gain[i] = MIN(cmd.gain[i], 3);
cmd.gain[i] |= IWN_GAIN_SET;
}
}
@@ -2788,8 +2788,8 @@ iwn_tune_sensitivity(struct iwn_softc *sc, const struct iwn_rx_stats *stats)
/* compute maximum noise among 3 antennas */
for (i = 0; i < 3; i++)
noise[i] = (letoh32(stats->general.noise[i]) >> 8) & 0xff;
- val = max(noise[0], noise[1]);
- val = max(noise[2], val);
+ val = MAX(noise[0], noise[1]);
+ val = MAX(noise[2], val);
/* insert it into our samples table */
calib->noise_samples[calib->cur_noise_sample] = val;
calib->cur_noise_sample = (calib->cur_noise_sample + 1) % 20;
@@ -2797,13 +2797,13 @@ iwn_tune_sensitivity(struct iwn_softc *sc, const struct iwn_rx_stats *stats)
/* compute maximum noise among last 20 samples */
noise_ref = calib->noise_samples[0];
for (i = 1; i < 20; i++)
- noise_ref = max(noise_ref, calib->noise_samples[i]);
+ noise_ref = MAX(noise_ref, calib->noise_samples[i]);
/* compute maximum energy among 3 antennas */
for (i = 0; i < 3; i++)
energy[i] = letoh32(stats->general.energy[i]);
- val = min(energy[0], energy[1]);
- val = min(energy[2], val);
+ val = MIN(energy[0], energy[1]);
+ val = MIN(energy[2], val);
/* insert it into our samples table */
calib->energy_samples[calib->cur_energy_sample] = val;
calib->cur_energy_sample = (calib->cur_energy_sample + 1) % 10;
@@ -2811,7 +2811,7 @@ iwn_tune_sensitivity(struct iwn_softc *sc, const struct iwn_rx_stats *stats)
/* compute minimum energy among last 10 samples */
energy_min = calib->energy_samples[0];
for (i = 1; i < 10; i++)
- energy_min = max(energy_min, calib->energy_samples[i]);
+ energy_min = MAX(energy_min, calib->energy_samples[i]);
energy_min += 6;
/* compute number of false alarms since last call for CCK */
diff --git a/sys/dev/pci/if_wpi.c b/sys/dev/pci/if_wpi.c
index 0549b16de86..04107d3d865 100644
--- a/sys/dev/pci/if_wpi.c
+++ b/sys/dev/pci/if_wpi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_wpi.c,v 1.60 2008/04/16 18:32:15 damien Exp $ */
+/* $OpenBSD: if_wpi.c,v 1.61 2008/06/16 18:43:06 damien Exp $ */
/*-
* Copyright (c) 2006, 2007
@@ -2295,7 +2295,7 @@ wpi_get_power_index(struct wpi_softc *sc, struct wpi_power_group *group,
}
/* never exceed channel's maximum allowed Tx power */
- pwr = min(pwr, sc->maxpwr[chan]);
+ pwr = MIN(pwr, sc->maxpwr[chan]);
/* retrieve power index into gain tables from samples */
for (sample = group->samples; sample < &group->samples[3]; sample++)