Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp4139199rwb; Mon, 21 Nov 2022 04:19:50 -0800 (PST) X-Google-Smtp-Source: AA0mqf5oKM/ccbI5r2VrHYtwp8XBG2h+BRDICtLFX1c4qgz4U7k5Qw/w3eewYDGgof2MKbslabnZ X-Received: by 2002:a17:902:ca92:b0:188:ef29:fe0e with SMTP id v18-20020a170902ca9200b00188ef29fe0emr211793pld.143.1669033189967; Mon, 21 Nov 2022 04:19:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669033189; cv=none; d=google.com; s=arc-20160816; b=GoR25dV9R1yVp2m0h5crM+0Rrdb39diLfvVAM2Rw1j3BMVZ3kIZ1Tvdcq4tolSTglt gk/Vq6c1RCrs0zQGnQW5T1rs95TZhTAEyorO2BtHym0EkboyUxLtqxZFw8gIcIPp1+lV VTGulD2nwpNsI1LT2ogTA/XO4w96x9xhy7sAKtyu2J2MN41klb3ZqBhijh5xWIXwsUYh ukeT2pyEV9lWrOhkP29Yh29sd3EXdLt4gPmQWZfhqS4zqcKpBSP30wnxCXLXNXc5N6Qx PQxvpMZ2Tk6aExG9IfoR5CsZiQ+lMVcon76zNpIEXX6IRQwGOHKqzXbYu8NGnQzAKqnb Mzfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=nVDeZyW08L6nlsmG9j40la0+32+2f6F/+Ex3JCMFolQ=; b=UTtp5H4PV2+tY+3c4yNy1XEvLM1kb4nb0gV9Ya0/bkbuLtCTMfHudRM9DATcHKKt9e ziJttRGnwCEhlu3qZzsdtZQCzndjfAdjai6i+P6IgEUjjQL2LUBjOz44Qb3xzRp34vi+ DOiTNLeN93pjfAH3FO9XGU5yc5iazBlOCR2DVzo3oXcmnlRAYIa3JTOdM4nQQWtSnbwq voPSLaIeYSB/3oU/Pni76ayFR19h2BrAYIxhfcZujEO9esJBjYuo2PgVQaUgI7UPkJYk COSV6GHw/XXJaGEeAlgqpsCjeIXTXFAU9V6G1vqXSK8WRfiQOrd2I/Caq4ZOgWmt0VW5 nYsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=RMHBFopq; 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=canonical.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w4-20020a170902904400b00183a85a9b54si9889083plz.279.2022.11.21.04.19.35; Mon, 21 Nov 2022 04:19:49 -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=@canonical.com header.s=20210705 header.b=RMHBFopq; 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=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230353AbiKULcm (ORCPT + 92 others); Mon, 21 Nov 2022 06:32:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231414AbiKULcH (ORCPT ); Mon, 21 Nov 2022 06:32:07 -0500 Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16D51BFF5C for ; Mon, 21 Nov 2022 03:27:05 -0800 (PST) Received: from mail-yb1-f198.google.com (mail-yb1-f198.google.com [209.85.219.198]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 9A7943F12E for ; Mon, 21 Nov 2022 11:27:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1669030023; bh=nVDeZyW08L6nlsmG9j40la0+32+2f6F/+Ex3JCMFolQ=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=RMHBFopqbrm4ahbWARLygpU613O26PLOhmQ7ewl7YFyhIaYddu0Y4lhaWmxm+5B1b 99pGBB3uWuKGC0p0rKtg2PFT5Wq48e4cSDxqNa1NPvvPdTNrvsb0QxC0TFM0mwHl9n WFLOc0jtTAE2yiXWUWDgHPJSIgwZrJMRPvncPES6hK/ikpwyab+XEPRB3oBW/nHWje e82V0ayXkCL/OUvLHQOdngGvCWR5vH5cy+xf7SLjOdThZX5axpb/cYCeFyh4qDbGIU UYrMh04NcAnkx9nTjAiufQM7qYQBrDE2B3BWU5j5bMYMrzXKrV7l0OZ6w0d5FVGIGm H6fp9UjriSutg== Received: by mail-yb1-f198.google.com with SMTP id o142-20020a257394000000b006eae582c285so3899977ybc.12 for ; Mon, 21 Nov 2022 03:27:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=nVDeZyW08L6nlsmG9j40la0+32+2f6F/+Ex3JCMFolQ=; b=dVWmJcpy2flEQgnr40OTOigK43QYNwjCqfwJsHno+4kVAHef7N85cG7QTAjNViTB1v on6asdPH7bZ2rMPMdqKf9/wCJRQ0bCSQsvZFQqckKkhW1A2Bo4a19cshCykKukg6q4us QUKu9/Ma5V/CyHoMFt2fERT+Nchrh1s8jBB/M3wTkTNXEYa/h/7cPGVXREVfnwv0JmPr azFF1OjQ98HEIrGAnPmeeDyVeQzJqmgHMjenvXqT9KUCNv+JuTkMIb1UKVF0+i9Cdo5O S4JkFBUp1+aZFKvPzJuowqvzpf/Aw3sQzCV+jTl9pZ53L0sigDQF5CwgbDO41+xk86SL tXJQ== X-Gm-Message-State: ANoB5pnPXC+EtdCpVhwrWUm3hMlq92iR3/hdjc1YmpJNzRaKi/Qxh+l1 Nvec8UyqzC/vrC4hEUC5DLJm5elPxSJ35MhgHTD2eW8L/0cwyUacUUAsL4jGp1emkc0ZCBdZUZJ 3DSqrosIeYXKZZcZUCn3LskRIaKzWdzGuFDrTrswj8mKxiwcXtS4GMdfZtQ== X-Received: by 2002:a81:7287:0:b0:36d:451:1ae3 with SMTP id n129-20020a817287000000b0036d04511ae3mr17133994ywc.412.1669030022444; Mon, 21 Nov 2022 03:27:02 -0800 (PST) X-Received: by 2002:a81:7287:0:b0:36d:451:1ae3 with SMTP id n129-20020a817287000000b0036d04511ae3mr17133979ywc.412.1669030022234; Mon, 21 Nov 2022 03:27:02 -0800 (PST) MIME-Version: 1.0 References: <20221118010627.70576-1-hal.feng@starfivetech.com> <20221118010627.70576-5-hal.feng@starfivetech.com> <4dd7ebaf-89db-3c22-e8bc-e9f7211fa06b@starfivetech.com> In-Reply-To: <4dd7ebaf-89db-3c22-e8bc-e9f7211fa06b@starfivetech.com> From: Emil Renner Berthing Date: Mon, 21 Nov 2022 12:26:45 +0100 Message-ID: Subject: Re: [PATCH v2 04/14] reset: starfive: Factor out common JH71X0 reset code To: Hal Feng Cc: "linux-riscv@lists.infradead.org" , "devicetree@vger.kernel.org" , "linux-clk@vger.kernel.org" , Conor Dooley , Palmer Dabbelt , Rob Herring , Krzysztof Kozlowski , Stephen Boyd , Michael Turquette , Philipp Zabel , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 Mon, 21 Nov 2022 at 10:24, Hal Feng wrote: > > On Sat, 19 Nov 2022 00:39:35 +0800, Emil Renner Berthing wrote: > > On Fri, 18 Nov 2022 at 02:06, Hal Feng wrote: > > > diff --git a/drivers/reset/starfive/reset-starfive-jh7100.c b/drivers/reset/starfive/reset-starfive-jh71x0.c > > > similarity index 50% > > > copy from drivers/reset/starfive/reset-starfive-jh7100.c > > > copy to drivers/reset/starfive/reset-starfive-jh71x0.c > > > index fc44b2fb3e03..1e230f3f9841 100644 > > > --- a/drivers/reset/starfive/reset-starfive-jh7100.c > > > +++ b/drivers/reset/starfive/reset-starfive-jh71x0.c > > [...] > > > > -static int __init jh7100_reset_probe(struct platform_device *pdev) > > > +int reset_starfive_jh7100_register(struct device *dev, struct device_node *of_node, > > > + void __iomem *assert, void __iomem *status, > > > + const u64 *asserted, unsigned int nr_resets, > > > + bool is_module) > > > { > > > struct jh7100_reset *data; > > > > > > - data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); > > > + data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); > > > if (!data) > > > return -ENOMEM; > > > > > > - data->base = devm_platform_ioremap_resource(pdev, 0); > > > - if (IS_ERR(data->base)) > > > - return PTR_ERR(data->base); > > > - > > > data->rcdev.ops = &jh7100_reset_ops; > > > - data->rcdev.owner = THIS_MODULE; > > > - data->rcdev.nr_resets = JH7100_RSTN_END; > > > - data->rcdev.dev = &pdev->dev; > > > - data->rcdev.of_node = pdev->dev.of_node; > > > + if (is_module) > > > + data->rcdev.owner = THIS_MODULE; > > > > nit: consider just passing the owner directly, so this would just be > > data->rcdev.owner = owner; > > > > ..and callers that used false can just pass NULL. > > Yeah, will fix it. > > > > > > + data->rcdev.nr_resets = nr_resets; > > > + data->rcdev.dev = dev; > > > + data->rcdev.of_node = of_node; > > > > Is it important to register this with the auxiliary device and not > > just use the parent device? > > I'm not sure whether it still works if we use the same device, Try it. > but > it's general to separate the devices of clock and reset. They have > different device names and different drivers. > > Best regards, > Hal > > > If not you can just always pass the device that has the right of_node > > and have this be > > > > data->rcdev.of_node = dev->of_node; > > > > > + > > > spin_lock_init(&data->lock); > > > + data->assert = assert; > > > + data->status = status; > > > + data->asserted = asserted; > > > > > > - return devm_reset_controller_register(&pdev->dev, &data->rcdev); > > > + return devm_reset_controller_register(dev, &data->rcdev); > > > } >