Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1156381pxb; Fri, 6 Nov 2020 02:25:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJwmlrV93KRDHBvJsdlXJbq/T1jInTu/3K70QF3THBsBiUVqTPxzIJiaBfjgkKLxqEOHZB6T X-Received: by 2002:a50:8b65:: with SMTP id l92mr1298449edl.132.1604658316382; Fri, 06 Nov 2020 02:25:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604658316; cv=none; d=google.com; s=arc-20160816; b=YyL7QWng9MbvVWL0K9ivBnwlCTszOQS78COXuXtuoAXDjwZxzcqnUmNztVDD3Yu7p7 qTHdCo3CCErxdlGBqDjC+Sye3PcKCnRVCgFrlLWGH5KCmS1704su6X1D0Up6Cv45agWp hAFMcxlShIweFmH4nJym55h7+6XR5yy2WMWeFXrdg9XSsT054YfzwD9v/nyF1pkZnfE+ nAxPKY+x5GQ7zgIQLWatddi4ub+s3Xe4gbjYKg3GnYlHNpAfE1OoBpAChUA23+g7IDO0 qvrbB2WMzU1bvEtlJ+QK+wY+tAQLa7P9cONp7E0N6wIu2L9ovAzuEZNXxHMIcngspHMS zZzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=9rhClAe0AE0/osKeInSHSpF66GY18nzFFZdxtAq/D2c=; b=eMwUmYwl9qV8Oy+u3MeSpJP0XdiAETdhMN7PEhkY6X75OlBE4rWGQCi5HJGk7hp64R qtpXjlVMZ33/rq7H46m2hBd1hIDnXdHvvPbYC7oYDEMpIv7vV10F1FtpXpM3Eo/nKQrK PxG6ZfSlJuD/UIoNV2rlpun3DlPoo8NJGIjZyaIGZ5DXcBUEKCRFFJd8pnhiecKcD3t6 m491ybzzoabcWUgHlzDMTANDsaCj5DyzWdC7tYYcaJ2iA/vwdnxUnfzHfkEjcdNkef2J aWSNCoCLK7ouDRmgiyrS/adfpdcce0eXz1rZfCCMSQhilc6ysNXyfbMLk0+7X7Xw3Ljr 8oow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cqeCLAYK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dk17si602713edb.383.2020.11.06.02.24.53; Fri, 06 Nov 2020 02:25:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cqeCLAYK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726758AbgKFKXZ (ORCPT + 99 others); Fri, 6 Nov 2020 05:23:25 -0500 Received: from mail.kernel.org ([198.145.29.99]:58308 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726345AbgKFKXZ (ORCPT ); Fri, 6 Nov 2020 05:23:25 -0500 Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0ED8621D81 for ; Fri, 6 Nov 2020 10:23:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604658204; bh=YO03IaFoz1g+4x3+n58bkH7/Cex+2ht8GRyZ0XAnoO0=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=cqeCLAYKapJVJRNG4S3OMnilHz3K4r8Frko0+JmQMT7J2clbC13dSgsPNazKUjPTg U2REJUwwMQ9FtssJg+oinCLpzWsO7Zgx4L1+6EpfkyJuFRR+Y80S8vhsL+UmmD+TrX ZPDSjBSDooSmHM6XB2CYELhYTJvM1odd42tDKWa4= Received: by mail-wr1-f53.google.com with SMTP id y12so742530wrp.6 for ; Fri, 06 Nov 2020 02:23:23 -0800 (PST) X-Gm-Message-State: AOAM532J5pf2ExYI/A8755doJOiiPWgatry5HLwg4w94gLaeuM6AChlQ 5m8kLIhyj/KTq57yMXHTsjDGAwaiP5tVCj5NohQ= X-Received: by 2002:adf:fe09:: with SMTP id n9mr1839224wrr.361.1604658201741; Fri, 06 Nov 2020 02:23:21 -0800 (PST) MIME-Version: 1.0 References: <20201027211154.3371691-1-enric.balletbo@collabora.com> In-Reply-To: From: Arnd Bergmann Date: Fri, 6 Nov 2020 11:23:05 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] mfd: syscon: Add syscon_regmap_lookup_by_phandle_optional() function. To: Arnd Bergmann Cc: Enric Balletbo i Serra , "linux-kernel@vger.kernel.org" , Collabora Kernel ML , Nicolas Boichat , Lee Jones Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I noticed that my earlier reply was rejected by some mail servers, resending from @kernel.org to make sure everyone has it. On Tue, Oct 27, 2020 at 10:57 PM Arnd Bergmann wrote: > > On Tue, Oct 27, 2020 at 10:11 PM Enric Balletbo i Serra > wrote: > > > > This adds syscon_regmap_lookup_by_phandle_optional() function to get an > > optional regmap. > > > > It behaves the same as syscon_regmap_lookup_by_phandle() except where > > there is no regmap phandle. In this case, instead of returning -ENODEV, > > the function returns NULL. This makes error checking simpler when the > > regmap phandle is optional. > > > > Suggested-by: Nicolas Boichat > > Signed-off-by: Enric Balletbo i Serra > > Looks good in principle. > > > @@ -255,6 +255,19 @@ struct regmap *syscon_regmap_lookup_by_phandle_args(struct device_node *np, > > } > > EXPORT_SYMBOL_GPL(syscon_regmap_lookup_by_phandle_args); > > > > +struct regmap *syscon_regmap_lookup_by_phandle_optional(struct device_node *np, > > + const char *property) > > +{ > > + struct regmap *regmap; > > + > > + regmap = syscon_regmap_lookup_by_phandle(np, property); > > + if (IS_ERR(regmap) && PTR_ERR(regmap) == -ENODEV) > > + return NULL; > > + > > + return regmap; > > +} > > I think the explanation from the patch description is needed here as well, > as an interface that might either return an error code or NULL is generally > a really bad idea. I understand what this is for, but it's easy to misread. > > > static inline struct regmap *device_node_to_regmap(struct device_node *np) > > { > > @@ -59,6 +62,14 @@ static inline struct regmap *syscon_regmap_lookup_by_phandle_args( > > { > > return ERR_PTR(-ENOTSUPP); > > } > > + > > +static inline struct regmap *syscon_regmap_lookup_by_phandle_optional( > > + struct device_node *np, > > + const char *property) > > +{ > > + return ERR_PTR(-ENOTSUPP); > > +} > > Shouldn't this also return NULL then? > > Arnd