From patchwork Fri Dec 9 15:29:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Pagani X-Patchwork-Id: 31831 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp841882wrr; Fri, 9 Dec 2022 07:31:08 -0800 (PST) X-Google-Smtp-Source: AA0mqf6K95wMqbbcpINJc4peGUzpUZfcXo5NI69J/QQ5KqAF3W95Ww4IKYA+GfjLzBKfwriN+i5R X-Received: by 2002:a17:90a:db97:b0:21b:c5b5:a6f4 with SMTP id h23-20020a17090adb9700b0021bc5b5a6f4mr6662095pjv.13.1670599868247; Fri, 09 Dec 2022 07:31:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670599868; cv=none; d=google.com; s=arc-20160816; b=N+VtwbSFGza4QzUv3A4wraYmqLHsbCfSFtuwy9eRIe2i1u7sqq+VWw+aco2SGHmSFd J0BksC/Os45e5S25tQjPIZtrv3n+th33mxn1ApKiVGDUoX0FHtBTpdYLcM9le68R/lpG MjMFU4Va6tpC5YwPq+2dU4TLfOIsvdfJVTJgcrr8ro5mO8tTRkRZX3DcesI8plC8XeBt iHE3CwrUvhly5rPSQfjlA4IUMk2iHRVROVvSxRJDkDAk/xiDx2rCZ/vres3/kT7E1RU9 ETwF6ht64HYufxb4W1FTYOJRDGe/KwXO82iIPh/fBJkw1zFtj27P5Gq7zAMdltRzA2zx 7cKA== 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=kBPZbzsz83JkmUujCQ8aIAfFvAeW6uUPjs+rv+f/Muo=; b=EdCluY9KSwdRGwUQPbbcOn6bTFjztzDq+Sf2HavKbf5KfqlACf2tWaR98cFB3+CFar CkuGFvrV0Ah15sSxC/HTmL5gfKkHoau0vvOgI7QJHW+U7tHrMUxmq5yZ5478P8J5Cog3 K3FcELgtNTo5n1mwP8NMMqWA9QrSff0r7agm5/4QyCPEu+CH/GbRq6cZyyILELEfQfy9 k36A07LeIWThCU5gkZn94JcTrKQibmV6eZ3lrFkozLYbfiE+zcQJ6qtDtsQODojJSLDN NMPmt90OeDfAkuMjPEBWdAPXSiUEqUNIEthNZPf0IPxanSPLFXCyQVZbGXVnhW+gh9v+ wWOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WloBNJWL; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 33-20020a630b21000000b00477d314a66fsi1677634pgl.585.2022.12.09.07.30.50; Fri, 09 Dec 2022 07:31:08 -0800 (PST) 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=@redhat.com header.s=mimecast20190719 header.b=WloBNJWL; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230402AbiLIPad (ORCPT + 99 others); Fri, 9 Dec 2022 10:30:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230111AbiLIPa1 (ORCPT ); Fri, 9 Dec 2022 10:30:27 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 037078F084 for ; Fri, 9 Dec 2022 07:29:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670599763; 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=kBPZbzsz83JkmUujCQ8aIAfFvAeW6uUPjs+rv+f/Muo=; b=WloBNJWLoF1GTTYvEjln8rp/aBcYNX0DpItdY7HbK+REzv0dLFOZekrltDqmLIbEM1FUX/ Zur/swzIJpx4Zlaq72OKypmIboxMkN31Ha5QAz1P8aoUeEm+4KQaRc71xOBF6/dmvZFyv9 iGUsKnoIwaj8b7p2bAzZ3fSSDSI6VCM= Received: from mail-yw1-f197.google.com (mail-yw1-f197.google.com [209.85.128.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-176-S5V3bL1GMYaWbKcfDHhKDg-1; Fri, 09 Dec 2022 10:29:22 -0500 X-MC-Unique: S5V3bL1GMYaWbKcfDHhKDg-1 Received: by mail-yw1-f197.google.com with SMTP id 00721157ae682-360b9418f64so53299837b3.7 for ; Fri, 09 Dec 2022 07:29:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kBPZbzsz83JkmUujCQ8aIAfFvAeW6uUPjs+rv+f/Muo=; b=RtnMjhEO6/cLQkJvdaXe/vc4mIVsMsxOPRQwUeBohpXIBzSBUl1QT/0Ehx7qeMevWt g2r2noVm2GI0XmW61KmLrgGSfFXVlbVptJ9NahPp9644EdRS7klEHPOvQGeRK9lMg3UG GLTedld8MMGeLqXCODCSAaNYjl+5jJZ4l17foO0ToF7K7IskHipK/hMnTY/BBGgml1dQ SMfSuF7u+/+V6sn4fMoXhbf56odhO1KbWIevM7xtf/5yj0Xib8pRjiYFlwWK46uISsKg ulvdp5WKx4o06UGBj2Hf120bcugfjSdKEq1jo9J3/MTdBi4cUoxt/3tOq/GaS3lOFWyE SBMA== X-Gm-Message-State: ANoB5pktQ3Huizt+xNeL3KwY/UKNFQ2IAX9ZQtyzeFLrKF72tnhkWGsk Emh/0P8YB2hBSAj/dLm0BECOgc4jMCc2uQ+A6hx/hFEO+tN7N94G5XnIFBH+hJ3LTRQ/BZkYOAB /9zHW8P7235za0/QDxxzcqzk= X-Received: by 2002:a25:5686:0:b0:70a:59ae:36ff with SMTP id k128-20020a255686000000b0070a59ae36ffmr8722597ybb.30.1670599761359; Fri, 09 Dec 2022 07:29:21 -0800 (PST) X-Received: by 2002:a25:5686:0:b0:70a:59ae:36ff with SMTP id k128-20020a255686000000b0070a59ae36ffmr8722568ybb.30.1670599761127; Fri, 09 Dec 2022 07:29:21 -0800 (PST) Received: from klayman.redhat.com (net-2-34-28-158.cust.vodafonedsl.it. [2.34.28.158]) by smtp.gmail.com with ESMTPSA id dt26-20020a05620a479a00b006fbf88667bcsm29484qkb.77.2022.12.09.07.29.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Dec 2022 07:29:20 -0800 (PST) From: Marco Pagani To: Dinh Nguyen , Michael Turquette , Stephen Boyd Cc: Marco Pagani , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/6] clk: socfpga: use of_clk_add_hw_provider and improve error handling Date: Fri, 9 Dec 2022 16:29:08 +0100 Message-Id: <20221209152913.1335068-2-marpagan@redhat.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221209152913.1335068-1-marpagan@redhat.com> References: <20221209152913.1335068-1-marpagan@redhat.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751750907830517314?= X-GMAIL-MSGID: =?utf-8?q?1751750927264304572?= The function of_clk_add_provider() has been deprecated, so use its suggested replacement of_clk_add_hw_provider() instead. Since of_clk_add_hw_provider() can fail, like of_clk_add_provider(), check its return value and do the error handling. The indentation of the init function parameters has been aligned to match open parenthesis, as suggested by checkpatch, and the __init macro moved before the function name, as specified in init.h. Signed-off-by: Marco Pagani --- drivers/clk/socfpga/clk-periph.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/drivers/clk/socfpga/clk-periph.c b/drivers/clk/socfpga/clk-periph.c index 43707e2d7248..6a4075147b9c 100644 --- a/drivers/clk/socfpga/clk-periph.c +++ b/drivers/clk/socfpga/clk-periph.c @@ -47,8 +47,8 @@ static const struct clk_ops periclk_ops = { .get_parent = clk_periclk_get_parent, }; -static __init void __socfpga_periph_init(struct device_node *node, - const struct clk_ops *ops) +static void __init __socfpga_periph_init(struct device_node *node, + const struct clk_ops *ops) { u32 reg; struct clk_hw *hw_clk; @@ -96,11 +96,25 @@ static __init void __socfpga_periph_init(struct device_node *node, periph_clk->hw.hw.init = &init; hw_clk = &periph_clk->hw.hw; - if (clk_hw_register(NULL, hw_clk)) { - kfree(periph_clk); - return; + rc = clk_hw_register(NULL, hw_clk); + if (rc) { + pr_err("Could not register clock:%s\n", clk_name); + goto err_clk_hw_register; + } + + rc = of_clk_add_hw_provider(node, of_clk_hw_simple_get, hw_clk); + if (rc) { + pr_err("Could not register clock provider for node:%s\n", + clk_name); + goto err_of_clk_add_hw_provider; } - rc = of_clk_add_provider(node, of_clk_src_simple_get, hw_clk); + + return; + +err_of_clk_add_hw_provider: + clk_hw_unregister(hw_clk); +err_clk_hw_register: + kfree(periph_clk); } void __init socfpga_periph_init(struct device_node *node) From patchwork Fri Dec 9 15:29:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Pagani X-Patchwork-Id: 31832 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp842007wrr; Fri, 9 Dec 2022 07:31:19 -0800 (PST) X-Google-Smtp-Source: AA0mqf5J6y5ILp1gyyOycHk/fKfkkqwvvS5bdTWBax0QdHG6EQY9pT1A0NgFmL5IK0ONm4WFtNCI X-Received: by 2002:a05:6402:380a:b0:467:7b2e:88a2 with SMTP id es10-20020a056402380a00b004677b2e88a2mr5305980edb.19.1670599879577; Fri, 09 Dec 2022 07:31:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670599879; cv=none; d=google.com; s=arc-20160816; b=q9ixRnupMY/dsJM3HPvIEhFCHoHslUooCY7rbhcgDlpzrcuFxSm83rj5DaTp5xH7l4 +5c4WPpUzdLlwHzN4H2FWSwa/gzc6sjFfLAWaLn4HutlAMLmyckoVV8uV0X/3slEDtAE qAD5ez4gkskGHTKm+FZVLf0Ec8vmTwWIEvwuZsfuRSaIgJAPevF+qbXMEv7TJcurc0Xo Z2JBi11Vl/QMG1Etf3C08wKy5zL/VCAp57s9EGXF8+D4kDLEviLsm4XzkHNeb9VH6RaM K0o+HJMthM1YCUOscJM10uOwiFeZQW5C874SZleMypQ6WttOTp13XZrWMBe3vihw2d3m L8kQ== 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=RUr5nGjxc+b90ljVLd9eIXOVWRTwlS2fejPnyUptxZ8=; b=d8N7P68y+BWKvBv8uk6A17MwIpiiuQk6Z2itQ/ESCqLT3TGbI8Js0fJ1uPXpEf6oJZ urMTEUjFzAcADBrzeYHSDxQwaTbI74OBidgtFfDFVCJC8l1HljSowlXuqpYSAFa+9pKF 4xFp3ru6jQEB/awYBwNkRkWbjK0RVe8Gm1cXA7gijD6QYDWUFa1W34TOho4UW1xBHfAV bhkmgfYHxvmLzIJc2zZjWyGxzvYF8EuabGCWG1U60ap6neYdKNNpg4RufjM17PvlqsUz H3zIvZUx9ifCXzk9SlEYViHMhYdHEzGHmIuL7EoGOwk/bVOPOYbHpV/TahP4H5WCTuk0 XUeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LAZ28H7C; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t3-20020a056402524300b004696af1a86fsi1920174edd.271.2022.12.09.07.30.54; Fri, 09 Dec 2022 07:31:19 -0800 (PST) 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=@redhat.com header.s=mimecast20190719 header.b=LAZ28H7C; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230397AbiLIPah (ORCPT + 99 others); Fri, 9 Dec 2022 10:30:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230222AbiLIPa3 (ORCPT ); Fri, 9 Dec 2022 10:30:29 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DE048F70A for ; Fri, 9 Dec 2022 07:29:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670599765; 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=RUr5nGjxc+b90ljVLd9eIXOVWRTwlS2fejPnyUptxZ8=; b=LAZ28H7CuafDG9I+QfTI8wHZ4q+9cL20bY01da1s5tb/MaOimVM4v6sJ0qAvbbUoCEaRL8 UPDHko1He+eT5aATopSQ08EGAtPUhV/mD43gMx20fVhtNbXbWe57/Csv2hHWw4OwCChwAE /xy0SsrxJii6z2JdSfir9FBGxaEhQ6c= Received: from mail-yw1-f199.google.com (mail-yw1-f199.google.com [209.85.128.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-470-C9a3L82FO6Wp3Wtubq2EGg-1; Fri, 09 Dec 2022 10:29:24 -0500 X-MC-Unique: C9a3L82FO6Wp3Wtubq2EGg-1 Received: by mail-yw1-f199.google.com with SMTP id 00721157ae682-40306a5a42cso53482267b3.1 for ; Fri, 09 Dec 2022 07:29:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RUr5nGjxc+b90ljVLd9eIXOVWRTwlS2fejPnyUptxZ8=; b=RerroyEGl9Il403VgNRcBvaCDpOg/9lpK4Agw0dBZCOlZJvb24rPzREfMRnc/IQ7/d nB0YZ19Gviu/LLG961Q44dwS/TFNcHDiUwNb5jnsAmefWp6QRkRgtsfIuXdUNcCjz14d EQ/E6iEJUtNWx9WOccSgQVgqS/Z4Y10Qqd4tXapHLq+FNV8LmBpepPBgbhIJks8LVF5v CZ1FVfFuE1Vr2/Lo+c6fDDItIEy2MbGs/j1ZeX8uYTyZN/gZaM63OxFEEO9Abxsg9P8q 3og2K6ozcSVWnFb7vUr0OZzFTnujRJDrELwIksfWeHj05J211B1wklt9dEdyrsVWAl1o hrUg== X-Gm-Message-State: ANoB5pm2KfnRiSEhAu3P4FE21qdD9SxMpZi2gI9wCWU086g4hXDTXlmA MpS2loqMboV+roIoPuOImcLRprAmNvE4AxXGCiy8sKo/RMLTBc3vp2oJihcit9LAI5cDh4vYRkI xeUNfR30nnKkCXcUO2xQl3+o= X-Received: by 2002:a25:b943:0:b0:702:61d3:e1c7 with SMTP id s3-20020a25b943000000b0070261d3e1c7mr5582490ybm.16.1670599763166; Fri, 09 Dec 2022 07:29:23 -0800 (PST) X-Received: by 2002:a25:b943:0:b0:702:61d3:e1c7 with SMTP id s3-20020a25b943000000b0070261d3e1c7mr5582469ybm.16.1670599762887; Fri, 09 Dec 2022 07:29:22 -0800 (PST) Received: from klayman.redhat.com (net-2-34-28-158.cust.vodafonedsl.it. [2.34.28.158]) by smtp.gmail.com with ESMTPSA id dt26-20020a05620a479a00b006fbf88667bcsm29484qkb.77.2022.12.09.07.29.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Dec 2022 07:29:22 -0800 (PST) From: Marco Pagani To: Dinh Nguyen , Michael Turquette , Stephen Boyd Cc: Marco Pagani , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/6] clk: socfpga: arria10: use of_clk_add_hw_provider and improve error handling Date: Fri, 9 Dec 2022 16:29:09 +0100 Message-Id: <20221209152913.1335068-3-marpagan@redhat.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221209152913.1335068-1-marpagan@redhat.com> References: <20221209152913.1335068-1-marpagan@redhat.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751750917263050843?= X-GMAIL-MSGID: =?utf-8?q?1751750939261837695?= The function of_clk_add_provider() has been deprecated, so use its suggested replacement of_clk_add_hw_provider() instead. Since of_clk_add_hw_provider() can fail, like of_clk_add_provider(), check its return value and do the error handling. The indentation of the init function parameters has been aligned to match open parenthesis, as suggested by checkpatch, and the __init macro moved before the function name, as specified in init.h. Signed-off-by: Marco Pagani --- drivers/clk/socfpga/clk-periph-a10.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/drivers/clk/socfpga/clk-periph-a10.c b/drivers/clk/socfpga/clk-periph-a10.c index b9cdde4b8441..64cc70b970b7 100644 --- a/drivers/clk/socfpga/clk-periph-a10.c +++ b/drivers/clk/socfpga/clk-periph-a10.c @@ -57,8 +57,8 @@ static const struct clk_ops periclk_ops = { .get_parent = clk_periclk_get_parent, }; -static __init void __socfpga_periph_init(struct device_node *node, - const struct clk_ops *ops) +static void __init __socfpga_periph_init(struct device_node *node, + const struct clk_ops *ops) { u32 reg; struct clk_hw *hw_clk; @@ -106,21 +106,25 @@ static __init void __socfpga_periph_init(struct device_node *node, hw_clk = &periph_clk->hw.hw; - if (clk_hw_register(NULL, hw_clk)) { - kfree(periph_clk); - return; + rc = clk_hw_register(NULL, hw_clk); + if (rc) { + pr_err("Could not register clock:%s\n", clk_name); + goto err_clk_hw_register; } - rc = of_clk_add_provider(node, of_clk_src_simple_get, hw_clk); - if (rc < 0) { + + rc = of_clk_add_hw_provider(node, of_clk_hw_simple_get, hw_clk); + if (rc) { pr_err("Could not register clock provider for node:%s\n", clk_name); - goto err_clk; + goto err_of_clk_add_hw_provider; } return; -err_clk: +err_of_clk_add_hw_provider: clk_hw_unregister(hw_clk); +err_clk_hw_register: + kfree(periph_clk); } void __init socfpga_a10_periph_init(struct device_node *node) From patchwork Fri Dec 9 15:29:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Pagani X-Patchwork-Id: 31834 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp842704wrr; Fri, 9 Dec 2022 07:32:36 -0800 (PST) X-Google-Smtp-Source: AA0mqf7r8ti3FgSS79VYo6soMDPvVYk74baQd+FAtY13F3AFeGLUrar/MyzSYT77LchQB8J1aJ90 X-Received: by 2002:a17:902:ecc2:b0:18b:271e:5804 with SMTP id a2-20020a170902ecc200b0018b271e5804mr8688222plh.59.1670599956470; Fri, 09 Dec 2022 07:32:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670599956; cv=none; d=google.com; s=arc-20160816; b=DDqivBJHZAdtDibqhY9sGmypb1yCsQ1RPw92F29rzAD/tK1U1wWuTYhL4kozr4meJz 2f/+3ukIfNy8VNg2FLGW9sx10lmjOPYlf6gor8q1KyBQNg0PSrsLVrWSbxg/XIAZYBdA iW+fvVE5w4KiWeyieYk7GWLnXKgKRZRBeiPeJ4n5/K5qvx6/JRjQl8wyNHbs9FMw7lBo ZnKOgJfpKBnCuY72wkFPM5K++fS8P3hYOJPYgC5iWToyecpLoXVVd6noFYe3h2gqfNKL Q3mmN5xTiyJlr2XiTw4uqrmeTgcTC26xfWAuc8+73OJzV5YqA1V0Jvv3sktZEQJXv/T0 8I/Q== 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=TnfSWneK8MGkHTJmldzwfHxM+WYStFYZRT9qyOXWyWc=; b=FE560Pd9o52/d21X0S4Nt4+BnasGL7lFPVUD8QjT4agJcUqmpQkz1SifzGx2KMXLL8 nUKiILgGjwQXArJPoEb0XUhJ8B56mxNtQ23V/qL4A1QC4CP9U187wDqeeRAs1M5lpWml tKmtfnL5JJfJG6CQvqUaiPj9zGfBJSFxHQ78+mw4K4nFHGZ+Am5LD/iAvjUY8D/J/db/ Ov0qRYWXf48WR5ond6ek1BKdqkjR5KAAuOhu6kjLZWpEiCH8rdXjNGmNGZfMttUd2dbn YPCrPQiZ+xtYoM655LJQhCVswzJzwWGbo1yUygvRyOqmg21GgGIBRSAaoElrAzPhCHXz /slg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=OEbQ77Ig; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m6-20020a170902db0600b001890c6ff018si1930652plx.486.2022.12.09.07.32.22; Fri, 09 Dec 2022 07:32:36 -0800 (PST) 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=@redhat.com header.s=mimecast20190719 header.b=OEbQ77Ig; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230510AbiLIPaq (ORCPT + 99 others); Fri, 9 Dec 2022 10:30:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230229AbiLIPad (ORCPT ); Fri, 9 Dec 2022 10:30:33 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2445F880DE for ; Fri, 9 Dec 2022 07:29:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670599766; 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=TnfSWneK8MGkHTJmldzwfHxM+WYStFYZRT9qyOXWyWc=; b=OEbQ77Igr6O9Sv1Zu86BhJEK0GVztdbR9EyYp9tjI0SC3yESCUiSO4ax5EHJxzXqHVDVN2 ETTufZ8E0UnvXxnwES5P2BO08MSowlXbfHEhu1GRVeuM+j4CrYy47Els4ig0telaSgt6hg Jc+Yyz6YqyI0bX5wNll0DEpzrCoucfA= Received: from mail-yw1-f197.google.com (mail-yw1-f197.google.com [209.85.128.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-348-nisF4oQhOVesOeIlhtTr7g-1; Fri, 09 Dec 2022 10:29:25 -0500 X-MC-Unique: nisF4oQhOVesOeIlhtTr7g-1 Received: by mail-yw1-f197.google.com with SMTP id 00721157ae682-3d3769a8103so54229347b3.17 for ; Fri, 09 Dec 2022 07:29:25 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TnfSWneK8MGkHTJmldzwfHxM+WYStFYZRT9qyOXWyWc=; b=1vk9+o3X6EHvwQVhY7DS/IBKz6z7XztVZdK/HOH1TE4APSW/baGUIiZlnzHynjmXZY lULHdsVCMrl5UcYzzer1xFK9qQs+kqbcAi68D63kcQZQnvjbRBHF/NC5SBhV4fsoRQmh 40jpaygVsLkPmN+LGOncGbtPqOZQOQBDtQaw+UPBaqec0hNh4bwHVUABvDymKtMAyuvp IJP9SxKWgQ7oJsTX5N0/csd390H3B2BuKwcNGllUcDehJwU/OKoSeu1EQcHTPXgRfZwZ 7S+tZXG48FPZn5G0IcPkpHr/kS43ituhZ3LJhmaoHJbBMVOucTspMwQZnWBOndbOFMIs PgcA== X-Gm-Message-State: ANoB5pkyKRKJ0u+eW7MZ3pZRgcq6y3sMwy070YDYdYi29z9Z3N+F8CnU cQXEvxgykytvJQX3bPkhyTDZREKYBi5SbAdCG4nfFxkrDHLB936jWBOgIzXqyGZUvZDGrLk6aK1 LGQ79ACt+VPpYIHwi1992fA8= X-Received: by 2002:a0d:db14:0:b0:369:942d:a53a with SMTP id d20-20020a0ddb14000000b00369942da53amr8672042ywe.24.1670599764996; Fri, 09 Dec 2022 07:29:24 -0800 (PST) X-Received: by 2002:a0d:db14:0:b0:369:942d:a53a with SMTP id d20-20020a0ddb14000000b00369942da53amr8672022ywe.24.1670599764793; Fri, 09 Dec 2022 07:29:24 -0800 (PST) Received: from klayman.redhat.com (net-2-34-28-158.cust.vodafonedsl.it. [2.34.28.158]) by smtp.gmail.com with ESMTPSA id dt26-20020a05620a479a00b006fbf88667bcsm29484qkb.77.2022.12.09.07.29.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Dec 2022 07:29:24 -0800 (PST) From: Marco Pagani To: Dinh Nguyen , Michael Turquette , Stephen Boyd Cc: Marco Pagani , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/6] clk: socfpga: use of_clk_add_hw_provider and improve error handling Date: Fri, 9 Dec 2022 16:29:10 +0100 Message-Id: <20221209152913.1335068-4-marpagan@redhat.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221209152913.1335068-1-marpagan@redhat.com> References: <20221209152913.1335068-1-marpagan@redhat.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751750907830517314?= X-GMAIL-MSGID: =?utf-8?q?1751751019961400821?= The function of_clk_add_provider() has been deprecated, so use its suggested replacement of_clk_add_hw_provider() instead. Since of_clk_add_hw_provider() can fail, like of_clk_add_provider(), check its return value and do the error handling. The err variable unnecessarily duplicates the functionality of the rc variable, so it has been removed. Signed-off-by: Marco Pagani --- drivers/clk/socfpga/clk-gate.c | 35 +++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/drivers/clk/socfpga/clk-gate.c b/drivers/clk/socfpga/clk-gate.c index 0c18c55edf8c..32ccda960f28 100644 --- a/drivers/clk/socfpga/clk-gate.c +++ b/drivers/clk/socfpga/clk-gate.c @@ -126,17 +126,14 @@ void __init socfpga_gate_init(struct device_node *node) struct clk_init_data init; struct clk_ops *ops; int rc; - int err; socfpga_clk = kzalloc(sizeof(*socfpga_clk), GFP_KERNEL); if (WARN_ON(!socfpga_clk)) return; ops = kmemdup(&gateclk_ops, sizeof(gateclk_ops), GFP_KERNEL); - if (WARN_ON(!ops)) { - kfree(socfpga_clk); - return; - } + if (WARN_ON(!ops)) + goto err_kmemdup; rc = of_property_read_u32_array(node, "clk-gate", clk_gate, 2); if (rc) @@ -182,13 +179,25 @@ void __init socfpga_gate_init(struct device_node *node) hw_clk = &socfpga_clk->hw.hw; - err = clk_hw_register(NULL, hw_clk); - if (err) { - kfree(ops); - kfree(socfpga_clk); - return; + rc = clk_hw_register(NULL, hw_clk); + if (rc) { + pr_err("Could not register clock:%s\n", clk_name); + goto err_clk_hw_register; } - rc = of_clk_add_provider(node, of_clk_src_simple_get, hw_clk); - if (WARN_ON(rc)) - return; + + rc = of_clk_add_hw_provider(node, of_clk_hw_simple_get, hw_clk); + if (rc) { + pr_err("Could not register clock provider for node:%s\n", + clk_name); + goto err_of_clk_add_hw_provider; + } + + return; + +err_of_clk_add_hw_provider: + clk_hw_unregister(hw_clk); +err_clk_hw_register: + kfree(ops); +err_kmemdup: + kfree(socfpga_clk); } From patchwork Fri Dec 9 15:29:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Pagani X-Patchwork-Id: 31833 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp842701wrr; Fri, 9 Dec 2022 07:32:36 -0800 (PST) X-Google-Smtp-Source: AA0mqf4nulZNxntIVfEaKoQRuUHUgd8ODvjVjDt/mUdS1BmmbUZf9YF/Ouf/N9rKIW9QE4OAksC0 X-Received: by 2002:a05:6a20:3d22:b0:a3:cc70:6dcc with SMTP id y34-20020a056a203d2200b000a3cc706dccmr9103170pzi.39.1670599956360; Fri, 09 Dec 2022 07:32:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670599956; cv=none; d=google.com; s=arc-20160816; b=Ac5GsT/r7SykvDWmpMvOLeCSXIYNbn/ANVNlQo4aKHPbAstRjxtVA7X6UE7vtJfl10 CpJfX96vlOSIFjXQ86bEv5fo0eJLe4dlf06DnHLuKWq5ODyw/3i0HWaf3CW04UVd2FvI ftsbB3yU1jwzeuNja8csay3doxpjJfjA2/r1rwARqjNUYGZB8KR5IiqMf9VnFBpWBbdT MANll2G7W3NWIZeyvC7GxR4ns4pu5/ZIAiZ1WG0ucV59KyExToomfkEMm2N8tN3Z5zpd sx68w2u4DNB5jGSfFdRb4fqatK/lDSQHOORpqbRVjkZ74rN/se9emdAFH8tWh+5NGvXp 1BjA== 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=lr1I/+6NJl6q9eP4NAD2iuzXJUU4OlB0nQOPAqBaOdE=; b=ZGPaN1yBqSM5ZD1FWirAODWNl/UbI+jTXhs9tzByCks6V9IgghKFV6BKxgv3qGp0OC LKPpFsb23XTpBBAmCMD+kfTkl+t2dKLfzlcrXb22PbnofGukxqYCLwuMPIcWwnoFwqDj /sJ37dR4uLRaCI7oyIbRkCECqINyi4kzoa/+9dkKm0rPFTCY+U/XFvCdwnrpZcZgdDVQ Vlm+0c4lN7HQb4FiIPsCwf9t68htGQdU6rUbeo4Nb8onSqGbT6AFWLpSHbpL43It/Ppo VmaZ9bdw4zzwHN6zljg01X+ekRqRnVKcaO4oT3UQeD9yjfPPiFsrgi2UABOhSzM0djrz 3MYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LgcKxnb4; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s24-20020a656918000000b004770d61d2a9si1803215pgq.120.2022.12.09.07.32.20; Fri, 09 Dec 2022 07:32:36 -0800 (PST) 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=@redhat.com header.s=mimecast20190719 header.b=LgcKxnb4; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230461AbiLIPam (ORCPT + 99 others); Fri, 9 Dec 2022 10:30:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230042AbiLIPa3 (ORCPT ); Fri, 9 Dec 2022 10:30:29 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E6141DF0C for ; Fri, 9 Dec 2022 07:29:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670599768; 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=lr1I/+6NJl6q9eP4NAD2iuzXJUU4OlB0nQOPAqBaOdE=; b=LgcKxnb4gv5dOQSNhENKN70U/S4NbpTQMJfkXPxSnEh7ZL4uE7fGPZBNskcMv84txyIffU SrS/RGFWmK7FPwv/PNuD/RChW7LV1ocX0MGu80VrDJTU7jORcBukNj/hPixgMAaoet59WX t34Vq4ew0SpyQaR3uRxaoYdrHJgBCAc= Received: from mail-yw1-f200.google.com (mail-yw1-f200.google.com [209.85.128.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-1-SLF0HJu_Mneq5wBRveorrA-1; Fri, 09 Dec 2022 10:29:27 -0500 X-MC-Unique: SLF0HJu_Mneq5wBRveorrA-1 Received: by mail-yw1-f200.google.com with SMTP id 00721157ae682-37360a6236fso53867927b3.12 for ; Fri, 09 Dec 2022 07:29:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lr1I/+6NJl6q9eP4NAD2iuzXJUU4OlB0nQOPAqBaOdE=; b=DWmJIsLESSZUjTF9qFSycZY4gpcoCVvVkaVdaihQmuVDNLn/3GDU+EDT9arDs5ZK7F 6TCKLB/HN6DFlJdHrxoQxw5ZQ4q9lnW88pm0Xy0qqBOSafRNT//e59KAs+vBv4EGK0gz jV9Qs6EiBQfMxFYywQsGWfSrTr0p1nEukkaje4/E+7osMf9s6foHdm5Ve433zTSVBLKm Dy+tmaqlWjL9fB6zqMpcCxsv6VfcznS6DGiXHxtINs5YXZwR/VsOmcb76UUWmXRokwGs 2pJ1iJTfFtCGjTW6vVKS4QWFKSSbFPeVQQ7ZpBYzB4/LxZaxEm+udhzVSNP8kkRv7zxH JYCg== X-Gm-Message-State: ANoB5pmDA1fFj2yG1P6MsDjJLhRA9kNNgaMFZuPzfhxPz1SfagvYkj4j NyK6XvZrS0PePljLcOZUhZJmRNQ/MT2uWT/JmAFnmzkIQuljvS6eZNBiVHc7/gEKPg3LTyi9MTK wLDTVDyy69yVGqsvyGCPf2Ww= X-Received: by 2002:a25:3c1:0:b0:711:a37b:d738 with SMTP id 184-20020a2503c1000000b00711a37bd738mr4987646ybd.1.1670599766788; Fri, 09 Dec 2022 07:29:26 -0800 (PST) X-Received: by 2002:a25:3c1:0:b0:711:a37b:d738 with SMTP id 184-20020a2503c1000000b00711a37bd738mr4987629ybd.1.1670599766591; Fri, 09 Dec 2022 07:29:26 -0800 (PST) Received: from klayman.redhat.com (net-2-34-28-158.cust.vodafonedsl.it. [2.34.28.158]) by smtp.gmail.com with ESMTPSA id dt26-20020a05620a479a00b006fbf88667bcsm29484qkb.77.2022.12.09.07.29.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Dec 2022 07:29:26 -0800 (PST) From: Marco Pagani To: Dinh Nguyen , Michael Turquette , Stephen Boyd Cc: Marco Pagani , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/6] clk: socfpga: arria10: use of_clk_add_hw_provider and improve error handling Date: Fri, 9 Dec 2022 16:29:11 +0100 Message-Id: <20221209152913.1335068-5-marpagan@redhat.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221209152913.1335068-1-marpagan@redhat.com> References: <20221209152913.1335068-1-marpagan@redhat.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751750917263050843?= X-GMAIL-MSGID: =?utf-8?q?1751751019495786085?= The function of_clk_add_provider() has been deprecated, so use its suggested replacement of_clk_add_hw_provider() instead. Since of_clk_add_hw_provider() can fail, like of_clk_add_provider(), check its return value and do the error handling. The indentation of the init function parameters has been aligned to match open parenthesis as suggested by checkpatch. Signed-off-by: Marco Pagani --- drivers/clk/socfpga/clk-gate-a10.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/drivers/clk/socfpga/clk-gate-a10.c b/drivers/clk/socfpga/clk-gate-a10.c index 7cdf2f07c79b..06f129c160bc 100644 --- a/drivers/clk/socfpga/clk-gate-a10.c +++ b/drivers/clk/socfpga/clk-gate-a10.c @@ -40,7 +40,7 @@ static struct clk_ops gateclk_ops = { }; static void __init __socfpga_gate_init(struct device_node *node, - const struct clk_ops *ops) + const struct clk_ops *ops) { u32 clk_gate[2]; u32 div_reg[3]; @@ -94,13 +94,25 @@ static void __init __socfpga_gate_init(struct device_node *node, socfpga_clk->hw.hw.init = &init; hw_clk = &socfpga_clk->hw.hw; - if (clk_hw_register(NULL, hw_clk)) { - kfree(socfpga_clk); - return; + rc = clk_hw_register(NULL, hw_clk); + if (rc) { + pr_err("Could not register clock:%s\n", clk_name); + goto err_clk_hw_register; } - rc = of_clk_add_provider(node, of_clk_src_simple_get, hw_clk); - if (WARN_ON(rc)) - return; + + rc = of_clk_add_hw_provider(node, of_clk_hw_simple_get, hw_clk); + if (rc) { + pr_err("Could not register clock provider for node:%s\n", + clk_name); + goto err_of_clk_add_hw_provider; + } + + return; + +err_of_clk_add_hw_provider: + clk_hw_unregister(hw_clk); +err_clk_hw_register: + kfree(socfpga_clk); } void __init socfpga_a10_gate_init(struct device_node *node) From patchwork Fri Dec 9 15:29:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Pagani X-Patchwork-Id: 31835 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp843054wrr; Fri, 9 Dec 2022 07:33:16 -0800 (PST) X-Google-Smtp-Source: AA0mqf5DdMSxAQGXjwTPGEJOjW5GXcvxUkSdpN2zNSlV0KDuEmGOFwRG5Yx/BI/VcPo4DCoYcJ6H X-Received: by 2002:a05:6a21:e31b:b0:ac:7a44:db5e with SMTP id cb27-20020a056a21e31b00b000ac7a44db5emr8328797pzc.31.1670599995751; Fri, 09 Dec 2022 07:33:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670599995; cv=none; d=google.com; s=arc-20160816; b=guPVYXD4to6HcFe26VixY6u96XZgXrPR1pZvNpntL9I0ypatOs135X/hSIuk1PqIsf iFYH0OwNjfZzLcdEiBxbbCDL7wZls1XF2XPBff+dDdq30j4aNIyjF0MsWPSy/CAa7ogu FpI6Ci1HPXIxyGeVuN9NqPHFmeEFK1IxrCBc1CH9+mWcVJnae/jmddoTPufyjNhM8bdk KuRwn1nabwYF4SVPSSOMXdZ7jwIIRE/8MqwkKy0v2CvYjD56s2Uf9LS4jEQ5iHAOiFyR pmn3HCOsjyXOoJCEcMyiG4wO6Tm1IYTfumt822SZuDKCQIf/IFKWd0xiDLMUhtAQ9n/C e3Fw== 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=78ekr5iKDc85J9/69t3GPkuuIlp1L5lRDkKcFj8Hw1M=; b=SMUMLuho6/7ywRg2yXC2lQjm6h6o+1umsLmVqCXwFoLHC1QKg3OzPvxpCS4f25yjwT ygG4fy2/q8qdEP8FPC6nAcwItPvZOvOL241DJD8cOYIC9yxFTTuaLAtuccLUo9WlE7hF /4CmOMt/aAWghvOjKLFFGgPq6GcFjSm7T3q7YXocApY/X01K1pzqAJNV3JROK6iyB9q8 LShKL4ejgFNxbphuylKyFhRoqP5ZsumxsxN0HRGe6IgVyMB+Jb2OTGSMxxfDYauq0zN7 8z26DNjwCTqjCSX2JLPU8ndpVgYRPNCpuHTAUZCZ/Kc6+lzim8qXKyzL2URSZ/wbn5BT NTcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AuaCXJ2D; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b196-20020a6334cd000000b004785b66be7bsi1890252pga.89.2022.12.09.07.33.00; Fri, 09 Dec 2022 07:33:15 -0800 (PST) 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=@redhat.com header.s=mimecast20190719 header.b=AuaCXJ2D; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230425AbiLIPax (ORCPT + 99 others); Fri, 9 Dec 2022 10:30:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230375AbiLIPae (ORCPT ); Fri, 9 Dec 2022 10:30:34 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4381C6300 for ; Fri, 9 Dec 2022 07:29:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670599770; 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=78ekr5iKDc85J9/69t3GPkuuIlp1L5lRDkKcFj8Hw1M=; b=AuaCXJ2DWcXa5wttcxjJ2h07eyUZwnecU9FjiML8k0wLsbmmrdTnXnQopHTRU+QnQEgnvL xhGL9pfZNWSwaVvvvWgQDKkQLuL6O4sQ+L2vs15saEiJhk3yQyGRKXSANcPloqrrqWecT1 iu1xiBTow8SacjhB8bDw/4BJ/ywb7QQ= Received: from mail-vs1-f72.google.com (mail-vs1-f72.google.com [209.85.217.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-39-S6JZRdKfOMSJwZ7DsVklBQ-1; Fri, 09 Dec 2022 10:29:29 -0500 X-MC-Unique: S6JZRdKfOMSJwZ7DsVklBQ-1 Received: by mail-vs1-f72.google.com with SMTP id n129-20020a677287000000b003b0e74e6491so1338133vsc.19 for ; Fri, 09 Dec 2022 07:29:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=78ekr5iKDc85J9/69t3GPkuuIlp1L5lRDkKcFj8Hw1M=; b=wFrWfITfk2tIh1ukE9+Imw/zZInQODVwMplOB8DU38Jv5UeZ6ZTjf/5sIyqUMXlRoZ +SV3q6VpFmwtQNARWM83K1u9tTvq7Lgz25BI9Es0LoQV4Gp4O2DjVStl2qeyuwiUitZA 2RwfhnTk8Txn8Yg994CPKZPJPT1vkIm3VRXTr9dkatIcsmPuuiwPvSZqNacr3RiMAYIg j+hQDTXHM6QKBCKBvlWQ9lzzd+2oeyhYYWDFWbiixytirO8uejbF3T4zHz9DJBoR9DnV Z0jZI7fhOyQjNO8Y2fF1r6xj3NjqVNdPCCFfDJlzS0i8t3flR7tEDQK56wnUHtyDBMWA qGdA== X-Gm-Message-State: ANoB5pmw6LQqpEPm0w719MUuIJP/qrMnNCfiiVYVYcEquXl6k4X8IHlf EFiQ1BlYYVz6z0qI/e8esgzYHlDwqDxi/RYxPbPgs8nqX4HnyptYGJrD63dwftcu6lYItpsnucv CxHtYORhNkQZANA3T+PdUfBM= X-Received: by 2002:a05:6102:21a6:b0:3b1:33e5:5acb with SMTP id i6-20020a05610221a600b003b133e55acbmr2993341vsb.13.1670599768581; Fri, 09 Dec 2022 07:29:28 -0800 (PST) X-Received: by 2002:a05:6102:21a6:b0:3b1:33e5:5acb with SMTP id i6-20020a05610221a600b003b133e55acbmr2993326vsb.13.1670599768371; Fri, 09 Dec 2022 07:29:28 -0800 (PST) Received: from klayman.redhat.com (net-2-34-28-158.cust.vodafonedsl.it. [2.34.28.158]) by smtp.gmail.com with ESMTPSA id dt26-20020a05620a479a00b006fbf88667bcsm29484qkb.77.2022.12.09.07.29.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Dec 2022 07:29:27 -0800 (PST) From: Marco Pagani To: Dinh Nguyen , Michael Turquette , Stephen Boyd Cc: Marco Pagani , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/6] clk: socfpga: use of_clk_add_hw_provider and improve error handling Date: Fri, 9 Dec 2022 16:29:12 +0100 Message-Id: <20221209152913.1335068-6-marpagan@redhat.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221209152913.1335068-1-marpagan@redhat.com> References: <20221209152913.1335068-1-marpagan@redhat.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751750907830517314?= X-GMAIL-MSGID: =?utf-8?q?1751751061060985640?= The function of_clk_add_provider() has been deprecated, so use its suggested replacement of_clk_add_hw_provider() instead. Since of_clk_add_hw_provider() can fail, like of_clk_add_provider(), check its return value and do the error handling. The return type of the init function has been changed to void since the return value was not used, and the indentation of the parameters has been aligned to match open parenthesis, as suggested by checkpatch. The err variable has been renamed rc for consistency. Signed-off-by: Marco Pagani --- drivers/clk/socfpga/clk-pll.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/drivers/clk/socfpga/clk-pll.c b/drivers/clk/socfpga/clk-pll.c index 127cc849c5ee..9dcc1b2d2cc0 100644 --- a/drivers/clk/socfpga/clk-pll.c +++ b/drivers/clk/socfpga/clk-pll.c @@ -70,8 +70,8 @@ static const struct clk_ops clk_pll_ops = { .get_parent = clk_pll_get_parent, }; -static __init struct clk_hw *__socfpga_pll_init(struct device_node *node, - const struct clk_ops *ops) +static void __init __socfpga_pll_init(struct device_node *node, + const struct clk_ops *ops) { u32 reg; struct clk_hw *hw_clk; @@ -80,13 +80,13 @@ static __init struct clk_hw *__socfpga_pll_init(struct device_node *node, const char *parent_name[SOCFPGA_MAX_PARENTS]; struct clk_init_data init; struct device_node *clkmgr_np; - int err; + int rc; of_property_read_u32(node, "reg", ®); pll_clk = kzalloc(sizeof(*pll_clk), GFP_KERNEL); if (WARN_ON(!pll_clk)) - return NULL; + return; clkmgr_np = of_find_compatible_node(NULL, NULL, "altr,clk-mgr"); clk_mgr_base_addr = of_iomap(clkmgr_np, 0); @@ -108,13 +108,25 @@ static __init struct clk_hw *__socfpga_pll_init(struct device_node *node, hw_clk = &pll_clk->hw.hw; - err = clk_hw_register(NULL, hw_clk); - if (err) { - kfree(pll_clk); - return ERR_PTR(err); + rc = clk_hw_register(NULL, hw_clk); + if (rc) { + pr_err("Could not register clock:%s\n", clk_name); + goto err_clk_hw_register; } - of_clk_add_provider(node, of_clk_src_simple_get, hw_clk); - return hw_clk; + + rc = of_clk_add_hw_provider(node, of_clk_hw_simple_get, hw_clk); + if (rc) { + pr_err("Could not register clock provider for node:%s\n", + clk_name); + goto err_of_clk_add_hw_provider; + } + + return; + +err_of_clk_add_hw_provider: + clk_hw_unregister(hw_clk); +err_clk_hw_register: + kfree(pll_clk); } void __init socfpga_pll_init(struct device_node *node) From patchwork Fri Dec 9 15:29:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Pagani X-Patchwork-Id: 31830 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp841798wrr; Fri, 9 Dec 2022 07:30:58 -0800 (PST) X-Google-Smtp-Source: AA0mqf41XfSu3o+lX1mtY2P1iUDWGYiapuFwY4jb2wx5aRGT/pQBR/l8BQ9pYfdPp8x5Z3Ss5NFj X-Received: by 2002:a17:903:48c:b0:189:5e07:80f7 with SMTP id jj12-20020a170903048c00b001895e0780f7mr6557158plb.51.1670599858637; Fri, 09 Dec 2022 07:30:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670599858; cv=none; d=google.com; s=arc-20160816; b=gQQA23Acrrxv27n6ORY5vEnpsqYyV5PPzo49WBK2Q4UeZEhQiPnGpbQBL7pMDqgLPO EccNYD1AgJha3ETXoA8IBhha9uchN40HtSgNyAezFmkt092ad6CcXopraGeq80IVSccH 5yyowgMs/AUBhulF5i93vC3avNNJPAUzVkyaax5SL8o35VAlJ86Q0mjRgasgSbFlzJVn 6gY3PmDfdrj3OaiSpuu7NVPvbUk1Cop2Ji/bKqf/l4r+IpXGICBLWCcnHIkrT5jhHyYh WgRel6qtrKZkhK0gM3ZOEBptas+P0N81H4Q3UWxrJI6J8XOCayDZdgY6PT3KEHgGlGoE i1xg== 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=iLUYz9gKiHY3ndA68I5cW74nts6kf3HnnSAI7CDyETY=; b=xKtoKd8Kmx+uepI9JOCi33h3QUeBWkj8duzK5JrsRw0Hx2WdpW6wW4j3itsrEBsZWt 0xhI26SdLL6NWPhKSMJH5E9gJtp02xU1TlOUamBHlWPpubKQi9r8wXYbD/3i+E+k3UN6 Zj4S2Fw7fkBgplVCwcSfm4DQKwir+kCTsEIOStrSclgEbSWyEE0kkhmFvM0CkO6VdaLw Ww7MzG0IGbWI0crc3j9uGVV6euOBepyObUZDnJG5U84s2EdtB1Ctb5axSlHE8FRGiw55 MG42DQS9a4IalqM1/SkGPrZ4XeZBkXapPStgIqyAhoV/U0Hok2p29nm/dkijHHlJuhsM sv+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dYIQ3XzW; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u3-20020a17090341c300b00189655d51f5si1291378ple.260.2022.12.09.07.30.43; Fri, 09 Dec 2022 07:30:58 -0800 (PST) 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=@redhat.com header.s=mimecast20190719 header.b=dYIQ3XzW; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229512AbiLIPaa (ORCPT + 99 others); Fri, 9 Dec 2022 10:30:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229759AbiLIPa0 (ORCPT ); Fri, 9 Dec 2022 10:30:26 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8986E1E3C8 for ; Fri, 9 Dec 2022 07:29:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670599771; 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=iLUYz9gKiHY3ndA68I5cW74nts6kf3HnnSAI7CDyETY=; b=dYIQ3XzWmwC+AzjFzcO3lS9fD1YTx5k63ME7n5BVhRpcQdiZfrnA6SVcaRvEC2upUyu1Z/ oIOsQm+eq+WIbzkCmwV9yRJjIa/q8oZklz4MfgkD8Gekrw8yeGy/izC2EjLOPzXZlKnwEd 3tct3b1EWrLf9XQuGo4Q4pJkmc49Itc= Received: from mail-vs1-f71.google.com (mail-vs1-f71.google.com [209.85.217.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-185-YveCQ8BnOKWSlsd-qdT_gA-1; Fri, 09 Dec 2022 10:29:30 -0500 X-MC-Unique: YveCQ8BnOKWSlsd-qdT_gA-1 Received: by mail-vs1-f71.google.com with SMTP id 190-20020a6719c7000000b003aa14ac75f5so1321656vsz.1 for ; Fri, 09 Dec 2022 07:29:30 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iLUYz9gKiHY3ndA68I5cW74nts6kf3HnnSAI7CDyETY=; b=ZNcEUNRC1JZVZ6oNEAQmMDsb2geG92PHfoxDZXSwufmpQ/0K+gpWWlxkk1XFbXKHkA rNsLjju88Z7eFj+qxu6wN0EHv2D+APnN5dvC0Fynhep4mYOSUEfoODEmmURRj6r015fP XVYOlqTbsd3nI6kwfK5ztw0Y/pFyClNM6y6FqK+IHbl90Yw19ykcHdSg8djafrtE+72r GwTpShpprc2SnzFs4SmhiQuUHeLlrbEhT6nzaPB+rM2M2sWZCPB0+hl65vEviz0wmIHK CCnT5cs8bNJ5okywZNCz6xIxbrXTUhhqRt6QoojEO0RJMjV/oc8PDAiv/fZ2+E10lu7g I+gA== X-Gm-Message-State: ANoB5pnt9ZOwqaLId+8yYYwNaoj6A2maixc95rArKp+LZROTEascD9kK LgA+zs42/5c25kkdjqtM6SOoOPJkR/BH02bMRxwgsnaelRaAMjm8BtsUKlWwshOhdA04WHnKlHS +1ShF52gX6GkSAPiU0wP7eHg= X-Received: by 2002:a05:6122:2c5:b0:3bd:b78b:102b with SMTP id k5-20020a05612202c500b003bdb78b102bmr3298744vki.5.1670599770344; Fri, 09 Dec 2022 07:29:30 -0800 (PST) X-Received: by 2002:a05:6122:2c5:b0:3bd:b78b:102b with SMTP id k5-20020a05612202c500b003bdb78b102bmr3298723vki.5.1670599770101; Fri, 09 Dec 2022 07:29:30 -0800 (PST) Received: from klayman.redhat.com (net-2-34-28-158.cust.vodafonedsl.it. [2.34.28.158]) by smtp.gmail.com with ESMTPSA id dt26-20020a05620a479a00b006fbf88667bcsm29484qkb.77.2022.12.09.07.29.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Dec 2022 07:29:29 -0800 (PST) From: Marco Pagani To: Dinh Nguyen , Michael Turquette , Stephen Boyd Cc: Marco Pagani , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 6/6] clk: socfpga: arria10: use of_clk_add_hw_provider and improve error handling Date: Fri, 9 Dec 2022 16:29:13 +0100 Message-Id: <20221209152913.1335068-7-marpagan@redhat.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221209152913.1335068-1-marpagan@redhat.com> References: <20221209152913.1335068-1-marpagan@redhat.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751750917263050843?= X-GMAIL-MSGID: =?utf-8?q?1751750917263050843?= The function of_clk_add_provider() has been deprecated, so use its suggested replacement of_clk_add_hw_provider() instead. Since of_clk_add_hw_provider() can fail, like of_clk_add_provider(), check its return value and do the error handling. The return type of the init function has been changed to void since the return value was not used, and the indentation of the parameters has been aligned to match open parenthesis, as suggested by checkpatch. Signed-off-by: Marco Pagani --- drivers/clk/socfpga/clk-pll-a10.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/drivers/clk/socfpga/clk-pll-a10.c b/drivers/clk/socfpga/clk-pll-a10.c index bee0f7da5b6e..b028f25c658a 100644 --- a/drivers/clk/socfpga/clk-pll-a10.c +++ b/drivers/clk/socfpga/clk-pll-a10.c @@ -63,8 +63,8 @@ static const struct clk_ops clk_pll_ops = { .get_parent = clk_pll_get_parent, }; -static struct clk_hw * __init __socfpga_pll_init(struct device_node *node, - const struct clk_ops *ops) +static void __init __socfpga_pll_init(struct device_node *node, + const struct clk_ops *ops) { u32 reg; struct clk_hw *hw_clk; @@ -73,13 +73,14 @@ static struct clk_hw * __init __socfpga_pll_init(struct device_node *node, const char *parent_name[SOCFGPA_MAX_PARENTS]; struct clk_init_data init; struct device_node *clkmgr_np; + int rc; int i = 0; of_property_read_u32(node, "reg", ®); pll_clk = kzalloc(sizeof(*pll_clk), GFP_KERNEL); if (WARN_ON(!pll_clk)) - return NULL; + return; clkmgr_np = of_find_compatible_node(NULL, NULL, "altr,clk-mgr"); clk_mgr_a10_base_addr = of_iomap(clkmgr_np, 0); @@ -103,12 +104,25 @@ static struct clk_hw * __init __socfpga_pll_init(struct device_node *node, pll_clk->hw.bit_idx = SOCFPGA_PLL_EXT_ENA; hw_clk = &pll_clk->hw.hw; - if (clk_hw_register(NULL, hw_clk)) { - kfree(pll_clk); - return NULL; + rc = clk_hw_register(NULL, hw_clk); + if (rc) { + pr_err("Could not register clock:%s\n", clk_name); + goto err_clk_hw_register; } - of_clk_add_provider(node, of_clk_src_simple_get, hw_clk); - return hw_clk; + + rc = of_clk_add_hw_provider(node, of_clk_hw_simple_get, hw_clk); + if (rc) { + pr_err("Could not register clock provider for node:%s\n", + clk_name); + goto err_of_clk_add_hw_provider; + } + + return; + +err_of_clk_add_hw_provider: + clk_hw_unregister(hw_clk); +err_clk_hw_register: + kfree(pll_clk); } void __init socfpga_a10_pll_init(struct device_node *node)