Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756100AbcC2I2g (ORCPT ); Tue, 29 Mar 2016 04:28:36 -0400 Received: from mx0a-001ae601.pphosted.com ([67.231.149.25]:51470 "EHLO mx0a-001ae601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751217AbcC2I2e (ORCPT ); Tue, 29 Mar 2016 04:28:34 -0400 Authentication-Results: ppops.net; spf=none smtp.mail=ckeepax@opensource.wolfsonmicro.com Date: Tue, 29 Mar 2016 09:28:36 +0100 From: Charles Keepax To: Sergei Shtylyov CC: , , , , Subject: Re: [PATCH] net: macb: Only call GPIO functions if there is a valid GPIO Message-ID: <20160329082836.GD31814@localhost.localdomain> References: <1459169262-3941-1-git-send-email-ckeepax@opensource.wolfsonmicro.com> <56F96A23.4000001@cogentembedded.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <56F96A23.4000001@cogentembedded.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=2 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1601100000 definitions=main-1603290120 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 976 Lines: 36 On Mon, Mar 28, 2016 at 08:30:11PM +0300, Sergei Shtylyov wrote: > >@@ -3029,7 +3030,8 @@ static int macb_remove(struct platform_device *pdev) > > mdiobus_free(bp->mii_bus); > > > > /* Shutdown the PHY if there is a GPIO reset */ > >- gpiod_set_value(bp->reset_gpio, 0); > >+ if (bp->reset_gpio) > >+ gpiod_set_value(bp->reset_gpio, 0); > > Hm, this function was previously OK to call with NULL (it didn't curse)... > Looks like it was changed so that it does complain fairly recently (patch librally snipped down): commit fdeb8e1547cb9dd39d5d7223b33f3565cf86c28e Author: Linus Walleij gpio: reflect base and ngpio into gpio_device +#define VALIDATE_DESC_VOID(desc) do { \ + if (!desc || !desc->gdev) { \ + pr_warn("%s: invalid GPIO\n", __func__); \ + return; \ + } \ + void gpiod_set_value(struct gpio_desc *desc, int value) { - if (!desc) - return; + VALIDATE_DESC_VOID(desc); Thanks, Charles