From patchwork Tue Aug 8 06:29:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 132709 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp2325320vqr; Tue, 8 Aug 2023 11:48:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IExvued2Yq/ps9k+9Ujp20tZl6a5UG/7D/2CCA/2ssTTa0HKqk86qTAPyC2Pfc1HsPsyWNl X-Received: by 2002:a17:903:1104:b0:1bc:45a8:c69a with SMTP id n4-20020a170903110400b001bc45a8c69amr545059plh.21.1691520502261; Tue, 08 Aug 2023 11:48:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691520502; cv=none; d=google.com; s=arc-20160816; b=GUcZnq1iICP2HW9N/1TdYw8B7mQc9wp5Ny8cZsYkEMB2PqJNBc4Q+tG+oGm0rdU9ev xncnABbjKagslnbEiKB9Eqd+cOAcDRas+nrOwwRw3/zSvYbXswsneusPDrMNyNvFksPF jSvWHDM51QfAbQ9QmV1JmXyKcQe3Rops9dJapNDcl5Ef0fz8YNnbRLUpW2k6EaEmdXEX T+EvLN5laGbjUBLBtM+U3ClA2G+FWDqkcFHNUt8UwNTpfZGoLDwJqT8YdFpmf/BgZ/rU N1/EuRsP/lGkPXtc8lySC6SWc7HkM3bwui45G1OvUjtejqSFmowxWo2iavVJwkSzzDda 5Ngw== 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=k55uZHfiXRpF27jXQb6vGfNuAVB3+v9hTegBtF+P78Ah3WqaJ/iKcNoEG70+f62VB/ HmQRr5FeaXox+Cj73cs4Tg7byB7z8nFMPEF+EYQgh76ZulpOkSDdAxuXVk8gIHEdeDSd RgvbqaXZHaEBdB7bJlU8g08S7GP3SyUlA2IZIKAacGr1ZkJ2oKmF3eyLbSZ9b3THzlPK wB26x7VuN+OwoFXVMNnlL4DMLcY58M8ZCVLMHaehfIdrEUV+D5sbEe/icFQGnGU3WlUA 8qRw+C3fc08hXs/eF8Ztu9TnzHgO5Nt55DGzYFLHd+v1srpa7hYY1I5pB4DASx852h2B hUoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=hmZdhcJM; 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 w3-20020a170902e88300b001b87b716f87si1606758plg.329.2023.08.08.11.48.09; Tue, 08 Aug 2023 11:48:22 -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=hmZdhcJM; 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 S232646AbjHHRma (ORCPT + 99 others); Tue, 8 Aug 2023 13:42:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234036AbjHHRls (ORCPT ); Tue, 8 Aug 2023 13:41:48 -0400 Received: from mslow1.mail.gandi.net (mslow1.mail.gandi.net [217.70.178.240]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D62F238FE for ; Tue, 8 Aug 2023 09:18:29 -0700 (PDT) Received: from relay1-d.mail.gandi.net (unknown [IPv6:2001:4b98:dc4:8::221]) by mslow1.mail.gandi.net (Postfix) with ESMTP id 6409AD2EC1 for ; Tue, 8 Aug 2023 06:29:55 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id CAD39240007; Tue, 8 Aug 2023 06:29:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1691476178; 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=hmZdhcJMLGN3+DbMpvMXzXuhrzlVj07IbxZyeePTN2JyLD/a4NiUtN4gIhsGaxBb2XmDnX lDvW/O/OeoxxLFtu2Ox/AtXUf8XDhli58FiYcE9/ABE6BSDCTuyYUVsA9HAGkd3pXqZlda jV5gb4hz3TBCnvpWHyErNG19MG20VyuvdHWEWfj4VKquO10teScjrO00EADRIUS0GAQ/Gc +xEOe/SdIFXUJRHoKtwZvauUmU0RQlzxRYZxg4Vzg1Npwzma1Nq6rnJy4LFreEpdjiCCVH RFc3JzffgR4WyC5JzOFJWXeIyGAwHqsIfwXo9xw5iyRm5unlW59VQRtlL0otFw== 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 v9 2/7] nvmem: core: Return NULL when no nvmem layout is found Date: Tue, 8 Aug 2023 08:29:27 +0200 Message-Id: <20230808062932.150588-3-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230808062932.150588-1-miquel.raynal@bootlin.com> References: <20230808062932.150588-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,URIBL_BLOCKED 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: 1773684451226623061 X-GMAIL-MSGID: 1773687801925703681 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 */