From patchwork Mon Aug 7 08:24:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 131764 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp1325418vqr; Mon, 7 Aug 2023 02:24:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEYTkX3J1BF8jHPXuDM2NqhvejCZVyBKzXDuRJK3g+tMBfjSfAOOqeB/8O4r+UkHWwRy4FC X-Received: by 2002:a05:6a20:6a0c:b0:13f:8e07:7ed4 with SMTP id p12-20020a056a206a0c00b0013f8e077ed4mr7573333pzk.13.1691400274563; Mon, 07 Aug 2023 02:24:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691400274; cv=none; d=google.com; s=arc-20160816; b=ds9PPXdYk06ORi8lPRgjOnfSQLjdQB/LRPgcMXIJfAxIEzRdoeS4j5yDSrTxWH9xmQ VVwO0cuIzOyVayUheq69ExtsEUm0rFg6QOYsDz7yT4wgH0SkGGC7C34p2x+NRUts2Zi0 0C7K38QxPYLIhR+eOrbNTtVFEU7Cy68Xf+fg4am9jWCaOsGEE0TnahzT7MACqIUvSZlI TrLi0GHOc+U0EmctJwUvAvF+Gfq2m60jTt7M/vBszzTCadX7W0utFJ08+AkkMBmmLsLa K21Ma6RVCZxusKiltZpqqce/khfqo6kAkqZVLefjTVOfkyu+3qZHcEbz2uk4n1hH/mrg cQwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=bS+vOtPyOkEkdV/nhm5MLbH36mndj+2cFLrBIoA8aFE=; fh=f7aD74tELEZtFO9O5agOhsaIYt+Ay32d6f6zjupLJ4g=; b=Odz3GOHh/jKUsD+3m9e+zXc7EIWHTee63Nr9Y9sD8ajZmCVhyyjBvdlOSG/D+sYB+0 AARc8uIh3G+huoSUBkLJbRRH07h/jVJIDlLz17ejo/iqqs7HsGRQeq6rq4lN9A2b20sz yyG3tnPlxyqqkkLUOIsquVkJHh6ZbvVcQyw3ZSIvmMe4Bi/zWzCj/ta63kGPMrToSkXK G5r9SOozOSVEU19zyvWLL1RUeeHrVxyLYYo/3ibrRTR2ChWwG2RjdijzUQG/wWxfZl3C rm6KuNAG2D+6enU2lKwKq1ARfQ39vmiFEEtNeGPzhexiLdCRH5YyEJqjyTH+SByRW2Oy +YVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=h9ITThFr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d19-20020a637353000000b0054f93b261cfsi5163171pgn.88.2023.08.07.02.24.21; Mon, 07 Aug 2023 02:24:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=h9ITThFr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231171AbjHGIY3 (ORCPT + 99 others); Mon, 7 Aug 2023 04:24:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230415AbjHGIY1 (ORCPT ); Mon, 7 Aug 2023 04:24:27 -0400 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::224]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0A5A10EF for ; Mon, 7 Aug 2023 01:24:25 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id 0A4D8E0006; Mon, 7 Aug 2023 08:24:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1691396664; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bS+vOtPyOkEkdV/nhm5MLbH36mndj+2cFLrBIoA8aFE=; b=h9ITThFrDAL4gw+CgsF85+DiojEI16eg8zukQy7IymB5qM5FbBKLO6ipVnaRE6SacEkjhR 7L5nvgEVIMngiuqj/R8yhL2FvmRtjUJnhhYZfLNxW+991cKBuKouJdVzRP1qABsEAgC+56 kfcX22kxvOX2XfiHYyEi5tHD4QzMsbGm9szl+2N/eau5vaDcv9xD/th32j7JuWEfzJrZ1J ZvXqBfnkzJczCDU6Qc8zrnVeaDDvmugqDscjpfUUQGKESVtse+EkpWp+noLVd8woI39s8b K2kZLQh7PjdPV9Uw98gWvYnAGFsQmefUbD6gnompMMStJg+FTKDL7WpoD3SrGg== From: Miquel Raynal To: Srinivas Kandagatla Cc: Greg Kroah-Hartman , Thomas Petazzoni , Robert Marko , Luka Perkov , Michael Walle , , Randy Dunlap , Chen-Yu Tsai , Daniel Golle , =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= , Miquel Raynal , kernel test robot , Dan Carpenter Subject: [PATCH v8 2/8] nvmem: core: Return NULL when no nvmem layout is found Date: Mon, 7 Aug 2023 10:24:13 +0200 Message-Id: <20230807082419.38780-3-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230807082419.38780-1-miquel.raynal@bootlin.com> References: <20230807082419.38780-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 X-GND-Sasl: miquel.raynal@bootlin.com X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773561734580285193 X-GMAIL-MSGID: 1773561734580285193 Currently, of_nvmem_layout_get_container() returns NULL on error, or an error pointer if either CONFIG_NVMEM or CONFIG_OF is turned off. We should likely avoid this kind of mix for two reasons: to clarify the intend and anyway fix the !CONFIG_OF which will likely always if we use this helper somewhere else. Let's just return NULL when no layout is found, we don't need an error value here. Link: https://staticthinking.wordpress.com/2022/08/01/mixing-error-pointers-and-null/ Fixes: 266570f496b9 ("nvmem: core: introduce NVMEM layouts") Reported-by: kernel test robot Reported-by: Dan Carpenter Closes: https://lore.kernel.org/r/202308030002.DnSFOrMB-lkp@intel.com/ Signed-off-by: Miquel Raynal --- Backports to stable kernels is likely not needed as I believe the error pointer will be discarded "magically" by the of/ code. --- include/linux/nvmem-consumer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/nvmem-consumer.h b/include/linux/nvmem-consumer.h index fa030d93b768..27373024856d 100644 --- a/include/linux/nvmem-consumer.h +++ b/include/linux/nvmem-consumer.h @@ -256,7 +256,7 @@ static inline struct nvmem_device *of_nvmem_device_get(struct device_node *np, static inline struct device_node * of_nvmem_layout_get_container(struct nvmem_device *nvmem) { - return ERR_PTR(-EOPNOTSUPP); + return NULL; } #endif /* CONFIG_NVMEM && CONFIG_OF */