From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755904AbbDGOVh (ORCPT ); Tue, 7 Apr 2015 10:21:37 -0400 Received: from devils.ext.ti.com ([198.47.26.153]:58569 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754708AbbDGOVe (ORCPT ); Tue, 7 Apr 2015 10:21:34 -0400 Message-ID: <5523E7E9.7010805@ti.com> Date: Tue, 7 Apr 2015 19:51:29 +0530 From: Kishon Vijay Abraham I User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.0 MIME-Version: 1.0 To: Axel Lin CC: "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] phy: core: Fix error checking in (devm_)phy_optional_get References: <1428406995.5137.1.camel@phoenix> In-Reply-To: <1428406995.5137.1.camel@phoenix> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Tuesday 07 April 2015 05:13 PM, Axel Lin wrote: > Don't pass valid pointer to PTR_ERR, use PTR_ERR(phy) only when > IS_ERR(phy) is true. > > Signed-off-by: Axel Lin > --- > drivers/phy/phy-core.c | 12 ++++++++---- > 1 file changed, 8 insertions(+), 4 deletions(-) > > diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c > index 3791838f..f112fff 100644 > --- a/drivers/phy/phy-core.c > +++ b/drivers/phy/phy-core.c > @@ -530,8 +530,10 @@ struct phy *phy_optional_get(struct device *dev, const char *string) > { > struct phy *phy = phy_get(dev, string); > > - if (PTR_ERR(phy) == -ENODEV) > - phy = NULL; > + if (IS_ERR(phy)) { > + if (PTR_ERR(phy) == -ENODEV) This can simply be (IS_ERR(phy) && (PTR_ERR(phy) == -ENODEV)). But I don't see a problem passing a valid pointer to PTR_ERR here. Thanks Kishon