Received: by 10.223.164.202 with SMTP id h10csp2999067wrb; Mon, 13 Nov 2017 00:10:09 -0800 (PST) X-Google-Smtp-Source: AGs4zMbthf+DaFBhkRNee7gXb/6i4F3I9aFmMRT12UsojzujL2/j04ahfE205c50lDywqyRbScsV X-Received: by 10.99.101.133 with SMTP id z127mr7890670pgb.139.1510560609800; Mon, 13 Nov 2017 00:10:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510560609; cv=none; d=google.com; s=arc-20160816; b=hZjazyHHVegl1WR20fpQy5Yf8WRVOOrSwTS7IfojFv+o4LMofkt1o0I8+4ux7shuIb c2o8/TQxDkj5LYn29HrAGk02mOCY6aShwZupf4PhdZP4HWZLga7o/8GmK5xtEEhcIvtc xn3hiLBQRJH0RreosdeLPEc9qMhcOzWgD8sbGIg0ouO6kaaPMIv1D3sBOxJBk+h984IE laTisbu7MvMaAvQ6KuEAB9gqJ1yI66Mxrp/GGAWqq9pDv79/qwJUdk2LFX8DvInJuRcs DnuHv8UV3oouJpGm5RsGaU2xM+3lXgRKTiH+rSMGokeQj7k1vNDZgWHBX25XJ6ASpO8i 4m6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:to:from:arc-authentication-results; bh=jqGHbSY3ZUuhKwyq5fpQb/nP3SV59RFCTkvx69aCX+A=; b=0LoPuWcdNNuZcET55jugF3dDZLKV36nFzKjUbUAqDtUaoNCBOgfGl0qk4Jo4YJKu/+ UhtqBsVWVuw0BTguNOxO4eF1JrQDo/wmFS+J1V7RVvA/Z5vn2b3yvJxGBemqXJYElAQU tRPFF/mnlW09HKLq8MBRqqsE11kNcqAFpIlWQMWGCsAmlidrp+8gTDqaeekpmk2AWkBv VGrmpD4YR0/4o9wYbTxHOAwUcotOHfZWZkeSG0n5SPxMA92zIcVLZqTpti/7qkops6zq 4Z6RUZ/Ppg9+2jmxSbotV25NXvVTEkVPprohF9wqD5r7oEW4f4NWojl409UuJ1da46Py t6aw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z22si15303024pfa.207.2017.11.13.00.09.57; Mon, 13 Nov 2017 00:10:09 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752141AbdKMIJB (ORCPT + 92 others); Mon, 13 Nov 2017 03:09:01 -0500 Received: from anchovy3.45ru.net.au ([203.30.46.155]:57705 "EHLO anchovy.45ru.net.au" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751987AbdKMIIZ (ORCPT ); Mon, 13 Nov 2017 03:08:25 -0500 Received: (qmail 24844 invoked by uid 5089); 13 Nov 2017 08:08:22 -0000 Received: by simscan 1.2.0 ppid: 24782, pid: 24783, t: 0.0284s scanners: regex: 1.2.0 attach: 1.2.0 clamav: 0.88.3/m:40/d:1950 X-RBL: $rbltext Received: from unknown (HELO preid-centos7.electromag.com.au) (preid@electromag.com.au@203.59.230.133) by anchovy2.45ru.net.au with ESMTPA; 13 Nov 2017 08:08:22 -0000 Received: by preid-centos7.electromag.com.au (Postfix, from userid 1000) id B521B304C5215; Mon, 13 Nov 2017 16:08:19 +0800 (AWST) From: Phil Reid To: andrew@lunn.ch, vivien.didelot@savoirfairelinux.com, f.fainelli@gmail.com, preid@electromag.com.au, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, bianpan2016@163.com, stable@vger.kernel.org Subject: [PATCH 2/2] net: dsa: lan9303: check error value from devm_gpiod_get_optional() Date: Mon, 13 Nov 2017 16:07:53 +0800 Message-Id: <1510560473-26727-3-git-send-email-preid@electromag.com.au> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1510560473-26727-1-git-send-email-preid@electromag.com.au> References: <1510560473-26727-1-git-send-email-preid@electromag.com.au> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org devm_gpiod_get_optional() can return an error in addition to a NULL ptr. Check for error and propagate that to the probe function. Check return value in probe. This will now handle EPROBE_DEFER for the reset gpio. Signed-off-by: Phil Reid --- drivers/net/dsa/lan9303-core.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c index cc00308..b63173c 100644 --- a/drivers/net/dsa/lan9303-core.c +++ b/drivers/net/dsa/lan9303-core.c @@ -820,15 +820,18 @@ static int lan9303_register_switch(struct lan9303 *chip) return dsa_register_switch(chip->ds); } -static void lan9303_probe_reset_gpio(struct lan9303 *chip, +static int lan9303_probe_reset_gpio(struct lan9303 *chip, struct device_node *np) { chip->reset_gpio = devm_gpiod_get_optional(chip->dev, "reset", GPIOD_OUT_LOW); + if (IS_ERR(chip->reset_gpio)) + return PTR_ERR(chip->reset_gpio); + if (!chip->reset_gpio) { dev_dbg(chip->dev, "No reset GPIO defined\n"); - return; + return 0; } chip->reset_duration = 200; @@ -843,6 +846,8 @@ static void lan9303_probe_reset_gpio(struct lan9303 *chip, /* A sane reset duration should not be longer than 1s */ if (chip->reset_duration > 1000) chip->reset_duration = 1000; + + return 0; } int lan9303_probe(struct lan9303 *chip, struct device_node *np) @@ -851,7 +856,9 @@ int lan9303_probe(struct lan9303 *chip, struct device_node *np) mutex_init(&chip->indirect_mutex); - lan9303_probe_reset_gpio(chip, np); + ret = lan9303_probe_reset_gpio(chip, np); + if (ret) + return ret; lan9303_handle_reset(chip); -- 1.8.3.1 From 1583937553417041728@xxx Mon Nov 13 08:09:23 +0000 2017 X-GM-THRID: 1583937553417041728 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread