]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/net/phy/phy_device.c
PHY: remove rwsem use from phy core
[linux-2.6-omap-h63xx.git] / drivers / net / phy / phy_device.c
index b01fc70a57db63a20e06ff58108621965a5b31a2..8f01952c48500457315624a2b6f962a8043ab838 100644 (file)
@@ -15,7 +15,6 @@
  *
  */
 #include <linux/kernel.h>
-#include <linux/sched.h>
 #include <linux/string.h>
 #include <linux/errno.h>
 #include <linux/unistd.h>
@@ -50,7 +49,7 @@ struct phy_device* phy_device_create(struct mii_bus *bus, int addr, int phy_id)
        struct phy_device *dev;
        /* We allocate the device, and initialize the
         * default values */
-       dev = kcalloc(1, sizeof(*dev), GFP_KERNEL);
+       dev = kzalloc(sizeof(*dev), GFP_KERNEL);
 
        if (NULL == dev)
                return (struct phy_device*) PTR_ERR((void*)-ENOMEM);
@@ -139,7 +138,7 @@ void phy_prepare_link(struct phy_device *phydev,
  */
 struct phy_device * phy_connect(struct net_device *dev, const char *phy_id,
                void (*handler)(struct net_device *), u32 flags,
-               u32 interface)
+               phy_interface_t interface)
 {
        struct phy_device *phydev;
 
@@ -188,7 +187,7 @@ static int phy_compare_id(struct device *dev, void *data)
 }
 
 struct phy_device *phy_attach(struct net_device *dev,
-               const char *phy_id, u32 flags, u32 interface)
+               const char *phy_id, u32 flags, phy_interface_t interface)
 {
        struct bus_type *bus = &mdio_bus_type;
        struct phy_device *phydev;
@@ -209,16 +208,12 @@ struct phy_device *phy_attach(struct net_device *dev,
         * exist, and we should use the genphy driver. */
        if (NULL == d->driver) {
                int err;
-               down_write(&d->bus->subsys.rwsem);
                d->driver = &genphy_driver.driver;
 
                err = d->driver->probe(d);
-
                if (err >= 0)
                        err = device_bind_driver(d);
 
-               up_write(&d->bus->subsys.rwsem);
-
                if (err)
                        return ERR_PTR(err);
        }
@@ -259,11 +254,8 @@ void phy_detach(struct phy_device *phydev)
         * was using the generic driver), we unbind the device
         * from the generic driver so that there's a chance a
         * real driver could be loaded */
-       if (phydev->dev.driver == &genphy_driver.driver) {
-               down_write(&phydev->dev.bus->subsys.rwsem);
+       if (phydev->dev.driver == &genphy_driver.driver)
                device_release_driver(&phydev->dev);
-               up_write(&phydev->dev.bus->subsys.rwsem);
-       }
 }
 EXPORT_SYMBOL(phy_detach);