Skip to content

Commit d1ce011

Browse files
committed
Merge branch 'PHYID-matching-macros'
Heiner Kallweit says: ==================== net: phy: add macros for PHYID matching in PHY driver config Add macros for PHYID matching to be used in PHY driver configs. By using these macros some boilerplate code can be avoided. Use them initially in the Realtek PHY drivers. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents fa28a2b + ca49493 commit d1ce011

File tree

2 files changed

+14
-19
lines changed

2 files changed

+14
-19
lines changed

drivers/net/phy/realtek.c

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -213,14 +213,12 @@ static int rtl8366rb_config_init(struct phy_device *phydev)
213213

214214
static struct phy_driver realtek_drvs[] = {
215215
{
216-
.phy_id = 0x00008201,
216+
PHY_ID_MATCH_EXACT(0x00008201),
217217
.name = "RTL8201CP Ethernet",
218-
.phy_id_mask = 0x0000ffff,
219218
.features = PHY_BASIC_FEATURES,
220219
}, {
221-
.phy_id = 0x001cc816,
220+
PHY_ID_MATCH_EXACT(0x001cc816),
222221
.name = "RTL8201F Fast Ethernet",
223-
.phy_id_mask = 0x001fffff,
224222
.features = PHY_BASIC_FEATURES,
225223
.ack_interrupt = &rtl8201_ack_interrupt,
226224
.config_intr = &rtl8201_config_intr,
@@ -229,17 +227,15 @@ static struct phy_driver realtek_drvs[] = {
229227
.read_page = rtl821x_read_page,
230228
.write_page = rtl821x_write_page,
231229
}, {
232-
.phy_id = 0x001cc910,
230+
PHY_ID_MATCH_EXACT(0x001cc910),
233231
.name = "RTL8211 Gigabit Ethernet",
234-
.phy_id_mask = 0x001fffff,
235232
.features = PHY_GBIT_FEATURES,
236233
.config_aneg = rtl8211_config_aneg,
237234
.read_mmd = &genphy_read_mmd_unsupported,
238235
.write_mmd = &genphy_write_mmd_unsupported,
239236
}, {
240-
.phy_id = 0x001cc912,
237+
PHY_ID_MATCH_EXACT(0x001cc912),
241238
.name = "RTL8211B Gigabit Ethernet",
242-
.phy_id_mask = 0x001fffff,
243239
.features = PHY_GBIT_FEATURES,
244240
.ack_interrupt = &rtl821x_ack_interrupt,
245241
.config_intr = &rtl8211b_config_intr,
@@ -248,35 +244,31 @@ static struct phy_driver realtek_drvs[] = {
248244
.suspend = rtl8211b_suspend,
249245
.resume = rtl8211b_resume,
250246
}, {
251-
.phy_id = 0x001cc913,
247+
PHY_ID_MATCH_EXACT(0x001cc913),
252248
.name = "RTL8211C Gigabit Ethernet",
253-
.phy_id_mask = 0x001fffff,
254249
.features = PHY_GBIT_FEATURES,
255250
.config_init = rtl8211c_config_init,
256251
.read_mmd = &genphy_read_mmd_unsupported,
257252
.write_mmd = &genphy_write_mmd_unsupported,
258253
}, {
259-
.phy_id = 0x001cc914,
254+
PHY_ID_MATCH_EXACT(0x001cc914),
260255
.name = "RTL8211DN Gigabit Ethernet",
261-
.phy_id_mask = 0x001fffff,
262256
.features = PHY_GBIT_FEATURES,
263257
.ack_interrupt = rtl821x_ack_interrupt,
264258
.config_intr = rtl8211e_config_intr,
265259
.suspend = genphy_suspend,
266260
.resume = genphy_resume,
267261
}, {
268-
.phy_id = 0x001cc915,
262+
PHY_ID_MATCH_EXACT(0x001cc915),
269263
.name = "RTL8211E Gigabit Ethernet",
270-
.phy_id_mask = 0x001fffff,
271264
.features = PHY_GBIT_FEATURES,
272265
.ack_interrupt = &rtl821x_ack_interrupt,
273266
.config_intr = &rtl8211e_config_intr,
274267
.suspend = genphy_suspend,
275268
.resume = genphy_resume,
276269
}, {
277-
.phy_id = 0x001cc916,
270+
PHY_ID_MATCH_EXACT(0x001cc916),
278271
.name = "RTL8211F Gigabit Ethernet",
279-
.phy_id_mask = 0x001fffff,
280272
.features = PHY_GBIT_FEATURES,
281273
.config_init = &rtl8211f_config_init,
282274
.ack_interrupt = &rtl8211f_ack_interrupt,
@@ -286,9 +278,8 @@ static struct phy_driver realtek_drvs[] = {
286278
.read_page = rtl821x_read_page,
287279
.write_page = rtl821x_write_page,
288280
}, {
289-
.phy_id = 0x001cc961,
281+
PHY_ID_MATCH_EXACT(0x001cc961),
290282
.name = "RTL8366RB Gigabit Ethernet",
291-
.phy_id_mask = 0x001fffff,
292283
.features = PHY_GBIT_FEATURES,
293284
.config_init = &rtl8366rb_config_init,
294285
.suspend = genphy_suspend,
@@ -299,7 +290,7 @@ static struct phy_driver realtek_drvs[] = {
299290
module_phy_driver(realtek_drvs);
300291

301292
static const struct mdio_device_id __maybe_unused realtek_tbl[] = {
302-
{ 0x001cc800, GENMASK(31, 10) },
293+
{ PHY_ID_MATCH_VENDOR(0x001cc800) },
303294
{ }
304295
};
305296

include/linux/phy.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,10 @@ struct phy_driver {
651651
#define PHY_ANY_ID "MATCH ANY PHY"
652652
#define PHY_ANY_UID 0xffffffff
653653

654+
#define PHY_ID_MATCH_EXACT(id) .phy_id = (id), .phy_id_mask = GENMASK(31, 0)
655+
#define PHY_ID_MATCH_MODEL(id) .phy_id = (id), .phy_id_mask = GENMASK(31, 4)
656+
#define PHY_ID_MATCH_VENDOR(id) .phy_id = (id), .phy_id_mask = GENMASK(31, 10)
657+
654658
/* A Structure for boards to register fixups with the PHY Lib */
655659
struct phy_fixup {
656660
struct list_head list;

0 commit comments

Comments
 (0)