Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp7320614rwl; Thu, 23 Mar 2023 02:39:16 -0700 (PDT) X-Google-Smtp-Source: AK7set/2u218cUq7V2JgZvmKwFc8SG38N2qhqA/HPmjoTJB9A4vnDBDrcVj06u3MGiX38xXlQR/r X-Received: by 2002:a17:90b:4b10:b0:23a:177b:5bfa with SMTP id lx16-20020a17090b4b1000b0023a177b5bfamr7322657pjb.22.1679564356497; Thu, 23 Mar 2023 02:39:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679564356; cv=none; d=google.com; s=arc-20160816; b=rtEu6LPhdtitWWvfImzrKHR9k+p0xhB/l15s/YmWVDrwz8NfDGh486k+ni7QmqWXuS 7iOZ0wLbyVTbGLluwF6sZfqFVya2nHt7W0UqoeVurLTdtfkvHAKT9wZXeQFcrIpKG+bU jtnVRMkHuq1QW3Zit+83VLo2PRan9h4CLeI9FgTyqvXx+vZJYu+/A9RbW7KwAGxjNBRB by6isRwlv3i2aFPexku3/M46dq9o19Xtz3NEw+Mv1PdcFvUdKx+Pm6A9qyKQgOaYx8+q 8AtB7huSmEK98sljb78RRKWKBGyxEvrxxAHbPV7NFtUg3T5kUyUTDe4+uHZVbRbcH2YD 29Og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id; bh=DyC7JIAxH+vkNPX2Q+A2UBc2d2lN5h+eOLAOqSWmLfE=; b=k8T7AgJYmY0qv+A9RqB8/VmxDhQxrrut2Mzm4khFTOXz2bQ6LDmaH1HVXpTUZaU1Vu Etvp+PIycP7AtqwfRYrZUOAzsNILIYwVMPV1FKcdXVO0N4BGxNxYwxRnQ8qM6ZPU59lq A0btTbRxVHV4UbpZhf7izhAp0n0xDKIVqW8iazvjBO5tIhznlqEKHJ6c7vFaIF6UJ4D0 SRynNgpmSx3p4wiGYPWJblLU0askRLEMuPcksSzW4B6k4jxrDK7lV7UMezNBuflABqtA NTY8J5cYTE19yKDAvI83xm4uVH0b7zJRHZ8eNhbRdI/UsC6ffpRgsfLfiOGDotfjnkim pWeg== 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 j20-20020a17090aeb1400b002340e488cc5si1328980pjz.96.2023.03.23.02.39.04; Thu, 23 Mar 2023 02:39:16 -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 S231466AbjCWJd3 convert rfc822-to-8bit (ORCPT + 99 others); Thu, 23 Mar 2023 05:33:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230373AbjCWJc6 (ORCPT ); Thu, 23 Mar 2023 05:32:58 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C8262D173 for ; Thu, 23 Mar 2023 02:30:08 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pfHGP-0005UF-IQ; Thu, 23 Mar 2023 10:29:41 +0100 Received: from [2a0a:edc0:0:900:1d::4e] (helo=lupine) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1pfHGM-0067Mm-BG; Thu, 23 Mar 2023 10:29:38 +0100 Received: from pza by lupine with local (Exim 4.94.2) (envelope-from ) id 1pfHGL-0002ek-J2; Thu, 23 Mar 2023 10:29:37 +0100 Message-ID: <2c99725a0bf259203a5b00f4c752eeb1b6596f59.camel@pengutronix.de> Subject: Re: [PATCH v3 4/5] usb: cdns3: add StarFive JH7110 USB driver. From: Philipp Zabel To: Minda Chen , 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: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org, linux-usb@vger.kernel.org, linux-riscv@lists.infradead.org, Paul Walmsley , Palmer Dabbelt , Albert Ou Date: Thu, 23 Mar 2023 10:29:37 +0100 In-Reply-To: <20230315104411.73614-5-minda.chen@starfivetech.com> References: <20230315104411.73614-1-minda.chen@starfivetech.com> <20230315104411.73614-5-minda.chen@starfivetech.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT User-Agent: Evolution 3.38.3-1+deb11u1 MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: p.zabel@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-2.3 required=5.0 tests=RCVD_IN_DNSWL_MED, SPF_HELO_NONE,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 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. > + 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