Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2694479rwl; Mon, 27 Mar 2023 04:07:35 -0700 (PDT) X-Google-Smtp-Source: AKy350YCvsc13IzPKDpxVfPQyBEai42sNHe8iuJDBguOPjwgtAIvtWwJNTbsfMWIROP0rrluXhga X-Received: by 2002:a17:90b:4f47:b0:23d:2f73:d3c8 with SMTP id pj7-20020a17090b4f4700b0023d2f73d3c8mr12941151pjb.42.1679915255472; Mon, 27 Mar 2023 04:07:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679915255; cv=none; d=google.com; s=arc-20160816; b=q0H39IO7K+pNDdaw3hjJLYb19ge9gSf4ez/AUMo7GTaGvssF5TIzIQi0+0RKPRpfYM 7EbpOe4qvRpxY+JKQWSXNdce8WsU6I6p60bvqr3A8mtl+uLjnKBZ39Gzd1Op+oJ1Rhad z7h0QGSpq9tW6r7lK6pwsuvGg3D/74jRIgg99HsgwVWIM8+vh/BCsr7PFzLpFkiZXlvp t/ynzUnntHo6H4WIWIzJJ5xKqGkPwRuXuBWxWW0pSnGrQEHqcCzzB/iLqzOZgJuxq07T ucOQLKVR3Vkza3Wgavlx2uiUWq3YrUhtoh2PxAQ4CQyTW1BVYLWq2AZWwEJtILjQsaBr 1PwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=vdiicdZ5HAVRczpvA6n4mIZFizfClCxz3IRwHSoeFaA=; b=ifjTfz00aLA9Mf9A0T+a/c3NEiK8GKQw4UA9t4KIvJhMCO08QuQJi8ZOYETfv+vmQg ICJm/nNwPBbriExv1b9H9uSybDiiMVCvm1iU+lElQxlw7O/w/WY9U7Ic5RAy+2YfmP7i l4FmQrOFJ3XlJhO+MHQ+yC1+bEDWs3xeydYxktbq2vTLLDNSsaI34CDrP+L23XbJZ+7n /2X12qmISVGTICYMZpw4jESpvhNQfOLntIKDF2R/uOUlR3RVFKMRGn+GpZ5BGkHeqgUR +uPHmJbhv9fUXhmQAqC6V0NFdCTQ9m6xZE1/81xXC9qcPwGOHostXT7ig7ofeuz1Fo4J iCeg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j7-20020a17090a7e8700b0023747b24923si9843135pjl.53.2023.03.27.04.07.22; Mon, 27 Mar 2023 04:07:35 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232252AbjC0LEX (ORCPT + 99 others); Mon, 27 Mar 2023 07:04:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232231AbjC0LEU (ORCPT ); Mon, 27 Mar 2023 07:04:20 -0400 Received: from fd01.gateway.ufhost.com (fd01.gateway.ufhost.com [61.152.239.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FE574483; Mon, 27 Mar 2023 04:04:11 -0700 (PDT) Received: from EXMBX165.cuchost.com (unknown [175.102.18.54]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "EXMBX165", Issuer "EXMBX165" (not verified)) by fd01.gateway.ufhost.com (Postfix) with ESMTP id 606B524E114; Mon, 27 Mar 2023 19:04:04 +0800 (CST) Received: from EXMBX171.cuchost.com (172.16.6.91) by EXMBX165.cuchost.com (172.16.6.75) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Mon, 27 Mar 2023 19:04:04 +0800 Received: from [192.168.125.108] (113.72.145.117) by EXMBX171.cuchost.com (172.16.6.91) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Mon, 27 Mar 2023 19:04:03 +0800 Message-ID: <20774e11-b7d4-e895-13f1-ea6dad130e4e@starfivetech.com> Date: Mon, 27 Mar 2023 19:04:02 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [PATCH v3 4/5] usb: cdns3: add StarFive JH7110 USB driver. Content-Language: en-US To: Philipp Zabel , Emil Renner Berthing , Conor Dooley , "Vinod Koul" , Kishon Vijay Abraham I , "Rob Herring" , Krzysztof Kozlowski , Pawel Laszczak , Greg Kroah-Hartman , Peter Chen , Roger Quadros CC: , , , , , Paul Walmsley , Palmer Dabbelt , Albert Ou References: <20230315104411.73614-1-minda.chen@starfivetech.com> <20230315104411.73614-5-minda.chen@starfivetech.com> <2c99725a0bf259203a5b00f4c752eeb1b6596f59.camel@pengutronix.de> From: Minda Chen In-Reply-To: <2c99725a0bf259203a5b00f4c752eeb1b6596f59.camel@pengutronix.de> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [113.72.145.117] X-ClientProxiedBy: EXCAS063.cuchost.com (172.16.6.23) To EXMBX171.cuchost.com (172.16.6.91) X-YovoleRuleAgent: yovoleflag X-Spam-Status: No, score=-0.0 required=5.0 tests=NICE_REPLY_A, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS 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 On 2023/3/23 17:29, Philipp Zabel wrote: > On Mi, 2023-03-15 at 18:44 +0800, Minda Chen wrote: >> There is a Cadence USB3 core for JH7110 SoCs, the cdns >> core is the child of this USB wrapper module device. >> >> Signed-off-by: Minda Chen >> --- > [...] >> diff --git a/drivers/usb/cdns3/cdns3-starfive.c b/drivers/usb/cdns3/cdns3-starfive.c >> new file mode 100644 >> index 000000000000..a99f98f85235 >> --- /dev/null >> +++ b/drivers/usb/cdns3/cdns3-starfive.c >> @@ -0,0 +1,305 @@ > [...] >> +static int cdns_clk_rst_init(struct cdns_starfive *data) >> +{ >> + int ret; >> + >> + data->num_clks = devm_clk_bulk_get_all(data->dev, &data->clks); >> + if (data->num_clks < 0) >> + return dev_err_probe(data->dev, -ENODEV, >> + "Failed to get clocks\n"); >> + >> + ret = clk_bulk_prepare_enable(data->num_clks, data->clks); >> + if (ret) >> + return dev_err_probe(data->dev, ret, >> + "failed to enable clocks\n"); > > In general, it's better to acquire all resources first and only then > start interacting with them, and to order all devm_ calls before non- > devm calls to make sure cleanup is done in reverse order. > > In this case you can switch clk_bulk_prepare_enable() with > devm_reset_control_array_get_exclusive() and simplify the error path. > OK, thanks >> + data->resets = devm_reset_control_array_get_exclusive(data->dev); >> + if (IS_ERR(data->resets)) { >> + ret = dev_err_probe(data->dev, PTR_ERR(data->resets), >> + "Failed to get resets"); >> + goto err_clk_init; >> + } >> + >> + ret = reset_control_deassert(data->resets); >> + if (ret) { >> + ret = dev_err_probe(data->dev, ret, >> + "failed to reset clocks\n"); >> + goto err_clk_init; >> + } >> + >> + return ret; >> + >> +err_clk_init: >> + clk_bulk_disable_unprepare(data->num_clks, data->clks); >> + return ret; >> +} > > regards > Philipp