]> nv-tegra.nvidia Code Review - linux-2.6.git/commitdiff
mv643xx_eth: smi sharing is a per-unit property, not a per-port one
authorLennert Buytenhek <buytenh@wantstofly.org>
Tue, 26 Aug 2008 10:56:56 +0000 (12:56 +0200)
committerLennert Buytenhek <buytenh@marvell.com>
Fri, 5 Sep 2008 04:33:58 +0000 (06:33 +0200)
Which top-level unit's SMI interface to use should be a property of
the top-level unit, not of the individual ports.  This patch moves the
->shared_smi pointer from the per-port platform data to the global
platform data.

Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
arch/arm/mach-mv78xx0/common.c
drivers/net/mv643xx_eth.c
include/linux/mv643xx_eth.h

index 953a26c469cb0b9cf0602ec038e75d81129b7405..5842d3bb02b27df67962d2c2140bbd3f5b5295e8 100644 (file)
@@ -330,6 +330,7 @@ void __init mv78xx0_ge00_init(struct mv643xx_eth_platform_data *eth_data)
 struct mv643xx_eth_shared_platform_data mv78xx0_ge01_shared_data = {
        .t_clk          = 0,
        .dram           = &mv78xx0_mbus_dram_info,
+       .shared_smi     = &mv78xx0_ge00_shared,
 };
 
 static struct resource mv78xx0_ge01_shared_resources[] = {
@@ -370,7 +371,6 @@ static struct platform_device mv78xx0_ge01 = {
 void __init mv78xx0_ge01_init(struct mv643xx_eth_platform_data *eth_data)
 {
        eth_data->shared = &mv78xx0_ge01_shared;
-       eth_data->shared_smi = &mv78xx0_ge00_shared;
        mv78xx0_ge01.dev.platform_data = eth_data;
 
        platform_device_register(&mv78xx0_ge01_shared);
@@ -384,6 +384,7 @@ void __init mv78xx0_ge01_init(struct mv643xx_eth_platform_data *eth_data)
 struct mv643xx_eth_shared_platform_data mv78xx0_ge10_shared_data = {
        .t_clk          = 0,
        .dram           = &mv78xx0_mbus_dram_info,
+       .shared_smi     = &mv78xx0_ge00_shared,
 };
 
 static struct resource mv78xx0_ge10_shared_resources[] = {
@@ -424,7 +425,6 @@ static struct platform_device mv78xx0_ge10 = {
 void __init mv78xx0_ge10_init(struct mv643xx_eth_platform_data *eth_data)
 {
        eth_data->shared = &mv78xx0_ge10_shared;
-       eth_data->shared_smi = &mv78xx0_ge00_shared;
        mv78xx0_ge10.dev.platform_data = eth_data;
 
        platform_device_register(&mv78xx0_ge10_shared);
@@ -438,6 +438,7 @@ void __init mv78xx0_ge10_init(struct mv643xx_eth_platform_data *eth_data)
 struct mv643xx_eth_shared_platform_data mv78xx0_ge11_shared_data = {
        .t_clk          = 0,
        .dram           = &mv78xx0_mbus_dram_info,
+       .shared_smi     = &mv78xx0_ge00_shared,
 };
 
 static struct resource mv78xx0_ge11_shared_resources[] = {
@@ -478,7 +479,6 @@ static struct platform_device mv78xx0_ge11 = {
 void __init mv78xx0_ge11_init(struct mv643xx_eth_platform_data *eth_data)
 {
        eth_data->shared = &mv78xx0_ge11_shared;
-       eth_data->shared_smi = &mv78xx0_ge00_shared;
        mv78xx0_ge11.dev.platform_data = eth_data;
 
        platform_device_register(&mv78xx0_ge11_shared);
index c41541d8710fd817be17ca727899071b56fb7d04..6d3da78b7ad547b652adea7daffd4726922640b0 100644 (file)
@@ -247,6 +247,11 @@ struct mv643xx_eth_shared_private {
         */
        void __iomem *base;
 
+       /*
+        * Points at the right SMI instance to use.
+        */
+       struct mv643xx_eth_shared_private *smi;
+
        /*
         * Protects access to SMI_REG, which is shared between ports.
         */
@@ -345,7 +350,6 @@ struct mv643xx_eth_private {
 
        struct net_device *dev;
 
-       struct mv643xx_eth_shared_private *shared_smi;
        int phy_addr;
 
        spinlock_t lock;
@@ -1015,7 +1019,7 @@ static int smi_wait_ready(struct mv643xx_eth_shared_private *msp)
 static int smi_reg_read(struct mv643xx_eth_private *mp,
                        unsigned int addr, unsigned int reg)
 {
-       struct mv643xx_eth_shared_private *msp = mp->shared_smi;
+       struct mv643xx_eth_shared_private *msp = mp->shared->smi;
        void __iomem *smi_reg = msp->base + SMI_REG;
        int ret;
 
@@ -1053,7 +1057,7 @@ out:
 static int smi_reg_write(struct mv643xx_eth_private *mp, unsigned int addr,
                         unsigned int reg, unsigned int value)
 {
-       struct mv643xx_eth_shared_private *msp = mp->shared_smi;
+       struct mv643xx_eth_shared_private *msp = mp->shared->smi;
        void __iomem *smi_reg = msp->base + SMI_REG;
 
        mutex_lock(&msp->phy_lock);
@@ -2311,6 +2315,10 @@ static int mv643xx_eth_shared_probe(struct platform_device *pdev)
        if (msp->base == NULL)
                goto out_free;
 
+       msp->smi = msp;
+       if (pd != NULL && pd->shared_smi != NULL)
+               msp->smi = platform_get_drvdata(pd->shared_smi);
+
        mutex_init(&msp->phy_lock);
 
        msp->err_interrupt = NO_IRQ;
@@ -2405,13 +2413,8 @@ static void set_params(struct mv643xx_eth_private *mp,
                uc_addr_get(mp, dev->dev_addr);
 
        if (pd->phy_addr == -1) {
-               mp->shared_smi = NULL;
                mp->phy_addr = -1;
        } else {
-               mp->shared_smi = mp->shared;
-               if (pd->shared_smi != NULL)
-                       mp->shared_smi = platform_get_drvdata(pd->shared_smi);
-
                if (pd->force_phy_addr || pd->phy_addr) {
                        mp->phy_addr = pd->phy_addr & 0x3f;
                        phy_addr_set(mp, mp->phy_addr);
index eb78b00edcde6a651b418e8fcb71ed504c6a7a07..12339eb65704cf9e1b25b6f36eb868cd465b9db8 100644 (file)
@@ -17,6 +17,7 @@
 
 struct mv643xx_eth_shared_platform_data {
        struct mbus_dram_target_info    *dram;
+       struct platform_device  *shared_smi;
        unsigned int            t_clk;
 };
 
@@ -30,7 +31,6 @@ struct mv643xx_eth_platform_data {
        /*
         * Whether a PHY is present, and if yes, at which address.
         */
-       struct platform_device  *shared_smi;
        int                     force_phy_addr;
        int                     phy_addr;