Skip to contentSkip to conversation

Move is_valid_reg_rule() in intersect.c.

PATCH In review Diego 'Flameeyes' Pettenò 2 participants 4 messages Dec 1, 2008 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 Move is_valid_reg_rule() in intersect.c.

The function is only ever used in that translation unit so it makes no sense to define it for all the binaries.
---

 intersect.c |   20 ++++++++++++++++++++
 reglib.c    |   20 --------------------
 reglib.h    |    1 -
 3 files changed, 20 insertions(+), 21 deletions(-)
intersect.c +20 -0
index d6d857d..2f4d416 100644
@@ -19,6 +19,26 @@
 	} \
 	} while (0)
 
+/* Sanity check on a regulatory rule */
+static int is_valid_reg_rule(const struct ieee80211_reg_rule *rule)
+{
+	const struct ieee80211_freq_range *freq_range = &rule->freq_range;
+	__u32 freq_diff;
+
+	if (freq_range->start_freq_khz == 0 || freq_range->end_freq_khz == 0)
+		return 0;
+
+	if (freq_range->start_freq_khz > freq_range->end_freq_khz)
+		return 0;
+
+	freq_diff = freq_range->end_freq_khz - freq_range->start_freq_khz;
+
+	if (freq_diff == 0 || freq_range->max_bandwidth_khz > freq_diff)
+		return 0;
+
+	return 1;
+}
+
 /* Helper for regdom_intersect(), this does the real
  * mathematical intersection fun */
 static int reg_rules_intersect(
reglib.c +0 -20
index 2f10d23..e02bd8f 100644
@@ -195,26 +195,6 @@ struct ieee80211_regdomain *country2rd(__u8 *db, int dblen,
 	return rd;
 }
 
-/* Sanity check on a regulatory rule */
-int is_valid_reg_rule(const struct ieee80211_reg_rule *rule)
-{
-	const struct ieee80211_freq_range *freq_range = &rule->freq_range;
-	__u32 freq_diff;
-
-	if (freq_range->start_freq_khz == 0 || freq_range->end_freq_khz == 0)
-		return 0;
-
-	if (freq_range->start_freq_khz > freq_range->end_freq_khz)
-		return 0;
-
-	freq_diff = freq_range->end_freq_khz - freq_range->start_freq_khz;
-
-	if (freq_diff == 0 || freq_range->max_bandwidth_khz > freq_diff)
-		return 0;
-
-	return 1;
-}
-
 static void print_reg_rule(struct ieee80211_reg_rule *rule)
 {
 	struct ieee80211_freq_range *freq;
reglib.h +0 -1
index 095090b..f3a76ef 100644
@@ -92,7 +92,6 @@ struct ieee80211_regdomain *country2rd(__u8 *db, int dblen,
 	struct regdb_file_reg_country *country);
 
 /* reg helpers */
-int is_valid_reg_rule(const struct ieee80211_reg_rule *rule);
 void print_regdom(struct ieee80211_regdomain *rd);
 
 #endif
#1 lore raw

PATCH 2/3 Split printing functions to their own translation unit.

This allows to avoid linking them in the crda binary where they are not used.
---

 Makefile       |    8 ++--
 print-regdom.c |  122 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 reglib.c       |  119 -------------------------------------------------------
 3 files changed, 126 insertions(+), 123 deletions(-)
 create mode 100644 print-regdom.c
Makefile +4 -4
index a8c0a45..2fb94fc 100644
@@ -46,13 +46,13 @@ crda: reglib.o crda.o
 	$(NQ) '  LD  ' $@
 	$(Q)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ reglib.o crda.o `pkg-config --libs libnl-1` $(LDLIBS)
 
-regdbdump: reglib.o regdbdump.o
+regdbdump: reglib.o regdbdump.o print-regdom.o
 	$(NQ) '  LD  ' $@
-	$(Q)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ reglib.o regdbdump.o $(LDLIBS)
+	$(Q)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ reglib.o regdbdump.o print-regdom.o $(LDLIBS)
 
-intersect: reglib.o intersect.o
+intersect: reglib.o intersect.o print-regdom.o
 	$(NQ) '  LD  ' $@
-	$(Q)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ reglib.o intersect.o $(LDLIBS)
+	$(Q)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ reglib.o intersect.o print-regdom.o $(LDLIBS)
 
 verify: $(REG_BIN) regdbdump
 	$(NQ) '  CHK  $(REG_BIN)'
print-regdom.c new file +122 -0

122 lines not on this page · raw message

reglib.c +0 -119

127 lines not on this page · raw message

#2 lore raw

PATCH 3/3 Use Makefile dependency information for linking.

In reply to Diego 'Flameeyes' Pettenò

---

 Makefile |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
Makefile +3 -3
index 2fb94fc..9651a9b 100644
@@ -44,15 +44,15 @@ keys-%.c: utils/key2pub.py $(PUBKEY_DIR)/$(wildcard *.pem)
 
 crda: reglib.o crda.o
 	$(NQ) '  LD  ' $@
-	$(Q)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ reglib.o crda.o `pkg-config --libs libnl-1` $(LDLIBS)
+	$(Q)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ `pkg-config --libs libnl-1` $(LDLIBS)
 
 regdbdump: reglib.o regdbdump.o print-regdom.o
 	$(NQ) '  LD  ' $@
-	$(Q)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ reglib.o regdbdump.o print-regdom.o $(LDLIBS)
+	$(Q)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS)
 
 intersect: reglib.o intersect.o print-regdom.o
 	$(NQ) '  LD  ' $@
-	$(Q)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ reglib.o intersect.o print-regdom.o $(LDLIBS)
+	$(Q)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS)
 
 verify: $(REG_BIN) regdbdump
 	$(NQ) '  CHK  $(REG_BIN)'
#3 lore raw
In reply to Diego 'Flameeyes' Pettenò

On Mon, Dec 01, 2008 at 04:26:57AM -0800, Diego 'Flameeyes' Petten=F2 w= rote:

Quoted 1 line

The function is only ever used in that translation unit so it makes n=

o

Quoted 1 line

sense to define it for all the binaries.

I was planning on using is_valid_reg_rule() before sending the reg rule but sure, this is good for now. All 3 patches applied, thanks.

Luis
--
To unsubscribe from this list: send the line "unsubscribe linux-wireles= s" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html