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); }