Re: [PATCH 1/2] ath5k: constify stuff

From: Nick Kossifidis
Date: Sat Mar 07 2009 - 07:03:49 EST


2009/3/7 Jiri Slaby <jirislaby@xxxxxxxxx>:
> Make some structures const to place them in .rodata, since we won't
> change them.
>
> Most important parts of objdump -h:
> - Â0 .text     00011170
> + Â0 .text     00011140
> - Â5 .rodata    0000828e
> + Â5 .rodata    0000895e
> - 13 .data     00000560
> + 13 .data     00000110
> - 14 .devinit.data 00000260
>
> Signed-off-by: Jiri Slaby <jirislaby@xxxxxxxxx>
> Cc: Nick Kossifidis <mickflemm@xxxxxxxxx>
> Cc: Luis R. Rodriguez <lrodriguez@xxxxxxxxxxx>
> Cc: Bob Copeland <me@xxxxxxxxxxxxxxx>
> ---
> Âdrivers/net/wireless/ath5k/attach.c | Â 13 ++++++-------
> Âdrivers/net/wireless/ath5k/base.c  |  Â8 ++++----
> Âdrivers/net/wireless/ath5k/debug.c Â| Â 10 +++++-----
> Âdrivers/net/wireless/ath5k/reset.c Â| Â Â2 +-
> Â4 files changed, 16 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/net/wireless/ath5k/attach.c b/drivers/net/wireless/ath5k/attach.c
> index 05bc5cb..656cb9d 100644
> --- a/drivers/net/wireless/ath5k/attach.c
> +++ b/drivers/net/wireless/ath5k/attach.c
> @@ -34,14 +34,14 @@
> Âstatic int ath5k_hw_post(struct ath5k_hw *ah)
> Â{
>
> - Â Â Â int i, c;
> - Â Â Â u16 cur_reg;
> - Â Â Â u16 regs[2] = {AR5K_STA_ID0, AR5K_PHY(8)};
> - Â Â Â u32 var_pattern;
> - Â Â Â u32 static_pattern[4] = {
> + Â Â Â static const u32 static_pattern[4] = {
> Â Â Â Â Â Â Â Â0x55555555, Â Â 0xaaaaaaaa,
> Â Â Â Â Â Â Â Â0x66666666, Â Â 0x99999999
> Â Â Â Â};
> + Â Â Â static const u16 regs[2] = { AR5K_STA_ID0, AR5K_PHY(8) };
> + Â Â Â int i, c;
> + Â Â Â u16 cur_reg;
> + Â Â Â u32 var_pattern;
> Â Â Â Âu32 init_val;
> Â Â Â Âu32 cur_val;
>
> @@ -106,7 +106,6 @@ struct ath5k_hw *ath5k_hw_attach(struct ath5k_softc *sc, u8 mac_version)
> Â{
> Â Â Â Âstruct ath5k_hw *ah;
> Â Â Â Âstruct pci_dev *pdev = sc->pdev;
> - Â Â Â u8 mac[ETH_ALEN] = {};
> Â Â Â Âint ret;
> Â Â Â Âu32 srev;
>
> @@ -312,7 +311,7 @@ struct ath5k_hw *ath5k_hw_attach(struct ath5k_softc *sc, u8 mac_version)
> Â Â Â Â}
>
> Â Â Â Â/* MAC address is cleared until add_interface */
> - Â Â Â ath5k_hw_set_lladdr(ah, mac);
> + Â Â Â ath5k_hw_set_lladdr(ah, (u8[ETH_ALEN]){});
>
> Â Â Â Â/* Set BSSID to bcast address: ff:ff:ff:ff:ff:ff for now */
> Â Â Â Âmemset(ah->ah_bssid, 0xff, ETH_ALEN);
> diff --git a/drivers/net/wireless/ath5k/base.c b/drivers/net/wireless/ath5k/base.c
> index 08d691d..780fe6c 100644
> --- a/drivers/net/wireless/ath5k/base.c
> +++ b/drivers/net/wireless/ath5k/base.c
> @@ -79,7 +79,7 @@ MODULE_VERSION("0.6.0 (EXPERIMENTAL)");
>
>
> Â/* Known PCI ids */
> -static struct pci_device_id ath5k_pci_id_table[] __devinitdata = {
> +static const struct pci_device_id ath5k_pci_id_table[] = {
> Â Â Â Â{ PCI_VDEVICE(ATHEROS, 0x0207), .driver_data = AR5K_AR5210 }, /* 5210 early */
> Â Â Â Â{ PCI_VDEVICE(ATHEROS, 0x0007), .driver_data = AR5K_AR5210 }, /* 5210 */
> Â Â Â Â{ PCI_VDEVICE(ATHEROS, 0x0011), .driver_data = AR5K_AR5211 }, /* 5311 - this is on AHB bus !*/
> @@ -103,7 +103,7 @@ static struct pci_device_id ath5k_pci_id_table[] __devinitdata = {
> ÂMODULE_DEVICE_TABLE(pci, ath5k_pci_id_table);
>
> Â/* Known SREVs */
> -static struct ath5k_srev_name srev_names[] = {
> +static const struct ath5k_srev_name srev_names[] = {
> Â Â Â Â{ "5210", Â Â Â AR5K_VERSION_MAC, Â Â Â AR5K_SREV_AR5210 },
> Â Â Â Â{ "5311", Â Â Â AR5K_VERSION_MAC, Â Â Â AR5K_SREV_AR5311 },
> Â Â Â Â{ "5311A", Â Â ÂAR5K_VERSION_MAC, Â Â Â AR5K_SREV_AR5311A },
> @@ -142,7 +142,7 @@ static struct ath5k_srev_name srev_names[] = {
> Â Â Â Â{ "xxxxx", Â Â ÂAR5K_VERSION_RAD, Â Â Â AR5K_SREV_UNKNOWN },
> Â};
>
> -static struct ieee80211_rate ath5k_rates[] = {
> +static const struct ieee80211_rate ath5k_rates[] = {
> Â Â Â Â{ .bitrate = 10,
> Â Â Â Â Â.hw_value = ATH5K_RATE_CODE_1M, },
> Â Â Â Â{ .bitrate = 20,
> @@ -248,7 +248,7 @@ static void ath5k_bss_info_changed(struct ieee80211_hw *hw,
> Â Â Â Â Â Â Â Âstruct ieee80211_bss_conf *bss_conf,
> Â Â Â Â Â Â Â Âu32 changes);
>
> -static struct ieee80211_ops ath5k_hw_ops = {
> +static const struct ieee80211_ops ath5k_hw_ops = {
>    Â.tx       = ath5k_tx,
>    Â.start     Â= ath5k_start,
>    Â.stop      = ath5k_stop,
> diff --git a/drivers/net/wireless/ath5k/debug.c b/drivers/net/wireless/ath5k/debug.c
> index 413ed68..9770bb3 100644
> --- a/drivers/net/wireless/ath5k/debug.c
> +++ b/drivers/net/wireless/ath5k/debug.c
> @@ -82,14 +82,14 @@ static int ath5k_debugfs_open(struct inode *inode, struct file *file)
> Â/* debugfs: registers */
>
> Âstruct reg {
> - Â Â Â char *name;
> + Â Â Â const char *name;
> Â Â Â Âint addr;
> Â};
>
> Â#define REG_STRUCT_INIT(r) { #r, r }
>
> Â/* just a few random registers, might want to add more */
> -static struct reg regs[] = {
> +static const struct reg regs[] = {
> Â Â Â ÂREG_STRUCT_INIT(AR5K_CR),
> Â Â Â ÂREG_STRUCT_INIT(AR5K_RXDP),
> Â Â Â ÂREG_STRUCT_INIT(AR5K_CFG),
> @@ -142,7 +142,7 @@ static struct reg regs[] = {
>
> Âstatic void *reg_start(struct seq_file *seq, loff_t *pos)
> Â{
> - Â Â Â return *pos < ARRAY_SIZE(regs) ? &regs[*pos] : NULL;
> + Â Â Â return *pos < ARRAY_SIZE(regs) ? (void *)&regs[*pos] : NULL;
> Â}
>
> Âstatic void reg_stop(struct seq_file *seq, void *p)
> @@ -153,7 +153,7 @@ static void reg_stop(struct seq_file *seq, void *p)
> Âstatic void *reg_next(struct seq_file *seq, void *p, loff_t *pos)
> Â{
> Â Â Â Â++*pos;
> - Â Â Â return *pos < ARRAY_SIZE(regs) ? &regs[*pos] : NULL;
> + Â Â Â return *pos < ARRAY_SIZE(regs) ? (void *)&regs[*pos] : NULL;
> Â}
>
> Âstatic int reg_show(struct seq_file *seq, void *p)
> @@ -290,7 +290,7 @@ static const struct file_operations fops_reset = {
>
> Â/* debugfs: debug level */
>
> -static struct {
> +static const struct {
> Â Â Â Âenum ath5k_debug_level level;
> Â Â Â Âconst char *name;
> Â Â Â Âconst char *desc;
> diff --git a/drivers/net/wireless/ath5k/reset.c b/drivers/net/wireless/ath5k/reset.c
> index 1531ccd..685dc21 100644
> --- a/drivers/net/wireless/ath5k/reset.c
> +++ b/drivers/net/wireless/ath5k/reset.c
> @@ -102,7 +102,7 @@ static inline int ath5k_hw_write_ofdm_timings(struct ath5k_hw *ah,
> Â* index into rates for control rates, we can set it up like this because
> Â* this is only used for AR5212 and we know it supports G mode
> Â*/
> -static int control_rates[] =
> +static const unsigned int control_rates[] =
> Â Â Â Â{ 0, 1, 1, 1, 4, 4, 6, 6, 8, 8, 8, 8 };
>
> Â/**

Acked-by: Nick Kossifidis <mickflemm@xxxxxxxxx>



--
GPG ID: 0xD21DB2DB
As you read this post global entropy rises. Have Fun ;-)
Nick
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/