sfc: make function tables const
authorstephen hemminger <shemminger@vyatta.com>
Thu, 14 Apr 2011 05:50:12 +0000 (05:50 +0000)
committerDavid S. Miller <davem@davemloft.net>
Fri, 15 Apr 2011 04:53:42 +0000 (21:53 -0700)
The phy, mac, and board information structures should be const.
Since tables contain function pointer this improves security
(at least theoretically).

Compile tested only.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Acked-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
13 files changed:
drivers/net/sfc/efx.c
drivers/net/sfc/falcon.c
drivers/net/sfc/falcon_xmac.c
drivers/net/sfc/mac.h
drivers/net/sfc/mcdi_mac.c
drivers/net/sfc/mcdi_phy.c
drivers/net/sfc/net_driver.h
drivers/net/sfc/nic.h
drivers/net/sfc/phy.h
drivers/net/sfc/qt202x_phy.c
drivers/net/sfc/siena.c
drivers/net/sfc/tenxpress.c
drivers/net/sfc/txc43128_phy.c

index db72a6e..c8871b2 100644 (file)
@@ -2245,7 +2245,7 @@ static bool efx_port_dummy_op_poll(struct efx_nic *efx)
        return false;
 }
 
-static struct efx_phy_operations efx_dummy_phy_operations = {
+static const struct efx_phy_operations efx_dummy_phy_operations = {
        .init            = efx_port_dummy_op_int,
        .reconfigure     = efx_port_dummy_op_int,
        .poll            = efx_port_dummy_op_poll,
@@ -2261,7 +2261,7 @@ static struct efx_phy_operations efx_dummy_phy_operations = {
 /* This zeroes out and then fills in the invariants in a struct
  * efx_nic (including all sub-structures).
  */
-static int efx_init_struct(struct efx_nic *efx, struct efx_nic_type *type,
+static int efx_init_struct(struct efx_nic *efx, const struct efx_nic_type *type,
                           struct pci_dev *pci_dev, struct net_device *net_dev)
 {
        int i;
@@ -2451,7 +2451,7 @@ static int efx_pci_probe_main(struct efx_nic *efx)
 static int __devinit efx_pci_probe(struct pci_dev *pci_dev,
                                   const struct pci_device_id *entry)
 {
-       struct efx_nic_type *type = (struct efx_nic_type *) entry->driver_data;
+       const struct efx_nic_type *type = (const struct efx_nic_type *) entry->driver_data;
        struct net_device *net_dev;
        struct efx_nic *efx;
        int i, rc;
index d96b237..60176e8 100644 (file)
@@ -1703,7 +1703,7 @@ static int falcon_set_wol(struct efx_nic *efx, u32 type)
  **************************************************************************
  */
 
-struct efx_nic_type falcon_a1_nic_type = {
+const struct efx_nic_type falcon_a1_nic_type = {
        .probe = falcon_probe_nic,
        .remove = falcon_remove_nic,
        .init = falcon_init_nic,
@@ -1744,7 +1744,7 @@ struct efx_nic_type falcon_a1_nic_type = {
        .reset_world_flags = ETH_RESET_IRQ,
 };
 
-struct efx_nic_type falcon_b0_nic_type = {
+const struct efx_nic_type falcon_b0_nic_type = {
        .probe = falcon_probe_nic,
        .remove = falcon_remove_nic,
        .init = falcon_init_nic,
index 2c9ee5d..9516452 100644 (file)
@@ -362,7 +362,7 @@ void falcon_poll_xmac(struct efx_nic *efx)
        falcon_ack_status_intr(efx);
 }
 
-struct efx_mac_operations falcon_xmac_operations = {
+const struct efx_mac_operations falcon_xmac_operations = {
        .reconfigure    = falcon_reconfigure_xmac,
        .update_stats   = falcon_update_stats_xmac,
        .check_fault    = falcon_xmac_check_fault,
index 6886cdf..d6a255d 100644 (file)
@@ -13,8 +13,8 @@
 
 #include "net_driver.h"
 
-extern struct efx_mac_operations falcon_xmac_operations;
-extern struct efx_mac_operations efx_mcdi_mac_operations;
+extern const struct efx_mac_operations falcon_xmac_operations;
+extern const struct efx_mac_operations efx_mcdi_mac_operations;
 extern int efx_mcdi_mac_stats(struct efx_nic *efx, dma_addr_t dma_addr,
                              u32 dma_len, int enable, int clear);
 
index 33f7294..50c2077 100644 (file)
@@ -138,7 +138,7 @@ static bool efx_mcdi_mac_check_fault(struct efx_nic *efx)
 }
 
 
-struct efx_mac_operations efx_mcdi_mac_operations = {
+const struct efx_mac_operations efx_mcdi_mac_operations = {
        .reconfigure    = efx_mcdi_mac_reconfigure,
        .update_stats   = efx_port_dummy_op_void,
        .check_fault    = efx_mcdi_mac_check_fault,
index 7e3c65b..1fcda2d 100644 (file)
@@ -739,7 +739,7 @@ static const char *efx_mcdi_phy_test_name(struct efx_nic *efx,
        return NULL;
 }
 
-struct efx_phy_operations efx_mcdi_phy_ops = {
+const struct efx_phy_operations efx_mcdi_phy_ops = {
        .probe          = efx_mcdi_phy_probe,
        .init           = efx_port_dummy_op_int,
        .reconfigure    = efx_mcdi_phy_reconfigure,
index 92a9067..ab4d05b 100644 (file)
@@ -773,10 +773,10 @@ struct efx_nic {
 
        struct efx_buffer stats_buffer;
 
-       struct efx_mac_operations *mac_op;
+       const struct efx_mac_operations *mac_op;
 
        unsigned int phy_type;
-       struct efx_phy_operations *phy_op;
+       const struct efx_phy_operations *phy_op;
        void *phy_data;
        struct mdio_if_info mdio;
        unsigned int mdio_bus;
@@ -897,7 +897,7 @@ struct efx_nic_type {
        void (*resume_wol)(struct efx_nic *efx);
        int (*test_registers)(struct efx_nic *efx);
        int (*test_nvram)(struct efx_nic *efx);
-       struct efx_mac_operations *default_mac_ops;
+       const struct efx_mac_operations *default_mac_ops;
 
        int revision;
        unsigned int mem_map_size;
index d9de1b6..f7ec03c 100644 (file)
@@ -150,9 +150,9 @@ struct siena_nic_data {
        int wol_filter_id;
 };
 
-extern struct efx_nic_type falcon_a1_nic_type;
-extern struct efx_nic_type falcon_b0_nic_type;
-extern struct efx_nic_type siena_a0_nic_type;
+extern const struct efx_nic_type falcon_a1_nic_type;
+extern const struct efx_nic_type falcon_b0_nic_type;
+extern const struct efx_nic_type siena_a0_nic_type;
 
 /**************************************************************************
  *
index b3b7947..11d148c 100644 (file)
 /****************************************************************************
  * 10Xpress (SFX7101) PHY
  */
-extern struct efx_phy_operations falcon_sfx7101_phy_ops;
+extern const struct efx_phy_operations falcon_sfx7101_phy_ops;
 
 extern void tenxpress_set_id_led(struct efx_nic *efx, enum efx_led_mode mode);
 
 /****************************************************************************
  * AMCC/Quake QT202x PHYs
  */
-extern struct efx_phy_operations falcon_qt202x_phy_ops;
+extern const struct efx_phy_operations falcon_qt202x_phy_ops;
 
 /* These PHYs provide various H/W control states for LEDs */
 #define QUAKE_LED_LINK_INVAL   (0)
@@ -39,7 +39,7 @@ extern void falcon_qt202x_set_led(struct efx_nic *p, int led, int state);
 /****************************************************************************
 * Transwitch CX4 retimer
 */
-extern struct efx_phy_operations falcon_txc_phy_ops;
+extern const struct efx_phy_operations falcon_txc_phy_ops;
 
 #define TXC_GPIO_DIR_INPUT     0
 #define TXC_GPIO_DIR_OUTPUT    1
@@ -50,7 +50,7 @@ extern void falcon_txc_set_gpio_val(struct efx_nic *efx, int pin, int val);
 /****************************************************************************
  * Siena managed PHYs
  */
-extern struct efx_phy_operations efx_mcdi_phy_ops;
+extern const struct efx_phy_operations efx_mcdi_phy_ops;
 
 extern int efx_mcdi_mdio_read(struct efx_nic *efx, unsigned int bus,
                              unsigned int prtad, unsigned int devad,
index 55f9092..7ad97e3 100644 (file)
@@ -449,7 +449,7 @@ static void qt202x_phy_remove(struct efx_nic *efx)
        efx->phy_data = NULL;
 }
 
-struct efx_phy_operations falcon_qt202x_phy_ops = {
+const struct efx_phy_operations falcon_qt202x_phy_ops = {
        .probe           = qt202x_phy_probe,
        .init            = qt202x_phy_init,
        .reconfigure     = qt202x_phy_reconfigure,
index e4dd898..ceac1c9 100644 (file)
@@ -581,7 +581,7 @@ static void siena_init_wol(struct efx_nic *efx)
  **************************************************************************
  */
 
-struct efx_nic_type siena_a0_nic_type = {
+const struct efx_nic_type siena_a0_nic_type = {
        .probe = siena_probe_nic,
        .remove = siena_remove_nic,
        .init = siena_init_nic,
index efdceb3..204ecda 100644 (file)
@@ -478,7 +478,7 @@ static void sfx7101_set_npage_adv(struct efx_nic *efx, u32 advertising)
                          advertising & ADVERTISED_10000baseT_Full);
 }
 
-struct efx_phy_operations falcon_sfx7101_phy_ops = {
+const struct efx_phy_operations falcon_sfx7101_phy_ops = {
        .probe            = tenxpress_phy_probe,
        .init             = tenxpress_phy_init,
        .reconfigure      = tenxpress_phy_reconfigure,
index d9886ad..7c21b33 100644 (file)
@@ -545,7 +545,7 @@ static void txc43128_get_settings(struct efx_nic *efx, struct ethtool_cmd *ecmd)
        mdio45_ethtool_gset(&efx->mdio, ecmd);
 }
 
-struct efx_phy_operations falcon_txc_phy_ops = {
+const struct efx_phy_operations falcon_txc_phy_ops = {
        .probe          = txc43128_phy_probe,
        .init           = txc43128_phy_init,
        .reconfigure    = txc43128_phy_reconfigure,