[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1jh5ztd63c.fsf@starbuckisacylon.baylibre.com>
Date: Thu, 03 Jul 2025 10:35:51 +0200
From: Jerome Brunet <jbrunet@...libre.com>
To: Chuan Liu <chuan.liu@...ogic.com>
Cc: Neil Armstrong <neil.armstrong@...aro.org>, Michael Turquette
<mturquette@...libre.com>, Stephen Boyd <sboyd@...nel.org>, Kevin Hilman
<khilman@...libre.com>, Martin Blumenstingl
<martin.blumenstingl@...glemail.com>, linux-amlogic@...ts.infradead.org,
linux-clk@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 16/26] clk: amlogic: add probe helper for mmio based
controllers
On Thu 03 Jul 2025 at 11:29, Chuan Liu <chuan.liu@...ogic.com> wrote:
>>
>> +static const struct regmap_config base_clkc_regmap_cfg = {
>> + .reg_bits = 32,
>> + .val_bits = 32,
>> + .reg_stride = 4,
>> +};
>> +
>
>
> Since 'base_clkc_regmap_cfg' is only referenced within
> 'meson_clkc_mmio_probe()',
> we should move it as a local variable inside the function. This would be
> more
> logical and may optimize code size (During compiler optimization, only
> critical
> data needs to be preserved rather than the entire structure?)
>
>
>> +int meson_clkc_mmio_probe(struct platform_device *pdev)
>> +{
>> + const struct meson_clkc_data *data;
>> + struct device *dev = &pdev->dev;
>> + struct regmap_config regmap_cfg;
Actually a partial init would do the job nicely. I'll refine this on v2
>> + struct resource *res;
>> + void __iomem *base;
>> + struct regmap *map;
>> +
>> + data = of_device_get_match_data(dev);
>> + if (!data)
>> + return -EINVAL;
>> +
>> + base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
>> + if (IS_ERR(base))
>> + return PTR_ERR(base);
>> +
>> + memcpy(®map_cfg, &base_clkc_regmap_cfg, sizeof(regmap_cfg));
>> + regmap_cfg.max_register = resource_size(res) - 4;
>> +
>> + map = devm_regmap_init_mmio(dev, base, ®map_cfg);
>> + if (IS_ERR(map))
>> + return PTR_ERR(map);
>> +
>> + return meson_clkc_init(dev, map);
>> +}
>> +EXPORT_SYMBOL_NS_GPL(meson_clkc_mmio_probe, "CLK_MESON");
>> +
>> MODULE_DESCRIPTION("Amlogic Clock Controller Utilities");
>> MODULE_LICENSE("GPL");
>> MODULE_IMPORT_NS("CLK_MESON");
>> diff --git a/drivers/clk/meson/meson-clkc-utils.h b/drivers/clk/meson/meson-clkc-utils.h
>> index 26cd47544302b28ca1a342e178956559a84b152a..b45f85f630d7190fb6509b088f05f17ca91fa1c8 100644
>> --- a/drivers/clk/meson/meson-clkc-utils.h
>> +++ b/drivers/clk/meson/meson-clkc-utils.h
>> @@ -25,5 +25,6 @@ struct meson_clkc_data {
>> };
>>
>> int meson_clkc_syscon_probe(struct platform_device *pdev);
>> +int meson_clkc_mmio_probe(struct platform_device *pdev);
>>
>> #endif
>>
>> --
>> 2.47.2
>>
>>
>> _______________________________________________
>> linux-amlogic mailing list
>> linux-amlogic@...ts.infradead.org
>> http://lists.infradead.org/mailman/listinfo/linux-amlogic
--
Jerome
Powered by blists - more mailing lists