netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Some phylib simplifications
@ 2015-08-28 18:33 Sergei Shtylyov
  2015-08-28 18:34 ` [PATCH 1/2] phylib: simplify bogus phy_device_create() result Sergei Shtylyov
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Sergei Shtylyov @ 2015-08-28 18:33 UTC (permalink / raw)
  To: netdev, f.fainelli; +Cc: linux-kernel

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] phylib: simplify bogus phy_device_create() result
  2015-08-28 18:33 [PATCH 0/2] Some phylib simplifications Sergei Shtylyov
@ 2015-08-28 18:34 ` Sergei Shtylyov
  2015-08-28 18:35 ` [PATCH 2/2] phylib: simplify NULL checks Sergei Shtylyov
  2015-08-28 21:15 ` [PATCH 0/2] Some phylib simplifications David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Sergei Shtylyov @ 2015-08-28 18:34 UTC (permalink / raw)
  To: netdev; +Cc: f.fainelli, linux-kernel

Get rid of the bogus string of type casts where ERR_PTR() is enough.

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>

---
 drivers/net/phy/phy_device.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: net-next/drivers/net/phy/phy_device.c
===================================================================
--- net-next.orig/drivers/net/phy/phy_device.c
+++ net-next/drivers/net/phy/phy_device.c
@@ -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;
 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/2] phylib: simplify NULL checks
  2015-08-28 18:33 [PATCH 0/2] Some phylib simplifications Sergei Shtylyov
  2015-08-28 18:34 ` [PATCH 1/2] phylib: simplify bogus phy_device_create() result Sergei Shtylyov
@ 2015-08-28 18:35 ` Sergei Shtylyov
  2015-08-28 21:15 ` [PATCH 0/2] Some phylib simplifications David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Sergei Shtylyov @ 2015-08-28 18:35 UTC (permalink / raw)
  To: netdev, f.fainelli; +Cc: linux-kernel

Fix 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).

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>

---
 drivers/net/phy/phy.c        |    4 ++--
 drivers/net/phy/phy_device.c |    6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

Index: net-next/drivers/net/phy/phy.c
===================================================================
--- net-next.orig/drivers/net/phy/phy.c
+++ net-next/drivers/net/phy/phy.c
@@ -1040,7 +1040,7 @@ int phy_read_mmd_indirect(struct phy_dev
 	struct 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);
Index: net-next/drivers/net/phy/phy_device.c
===================================================================
--- net-next.orig/drivers/net/phy/phy_device.c
+++ net-next/drivers/net/phy/phy_device.c
@@ -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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] Some phylib simplifications
  2015-08-28 18:33 [PATCH 0/2] Some phylib simplifications Sergei Shtylyov
  2015-08-28 18:34 ` [PATCH 1/2] phylib: simplify bogus phy_device_create() result Sergei Shtylyov
  2015-08-28 18:35 ` [PATCH 2/2] phylib: simplify NULL checks Sergei Shtylyov
@ 2015-08-28 21:15 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2015-08-28 21:15 UTC (permalink / raw)
  To: sergei.shtylyov; +Cc: netdev, f.fainelli, linux-kernel

From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Date: Fri, 28 Aug 2015 21:33:43 +0300

>    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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-08-28 21:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-28 18:33 [PATCH 0/2] Some phylib simplifications Sergei Shtylyov
2015-08-28 18:34 ` [PATCH 1/2] phylib: simplify bogus phy_device_create() result Sergei Shtylyov
2015-08-28 18:35 ` [PATCH 2/2] phylib: simplify NULL checks Sergei Shtylyov
2015-08-28 21:15 ` [PATCH 0/2] Some phylib simplifications David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).