Changeset 9923


Ignore:
Timestamp:
2007-12-25T13:38:15+01:00 (9 years ago)
Author:
blogic
Message:

make ifxmips mii0 a platform device

Location:
trunk/target/linux/ifxmips/files
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/target/linux/ifxmips/files/arch/mips/ifxmips/board.c

    r9922 r9923  
    2626#include <linux/string.h> 
    2727#include <linux/mtd/physmap.h> 
    28 #include <linux/platform_device.h> 
    2928#include <linux/kernel.h> 
    3029#include <linux/reboot.h> 
     30#include <linux/platform_device.h>  
    3131#include <asm/bootinfo.h> 
    3232#include <asm/reboot.h> 
     
    5555}; 
    5656 
     57static struct platform_device ifxmips_mii[] = 
     58{ 
     59        { 
     60                .id = 0, 
     61                .name = "ifxmips_mii0", 
     62        }, 
     63}; 
     64 
    5765int __init ifxmips_init_devices(void) 
    5866{ 
     
    7179        ifxmips_devs[dev++] = ifxmips_led; 
    7280        ifxmips_devs[dev++] = ifxmips_gpio; 
     81        ifxmips_devs[dev++] = ifxmips_mii; 
    7382 
    7483        return platform_add_devices(ifxmips_devs, dev); 
  • trunk/target/linux/ifxmips/files/drivers/net/ifxmips_mii0.c

    r9826 r9923  
    3838#include <linux/skbuff.h> 
    3939#include <linux/mm.h> 
     40#include <linux/platform_device.h> 
    4041#include <linux/ethtool.h> 
    4142#include <asm/checksum.h> 
     
    4748#include <asm/ifxmips/ifxmips_pmu.h> 
    4849 
     50#define DRVNAME         "ifxmips_mii0" 
     51 
    4952static struct net_device ifxmips_mii0_dev; 
    5053static unsigned char u_boot_ethaddr[MAX_ADDR_LEN]; 
     
    120123        if (len >= ETHERNET_PACKET_DMA_BUFFER_SIZE) 
    121124        { 
    122                 printk("packet too large %d\n",len); 
     125                printk(KERN_INFO DRVNAME ": packet too large %d\n",len); 
    123126                goto switch_hw_receive_err_exit; 
    124127        } 
     
    128131        if (skb == NULL ) 
    129132        { 
    130                 printk("cannot restore pointer\n"); 
     133                printk(KERN_INFO DRVNAME ": cannot restore pointer\n"); 
    131134                goto switch_hw_receive_err_exit; 
    132135        } 
     
    134137        if (len > (skb->end - skb->tail)) 
    135138        { 
    136                 printk("BUG, len:%d end:%p tail:%p\n", (len+4), skb->end, skb->tail); 
     139                printk(KERN_INFO DRVNAME ": BUG, len:%d end:%p tail:%p\n", (len+4), skb->end, skb->tail); 
    137140                goto switch_hw_receive_err_exit; 
    138141        } 
     
    235238 
    236239        case TX_BUF_FULL_INT: 
    237                 printk("tx buffer full\n"); 
     240                printk(KERN_INFO DRVNAME ": tx buffer full\n"); 
    238241                netif_stop_queue(&ifxmips_mii0_dev); 
    239242                for (i = 0; i < dma_dev->max_tx_chan_num; i++) 
     
    302305        ether_setup(dev); 
    303306 
    304         printk("%s up\n", dev->name); 
     307        printk(KERN_INFO DRVNAME ": %s is up\n", dev->name); 
    305308 
    306309        dev->open = ifxmips_switch_open; 
     
    348351        /*read the mac address from the mac table and put them into the mac table.*/ 
    349352        for (i = 0; i < 6; i++) 
    350         { 
    351353                retval += u_boot_ethaddr[i]; 
    352         } 
    353354 
    354355        //TODO 
     
    356357        if (retval == 0) 
    357358        { 
    358                 printk("use default MAC address\n"); 
     359                printk(KERN_INFO DRVNAME ": using default MAC address\n"); 
    359360                dev->dev_addr[0] = 0x00; 
    360361                dev->dev_addr[1] = 0x11; 
     
    389390} 
    390391 
    391 int __init 
    392 switch_init_module(void) 
     392static int 
     393ifxmips_mii_probe(struct platform_device *dev) 
    393394{ 
    394395        int result = 0; 
     
    402403        if (result) 
    403404        { 
    404                 printk("error %i registering device \"%s\"\n", result, ifxmips_mii0_dev.name); 
     405                printk(KERN_INFO DRVNAME ": error %i registering device \"%s\"\n", result, ifxmips_mii0_dev.name); 
    405406                goto out; 
    406407        } 
     
    408409        /* ifxmips eval kit connects the phy/switch in REV mode */ 
    409410        ifxmips_sw_chip_init(REV_MII_MODE); 
    410         printk("ifxmips MAC driver loaded!\n"); 
     411        printk(KERN_INFO DRVNAME ": driver loaded!\n"); 
    411412 
    412413out: 
     
    414415} 
    415416 
    416 static void __exit 
    417 switch_cleanup(void) 
     417static int 
     418ifxmips_mii_remove(struct platform_device *dev) 
    418419{ 
    419420        struct switch_priv *priv = (struct switch_priv*)ifxmips_mii0_dev.priv; 
    420421 
    421         printk("ifxmips_mii0 cleanup\n"); 
     422        printk(KERN_INFO DRVNAME ": ifxmips_mii0 cleanup\n"); 
    422423 
    423424        dma_device_unregister(priv->dma_device); 
     
    427428        unregister_netdev(&ifxmips_mii0_dev); 
    428429 
    429         return; 
    430 } 
    431  
    432 module_init(switch_init_module); 
    433 module_exit(switch_cleanup); 
     430        return 0; 
     431} 
     432 
     433static struct  
     434platform_driver ifxmips_mii_driver = {  
     435        .probe = ifxmips_mii_probe,  
     436        .remove = ifxmips_mii_remove,  
     437        .driver = {  
     438                .name = DRVNAME,  
     439                .owner = THIS_MODULE,  
     440        },  
     441}; 
     442 
     443int __init 
     444ifxmips_mii_init(void) 
     445{ 
     446        int ret = platform_driver_register(&ifxmips_mii_driver);  
     447        if (ret)  
     448                printk(KERN_INFO DRVNAME ": Error registering platfom driver!");  
     449 
     450        return ret;  
     451} 
     452 
     453static void __exit 
     454ifxmips_mii_cleanup(void) 
     455{ 
     456        platform_driver_unregister(&ifxmips_mii_driver); 
     457} 
     458 
     459module_init(ifxmips_mii_init); 
     460module_exit(ifxmips_mii_cleanup); 
Note: See TracChangeset for help on using the changeset viewer.