Some phylib simplifications
Subsystems (3)
cover Some phylib simplifications
Hello.
Here's 2 patches against DaveM's 'net-next.git' repo. We simplify a bogus
string of type casts in the 1st patch and make the code respect some coding standards of the networking code in the 2nd one. I may follow with fixing of checkpatch.pl's complaints. if I have time..
[1/2] phylib: simplify bogus phy_device_create() result [2/2] phylib: simplify NULL checks
MBR, Sergei
PATCH 1/2 phylib: simplify bogus phy_device_create() result
Get rid of the bogus string of type casts where ERR_PTR() is enough.
--- drivers/net/phy/phy_device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/phy/phy_device.c +1 -1
@@ -157,7 +157,7 @@ struct phy_device *phy_device_create(str/* We allocate the device, and initialize the default values */ dev =kzalloc (sizeof (*dev),GFP_KERNEL );if (NULL == dev) -return (struct phy_device *)PTR_ERR ((void *)-ENOMEM ); +return ERR_PTR (-ENOMEM ); dev->dev.release = phy_device_release;
PATCH 2/2 phylib: simplify NULL checks
In reply to Sergei ShtylyovFix scripts/checkpatch.pl's messages like:
CHECK: Comparison to NULL could be written "!phydrv->read_mmd_indirect"
BTW, it doesn't detect the reversed comparisons (which I've fixed as well).
--- drivers/net/phy/phy.c | 4 ++-- drivers/net/phy/phy_device.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/net/phy/phy.c +2 -2
@@ -1040,7 +1040,7 @@ int phy_read_mmd_indirect(struct phy_devstruct phy_driver *phydrv = phydev->drv;int value =-1 ; -if (phydrv->read_mmd_indirect ==NULL ) { +if (!phydrv->read_mmd_indirect) {struct mii_bus *bus = phydev->bus;mutex_lock (&bus->mdio_lock);
@@ -1077,7 +1077,7 @@ void phy_write_mmd_indirect(struct phy_d {struct phy_driver *phydrv = phydev->drv; -if (phydrv->write_mmd_indirect ==NULL ) { +if (!phydrv->write_mmd_indirect) {struct mii_bus *bus = phydev->bus;mutex_lock (&bus->mdio_lock);
drivers/net/phy/phy_device.c +3 -3
@@ -156,7 +156,7 @@ struct phy_device *phy_device_create(str/* We allocate the device, and initialize the default values */ dev =kzalloc (sizeof (*dev),GFP_KERNEL ); -if (NULL == dev) +if (!dev)return ERR_PTR (-ENOMEM ); dev->dev.release = phy_device_release;
@@ -178,7 +178,7 @@ struct phy_device *phy_device_create(str dev->bus = bus; dev->dev.parent = &bus->dev; dev->dev.bus = &mdio_bus_type; - dev->irq = bus->irq !=NULL ? bus->irq[addr] :PHY_POLL ; + dev->irq = bus->irq ? bus->irq[addr] :PHY_POLL ;dev_set_name (&dev->dev,PHY_ID_FMT , bus->id, addr); dev->state =PHY_DOWN ;
@@ -589,7 +589,7 @@ int phy_attach_direct(struct net_device/* Assume that if there is no driver, that it doesn't * exist, and we should use the genphy driver. */ -if (NULL == d->driver) { +if (!d->driver) {if (phydev->is_c45) d->driver = &genphy_driver[GENPHY_DRV_10G ].driver;else
David Miller
maintainerFrom: Sergei Shtylyov <[email protected]>
Date: Fri, 28 Aug 2015 21:33:43 +0300
Quoted 4 lines
Here's 2 patches against DaveM's 'net-next.git' repo. We simplify a bogus
string of type casts in the 1st patch and make the code respect some coding standards of the networking code in the 2nd one. I may follow with fixing of checkpatch.pl's complaints. if I have time..
Series applied, thanks.