Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1313526rdb; Wed, 6 Dec 2023 15:18:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IEvQdaw7qrQ5moabHliTztW+ZJCqnEhLdzAQCvB19FarLlpDVwWbFCQwvDQ6fAoqMnRoiD+ X-Received: by 2002:a05:6e02:5b2:b0:35d:59a2:a337 with SMTP id k18-20020a056e0205b200b0035d59a2a337mr2172889ils.57.1701904718493; Wed, 06 Dec 2023 15:18:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701904718; cv=none; d=google.com; s=arc-20160816; b=QogiWSeAVmaAiy5oRBvB9bidk9G888s+1WVr62ntq0nY1tCN+9qqaeaUzzH4ejBk1t A18fJHXOAB/cdec9w0jrZwu6rmMkBdxqmU/Z9u2RRfTgMtoBegpIia56A3SI6uHVwxrZ QsDgB11DL8RhNmlkcSIbWIaQJNOF18LhX8hMVQ36WTnWsKqqAtid8+e5lOcmhk3XE7fs wN1VnQkkVAqzqqRkHaeeNPPndTq5Cqtim/zd6QSOVX14rPeV4BXWgIjebE/x2wrurcEq SzMINKD6cBC8Z0TkGMtyFkQQ0uoj+1JajXYa2TDvFMx3+NrkXGaDl+0BTQEV9H/IxTG+ Qwdw== 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=Gwv/6oPFanLePWslpfRNyjWyOxGu6dVOOW4rGpdEP+Y=; fh=G6Hp1tEbdXsoLeWD0Yc7Z9n/scIRldNp9qabfZjjMx0=; b=JZIz1tpFOfyZvVAevZv+dyOoIZzSeTObS9EZ+gkJzfyqG7nk+KMYtpgAYzBznkXn6M kRZkg/o4v0aHyqeSjrnvFzw13+40y5BBrMmj91V8vjQKpHBj2pjJTmoHhIGFHZkynfzy U5OYDh93zsbBpu1bTUXH5C/9kYf3/AYcQH+lcggN3GHDAKCSOKwNCbGUVkRVhbh6E9d5 bOsMgeNbZ2X8gMMPJH63cbtKeY6Tsx714ukPpNg9oHT+2hzKJGmnNJEUsbVqLhowXof/ opYf2G/A8HycIwfmKEYM5sNfdL8ZXSPhrB6eEvfmZ1d1YqaRHCDUfX9SFHkE68VRoXvB FN9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qAxZ9aTS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id cm23-20020a056a020a1700b005c65f924f6csi51866pgb.319.2023.12.06.15.18.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 15:18:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qAxZ9aTS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 2FB6E8339663; Wed, 6 Dec 2023 15:18:33 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379547AbjLFXRu (ORCPT + 99 others); Wed, 6 Dec 2023 18:17:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379625AbjLFXRb (ORCPT ); Wed, 6 Dec 2023 18:17:31 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81D24D6D for ; Wed, 6 Dec 2023 15:17:37 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE161C433C8; Wed, 6 Dec 2023 23:17:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701904657; bh=0Qw8myzJlI3KvHO4ZZ9sYNzQlLdb50E+KYoJvBETQBg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qAxZ9aTSAhvoOKJ3eMtfYllXKM8tyzCzwF0nY3H0T7478W3tIEvmsSp7Wg7bfvNMm sATZj5/cS+X8srz04BDBgDT119KuKL89gaBl5B/mgH1C2P/r7FoDVc+DCu7qvsAVXJ E8Ct3p4XBEyyU46XyBq6rNT2TYcDXS0kXvidAmIuNitbkulQcwXjlI+4tb5O/czBPP vciad4Q00mi9IbLeywfL80hvUx9QGLGY69JpCkqsu8WAjWPqHTXyUqW4iGpBihRqoJ oEndnjKfQIfbgritGCDZi3BMI6SZEBVEGDbdjbwtCphk7OCvV1/kIWERQHQSeQM0QN ZTAIx7m4IRM+w== From: Stephen Boyd To: Greg Kroah-Hartman Cc: Fei Shao , linux-kernel@vger.kernel.org, patches@lists.linux.dev Subject: [PATCH 7/8] spmi: Return meaningful errors in spmi_controller_alloc() Date: Wed, 6 Dec 2023 15:17:30 -0800 Message-ID: <20231206231733.4031901-8-sboyd@kernel.org> X-Mailer: git-send-email 2.43.0.rc2.451.g8631bc7472-goog In-Reply-To: <20231206231733.4031901-1-sboyd@kernel.org> References: <20231206231733.4031901-1-sboyd@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 06 Dec 2023 15:18:33 -0800 (PST) From: Fei Shao spmi_controller_alloc() currently returns NULL to all types of errors, which can be improved. Use appropriate error code in returns and pass the errors from used functions where possible. Signed-off-by: Fei Shao Link: https://lore.kernel.org/r/20230824104101.4083400-6-fshao@chromium.org Signed-off-by: Stephen Boyd --- drivers/spmi/spmi-devres.c | 4 ++-- drivers/spmi/spmi.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/spmi/spmi-devres.c b/drivers/spmi/spmi-devres.c index 7683e6fdb18f..62c4b3f24d06 100644 --- a/drivers/spmi/spmi-devres.c +++ b/drivers/spmi/spmi-devres.c @@ -20,9 +20,9 @@ struct spmi_controller *devm_spmi_controller_alloc(struct device *parent, size_t return ERR_PTR(-ENOMEM); ctrl = spmi_controller_alloc(parent, size); - if (!ctrl) { + if (IS_ERR(ctrl)) { devres_free(ptr); - return ERR_PTR(-ENOMEM); + return ctrl; } *ptr = ctrl; diff --git a/drivers/spmi/spmi.c b/drivers/spmi/spmi.c index 7313d4c18a04..5f11ced3f8b9 100644 --- a/drivers/spmi/spmi.c +++ b/drivers/spmi/spmi.c @@ -445,11 +445,11 @@ struct spmi_controller *spmi_controller_alloc(struct device *parent, int id; if (WARN_ON(!parent)) - return NULL; + return ERR_PTR(-EINVAL); ctrl = kzalloc(sizeof(*ctrl) + size, GFP_KERNEL); if (!ctrl) - return NULL; + return ERR_PTR(-ENOMEM); device_initialize(&ctrl->dev); ctrl->dev.type = &spmi_ctrl_type; @@ -463,7 +463,7 @@ struct spmi_controller *spmi_controller_alloc(struct device *parent, dev_err(parent, "unable to allocate SPMI controller identifier.\n"); spmi_controller_put(ctrl); - return NULL; + return ERR_PTR(id); } ctrl->nr = id; -- https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git/ https://git.kernel.org/pub/scm/linux/kernel/git/sboyd/spmi.git