From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.44 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795998729; b=4Khz/oW9uS3xIfE+JZE9PLRWHxdKwXh6fFRjLizlSZQ6ZODWDNQ2PYHH0/BKNWeGntB5 rLnhR2o8FxSDDbKcGJrDc+9Kag6g8u4VJrRb17Mo1mxAaCr6Juvs8bNTZWExbce9Q1zCM VkgogKs2P8ClfVRlwfjsxWiZghM0+i3yo+dfYKIVNUCcn1YXDVwP+nSutvgUWlAMM6Wbl LUchmw/pXIvv+kJi5S5mPKrebfAaftlpIGp5yBZ7Hd9ZU6LkYrBnkBosS2MDGEGF21WBe PQvGGsM+fH1VqRcXn6biT5R/6bJHzPbq2xuxjVsmDIFNUjiWiDqpdzAHDie963fwkZQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795998729; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Message-ID:X-Google-Original-Message-ID:Date:From:To:Cc:Subject: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=h61+6NXfVzfmubiopTJKKbuKAljTVR7CN8a6TVBpqnc=; b=HZW7jsOtwslrzMRirJnKl7WA6SZXDInlTMLsf9Cs+e7b8AWHj3iWlzB2U7ocEPOr0ygR 3Qz+JKgxeotJotMyUuxAl/RTTuQiagUZib2alN9Ltc2FjYQkfzIZHd2UaW5nsTGTGk++L dLiKYsx1NOjBX642+pJoYjtte83h86znh8fdqi5lK8nM9T10tcoGbdhS8c22jmWJDy25v a3JYNkgmwda+eQsbM+Hxn50kZ2nas7J2vtOXNVprjaQxBGbZNvnudLbyS+6vw+gp4PD5t 43oGLO/kKz+taZ0U7SnSNSudvR9P1ITRA5r2CQ0vFxGOZO+JEvlplRBvU0vk4YvYXvg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=e1pHJM+L; arc=none smtp.remote-ip=209.85.221.44 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0777C606A325 for ; Mon, 30 Nov 2026 00:32:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0777C606A325 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=e1pHJM+L Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-4aa5833c263so9575849f8f.2 for ; Sun, 29 Nov 2026 16:32:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795998726; x=1796603526; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:subject:cc:to:from:date:message-id:from:to:cc:subject :date:message-id:reply-to:content-type; bh=h61+6NXfVzfmubiopTJKKbuKAljTVR7CN8a6TVBpqnc=; b=e1pHJM+LwqXZJlKjIobsJielQpgTlT7n/SX5vqnqWg17kK7I4kkoYob8QHuVAi2jSG IQ8NFk9ki2KPgrOmK4wZGoB7KzuI+ccCLPdiEj53XtBZ8UMoMyiZk1JEG5dyfBgYUavk /6pi2DFuI+1CB/mxSltJJqB+fViuTV2KE3/3OgCTowU722+SiCkyZ6ZTjBWtcmKec/Jp Rs8U2ObbiNvHm+a7OssV1+h0wWKKi07z9gsqTqE721dB2pzdz9mPR2sTsKD99dkbuN8B lTpHKH2r4d5gnrn6hbe1/wtNFhSAxvo93sJQPV7foZINJCNRLSenZbTOFQZYXscFT6AW +faw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795998726; x=1796603526; h=in-reply-to:content-disposition:content-type:mime-version :references:subject:cc:to:from:date:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=h61+6NXfVzfmubiopTJKKbuKAljTVR7CN8a6TVBpqnc=; b=kJQSKJ48yiXX61cYF8Gd06d4lv/mQQS0HijT8aCPrO1jpuCZb1Dan3ZspBUrkkUnGk x/nC7WrGitFppA927LozvTfHuOL4Jzbv2bcBkZU0dSvxcZ9ItHD+6fL126D2CCVmmS6L RYhSqi5M2MuN3lS2sinJrRhAYklyXJMDP1VE2QlR3ccjtP0NngV9Yr4K57y+KZvuUM7i IabAvw9WhYF4tHCGQZ2C9wU29EpZNTC4FIpCJygDWVUlrLl5g6rq+mvMJj7S59rhfKtd gp20Gh8sdTBmWxYJI1PeLtx8Eb76QK7LV11Lf+zJD2+2Cf1y5FZA0IHTuc53tjmn+3vo 8DBQ== X-Forwarded-Encrypted: i=1; AL+hErGEBKiN0QdBpFo2hRsN/mKqeUDAkSvVAvIvcC/j5pE/Mt2gpAluk5glP990hf2Koq5VFiWrAldABpx8pY4=@vger.kernel.org X-Gm-Message-State: APuU4Z+AKutZji6371RzN91Aio6GGmA0MPAdWqbei4yqnaglgu5XZzfz QFnPGLhG1MwEbE15uiJ9hpc4rpFvh7+zR+XqIJOUSuqAYjICy8ZKhTGe X-Gm-Gg: AZFdTZf8CbetpT1VSxveuqQmbaRFiE6adVu+B/KxZjRt+I6tKLOMIonNIJt4+ULOlRK 7rQVlIlcO1txGjmpUB3vgCkE6M7wNwWAGFDqjo1nfBQJIIxxQHeQ4G52XUxGkUcYoGGmOJ5Ot2B 7JUNBUNqQsuydjZl6o3gy+IeWr7rSh8eKYL0W7H/wzuXx4qT1wHP4+0ZT279sxAWq9rgIdKc7eh 71TW/c8+f79zTwrMO9GY9q2/0uEz3Bhm7vjNZb8Lu0HbocXJJKA97gWnv+VlHN+WG9rGBZDOOiM Dy+aMU4Mttek85gHN37d9B8BUYRb4IiWEPipO1g9j20nMJOJ19vr2vg865zXJKm9z427PV8BqX2 zQT+rn+hr4AFR0g2/YwPdTYTnRiZd2TpBoWAfvVAuvnRehXwEUM9uaS8E4lziujlOteIhlbApR8 tEkGafAYl/w92hJ19J4potO+MQmQrBO2vSBlz0LL95EM6OM8a0/1NTf+we3B3AecnRjxzdIwMRo LD03Vu8OILTb6VdP1oOJZVREYr1Ts/mywSaibDIQX5CJy+7x1SNfxEvRLdQ2Q8FwfeFnVt2TXQd jqqsXKBWCZHPZKiX5FfscipZebJora5DSvDlANg4TiN5PrHqloRmRRKdAEqIeRRMywCyLXwdM7y ahbtlRCpTYRXJlzfv X-Received: by 2002:a05:6000:27c9:10b0:4ab:6077:32a5 with SMTP id ffacd0b85a97d-4abb30b85e2mr45905761f8f.30.1795998726215; Sun, 29 Nov 2026 16:32:06 -0800 (PST) Received: from Ansuel-XPS. (93-34-92-103.ip49.fastwebnet.it. [93.34.92.103]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab6c61e53asm67021140f8f.59.2026.11.29.16.32.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2026 16:32:05 -0800 (PST) Message-ID: <6b0cc405.f0979b8b.82d75.69b8@mx.google.com> X-Google-Original-Message-ID: Date: Mon, 30 Nov 2026 01:31:47 +0100 From: Christian Marangi To: Brian Masney Cc: Stephen Boyd , Brian Masney , Jerome Brunet , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Philipp Zabel , Felix Fietkau , linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v15 4/5] clk: en7523: generalize register clocks function References: <20261121212738.170775-1-ansuelsmth@gmail.com> <20261121212738.170775-5-ansuelsmth@gmail.com> <179599621643.201962.10048110742781718297.b4-review@b4> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <179599621643.201962.10048110742781718297.b4-review@b4> On Sun, Nov 29, 2026 at 06:50:16PM -0500, Brian Masney wrote: > Hi Christian, > > > Airoha AN7583 SoC will use the same logic used by Airoha EN7581 SoC to > > register clocks. Generalize it to register clocks defined in soc_data. > > > > Add the clocks definition in EN7581 SoC to support this new implementation. > > > > Rework the .num_clocks value to declare the number of base clocks and > > increase internally if PCIe OPs is_enabled is defined. > > > > EN751221 is updated to address the new num_clocks meaning. > > > > Signed-off-by: Christian Marangi > > --- > > drivers/clk/clk-en7523.c | 29 +++++++++++++++++++---------- > > 1 file changed, 19 insertions(+), 10 deletions(-) > > > > diff --git a/drivers/clk/clk-en7523.c b/drivers/clk/clk-en7523.c > > index 280918ec25e3..d2cc25f30561 100644 > > --- a/drivers/clk/clk-en7523.c > > +++ b/drivers/clk/clk-en7523.c > > @@ -147,6 +147,7 @@ struct en_clk_priv { > > > > struct en_clk_soc_data { > > u32 num_clocks; > > + const struct en_clk_desc *base_clks; > > const struct clk_ops pcie_ops; > > int (*hw_init)(struct platform_device *pdev, > > struct clk_hw_onecell_data *clk_data); > > @@ -799,12 +800,15 @@ static int en7523_clk_hw_init(struct platform_device *pdev, > > static void en7581_register_clocks(struct device *dev, struct clk_hw_onecell_data *clk_data, > > struct regmap *map, void __iomem *base) > > { > > + const struct en_clk_soc_data *soc_data; > > struct clk_hw *hw; > > u32 rate; > > int i; > > > > - for (i = 0; i < ARRAY_SIZE(en7581_base_clks); i++) { > > - const struct en_clk_desc *desc = &en7581_base_clks[i]; > > + soc_data = device_get_match_data(dev); > > + > > + for (i = 0; i < soc_data->num_clocks; i++) { > > + const struct en_clk_desc *desc = &soc_data->base_clks[i]; > > u32 val, reg = desc->div_reg ? desc->div_reg : desc->base_reg; > > int err; > > > > @@ -1246,7 +1250,7 @@ static int en7523_clk_probe(struct platform_device *pdev) > > const struct en_clk_soc_data *soc_data; > > struct clk_hw_onecell_data *clk_data; > > struct en_clk_priv *priv; > > - int r; > > + int num_clocks, r; > > > > soc_data = device_get_match_data(&pdev->dev); > > > > @@ -1256,15 +1260,18 @@ static int en7523_clk_probe(struct platform_device *pdev) > > > > spin_lock_init(&priv->lock); > > > > - clk_data = devm_kzalloc(&pdev->dev, > > - struct_size(clk_data, hws, soc_data->num_clocks), > > - GFP_KERNEL); > > + num_clocks = soc_data->num_clocks; > > + /* Num clocks are incremented by 1 if PCIe clock is supported */ > > + if (soc_data->pcie_ops.is_enabled) > > + num_clocks++; > > Why can't soc_data->num_clocks store the actual count? Or in a different > variable? Below you have to subtract one, and this is very fragile. > I agree it's very fragile. > > + > > + clk_data = devm_kzalloc_flex(&pdev->dev, *clk_data, hws, num_clocks); > > if (!clk_data) > > return -ENOMEM; > > > > platform_set_drvdata(pdev, priv); > > > > - clk_data->num = soc_data->num_clocks; > > + clk_data->num = num_clocks; > > r = soc_data->hw_init(pdev, clk_data); > > if (r) > > return r; > > @@ -1273,7 +1280,7 @@ static int en7523_clk_probe(struct platform_device *pdev) > > } > > > > static const struct en_clk_soc_data en7523_data = { > > - .num_clocks = ARRAY_SIZE(en7523_base_clks) + 1, > > + .num_clocks = ARRAY_SIZE(en7523_base_clks), > > .pcie_ops = { > > .is_enabled = en7523_pci_is_enabled, > > .prepare = en7523_pci_prepare, > > @@ -1284,8 +1291,8 @@ static const struct en_clk_soc_data en7523_data = { > > }; > > > > static const struct en_clk_soc_data en7581_data = { > > - /* We increment num_clocks by 1 to account for additional PCIe clock */ > > - .num_clocks = ARRAY_SIZE(en7581_base_clks) + 1, > > + .base_clks = en7581_base_clks, > > + .num_clocks = ARRAY_SIZE(en7581_base_clks), > > .pcie_ops = { > > .is_enabled = en7581_pci_is_enabled, > > .enable = en7581_pci_enable, > > @@ -1295,7 +1302,8 @@ static const struct en_clk_soc_data en7581_data = { > > }; > > > > static const struct en_clk_soc_data en751221_data = { > > - .num_clocks = EN751221_MAX_CLKS, > > + /* Decrease of one as PCIe is incremented internally with PCIe OPs */ > > + .num_clocks = EN751221_MAX_CLKS - 1, > > Here's where it's decremented again. > Maybe you can also help here... the main problem is that there is this special handling for the PCIe clock that is handled outside all the other clocks... but for EN751221 it's included in the define... it was to not change the resto of the code to align to the new define meaning... Seems wasteful to introduce a dedicated variable for all the clocks and one for only the SCU one. But up to you what you prefer. -- Ansuel