Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1970602imm; Thu, 19 Jul 2018 10:49:20 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeiFw/8QnCz3Pxnt6u2FF4FWmels5LIKc5dcBdALELx6FwEkKDGE1FkXmo3R6lS4JSQ2lUQ X-Received: by 2002:a17:902:7c89:: with SMTP id y9-v6mr10959576pll.187.1532022560126; Thu, 19 Jul 2018 10:49:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532022560; cv=none; d=google.com; s=arc-20160816; b=TjEyzhbdUgofoxUf7WhC26A17+ZaapzCAl+9L5IhYw3VMmYaxQ7o3ohRnFbhXHNxWh ElW7DwgYmVnLKV5Hawo8FW+RjLfju9DnKZ8TT6PtvBcnMJxwxy2293f+bTjfjg8Cdeh4 XVgImKhpjILW6CqTJaKBuiyLy6M9p39mRTauh0cIThjwh26p9WQlIi+63i21TRw7H3kL ey3QiqHgNIhhre3YwNeugJTImMgr7YyzzCSTjgqI2kSCoX7z5dmJvC/DuL7EC0C2qKnG B7BQqrEmC0OdHjsLCyC42Ded4bJAC1seJpvogx6wlIH3ThR+TsPkQC/oi8zUiNC7KaOe VblQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=EO2Hbi1vBfGjI0LENgkjLqcytzhUgqwUuAObJ8ngMv8=; b=LlkfKtUY3cRLuGecZ0O3fovUKGITM3j3J+3yR570UK45pLZGWycKHtn1bINOUIhdyb DZMsFV/PehC33oIG6Qfky9cl2dwuSzIErc6X5QeS9bLGnBd5ENnCVNNcfXKWKrbGoLy+ TL2F8M9foXPofOAwm7s7TnAGoGWRqq+wplJU5IC8LZYVRt6S4Ntok0uX1qyIzBBc9yLC ujo5bwm5XPn+gtw+/MM4oUuM43PTuVe4m/5//RQTIWxnTDdMYkeS/MDNe0rDpvHjv/B5 v4epDX8Oi3AiHRyb+wgoZyBkaR4tImWrx6v6eXnUnNufM6EVqZhyfqmgmdC7NG+PdZV1 uPHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@armlinux.org.uk header.s=pandora-2014 header.b=WkcfxOJY; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k91-v6si6061138pld.248.2018.07.19.10.49.05; Thu, 19 Jul 2018 10:49:20 -0700 (PDT) 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; dkim=fail header.i=@armlinux.org.uk header.s=pandora-2014 header.b=WkcfxOJY; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732136AbeGSScH (ORCPT + 99 others); Thu, 19 Jul 2018 14:32:07 -0400 Received: from pandora.armlinux.org.uk ([78.32.30.218]:60182 "EHLO pandora.armlinux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731733AbeGSScH (ORCPT ); Thu, 19 Jul 2018 14:32:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2014; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=EO2Hbi1vBfGjI0LENgkjLqcytzhUgqwUuAObJ8ngMv8=; b=WkcfxOJYw/7/U/yheJJx6DqPt guZ0vBnggDejpgyVyIxYzAvSYt/5ZJrcHU+6bph7d4hXu58ev16tdWfRQpLkydmuFovRqN1OiGqd8 heyf9eObRnHVVgepNJSgoHjQ63ZeU8UqNet0K4CoYCFnb6oGz9cI+Q19KeUBG1Gl8UQMU=; Received: from n2100.armlinux.org.uk ([2002:4e20:1eda:1:214:fdff:fe10:4f86]:37521) by pandora.armlinux.org.uk with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.90_1) (envelope-from ) id 1fgD1Z-00070e-0P; Thu, 19 Jul 2018 18:47:33 +0100 Received: from linux by n2100.armlinux.org.uk with local (Exim 4.90_1) (envelope-from ) id 1fgD1V-00069y-Vl; Thu, 19 Jul 2018 18:47:30 +0100 Date: Thu, 19 Jul 2018 18:47:28 +0100 From: Russell King - ARM Linux To: Bartosz Golaszewski Cc: Sekhar Nori , Kevin Hilman , Grygorii Strashko , "David S . Miller" , Srinivas Kandagatla , Lukas Wunner , Rob Herring , Florian Fainelli , Dan Carpenter , Ivan Khoronzhuk , David Lechner , Greg Kroah-Hartman , Andrew Lunn , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, netdev@vger.kernel.org, Bartosz Golaszewski Subject: Re: [PATCH 4/5] net: add support for nvmem to eth_platform_get_mac_address() Message-ID: <20180719174728.GK6920@n2100.armlinux.org.uk> References: <20180718161035.7005-1-brgl@bgdev.pl> <20180718161035.7005-5-brgl@bgdev.pl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180718161035.7005-5-brgl@bgdev.pl> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 18, 2018 at 06:10:34PM +0200, Bartosz Golaszewski wrote: > @@ -544,6 +548,31 @@ int eth_platform_get_mac_address(struct device *dev, u8 *mac_addr) > from = "arch callback"; > } > > + if (!addr) { > + nvmem = nvmem_cell_get(dev, "mac-address"); > + if (IS_ERR(nvmem) && PTR_ERR(nvmem) == -EPROBE_DEFER) This is way too verbose. To quote Al Viro from earlier today: sigh... if (IS_ERR(link) && PTR_ERR(link) == -EEXIST) what the hell is wrong with if (link == ERR_PTR(-EEXIST))? I wonder why so many people haven't heard of pointer comparison... ;) IS_ERR(ERR_PTR(-EPROBE_DEFER)) is always true - if it wasn't, then we'd be in for problems. So, if you're asserting that nvmem is ERR_PTR(-EPROBE_DEFER) then there's no need to do the IS_ERR(nvmem) must also be true. Hence, a simple pointer comparison is sufficient: if (nvmem == ERR_PTR(-EPROBE_DEFER)) return -EPROBE_DEFER; -- RMK's Patch system: http://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 13.8Mbps down 630kbps up According to speedtest.net: 13Mbps down 490kbps up