Skip to content

Commit

Permalink
zd1211rw: make use of new regulatory_hint()
Browse files Browse the repository at this point in the history
This cleans up zd1211rw's own regulatory work, and makes use of
the new cfg80211 regulatory_hint().

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
  • Loading branch information
Luis R. Rodriguez authored and John W. Linville committed Sep 15, 2008
1 parent b2e1b30 commit e83a107
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 203 deletions.
2 changes: 1 addition & 1 deletion drivers/net/wireless/zd1211rw/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
obj-$(CONFIG_ZD1211RW) += zd1211rw.o

zd1211rw-objs := zd_chip.o zd_ieee80211.o zd_mac.o \
zd1211rw-objs := zd_chip.o zd_mac.o \
zd_rf_al2230.o zd_rf_rf2959.o \
zd_rf_al7230b.o zd_rf_uw2453.o \
zd_rf.o zd_usb.o
Expand Down
1 change: 0 additions & 1 deletion drivers/net/wireless/zd1211rw/zd_chip.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

#include "zd_def.h"
#include "zd_chip.h"
#include "zd_ieee80211.h"
#include "zd_mac.h"
#include "zd_rf.h"

Expand Down
100 changes: 0 additions & 100 deletions drivers/net/wireless/zd1211rw/zd_ieee80211.c

This file was deleted.

95 changes: 0 additions & 95 deletions drivers/net/wireless/zd1211rw/zd_ieee80211.h

This file was deleted.

40 changes: 36 additions & 4 deletions drivers/net/wireless/zd1211rw/zd_mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Copyright (C) 2005-2007 Ulrich Kunitz <kune@deine-taler.de>
* Copyright (C) 2006-2007 Daniel Drake <dsd@gentoo.org>
* Copyright (C) 2006-2007 Michael Wu <flamingice@sourmilk.net>
* Copyright (c) 2007 Luis R. Rodriguez <mcgrof@winlab.rutgers.edu>
* Copyright (C) 2007-2008 Luis R. Rodriguez <mcgrof@winlab.rutgers.edu>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -29,9 +29,23 @@
#include "zd_def.h"
#include "zd_chip.h"
#include "zd_mac.h"
#include "zd_ieee80211.h"
#include "zd_rf.h"

struct zd_reg_alpha2_map {
u32 reg;
char alpha2[2];
};

static struct zd_reg_alpha2_map reg_alpha2_map[] = {
{ ZD_REGDOMAIN_FCC, "US" },
{ ZD_REGDOMAIN_IC, "CA" },
{ ZD_REGDOMAIN_ETSI, "DE" }, /* Generic ETSI, use most restrictive */
{ ZD_REGDOMAIN_JAPAN, "JP" },
{ ZD_REGDOMAIN_JAPAN_ADD, "JP" },
{ ZD_REGDOMAIN_SPAIN, "ES" },
{ ZD_REGDOMAIN_FRANCE, "FR" },
};

/* This table contains the hardware specific values for the modulation rates. */
static const struct ieee80211_rate zd_rates[] = {
{ .bitrate = 10,
Expand Down Expand Up @@ -95,6 +109,21 @@ static void housekeeping_init(struct zd_mac *mac);
static void housekeeping_enable(struct zd_mac *mac);
static void housekeeping_disable(struct zd_mac *mac);

static int zd_reg2alpha2(u8 regdomain, char *alpha2)
{
unsigned int i;
struct zd_reg_alpha2_map *reg_map;
for (i = 0; i < ARRAY_SIZE(reg_alpha2_map); i++) {
reg_map = &reg_alpha2_map[i];
if (regdomain == reg_map->reg) {
alpha2[0] = reg_map->alpha2[0];
alpha2[1] = reg_map->alpha2[1];
return 0;
}
}
return 1;
}

int zd_mac_preinit_hw(struct ieee80211_hw *hw)
{
int r;
Expand All @@ -115,6 +144,7 @@ int zd_mac_init_hw(struct ieee80211_hw *hw)
int r;
struct zd_mac *mac = zd_hw_mac(hw);
struct zd_chip *chip = &mac->chip;
char alpha2[2];
u8 default_regdomain;

r = zd_chip_enable_int(chip);
Expand All @@ -139,7 +169,9 @@ int zd_mac_init_hw(struct ieee80211_hw *hw)
if (r)
goto disable_int;

zd_geo_init(hw, mac->regdomain);
r = zd_reg2alpha2(mac->regdomain, alpha2);
if (!r)
regulatory_hint(hw->wiphy, alpha2, NULL);

r = 0;
disable_int:
Expand Down Expand Up @@ -753,7 +785,7 @@ static int zd_op_config_interface(struct ieee80211_hw *hw,
return 0;
}

void zd_process_intr(struct work_struct *work)
static void zd_process_intr(struct work_struct *work)
{
u16 int_status;
struct zd_mac *mac = container_of(work, struct zd_mac, process_intr);
Expand Down
65 changes: 64 additions & 1 deletion drivers/net/wireless/zd1211rw/zd_mac.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include <net/mac80211.h>

#include "zd_chip.h"
#include "zd_ieee80211.h"

struct zd_ctrlset {
u8 modulation;
Expand Down Expand Up @@ -187,6 +186,70 @@ struct zd_mac {
unsigned int pass_ctrl:1;
};

#define ZD_REGDOMAIN_FCC 0x10
#define ZD_REGDOMAIN_IC 0x20
#define ZD_REGDOMAIN_ETSI 0x30
#define ZD_REGDOMAIN_SPAIN 0x31
#define ZD_REGDOMAIN_FRANCE 0x32
#define ZD_REGDOMAIN_JAPAN_ADD 0x40
#define ZD_REGDOMAIN_JAPAN 0x41

enum {
MIN_CHANNEL24 = 1,
MAX_CHANNEL24 = 14,
};

#define ZD_PLCP_SERVICE_LENGTH_EXTENSION 0x80

struct ofdm_plcp_header {
u8 prefix[3];
__le16 service;
} __attribute__((packed));

static inline u8 zd_ofdm_plcp_header_rate(const struct ofdm_plcp_header *header)
{
return header->prefix[0] & 0xf;
}

/* The following defines give the encoding of the 4-bit rate field in the
* OFDM (802.11a/802.11g) PLCP header. Notify that these values are used to
* define the zd-rate values for OFDM.
*
* See the struct zd_ctrlset definition in zd_mac.h.
*/
#define ZD_OFDM_PLCP_RATE_6M 0xb
#define ZD_OFDM_PLCP_RATE_9M 0xf
#define ZD_OFDM_PLCP_RATE_12M 0xa
#define ZD_OFDM_PLCP_RATE_18M 0xe
#define ZD_OFDM_PLCP_RATE_24M 0x9
#define ZD_OFDM_PLCP_RATE_36M 0xd
#define ZD_OFDM_PLCP_RATE_48M 0x8
#define ZD_OFDM_PLCP_RATE_54M 0xc

struct cck_plcp_header {
u8 signal;
u8 service;
__le16 length;
__le16 crc16;
} __attribute__((packed));

static inline u8 zd_cck_plcp_header_signal(const struct cck_plcp_header *header)
{
return header->signal;
}

/* These defines give the encodings of the signal field in the 802.11b PLCP
* header. The signal field gives the bit rate of the following packet. Even
* if technically wrong we use CCK here also for the 1 MBit/s and 2 MBit/s
* rate to stay consistent with Zydas and our use of the term.
*
* Notify that these values are *not* used in the zd-rates.
*/
#define ZD_CCK_PLCP_SIGNAL_1M 0x0a
#define ZD_CCK_PLCP_SIGNAL_2M 0x14
#define ZD_CCK_PLCP_SIGNAL_5M5 0x37
#define ZD_CCK_PLCP_SIGNAL_11M 0x6e

static inline struct zd_mac *zd_hw_mac(struct ieee80211_hw *hw)
{
return hw->priv;
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/wireless/zd1211rw/zd_rf.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

#include "zd_def.h"
#include "zd_rf.h"
#include "zd_ieee80211.h"
#include "zd_mac.h"
#include "zd_chip.h"

static const char * const rfs[] = {
Expand Down

0 comments on commit e83a107

Please sign in to comment.