Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp355645yba; Fri, 3 May 2019 03:14:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqymjUEJlqwJ3yQ+t0tW/hNx0W7L/RaQtZtBtmRmnUszxNCUlUfrPwjv2cJga+a46SLy7VTG X-Received: by 2002:aa7:8046:: with SMTP id y6mr9810886pfm.251.1556878446287; Fri, 03 May 2019 03:14:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556878446; cv=none; d=google.com; s=arc-20160816; b=Zpzg2lg8m7zite+/g9U4zvOglw1wW9OFwU3y+iev3m+fWHl3NWyhZuN8ab85ZGLy7d yo45lwyc/QAHNkUM820+JdKHnNnA1zklH4GdUcJhoiXw4LQmOfchxSbBh6hOaZgTrDvT CiAxs8T+zPefvPF5nMvFYIepzvGuS5gPb70lxZVG5huxe0NZBQr5uOPW7UNhyMbefEAx eCQ9yreO4RMiWDg+oi0oUm+ZNgYE8evF8CiV4riNDUY6oJW6IfT0YVhrhx4+6772+Vs+ d98TQaYTLQGpI/+76z11CdZDJ/lMD6bmzMziesGKXHrzx9CIdcoJ0TeGN39wFSm6WfyE JP6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:reply-to:message-id:subject:cc:to:from:date; bh=gjoTLj86PJrg621PfPaVTOua/JSyzkjv9krMS8omzHI=; b=zJehHCczdNDjHituNR38SVt4bGuvghv1PHFyDS0wKllfEwlxdLnfv81hPR+yZF6dcs wZegdPKbXsBGpIXJWKGe9iccQLgO1A45KQMZkr29yOzhln4RZq9B1O9AAAccDQglN9JI TyHv0TbQZNdeMqUFYJGDa8IA69WQn2f2SnVh4egbPqw3pIKdpH3HRy5i5Xw6v21o8LXY o4VM8IW7jnhO+ZGP2yCDr2kJjyp8ghwREEXY7Vj3hGQ1k73+f19Ayzzg0xDNGvGce6q7 2GHzAFfPb9Wi7AyqQOKPflzWRkYJTNX2lqgsObi0qy1tMFwXTOKIaKD/1+OjsQsjA/x3 f/Jg== 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 o11si1831384pll.113.2019.05.03.03.13.51; Fri, 03 May 2019 03:14:06 -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; 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 S1727111AbfECJPs (ORCPT + 99 others); Fri, 3 May 2019 05:15:48 -0400 Received: from smtp-out.xnet.cz ([178.217.244.18]:51917 "EHLO smtp-out.xnet.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725777AbfECJPr (ORCPT ); Fri, 3 May 2019 05:15:47 -0400 Received: from meh.true.cz (meh.true.cz [108.61.167.218]) (Authenticated sender: petr@true.cz) by smtp-out.xnet.cz (Postfix) with ESMTPSA id 423283970; Fri, 3 May 2019 11:15:44 +0200 (CEST) Received: from localhost (meh.true.cz [local]) by meh.true.cz (OpenSMTPD) with ESMTPA id 3fe29465; Fri, 3 May 2019 11:15:42 +0200 (CEST) Date: Fri, 3 May 2019 11:15:42 +0200 From: Petr =?utf-8?Q?=C5=A0tetiar?= To: Sergei Shtylyov Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org, Andrew Lunn , Florian Fainelli , Rob Herring , Frank Rowand , Heiner Kallweit , Srinivas Kandagatla , Maxime Ripard , Alban Bedel , Felix Fietkau , John Crispin , linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 01/10] of_net: add NVMEM support to of_get_mac_address Message-ID: <20190503091542.GE346@meh.true.cz> Reply-To: Petr =?utf-8?Q?=C5=A0tetiar?= References: <1556870168-26864-1-git-send-email-ynezz@true.cz> <1556870168-26864-2-git-send-email-ynezz@true.cz> <2a5fcdec-c661-6dc5-6741-7d6675457b9b@cogentembedded.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2a5fcdec-c661-6dc5-6741-7d6675457b9b@cogentembedded.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Sergei Shtylyov [2019-05-03 11:44:54]: Hi Sergei, > > diff --git a/drivers/of/of_net.c b/drivers/of/of_net.c > > index d820f3e..258ceb8 100644 > > --- a/drivers/of/of_net.c > > +++ b/drivers/of/of_net.c > [...] > > @@ -64,6 +113,9 @@ static const void *of_get_mac_addr(struct device_node *np, const char *name) > > * addresses. Some older U-Boots only initialized 'local-mac-address'. In > > * this case, the real MAC is in 'local-mac-address', and 'mac-address' exists > > * but is all zeros. > > + * > > + * Return: Will be a valid pointer on success, NULL in case there wasn't > > + * 'mac-address' nvmem cell node found, and ERR_PTR in case of error. > > Returning both NULL and error codes on failure is usually a sign of a > misdesigned API. well, then there's a lot of misdesigned APIs in the tree already, as I've just grepped for IS_ERR_OR_NULL usage and found this pointer/NULL/ERR_PTR usage pretty legit. > Why not always return an error code? I've received following comment[1] from Andrew: "What you have to be careful of, is the return value from your new code looking in NVMEM. It should only return EPROBE_DEFER, or another error if there really is expected to be a value in NVMEM, or getting it from NVMEM resulted in an error." So in order to fullfil this remark, I can't simply use ENOENT instead of current NULL, as the caller couldn't distinguish between ENOENT from of_get_mac_address or ENOENT from NVMEM subsystem. 1. https://patchwork.ozlabs.org/patch/1092243/#2161764 -- ynezz