Ignore:
Timestamp:
2012-03-15T10:25:47+01:00 (5 years ago)
Author:
juhosg
Message:

linux/3.2: build mdio_register_board_info into the kernel if PHYLIB is selected

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/target/linux/generic/patches-3.2/710-phy-add-mdio_register_board_info.patch

    r30905 r30944  
    11--- a/drivers/net/phy/mdio_bus.c 
    22+++ b/drivers/net/phy/mdio_bus.c 
    3 @@ -36,6 +36,44 @@ 
     3@@ -36,6 +36,8 @@ 
    44 #include <asm/irq.h> 
    55 #include <asm/uaccess.h> 
    66  
    7 +struct mdio_board_entry { 
    8 +       struct list_head        list; 
    9 +       struct mdio_board_info  board_info; 
    10 +}; 
    11 + 
    12 +static LIST_HEAD(mdio_board_list); 
    13 +static DEFINE_MUTEX(mdio_board_lock); 
    14 + 
    15 +/** 
    16 + * mdio_register_board_info - register PHY devices for a given board 
    17 + * @info: array of chip descriptors 
    18 + * @n: how many descriptors are provided 
    19 + * Context: can sleep 
    20 + * 
    21 + * The board info passed can safely be __initdata ... but be careful of 
    22 + * any embedded pointers (platform_data, etc), they're copied as-is. 
    23 + */ 
    24 +int __init 
    25 +mdiobus_register_board_info(struct mdio_board_info const *info, unsigned n) 
    26 +{ 
    27 +       struct mdio_board_entry *be; 
    28 +       int i; 
    29 + 
    30 +       be = kzalloc(n * sizeof(*be), GFP_KERNEL); 
    31 +       if (!be) 
    32 +               return -ENOMEM; 
    33 + 
    34 +       for (i = 0; i < n; i++, be++, info++) { 
    35 +               memcpy(&be->board_info, info, sizeof(*info)); 
    36 +               mutex_lock(&mdio_board_lock); 
    37 +               list_add_tail(&be->list, &mdio_board_list); 
    38 +               mutex_unlock(&mdio_board_lock); 
    39 +       } 
    40 + 
    41 +       return 0; 
    42 +} 
    43 + 
     7+#include "mdio-boardinfo.h" 
    448+ 
    459 /** 
    4610  * mdiobus_alloc - allocate a mii_bus structure 
    4711  * 
    48 @@ -179,15 +217,31 @@ void mdiobus_free(struct mii_bus *bus) 
     12@@ -179,15 +181,33 @@ void mdiobus_free(struct mii_bus *bus) 
    4913 } 
    5014 EXPORT_SYMBOL(mdiobus_free); 
     
    7135                return phydev; 
    7236  
    73 +       list_for_each_entry(be, &mdio_board_list, list) 
     37+       mutex_lock(&__mdio_board_lock); 
     38+       list_for_each_entry(be, &__mdio_board_list, list) 
    7439+               mdiobus_setup_phydev_from_boardinfo(bus, phydev, 
    7540+                                                   &be->board_info); 
     41+       mutex_unlock(&__mdio_board_lock); 
    7642+ 
    7743        err = phy_device_register(phydev); 
     
    8046--- a/include/linux/phy.h 
    8147+++ b/include/linux/phy.h 
    82 @@ -394,8 +394,8 @@ struct phy_driver { 
    83         /* Determines the negotiated speed and duplex */ 
    84         int (*read_status)(struct phy_device *phydev); 
    85   
    86 -       /*  
    87 -        * Update the value in phydev->link to reflect the  
    88 +       /* 
    89 +        * Update the value in phydev->link to reflect the 
    90          * current link value 
    91          */ 
    92         int (*update_link)(struct phy_device *phydev); 
    9348@@ -538,4 +538,22 @@ int __init mdio_bus_init(void); 
    9449 void mdio_bus_exit(void); 
     
    10358+}; 
    10459+ 
    105 +#ifdef CONFIG_PHYLIB 
    106 +int mdiobus_register_board_info(struct mdio_board_info const *info, unsigned n); 
     60+#ifdef CONFIG_MDIO_BOARDINFO 
     61+int mdiobus_register_board_info(const struct mdio_board_info *info, unsigned n); 
    10762+#else 
    10863+static inline int 
    109 +mdiobus_register_board_info(struct mdio_board_info const *info, unsigned n) 
     64+mdiobus_register_board_info(const struct mdio_board_info *info, unsigned n) 
    11065+{ 
    11166+       return 0; 
     
    11469+ 
    11570 #endif /* __PHY_H */ 
     71--- a/drivers/net/phy/Kconfig 
     72+++ b/drivers/net/phy/Kconfig 
     73@@ -13,6 +13,10 @@ menuconfig PHYLIB 
     74  
     75 if PHYLIB 
     76  
     77+config MDIO_BOARDINFO 
     78+       bool 
     79+       default y 
     80+ 
     81 config SWCONFIG 
     82        tristate "Switch configuration API" 
     83        ---help--- 
     84--- a/drivers/net/phy/Makefile 
     85+++ b/drivers/net/phy/Makefile 
     86@@ -2,6 +2,8 @@ 
     87  
     88 libphy-objs                    := phy.o phy_device.o mdio_bus.o 
     89  
     90+obj-$(CONFIG_MDIO_BOARDINFO)   += mdio-boardinfo.o 
     91+ 
     92 obj-$(CONFIG_PHYLIB)           += libphy.o 
     93 obj-$(CONFIG_SWCONFIG)         += swconfig.o 
     94 obj-$(CONFIG_MARVELL_PHY)      += marvell.o 
     95--- /dev/null 
     96+++ b/drivers/net/phy/mdio-boardinfo.c 
     97@@ -0,0 +1,58 @@ 
     98+/* 
     99+ * mdio-boardinfo.c - collect pre-declarations of PHY devices 
     100+ * 
     101+ * This program is free software; you can redistribute  it and/or modify it 
     102+ * under  the terms of  the GNU General  Public License as published by the 
     103+ * Free Software Foundation;  either version 2 of the  License, or (at your 
     104+ * option) any later version. 
     105+ * 
     106+ */ 
     107+ 
     108+#include <linux/kernel.h> 
     109+#include <linux/phy.h> 
     110+#include <linux/slab.h> 
     111+#include <linux/export.h> 
     112+#include <linux/mutex.h> 
     113+#include <linux/phy.h> 
     114+ 
     115+#include "mdio-boardinfo.h" 
     116+ 
     117+/* 
     118+ * These symbols are exported ONLY FOR the mdio_bus component. 
     119+ * No other users will be supported. 
     120+ */ 
     121+ 
     122+LIST_HEAD(__mdio_board_list); 
     123+EXPORT_SYMBOL_GPL(__mdio_board_list); 
     124+ 
     125+DEFINE_MUTEX(__mdio_board_lock); 
     126+EXPORT_SYMBOL_GPL(__mdio_board_lock); 
     127+ 
     128+/** 
     129+ * mdio_register_board_info - register PHY devices for a given board 
     130+ * @info: array of chip descriptors 
     131+ * @n: how many descriptors are provided 
     132+ * Context: can sleep 
     133+ * 
     134+ * The board info passed can safely be __initdata ... but be careful of 
     135+ * any embedded pointers (platform_data, etc), they're copied as-is. 
     136+ */ 
     137+int __init 
     138+mdiobus_register_board_info(struct mdio_board_info const *info, unsigned n) 
     139+{ 
     140+       struct mdio_board_entry *be; 
     141+       int i; 
     142+ 
     143+       be = kzalloc(n * sizeof(*be), GFP_KERNEL); 
     144+       if (!be) 
     145+               return -ENOMEM; 
     146+ 
     147+       for (i = 0; i < n; i++, be++, info++) { 
     148+               memcpy(&be->board_info, info, sizeof(*info)); 
     149+               mutex_lock(&__mdio_board_lock); 
     150+               list_add_tail(&be->list, &__mdio_board_list); 
     151+               mutex_unlock(&__mdio_board_lock); 
     152+       } 
     153+ 
     154+       return 0; 
     155+} 
     156--- /dev/null 
     157+++ b/drivers/net/phy/mdio-boardinfo.h 
     158@@ -0,0 +1,22 @@ 
     159+/* 
     160+ * mdio-boardinfo.h - boardinfo interface internal to the mdio_bus component 
     161+ * 
     162+ * This program is free software; you can redistribute  it and/or modify it 
     163+ * under  the terms of  the GNU General  Public License as published by the 
     164+ * Free Software Foundation;  either version 2 of the  License, or (at your 
     165+ * option) any later version. 
     166+ * 
     167+ */ 
     168+ 
     169+#include <linux/mutex.h> 
     170+ 
     171+struct mdio_board_entry { 
     172+       struct list_head        list; 
     173+       struct mdio_board_info  board_info; 
     174+}; 
     175+ 
     176+/* __mdio_board_lock protects __mdio_board_list 
     177+ * only mdio_bus components are allowed to use these symbols. 
     178+ */ 
     179+extern struct mutex __mdio_board_lock; 
     180+extern struct list_head __mdio_board_list; 
     181--- a/drivers/net/Makefile 
     182+++ b/drivers/net/Makefile 
     183@@ -15,7 +15,7 @@ obj-$(CONFIG_MII) += mii.o 
     184 obj-$(CONFIG_MDIO) += mdio.o 
     185 obj-$(CONFIG_NET) += Space.o loopback.o 
     186 obj-$(CONFIG_NETCONSOLE) += netconsole.o 
     187-obj-$(CONFIG_PHYLIB) += phy/ 
     188+obj-y += phy/ 
     189 obj-$(CONFIG_RIONET) += rionet.o 
     190 obj-$(CONFIG_TUN) += tun.o 
     191 obj-$(CONFIG_VETH) += veth.o 
Note: See TracChangeset for help on using the changeset viewer.