2007-02-27 21:20:02

by Helge Deller

[permalink] [raw]
Subject: [PATCH] p54 various cleanups

Patch below
- uses PCI_DEVICE macro
- adds a "const" to the p54_ops struct and
- replaces "__attribute__ ((packed))" by the generic "__packed" keyword.

Signed-off-by: Helge Deller <[email protected]>

PS: There are more possibilities to replace "__attribute__ ((packed))" by the "__packed". Is this wished ? If yes, I can send additional patches for the other subdirectories...


diff --git a/drivers/net/wireless/mac80211/p54/prism54pci.c b/drivers/net/wireless/mac80211/p54/prism54pci.c
index 9ccf42a..7f61202 100644
--- a/drivers/net/wireless/mac80211/p54/prism54pci.c
+++ b/drivers/net/wireless/mac80211/p54/prism54pci.c
@@ -30,13 +30,13 @@ MODULE_LICENSE("GPL");

static struct pci_device_id p54p_table[] __devinitdata = {
/* Intersil PRISM Duette/Prism GT Wireless LAN adapter */
- { 0x1260, 0x3890, PCI_ANY_ID, PCI_ANY_ID },
+ { PCI_DEVICE(0x1260, 0x3890) },
/* 3COM 3CRWE154G72 Wireless LAN adapter */
- { 0x10b7, 0x6001, PCI_ANY_ID, PCI_ANY_ID },
+ { PCI_DEVICE(0x10b7, 0x6001) },
/* Intersil PRISM Indigo Wireless LAN adapter */
- { 0x1260, 0x3877, PCI_ANY_ID, PCI_ANY_ID },
+ { PCI_DEVICE(0x1260, 0x3877) },
/* Intersil PRISM Javelin/Xbow Wireless LAN adapter */
- { 0x1260, 0x3886, PCI_ANY_ID, PCI_ANY_ID },
+ { PCI_DEVICE(0x1260, 0x3886) },
};

MODULE_DEVICE_TABLE(pci, p54p_table);
diff --git a/drivers/net/wireless/mac80211/p54/prism54common.c b/drivers/net/wireless/mac80211/p54/prism54common.c
index 7b73463..cf7c018 100644
--- a/drivers/net/wireless/mac80211/p54/prism54common.c
+++ b/drivers/net/wireless/mac80211/p54/prism54common.c
@@ -727,7 +727,7 @@ static int p54_get_tx_stats(struct ieee8
return 0;
}

-static struct ieee80211_ops p54_ops = {
+static const struct ieee80211_ops p54_ops = {
.tx = p54_tx,
.add_interface = p54_add_interface,
.remove_interface = p54_remove_interface,





diff --git a/drivers/net/wireless/mac80211/p54/net2280.h b/drivers/net/wireless/mac80211/p54/net2280.h
index 120eb83..e4cf811 100644
--- a/drivers/net/wireless/mac80211/p54/net2280.h
+++ b/drivers/net/wireless/mac80211/p54/net2280.h
@@ -232,7 +232,7 @@ #define GPIO3_INTERRUPT
#define GPIO2_INTERRUPT 2
#define GPIO1_INTERRUPT 1
#define GPIO0_INTERRUPT 0
-} __attribute__ ((packed));
+} __packed;

/* usb control, BAR0 + 0x0080 */
struct net2280_usb_regs {
@@ -296,7 +296,7 @@ #define TERMINATION_SELECT
#define FORCE_IMMEDIATE 7
#define OUR_USB_ADDRESS 0
__le32 ourconfig;
-} __attribute__ ((packed));
+} __packed;

/* pci control, BAR0 + 0x0100 */
struct net2280_pci_regs {
@@ -323,7 +323,7 @@ #define PCI_MASTER_BYTE_WRITE_ENABLE
#define PCI_ARBITER_CLEAR 2
#define PCI_EXTERNAL_ARBITER 1
#define PCI_HOST_MODE 0
-} __attribute__ ((packed));
+} __packed;

/* dma control, BAR0 + 0x0180 ... array of four structs like this,
* for channels 0..3. see also struct net2280_dma: descriptor
@@ -364,7 +364,7 @@ #define DMA_BYTE_COUNT
__le32 dmaaddr;
__le32 dmadesc;
u32 _unused1;
-} __attribute__ ((packed));
+} __packed;

/* dedicated endpoint registers, BAR0 + 0x0200 */

@@ -374,7 +374,7 @@ struct net2280_dep_regs { /* [11.8] */
// offset 0x0204, 0x0214, 0x224, 0x234, 0x244
__le32 dep_rsp;
u32 _unused[2];
-} __attribute__ ((packed));
+} __packed;

/* configurable endpoint registers, BAR0 + 0x0300 ... array of seven structs
* like this, for ep0 then the configurable endpoints A..F
@@ -437,16 +437,16 @@ #define DATA_IN_TOKEN_INTERRUPT
__le32 ep_avail;
__le32 ep_data;
u32 _unused0[2];
-} __attribute__ ((packed));
+} __packed;

struct net2280_reg_write {
__le16 port;
__le32 addr;
__le32 val;
-} __attribute__ ((packed));
+} __packed;

struct net2280_reg_read {
__le16 port;
__le32 addr;
-} __attribute__ ((packed));
+} __packed;
#endif /* NET2280_H */
diff --git a/drivers/net/wireless/mac80211/p54/prism54.h b/drivers/net/wireless/mac80211/p54/prism54.h
index 884ba50..0a8222e 100644
--- a/drivers/net/wireless/mac80211/p54/prism54.h
+++ b/drivers/net/wireless/mac80211/p54/prism54.h
@@ -36,7 +36,7 @@ struct p54_control_hdr {
u8 retry1;
u8 retry2;
u8 data[0];
-} __attribute__ ((packed));
+} __packed;

#define EEPROM_READBACK_LEN (sizeof(struct p54_control_hdr) + 4 /* p54_eeprom_lm86 */)
#define MAX_RX_SIZE (IEEE80211_MAX_RTS_THRESHOLD + sizeof(struct p54_control_hdr) + 20 /* length of struct p54_rx_hdr */ + 16 )
diff --git a/drivers/net/wireless/mac80211/p54/prism54common.h b/drivers/net/wireless/mac80211/p54/prism54common.h
index 18cd4d9..a687de8 100644
--- a/drivers/net/wireless/mac80211/p54/prism54common.h
+++ b/drivers/net/wireless/mac80211/p54/prism54common.h
@@ -18,7 +18,7 @@ struct bootrec {
__le32 code;
__le32 len;
u32 data[];
-} __attribute__((packed));
+} __packed;

struct bootrec_exp_if {
__le16 role;
@@ -26,7 +26,7 @@ struct bootrec_exp_if {
__le16 variant;
__le16 btm_compat;
__le16 top_compat;
-} __attribute__((packed));
+} __packed;

#define BR_CODE_MIN 0x80000000
#define BR_CODE_COMPONENT_ID 0x80000001
@@ -49,7 +49,7 @@ struct pda_entry {
__le16 len; /* includes both code and data */
__le16 code;
u8 data[0];
-} __attribute__ ((packed));
+} __packed;

struct eeprom_pda_wrap {
u32 magic;
@@ -57,12 +57,12 @@ struct eeprom_pda_wrap {
u16 len;
u32 arm_opcode;
u8 data[0];
-} __attribute__ ((packed));
+} __packed;

struct pda_iq_autocal_entry {
__le16 freq;
__le16 iq_param[4];
-} __attribute__ ((packed));
+} __packed;

struct pda_channel_output_limit {
__le16 freq;
@@ -72,13 +72,13 @@ struct pda_channel_output_limit {
u8 val_64qam;
u8 rate_set_mask;
u8 rate_set_size;
-} __attribute__ ((packed));
+} __packed;

struct pda_pa_curve_data_sample_rev0 {
u8 rf_power;
u8 pa_detector;
u8 pcv;
-} __attribute__ ((packed));
+} __packed;

struct pda_pa_curve_data_sample_rev1 {
u8 rf_power;
@@ -89,7 +89,7 @@ struct pda_pa_curve_data_sample_rev1 {
u8 data_16qam;
u8 data_64qam;
u8 padding;
-} __attribute__ ((packed));
+} __packed;

struct pda_pa_curve_data {
u8 cal_method_rev;
@@ -97,7 +97,7 @@ struct pda_pa_curve_data {
u8 points_per_channel;
u8 padding;
u8 data[0];
-} __attribute__ ((packed));
+} __packed;

/*
* this defines the PDR codes used to build PDAs as defined in document
@@ -158,7 +158,7 @@ struct p54_eeprom_lm86 {
__le16 offset;
__le16 len;
u8 data[0];
-} __attribute__ ((packed));
+} __packed;

struct p54_rx_hdr {
__le16 magic;
@@ -171,14 +171,14 @@ struct p54_rx_hdr {
u16 unknown2;
__le64 timestamp;
u8 data[0];
-} __attribute__ ((packed));
+} __packed;

struct p54_frame_sent_hdr {
__le16 status;
__le16 ack_rssi;
__le16 seq;
u16 unknown;
-} __attribute__ ((packed));
+} __packed;

struct p54_tx_control_allocdata {
u8 rateset[8];
@@ -191,7 +191,7 @@ struct p54_tx_control_allocdata {
__le32 magic4;
__le32 magic5;
u8 align[0];
-} __attribute__ ((packed));
+} __packed;

struct p54_tx_control_filter {
__le16 filter_type;
@@ -206,7 +206,7 @@ struct p54_tx_control_filter {
__le16 rxhw;
__le16 magic8;
__le16 magic9;
-} __attribute__ ((packed));
+} __packed;

struct p54_tx_control_channel {
__le16 magic1;
@@ -221,14 +221,14 @@ struct p54_tx_control_channel {
u8 val_64qam;
struct pda_pa_curve_data_sample_rev1 curve_data[0];
/* additional padding/data after curve_data */
-} __attribute__ ((packed));
+} __packed;

struct p54_tx_control_led {
__le16 mode;
__le16 led_temporary;
__le16 led_permanent;
__le16 duration;
-} __attribute__ ((packed));
+} __packed;

static const struct ieee80211_rate p54_rates[] = {
{ .rate = 10,
diff --git a/drivers/net/wireless/mac80211/p54/prism54pci.h b/drivers/net/wireless/mac80211/p54/prism54pci.h
index 52feb59..f0d2716 100644
--- a/drivers/net/wireless/mac80211/p54/prism54pci.h
+++ b/drivers/net/wireless/mac80211/p54/prism54pci.h
@@ -65,7 +65,7 @@ struct p54p_csr {
u8 unused_6[1924];
u8 cardbus_cis[0x800];
u8 direct_mem_win[0x1000];
-} __attribute__ ((packed));
+} __packed;

/* usb backend only needs the register defines above */
#ifndef PRISM54USB_H
@@ -74,7 +74,7 @@ struct p54p_desc {
__le32 device_addr;
__le16 len;
__le16 flags;
-} __attribute__ ((packed));
+} __packed;

struct p54p_ring_control {
__le32 host_idx[4];
@@ -83,7 +83,7 @@ struct p54p_ring_control {
struct p54p_desc tx_data[32];
struct p54p_desc rx_mgmt[4];
struct p54p_desc tx_mgmt[4];
-} __attribute__ ((packed));
+} __packed;

#define P54P_READ(r) __raw_readl(&priv->map->r)
#define P54P_WRITE(r, val) __raw_writel((__force u32)(val), &priv->map->r)
diff --git a/drivers/net/wireless/mac80211/p54/prism54usb.c b/drivers/net/wireless/mac80211/p54/prism54usb.c
diff --git a/drivers/net/wireless/mac80211/p54/prism54usb.h b/drivers/net/wireless/mac80211/p54/prism54usb.h
index 5deffa8..022ffa2 100644
--- a/drivers/net/wireless/mac80211/p54/prism54usb.h
+++ b/drivers/net/wireless/mac80211/p54/prism54usb.h
@@ -70,7 +70,7 @@ struct net2280_tx_hdr {
__le16 len;
__le16 follower; /* ? */
u8 padding[8];
-} __attribute__((packed));
+} __packed;

/* Some flags for the isl hardware registers controlling DMA inside the
* chip */
@@ -98,7 +98,7 @@ struct x2_header {
__le32 fw_load_addr;
__le32 fw_length;
__le32 crc;
-} __attribute__((packed));
+} __packed;

/* pipes 3 and 4 are not used by the driver */
#define P54U_PIPE_NUMBER 9



2007-02-27 23:26:25

by Michael Wu

[permalink] [raw]
Subject: Re: [PATCH] p54 various cleanups

On Tuesday 27 February 2007 16:19, Helge Deller wrote:
> Patch below
> - uses PCI_DEVICE macro
> - adds a "const" to the p54_ops struct and
> - replaces "__attribute__ ((packed))" by the generic "__packed" keyword.
>
> Signed-off-by: Helge Deller <[email protected]>
>
> PS: There are more possibilities to replace "__attribute__ ((packed))" by
> the "__packed". Is this wished ? If yes, I can send additional patches for
> the other subdirectories...
>
If you don't mind, please split each cleanup into a separate patch and do all
d80211 drivers at the same time. adm8211 can also use the PCI_DEVICE cleanup,
and adm8211, rt2x00, rtl8187, and zd1211rw can also switch to a const
ieee80211_ops struct. I don't take patches for rt2x00 so you can either have
a patch with the adm8211/p54/zd1211rw ieee80211_ops cleanup and another with
the rt2x00 ieee80211_ops cleanup or you can make one big ieee80211_ops patch
and let Linville apply that patch.

As for the __packed cleanup, I do not see any code in the kernel that uses
__packed, so I think it would be better if we dropped that for now.

Thanks,
-Michael Wu


Attachments:
(No filename) (1.09 kB)
(No filename) (189.00 B)
Download all attachments

2007-03-02 18:45:26

by Helge Deller

[permalink] [raw]
Subject: Re: [PATCH] p54 various cleanups

On Wednesday 28 February 2007, Michael Wu wrote:
> On Tuesday 27 February 2007 16:19, Helge Deller wrote:
> > Patch below
> > - uses PCI_DEVICE macro
> > - adds a "const" to the p54_ops struct and
> > - replaces "__attribute__ ((packed))" by the generic "__packed" keyword.
> >
> > Signed-off-by: Helge Deller <[email protected]>
> >
> > PS: There are more possibilities to replace "__attribute__ ((packed))" by
> > the "__packed". Is this wished ? If yes, I can send additional patches for
> > the other subdirectories...
> >
> If you don't mind, please split each cleanup into a separate patch and do all
> d80211 drivers at the same time. adm8211 can also use the PCI_DEVICE cleanup,
> and adm8211, rt2x00, rtl8187, and zd1211rw can also switch to a const
> ieee80211_ops struct. I don't take patches for rt2x00 so you can either have
> a patch with the adm8211/p54/zd1211rw ieee80211_ops cleanup and another with
> the rt2x00 ieee80211_ops cleanup or you can make one big ieee80211_ops patch
> and let Linville apply that patch.
>
> As for the __packed cleanup, I do not see any code in the kernel that uses
> __packed, so I think it would be better if we dropped that for now.

Hi Michael,

thanks for the feedback.
I dropped the __packed patch, and instead just modified the drivers you mentioned.
Patch follows:


[PATCH] use PCI_DEVICE macro and add some const/__read_mostly annotations
Signed-off-by: Helge Deller <[email protected]>

adm8211/adm8211.c | 18 +++++++++---------
p54/prism54common.c | 2 +-
p54/prism54pci.c | 8 ++++----
rtl818x/rtl8187_dev.c | 2 +-
rtl818x/rtl8187_rtl8225.c | 4 ++--
zd1211rw/zd_mac.c | 2 +-
zd1211rw/zd_rf.c | 2 +-
zd1211rw/zd_rf_al7230b.c | 4 ++--
zd1211rw/zd_rf_rf2959.c | 4 ++--
9 files changed, 23 insertions(+), 23 deletions(-)


diff --git a/drivers/net/wireless/mac80211/adm8211/adm8211.c b/drivers/net/wireless/mac80211/adm8211/adm8211.c
index 525821b..270e616 100644
--- a/drivers/net/wireless/mac80211/adm8211/adm8211.c
+++ b/drivers/net/wireless/mac80211/adm8211/adm8211.c
@@ -34,25 +34,25 @@ MODULE_DESCRIPTION("Driver for IEEE 802.
MODULE_SUPPORTED_DEVICE("ADM8211");
MODULE_LICENSE("GPL");

-static unsigned int tx_ring_size = 16;
-static unsigned int rx_ring_size = 16;
-static int debug = 1;
+static unsigned int tx_ring_size __read_mostly = 16;
+static unsigned int rx_ring_size __read_mostly = 16;
+static int debug __read_mostly = 1;

module_param(tx_ring_size, uint, 0);
module_param(rx_ring_size, uint, 0);
module_param(debug, int, 0);

-static const char *version = KERN_INFO "adm8211: "
+static const char version[] = KERN_INFO "adm8211: "
"Copyright 2003, Jouni Malinen <[email protected]>; "
"Copyright 2004-2006, Michael Wu <[email protected]>\n";


static struct pci_device_id adm8211_pci_id_table[] __devinitdata = {
/* ADMtek ADM8211 */
- { 0x10B7, 0x6000, PCI_ANY_ID, PCI_ANY_ID }, /* 3Com 3CRSHPW796 */
- { 0x1200, 0x8201, PCI_ANY_ID, PCI_ANY_ID }, /* ? */
- { 0x1317, 0x8201, PCI_ANY_ID, PCI_ANY_ID }, /* ADM8211A */
- { 0x1317, 0x8211, PCI_ANY_ID, PCI_ANY_ID }, /* ADM8211B/C */
+ { PCI_DEVICE(0x10B7, 0x6000) }, /* 3Com 3CRSHPW796 */
+ { PCI_DEVICE(0x1200, 0x8201) }, /* ? */
+ { PCI_DEVICE(0x1317, 0x8201) }, /* ADM8211A */
+ { PCI_DEVICE(0x1317, 0x8211) }, /* ADM8211B/C */
{ 0 }
};

@@ -1898,7 +1898,7 @@ static int adm8211_alloc_rings(struct ie
return 0;
}

-static struct ieee80211_ops adm8211_ops = {
+static const struct ieee80211_ops adm8211_ops = {
.tx = adm8211_tx,
.reset = adm8211_reset,
.open = adm8211_open,
diff --git a/drivers/net/wireless/mac80211/p54/prism54common.c b/drivers/net/wireless/mac80211/p54/prism54common.c
index 7b73463..cf7c018 100644
--- a/drivers/net/wireless/mac80211/p54/prism54common.c
+++ b/drivers/net/wireless/mac80211/p54/prism54common.c
@@ -727,7 +727,7 @@ static int p54_get_tx_stats(struct ieee8
return 0;
}

-static struct ieee80211_ops p54_ops = {
+static const struct ieee80211_ops p54_ops = {
.tx = p54_tx,
.add_interface = p54_add_interface,
.remove_interface = p54_remove_interface,
diff --git a/drivers/net/wireless/mac80211/p54/prism54pci.c b/drivers/net/wireless/mac80211/p54/prism54pci.c
index 9ccf42a..7f61202 100644
--- a/drivers/net/wireless/mac80211/p54/prism54pci.c
+++ b/drivers/net/wireless/mac80211/p54/prism54pci.c
@@ -30,13 +30,13 @@ MODULE_LICENSE("GPL");

static struct pci_device_id p54p_table[] __devinitdata = {
/* Intersil PRISM Duette/Prism GT Wireless LAN adapter */
- { 0x1260, 0x3890, PCI_ANY_ID, PCI_ANY_ID },
+ { PCI_DEVICE(0x1260, 0x3890) },
/* 3COM 3CRWE154G72 Wireless LAN adapter */
- { 0x10b7, 0x6001, PCI_ANY_ID, PCI_ANY_ID },
+ { PCI_DEVICE(0x10b7, 0x6001) },
/* Intersil PRISM Indigo Wireless LAN adapter */
- { 0x1260, 0x3877, PCI_ANY_ID, PCI_ANY_ID },
+ { PCI_DEVICE(0x1260, 0x3877) },
/* Intersil PRISM Javelin/Xbow Wireless LAN adapter */
- { 0x1260, 0x3886, PCI_ANY_ID, PCI_ANY_ID },
+ { PCI_DEVICE(0x1260, 0x3886) },
};

MODULE_DEVICE_TABLE(pci, p54p_table);
diff --git a/drivers/net/wireless/mac80211/rtl818x/rtl8187_dev.c b/drivers/net/wireless/mac80211/rtl818x/rtl8187_dev.c
index 6a203d4..8d49391 100644
--- a/drivers/net/wireless/mac80211/rtl818x/rtl8187_dev.c
+++ b/drivers/net/wireless/mac80211/rtl818x/rtl8187_dev.c
@@ -507,7 +507,7 @@ static int rtl8187_config_interface(stru
return 0;
}

-static struct ieee80211_ops rtl8187_ops = {
+static const struct ieee80211_ops rtl8187_ops = {
.tx = rtl8187_tx,
.open = rtl8187_open,
.stop = rtl8187_stop,
diff --git a/drivers/net/wireless/mac80211/rtl818x/rtl8187_rtl8225.c b/drivers/net/wireless/mac80211/rtl818x/rtl8187_rtl8225.c
index 2bcd0f0..d278aa1 100644
--- a/drivers/net/wireless/mac80211/rtl818x/rtl8187_rtl8225.c
+++ b/drivers/net/wireless/mac80211/rtl818x/rtl8187_rtl8225.c
@@ -210,7 +210,7 @@ static const u16 rtl8225bcd_rxgain[] = {
0x07b4, 0x07b5, 0x07b8, 0x07b9, 0x07ba, 0x07bb, 0x07bb
};

-const u8 rtl8225_agc[] = {
+const const u8 rtl8225_agc[] = {
0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e,
0x9d, 0x9c, 0x9b, 0x9a, 0x99, 0x98, 0x97, 0x96,
0x95, 0x94, 0x93, 0x92, 0x91, 0x90, 0x8f, 0x8e,
@@ -269,7 +269,7 @@ static const u8 rtl8225_tx_power_ofdm[]
0x80, 0x90, 0xa2, 0xb5, 0xcb, 0xe4
};

-const u32 rtl8225_chan[] = {
+const const u32 rtl8225_chan[] = {
0x085c, 0x08dc, 0x095c, 0x09dc, 0x0a5c, 0x0adc, 0x0b5c,
0x0bdc, 0x0c5c, 0x0cdc, 0x0d5c, 0x0ddc, 0x0e5c, 0x0f72
};
diff --git a/drivers/net/wireless/mac80211/zd1211rw/zd_mac.c b/drivers/net/wireless/mac80211/zd1211rw/zd_mac.c
index 5b9e04a..7a3b3b5 100644
--- a/drivers/net/wireless/mac80211/zd1211rw/zd_mac.c
+++ b/drivers/net/wireless/mac80211/zd1211rw/zd_mac.c
@@ -591,7 +591,7 @@ static void zd_mac_set_multicast_list(st
queue_work(zd_workqueue, &mac->set_multicast_hash_work);
}

-static struct ieee80211_ops zd_ops = {
+static const struct ieee80211_ops zd_ops = {
.tx = zd_mac_tx,
.open = zd_mac_open,
.stop = zd_mac_stop,
diff --git a/drivers/net/wireless/mac80211/zd1211rw/zd_rf.c b/drivers/net/wireless/mac80211/zd1211rw/zd_rf.c
index f50cff3..701e8cb 100644
--- a/drivers/net/wireless/mac80211/zd1211rw/zd_rf.c
+++ b/drivers/net/wireless/mac80211/zd1211rw/zd_rf.c
@@ -23,7 +23,7 @@ #include "zd_rf.h"
#include "zd_ieee80211.h"
#include "zd_chip.h"

-static const char *rfs[] = {
+static const char * const rfs[] = {
[0] = "unknown RF0",
[1] = "unknown RF1",
[UW2451_RF] = "UW2451_RF",
diff --git a/drivers/net/wireless/mac80211/zd1211rw/zd_rf_al7230b.c b/drivers/net/wireless/mac80211/zd1211rw/zd_rf_al7230b.c
index a289f95..bd07c9b 100644
--- a/drivers/net/wireless/mac80211/zd1211rw/zd_rf_al7230b.c
+++ b/drivers/net/wireless/mac80211/zd1211rw/zd_rf_al7230b.c
@@ -183,12 +183,12 @@ static int al7230b_set_channel(struct zd
const u32 *rv = chan_rv[channel-1];
struct zd_chip *chip = zd_rf_to_chip(rf);

- struct zd_ioreq16 ioreqs_1[] = {
+ static const struct zd_ioreq16 ioreqs_1[] = {
{ CR128, 0x14 }, { CR129, 0x12 }, { CR130, 0x10 },
{ CR38, 0x38 }, { CR136, 0xdf },
};

- struct zd_ioreq16 ioreqs_2[] = {
+ static const struct zd_ioreq16 ioreqs_2[] = {
/* PLL_ON */
{ CR251, 0x3f },
{ CR203, 0x06 }, { CR240, 0x08 },
diff --git a/drivers/net/wireless/mac80211/zd1211rw/zd_rf_rf2959.c b/drivers/net/wireless/mac80211/zd1211rw/zd_rf_rf2959.c
index 5824727..2d736bd 100644
--- a/drivers/net/wireless/mac80211/zd1211rw/zd_rf_rf2959.c
+++ b/drivers/net/wireless/mac80211/zd1211rw/zd_rf_rf2959.c
@@ -21,7 +21,7 @@ #include "zd_rf.h"
#include "zd_usb.h"
#include "zd_chip.h"

-static u32 rf2959_table[][2] = {
+static const u32 rf2959_table[][2] = {
RF_CHANNEL( 1) = { 0x181979, 0x1e6666 },
RF_CHANNEL( 2) = { 0x181989, 0x1e6666 },
RF_CHANNEL( 3) = { 0x181999, 0x1e6666 },
@@ -228,7 +228,7 @@ static int rf2959_init_hw(struct zd_rf *
static int rf2959_set_channel(struct zd_rf *rf, u8 channel)
{
int i, r;
- u32 *rv = rf2959_table[channel-1];
+ const u32 *rv = rf2959_table[channel-1];
struct zd_chip *chip = zd_rf_to_chip(rf);

for (i = 0; i < 2; i++) {




2007-03-07 18:16:40

by Michael Wu

[permalink] [raw]
Subject: Re: [PATCH] p54 various cleanups

On Monday 05 March 2007 11:06, Helge Deller wrote:
> > > -static const char *rfs[] = {
> > > +static const char * const rfs[] = {
> >
> > ?
>
> That's correct.
> 'rfs' is a pointer array to strings.
> The first part ("const char") tells the compiler to put the strings into
> read-only memory. The second const after the * tells the compiler, that the
> pointer array itself is read-only as well. This prevents e.g. this kind of
> runtime modifications: rfs[2] = "test"; Another example:
> drivers/video/s3fb.c:static const char * const s3_names[] = {"S3 Unknown",
> ... But if you don't like it, I'm fine wit dropping this part.
>
Nah, it's fine. It looked like it was doing that but I've never seen any code
that actually did that so I wasn't sure.

> > BTW, you should have an updated summary for this patch.
>
> This one -> ?
>
> [PATCH] p54/rtl818x/zd1211rw - various fixes
> - use PCI_DEVICE macro
> - add some const / __read_mostly annotations
> - mark some arrays 'static'
>
> Signed-off-by: Helge Deller <[email protected]>
>
Yup. Merged in my tree and pushing to wireless-dev. Thanks!

-Michael Wu


Attachments:
(No filename) (1.08 kB)
(No filename) (189.00 B)
Download all attachments

2007-03-04 05:19:05

by Michael Wu

[permalink] [raw]
Subject: Re: [PATCH] p54 various cleanups

On Friday 02 March 2007 13:45, Helge Deller wrote:
> -static unsigned int tx_ring_size = 16;
> -static unsigned int rx_ring_size = 16;
> -static int debug = 1;
> +static unsigned int tx_ring_size __read_mostly = 16;
> +static unsigned int rx_ring_size __read_mostly = 16;
> +static int debug __read_mostly = 1;
>
Hm, sure why not..

> -const u8 rtl8225_agc[] = {
> +const const u8 rtl8225_agc[] = {
What does const const do?

> -static const char *rfs[] = {
> +static const char * const rfs[] = {
?

BTW, you should have an updated summary for this patch.

Rest of the patch looks okay to me.

Thanks,
-Michael Wu


Attachments:
(No filename) (615.00 B)
(No filename) (189.00 B)
Download all attachments

2007-03-05 16:06:39

by Helge Deller

[permalink] [raw]
Subject: Re: [PATCH] p54 various cleanups

Hi Michael,

On Sunday 04 March 2007, Michael Wu wrote:
> On Friday 02 March 2007 13:45, Helge Deller wrote:
> > -const u8 rtl8225_agc[] = {
> > +const const u8 rtl8225_agc[] = {
> What does const const do?

Yes, that's wrong. This should have been "static const...".
It's fixed in the updated patch below.

> > -static const char *rfs[] = {
> > +static const char * const rfs[] = {
> ?

That's correct.
'rfs' is a pointer array to strings.
The first part ("const char") tells the compiler to put the strings into read-only memory.
The second const after the * tells the compiler, that the pointer array itself is read-only as well.
This prevents e.g. this kind of runtime modifications: rfs[2] = "test";
Another example: drivers/video/s3fb.c:static const char * const s3_names[] = {"S3 Unknown", ...
But if you don't like it, I'm fine wit dropping this part.

> BTW, you should have an updated summary for this patch.

This one -> ?

[PATCH] p54/rtl818x/zd1211rw - various fixes
- use PCI_DEVICE macro
- add some const / __read_mostly annotations
- mark some arrays 'static'

Signed-off-by: Helge Deller <[email protected]>

diff --git a/drivers/net/wireless/mac80211/adm8211/adm8211.c b/drivers/net/wireless/mac80211/adm8211/adm8211.c
index 525821b..270e616 100644
--- a/drivers/net/wireless/mac80211/adm8211/adm8211.c
+++ b/drivers/net/wireless/mac80211/adm8211/adm8211.c
@@ -34,25 +34,25 @@ MODULE_DESCRIPTION("Driver for IEEE 802.
MODULE_SUPPORTED_DEVICE("ADM8211");
MODULE_LICENSE("GPL");

-static unsigned int tx_ring_size = 16;
-static unsigned int rx_ring_size = 16;
-static int debug = 1;
+static unsigned int tx_ring_size __read_mostly = 16;
+static unsigned int rx_ring_size __read_mostly = 16;
+static int debug __read_mostly = 1;

module_param(tx_ring_size, uint, 0);
module_param(rx_ring_size, uint, 0);
module_param(debug, int, 0);

-static const char *version = KERN_INFO "adm8211: "
+static const char version[] = KERN_INFO "adm8211: "
"Copyright 2003, Jouni Malinen <[email protected]>; "
"Copyright 2004-2006, Michael Wu <[email protected]>\n";


static struct pci_device_id adm8211_pci_id_table[] __devinitdata = {
/* ADMtek ADM8211 */
- { 0x10B7, 0x6000, PCI_ANY_ID, PCI_ANY_ID }, /* 3Com 3CRSHPW796 */
- { 0x1200, 0x8201, PCI_ANY_ID, PCI_ANY_ID }, /* ? */
- { 0x1317, 0x8201, PCI_ANY_ID, PCI_ANY_ID }, /* ADM8211A */
- { 0x1317, 0x8211, PCI_ANY_ID, PCI_ANY_ID }, /* ADM8211B/C */
+ { PCI_DEVICE(0x10B7, 0x6000) }, /* 3Com 3CRSHPW796 */
+ { PCI_DEVICE(0x1200, 0x8201) }, /* ? */
+ { PCI_DEVICE(0x1317, 0x8201) }, /* ADM8211A */
+ { PCI_DEVICE(0x1317, 0x8211) }, /* ADM8211B/C */
{ 0 }
};

@@ -1898,7 +1898,7 @@ static int adm8211_alloc_rings(struct ie
return 0;
}

-static struct ieee80211_ops adm8211_ops = {
+static const struct ieee80211_ops adm8211_ops = {
.tx = adm8211_tx,
.reset = adm8211_reset,
.open = adm8211_open,
diff --git a/drivers/net/wireless/mac80211/p54/prism54common.c b/drivers/net/wireless/mac80211/p54/prism54common.c
index 7b73463..cf7c018 100644
--- a/drivers/net/wireless/mac80211/p54/prism54common.c
+++ b/drivers/net/wireless/mac80211/p54/prism54common.c
@@ -727,7 +727,7 @@ static int p54_get_tx_stats(struct ieee8
return 0;
}

-static struct ieee80211_ops p54_ops = {
+static const struct ieee80211_ops p54_ops = {
.tx = p54_tx,
.add_interface = p54_add_interface,
.remove_interface = p54_remove_interface,
diff --git a/drivers/net/wireless/mac80211/p54/prism54pci.c b/drivers/net/wireless/mac80211/p54/prism54pci.c
index 9ccf42a..7f61202 100644
--- a/drivers/net/wireless/mac80211/p54/prism54pci.c
+++ b/drivers/net/wireless/mac80211/p54/prism54pci.c
@@ -30,13 +30,13 @@ MODULE_LICENSE("GPL");

static struct pci_device_id p54p_table[] __devinitdata = {
/* Intersil PRISM Duette/Prism GT Wireless LAN adapter */
- { 0x1260, 0x3890, PCI_ANY_ID, PCI_ANY_ID },
+ { PCI_DEVICE(0x1260, 0x3890) },
/* 3COM 3CRWE154G72 Wireless LAN adapter */
- { 0x10b7, 0x6001, PCI_ANY_ID, PCI_ANY_ID },
+ { PCI_DEVICE(0x10b7, 0x6001) },
/* Intersil PRISM Indigo Wireless LAN adapter */
- { 0x1260, 0x3877, PCI_ANY_ID, PCI_ANY_ID },
+ { PCI_DEVICE(0x1260, 0x3877) },
/* Intersil PRISM Javelin/Xbow Wireless LAN adapter */
- { 0x1260, 0x3886, PCI_ANY_ID, PCI_ANY_ID },
+ { PCI_DEVICE(0x1260, 0x3886) },
};

MODULE_DEVICE_TABLE(pci, p54p_table);
diff --git a/drivers/net/wireless/mac80211/rtl818x/rtl8187_dev.c b/drivers/net/wireless/mac80211/rtl818x/rtl8187_dev.c
index 6a203d4..8d49391 100644
--- a/drivers/net/wireless/mac80211/rtl818x/rtl8187_dev.c
+++ b/drivers/net/wireless/mac80211/rtl818x/rtl8187_dev.c
@@ -507,7 +507,7 @@ static int rtl8187_config_interface(stru
return 0;
}

-static struct ieee80211_ops rtl8187_ops = {
+static const struct ieee80211_ops rtl8187_ops = {
.tx = rtl8187_tx,
.open = rtl8187_open,
.stop = rtl8187_stop,
diff --git a/drivers/net/wireless/mac80211/rtl818x/rtl8187_rtl8225.c b/drivers/net/wireless/mac80211/rtl818x/rtl8187_rtl8225.c
index 2bcd0f0..292e151 100644
--- a/drivers/net/wireless/mac80211/rtl818x/rtl8187_rtl8225.c
+++ b/drivers/net/wireless/mac80211/rtl818x/rtl8187_rtl8225.c
@@ -210,7 +210,7 @@ static const u16 rtl8225bcd_rxgain[] = {
0x07b4, 0x07b5, 0x07b8, 0x07b9, 0x07ba, 0x07bb, 0x07bb
};

-const u8 rtl8225_agc[] = {
+static const u8 rtl8225_agc[] = {
0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e,
0x9d, 0x9c, 0x9b, 0x9a, 0x99, 0x98, 0x97, 0x96,
0x95, 0x94, 0x93, 0x92, 0x91, 0x90, 0x8f, 0x8e,
@@ -269,7 +269,7 @@ static const u8 rtl8225_tx_power_ofdm[]
0x80, 0x90, 0xa2, 0xb5, 0xcb, 0xe4
};

-const u32 rtl8225_chan[] = {
+static const u32 rtl8225_chan[] = {
0x085c, 0x08dc, 0x095c, 0x09dc, 0x0a5c, 0x0adc, 0x0b5c,
0x0bdc, 0x0c5c, 0x0cdc, 0x0d5c, 0x0ddc, 0x0e5c, 0x0f72
};
diff --git a/drivers/net/wireless/mac80211/zd1211rw/zd_mac.c b/drivers/net/wireless/mac80211/zd1211rw/zd_mac.c
index 5b9e04a..7a3b3b5 100644
--- a/drivers/net/wireless/mac80211/zd1211rw/zd_mac.c
+++ b/drivers/net/wireless/mac80211/zd1211rw/zd_mac.c
@@ -591,7 +591,7 @@ static void zd_mac_set_multicast_list(st
queue_work(zd_workqueue, &mac->set_multicast_hash_work);
}

-static struct ieee80211_ops zd_ops = {
+static const struct ieee80211_ops zd_ops = {
.tx = zd_mac_tx,
.open = zd_mac_open,
.stop = zd_mac_stop,
diff --git a/drivers/net/wireless/mac80211/zd1211rw/zd_rf.c b/drivers/net/wireless/mac80211/zd1211rw/zd_rf.c
index f50cff3..701e8cb 100644
--- a/drivers/net/wireless/mac80211/zd1211rw/zd_rf.c
+++ b/drivers/net/wireless/mac80211/zd1211rw/zd_rf.c
@@ -23,7 +23,7 @@ #include "zd_rf.h"
#include "zd_ieee80211.h"
#include "zd_chip.h"

-static const char *rfs[] = {
+static const char * const rfs[] = {
[0] = "unknown RF0",
[1] = "unknown RF1",
[UW2451_RF] = "UW2451_RF",
diff --git a/drivers/net/wireless/mac80211/zd1211rw/zd_rf_al7230b.c b/drivers/net/wireless/mac80211/zd1211rw/zd_rf_al7230b.c
index a289f95..bd07c9b 100644
--- a/drivers/net/wireless/mac80211/zd1211rw/zd_rf_al7230b.c
+++ b/drivers/net/wireless/mac80211/zd1211rw/zd_rf_al7230b.c
@@ -183,12 +183,12 @@ static int al7230b_set_channel(struct zd
const u32 *rv = chan_rv[channel-1];
struct zd_chip *chip = zd_rf_to_chip(rf);

- struct zd_ioreq16 ioreqs_1[] = {
+ static const struct zd_ioreq16 ioreqs_1[] = {
{ CR128, 0x14 }, { CR129, 0x12 }, { CR130, 0x10 },
{ CR38, 0x38 }, { CR136, 0xdf },
};

- struct zd_ioreq16 ioreqs_2[] = {
+ static const struct zd_ioreq16 ioreqs_2[] = {
/* PLL_ON */
{ CR251, 0x3f },
{ CR203, 0x06 }, { CR240, 0x08 },
diff --git a/drivers/net/wireless/mac80211/zd1211rw/zd_rf_rf2959.c b/drivers/net/wireless/mac80211/zd1211rw/zd_rf_rf2959.c
index 5824727..2d736bd 100644
--- a/drivers/net/wireless/mac80211/zd1211rw/zd_rf_rf2959.c
+++ b/drivers/net/wireless/mac80211/zd1211rw/zd_rf_rf2959.c
@@ -21,7 +21,7 @@ #include "zd_rf.h"
#include "zd_usb.h"
#include "zd_chip.h"

-static u32 rf2959_table[][2] = {
+static const u32 rf2959_table[][2] = {
RF_CHANNEL( 1) = { 0x181979, 0x1e6666 },
RF_CHANNEL( 2) = { 0x181989, 0x1e6666 },
RF_CHANNEL( 3) = { 0x181999, 0x1e6666 },
@@ -228,7 +228,7 @@ static int rf2959_init_hw(struct zd_rf *
static int rf2959_set_channel(struct zd_rf *rf, u8 channel)
{
int i, r;
- u32 *rv = rf2959_table[channel-1];
+ const u32 *rv = rf2959_table[channel-1];
struct zd_chip *chip = zd_rf_to_chip(rf);

for (i = 0; i < 2; i++) {