Skip to content

Commit 3768901

Browse files
mdrustadJeff Kirsher
authored andcommitted
ixgbe: Make all unchanging ops structures const
The source for the ops structure contents are const, so make them so. Copy them in place with structure assignments instead of memcpys. Make the mbx_ops accessed by reference instead of making a copy of the source structure. Update copyright date on the touched files. Reported-by: Julia Lawall <[email protected]> Signed-off-by: Mark Rustad <[email protected]> Acked-by: Julia Lawall <[email protected]> Tested-by: Andrew Bowers <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent 06bb1c3 commit 3768901

File tree

9 files changed

+63
-63
lines changed

9 files changed

+63
-63
lines changed

drivers/net/ethernet/intel/ixgbe/ixgbe.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*******************************************************************************
22
33
Intel 10 Gigabit PCI Express Linux driver
4-
Copyright(c) 1999 - 2013 Intel Corporation.
4+
Copyright(c) 1999 - 2016 Intel Corporation.
55
66
This program is free software; you can redistribute it and/or modify it
77
under the terms and conditions of the GNU General Public License,
@@ -862,11 +862,11 @@ enum ixgbe_boards {
862862
board_X550EM_x,
863863
};
864864

865-
extern struct ixgbe_info ixgbe_82598_info;
866-
extern struct ixgbe_info ixgbe_82599_info;
867-
extern struct ixgbe_info ixgbe_X540_info;
868-
extern struct ixgbe_info ixgbe_X550_info;
869-
extern struct ixgbe_info ixgbe_X550EM_x_info;
865+
extern const struct ixgbe_info ixgbe_82598_info;
866+
extern const struct ixgbe_info ixgbe_82599_info;
867+
extern const struct ixgbe_info ixgbe_X540_info;
868+
extern const struct ixgbe_info ixgbe_X550_info;
869+
extern const struct ixgbe_info ixgbe_X550EM_x_info;
870870
#ifdef CONFIG_IXGBE_DCB
871871
extern const struct dcbnl_rtnl_ops dcbnl_ops;
872872
#endif

drivers/net/ethernet/intel/ixgbe/ixgbe_82598.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*******************************************************************************
22
33
Intel 10 Gigabit PCI Express Linux driver
4-
Copyright(c) 1999 - 2015 Intel Corporation.
4+
Copyright(c) 1999 - 2016 Intel Corporation.
55
66
This program is free software; you can redistribute it and/or modify it
77
under the terms and conditions of the GNU General Public License,
@@ -1160,7 +1160,7 @@ static void ixgbe_set_rxpba_82598(struct ixgbe_hw *hw, int num_pb,
11601160
IXGBE_WRITE_REG(hw, IXGBE_TXPBSIZE(i), IXGBE_TXPBSIZE_40KB);
11611161
}
11621162

1163-
static struct ixgbe_mac_operations mac_ops_82598 = {
1163+
static const struct ixgbe_mac_operations mac_ops_82598 = {
11641164
.init_hw = &ixgbe_init_hw_generic,
11651165
.reset_hw = &ixgbe_reset_hw_82598,
11661166
.start_hw = &ixgbe_start_hw_82598,
@@ -1203,7 +1203,7 @@ static struct ixgbe_mac_operations mac_ops_82598 = {
12031203
.disable_rx = &ixgbe_disable_rx_generic,
12041204
};
12051205

1206-
static struct ixgbe_eeprom_operations eeprom_ops_82598 = {
1206+
static const struct ixgbe_eeprom_operations eeprom_ops_82598 = {
12071207
.init_params = &ixgbe_init_eeprom_params_generic,
12081208
.read = &ixgbe_read_eerd_generic,
12091209
.write = &ixgbe_write_eeprom_generic,
@@ -1214,7 +1214,7 @@ static struct ixgbe_eeprom_operations eeprom_ops_82598 = {
12141214
.update_checksum = &ixgbe_update_eeprom_checksum_generic,
12151215
};
12161216

1217-
static struct ixgbe_phy_operations phy_ops_82598 = {
1217+
static const struct ixgbe_phy_operations phy_ops_82598 = {
12181218
.identify = &ixgbe_identify_phy_generic,
12191219
.identify_sfp = &ixgbe_identify_module_generic,
12201220
.init = &ixgbe_init_phy_ops_82598,
@@ -1230,7 +1230,7 @@ static struct ixgbe_phy_operations phy_ops_82598 = {
12301230
.check_overtemp = &ixgbe_tn_check_overtemp,
12311231
};
12321232

1233-
struct ixgbe_info ixgbe_82598_info = {
1233+
const struct ixgbe_info ixgbe_82598_info = {
12341234
.mac = ixgbe_mac_82598EB,
12351235
.get_invariants = &ixgbe_get_invariants_82598,
12361236
.mac_ops = &mac_ops_82598,

drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*******************************************************************************
22
33
Intel 10 Gigabit PCI Express Linux driver
4-
Copyright(c) 1999 - 2015 Intel Corporation.
4+
Copyright(c) 1999 - 2016 Intel Corporation.
55
66
This program is free software; you can redistribute it and/or modify it
77
under the terms and conditions of the GNU General Public License,
@@ -2181,7 +2181,7 @@ static s32 ixgbe_write_i2c_byte_82599(struct ixgbe_hw *hw, u8 byte_offset,
21812181
return status;
21822182
}
21832183

2184-
static struct ixgbe_mac_operations mac_ops_82599 = {
2184+
static const struct ixgbe_mac_operations mac_ops_82599 = {
21852185
.init_hw = &ixgbe_init_hw_generic,
21862186
.reset_hw = &ixgbe_reset_hw_82599,
21872187
.start_hw = &ixgbe_start_hw_82599,
@@ -2235,7 +2235,7 @@ static struct ixgbe_mac_operations mac_ops_82599 = {
22352235
.disable_rx = &ixgbe_disable_rx_generic,
22362236
};
22372237

2238-
static struct ixgbe_eeprom_operations eeprom_ops_82599 = {
2238+
static const struct ixgbe_eeprom_operations eeprom_ops_82599 = {
22392239
.init_params = &ixgbe_init_eeprom_params_generic,
22402240
.read = &ixgbe_read_eeprom_82599,
22412241
.read_buffer = &ixgbe_read_eeprom_buffer_82599,
@@ -2246,7 +2246,7 @@ static struct ixgbe_eeprom_operations eeprom_ops_82599 = {
22462246
.update_checksum = &ixgbe_update_eeprom_checksum_generic,
22472247
};
22482248

2249-
static struct ixgbe_phy_operations phy_ops_82599 = {
2249+
static const struct ixgbe_phy_operations phy_ops_82599 = {
22502250
.identify = &ixgbe_identify_phy_82599,
22512251
.identify_sfp = &ixgbe_identify_module_generic,
22522252
.init = &ixgbe_init_phy_ops_82599,
@@ -2263,7 +2263,7 @@ static struct ixgbe_phy_operations phy_ops_82599 = {
22632263
.check_overtemp = &ixgbe_tn_check_overtemp,
22642264
};
22652265

2266-
struct ixgbe_info ixgbe_82599_info = {
2266+
const struct ixgbe_info ixgbe_82599_info = {
22672267
.mac = ixgbe_mac_82599EB,
22682268
.get_invariants = &ixgbe_get_invariants_82599,
22692269
.mac_ops = &mac_ops_82599,

drivers/net/ethernet/intel/ixgbe/ixgbe_main.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*******************************************************************************
22
33
Intel 10 Gigabit PCI Express Linux driver
4-
Copyright(c) 1999 - 2015 Intel Corporation.
4+
Copyright(c) 1999 - 2016 Intel Corporation.
55
66
This program is free software; you can redistribute it and/or modify it
77
under the terms and conditions of the GNU General Public License,
@@ -9136,12 +9136,12 @@ static int ixgbe_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
91369136
strlcpy(netdev->name, pci_name(pdev), sizeof(netdev->name));
91379137

91389138
/* Setup hw api */
9139-
memcpy(&hw->mac.ops, ii->mac_ops, sizeof(hw->mac.ops));
9139+
hw->mac.ops = *ii->mac_ops;
91409140
hw->mac.type = ii->mac;
91419141
hw->mvals = ii->mvals;
91429142

91439143
/* EEPROM */
9144-
memcpy(&hw->eeprom.ops, ii->eeprom_ops, sizeof(hw->eeprom.ops));
9144+
hw->eeprom.ops = *ii->eeprom_ops;
91459145
eec = IXGBE_READ_REG(hw, IXGBE_EEC(hw));
91469146
if (ixgbe_removed(hw->hw_addr)) {
91479147
err = -EIO;
@@ -9152,7 +9152,7 @@ static int ixgbe_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
91529152
hw->eeprom.ops.read = &ixgbe_read_eeprom_bit_bang_generic;
91539153

91549154
/* PHY */
9155-
memcpy(&hw->phy.ops, ii->phy_ops, sizeof(hw->phy.ops));
9155+
hw->phy.ops = *ii->phy_ops;
91569156
hw->phy.sfp_type = ixgbe_sfp_type_unknown;
91579157
/* ixgbe_identify_phy_generic will set prtad and mmds properly */
91589158
hw->phy.mdio.prtad = MDIO_PRTAD_NONE;
@@ -9215,7 +9215,7 @@ static int ixgbe_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
92159215
goto skip_sriov;
92169216
/* Mailbox */
92179217
ixgbe_init_mbx_params_pf(hw);
9218-
memcpy(&hw->mbx.ops, ii->mbx_ops, sizeof(hw->mbx.ops));
9218+
hw->mbx.ops = ii->mbx_ops;
92199219
pci_sriov_set_totalvfs(pdev, IXGBE_MAX_VFS_DRV_LIMIT);
92209220
ixgbe_enable_sriov(adapter);
92219221
skip_sriov:

drivers/net/ethernet/intel/ixgbe/ixgbe_mbx.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*******************************************************************************
22
33
Intel 10 Gigabit PCI Express Linux driver
4-
Copyright(c) 1999 - 2014 Intel Corporation.
4+
Copyright(c) 1999 - 2016 Intel Corporation.
55
66
This program is free software; you can redistribute it and/or modify it
77
under the terms and conditions of the GNU General Public License,
@@ -48,10 +48,10 @@ s32 ixgbe_read_mbx(struct ixgbe_hw *hw, u32 *msg, u16 size, u16 mbx_id)
4848
if (size > mbx->size)
4949
size = mbx->size;
5050

51-
if (!mbx->ops.read)
51+
if (!mbx->ops)
5252
return IXGBE_ERR_MBX;
5353

54-
return mbx->ops.read(hw, msg, size, mbx_id);
54+
return mbx->ops->read(hw, msg, size, mbx_id);
5555
}
5656

5757
/**
@@ -70,10 +70,10 @@ s32 ixgbe_write_mbx(struct ixgbe_hw *hw, u32 *msg, u16 size, u16 mbx_id)
7070
if (size > mbx->size)
7171
return IXGBE_ERR_MBX;
7272

73-
if (!mbx->ops.write)
73+
if (!mbx->ops)
7474
return IXGBE_ERR_MBX;
7575

76-
return mbx->ops.write(hw, msg, size, mbx_id);
76+
return mbx->ops->write(hw, msg, size, mbx_id);
7777
}
7878

7979
/**
@@ -87,10 +87,10 @@ s32 ixgbe_check_for_msg(struct ixgbe_hw *hw, u16 mbx_id)
8787
{
8888
struct ixgbe_mbx_info *mbx = &hw->mbx;
8989

90-
if (!mbx->ops.check_for_msg)
90+
if (!mbx->ops)
9191
return IXGBE_ERR_MBX;
9292

93-
return mbx->ops.check_for_msg(hw, mbx_id);
93+
return mbx->ops->check_for_msg(hw, mbx_id);
9494
}
9595

9696
/**
@@ -104,10 +104,10 @@ s32 ixgbe_check_for_ack(struct ixgbe_hw *hw, u16 mbx_id)
104104
{
105105
struct ixgbe_mbx_info *mbx = &hw->mbx;
106106

107-
if (!mbx->ops.check_for_ack)
107+
if (!mbx->ops)
108108
return IXGBE_ERR_MBX;
109109

110-
return mbx->ops.check_for_ack(hw, mbx_id);
110+
return mbx->ops->check_for_ack(hw, mbx_id);
111111
}
112112

113113
/**
@@ -121,10 +121,10 @@ s32 ixgbe_check_for_rst(struct ixgbe_hw *hw, u16 mbx_id)
121121
{
122122
struct ixgbe_mbx_info *mbx = &hw->mbx;
123123

124-
if (!mbx->ops.check_for_rst)
124+
if (!mbx->ops)
125125
return IXGBE_ERR_MBX;
126126

127-
return mbx->ops.check_for_rst(hw, mbx_id);
127+
return mbx->ops->check_for_rst(hw, mbx_id);
128128
}
129129

130130
/**
@@ -139,10 +139,10 @@ static s32 ixgbe_poll_for_msg(struct ixgbe_hw *hw, u16 mbx_id)
139139
struct ixgbe_mbx_info *mbx = &hw->mbx;
140140
int countdown = mbx->timeout;
141141

142-
if (!countdown || !mbx->ops.check_for_msg)
142+
if (!countdown || !mbx->ops)
143143
return IXGBE_ERR_MBX;
144144

145-
while (mbx->ops.check_for_msg(hw, mbx_id)) {
145+
while (mbx->ops->check_for_msg(hw, mbx_id)) {
146146
countdown--;
147147
if (!countdown)
148148
return IXGBE_ERR_MBX;
@@ -164,10 +164,10 @@ static s32 ixgbe_poll_for_ack(struct ixgbe_hw *hw, u16 mbx_id)
164164
struct ixgbe_mbx_info *mbx = &hw->mbx;
165165
int countdown = mbx->timeout;
166166

167-
if (!countdown || !mbx->ops.check_for_ack)
167+
if (!countdown || !mbx->ops)
168168
return IXGBE_ERR_MBX;
169169

170-
while (mbx->ops.check_for_ack(hw, mbx_id)) {
170+
while (mbx->ops->check_for_ack(hw, mbx_id)) {
171171
countdown--;
172172
if (!countdown)
173173
return IXGBE_ERR_MBX;
@@ -193,15 +193,15 @@ static s32 ixgbe_read_posted_mbx(struct ixgbe_hw *hw, u32 *msg, u16 size,
193193
struct ixgbe_mbx_info *mbx = &hw->mbx;
194194
s32 ret_val;
195195

196-
if (!mbx->ops.read)
196+
if (!mbx->ops)
197197
return IXGBE_ERR_MBX;
198198

199199
ret_val = ixgbe_poll_for_msg(hw, mbx_id);
200200
if (ret_val)
201201
return ret_val;
202202

203203
/* if ack received read message */
204-
return mbx->ops.read(hw, msg, size, mbx_id);
204+
return mbx->ops->read(hw, msg, size, mbx_id);
205205
}
206206

207207
/**
@@ -221,11 +221,11 @@ static s32 ixgbe_write_posted_mbx(struct ixgbe_hw *hw, u32 *msg, u16 size,
221221
s32 ret_val;
222222

223223
/* exit if either we can't write or there isn't a defined timeout */
224-
if (!mbx->ops.write || !mbx->timeout)
224+
if (!mbx->ops || !mbx->timeout)
225225
return IXGBE_ERR_MBX;
226226

227227
/* send msg */
228-
ret_val = mbx->ops.write(hw, msg, size, mbx_id);
228+
ret_val = mbx->ops->write(hw, msg, size, mbx_id);
229229
if (ret_val)
230230
return ret_val;
231231

@@ -446,7 +446,7 @@ void ixgbe_init_mbx_params_pf(struct ixgbe_hw *hw)
446446
}
447447
#endif /* CONFIG_PCI_IOV */
448448

449-
struct ixgbe_mbx_operations mbx_ops_generic = {
449+
const struct ixgbe_mbx_operations mbx_ops_generic = {
450450
.read = ixgbe_read_mbx_pf,
451451
.write = ixgbe_write_mbx_pf,
452452
.read_posted = ixgbe_read_posted_mbx,

drivers/net/ethernet/intel/ixgbe/ixgbe_mbx.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*******************************************************************************
22
33
Intel 10 Gigabit PCI Express Linux driver
4-
Copyright(c) 1999 - 2013 Intel Corporation.
4+
Copyright(c) 1999 - 2016 Intel Corporation.
55
66
This program is free software; you can redistribute it and/or modify it
77
under the terms and conditions of the GNU General Public License,
@@ -123,6 +123,6 @@ s32 ixgbe_check_for_rst(struct ixgbe_hw *, u16);
123123
void ixgbe_init_mbx_params_pf(struct ixgbe_hw *);
124124
#endif /* CONFIG_PCI_IOV */
125125

126-
extern struct ixgbe_mbx_operations mbx_ops_generic;
126+
extern const struct ixgbe_mbx_operations mbx_ops_generic;
127127

128128
#endif /* _IXGBE_MBX_H_ */

drivers/net/ethernet/intel/ixgbe/ixgbe_type.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*******************************************************************************
22
33
Intel 10 Gigabit PCI Express Linux driver
4-
Copyright(c) 1999 - 2015 Intel Corporation.
4+
Copyright(c) 1999 - 2016 Intel Corporation.
55
66
This program is free software; you can redistribute it and/or modify it
77
under the terms and conditions of the GNU General Public License,
@@ -3442,7 +3442,7 @@ struct ixgbe_mbx_stats {
34423442
};
34433443

34443444
struct ixgbe_mbx_info {
3445-
struct ixgbe_mbx_operations ops;
3445+
const struct ixgbe_mbx_operations *ops;
34463446
struct ixgbe_mbx_stats stats;
34473447
u32 timeout;
34483448
u32 usec_delay;
@@ -3475,10 +3475,10 @@ struct ixgbe_hw {
34753475
struct ixgbe_info {
34763476
enum ixgbe_mac_type mac;
34773477
s32 (*get_invariants)(struct ixgbe_hw *);
3478-
struct ixgbe_mac_operations *mac_ops;
3479-
struct ixgbe_eeprom_operations *eeprom_ops;
3480-
struct ixgbe_phy_operations *phy_ops;
3481-
struct ixgbe_mbx_operations *mbx_ops;
3478+
const struct ixgbe_mac_operations *mac_ops;
3479+
const struct ixgbe_eeprom_operations *eeprom_ops;
3480+
const struct ixgbe_phy_operations *phy_ops;
3481+
const struct ixgbe_mbx_operations *mbx_ops;
34823482
const u32 *mvals;
34833483
};
34843484

drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*******************************************************************************
22
33
Intel 10 Gigabit PCI Express Linux driver
4-
Copyright(c) 1999 - 2014 Intel Corporation.
4+
Copyright(c) 1999 - 2016 Intel Corporation.
55
66
This program is free software; you can redistribute it and/or modify it
77
under the terms and conditions of the GNU General Public License,
@@ -810,7 +810,7 @@ s32 ixgbe_blink_led_stop_X540(struct ixgbe_hw *hw, u32 index)
810810

811811
return 0;
812812
}
813-
static struct ixgbe_mac_operations mac_ops_X540 = {
813+
static const struct ixgbe_mac_operations mac_ops_X540 = {
814814
.init_hw = &ixgbe_init_hw_generic,
815815
.reset_hw = &ixgbe_reset_hw_X540,
816816
.start_hw = &ixgbe_start_hw_X540,
@@ -863,7 +863,7 @@ static struct ixgbe_mac_operations mac_ops_X540 = {
863863
.disable_rx = &ixgbe_disable_rx_generic,
864864
};
865865

866-
static struct ixgbe_eeprom_operations eeprom_ops_X540 = {
866+
static const struct ixgbe_eeprom_operations eeprom_ops_X540 = {
867867
.init_params = &ixgbe_init_eeprom_params_X540,
868868
.read = &ixgbe_read_eerd_X540,
869869
.read_buffer = &ixgbe_read_eerd_buffer_X540,
@@ -874,7 +874,7 @@ static struct ixgbe_eeprom_operations eeprom_ops_X540 = {
874874
.update_checksum = &ixgbe_update_eeprom_checksum_X540,
875875
};
876876

877-
static struct ixgbe_phy_operations phy_ops_X540 = {
877+
static const struct ixgbe_phy_operations phy_ops_X540 = {
878878
.identify = &ixgbe_identify_phy_generic,
879879
.identify_sfp = &ixgbe_identify_sfp_module_generic,
880880
.init = NULL,
@@ -897,7 +897,7 @@ static const u32 ixgbe_mvals_X540[IXGBE_MVALS_IDX_LIMIT] = {
897897
IXGBE_MVALS_INIT(X540)
898898
};
899899

900-
struct ixgbe_info ixgbe_X540_info = {
900+
const struct ixgbe_info ixgbe_X540_info = {
901901
.mac = ixgbe_mac_X540,
902902
.get_invariants = &ixgbe_get_invariants_X540,
903903
.mac_ops = &mac_ops_X540,

0 commit comments

Comments
 (0)