[PATCH 2/3] hwrng: starfive - Add TRNG driver for StarFive SoC

Krzysztof Kozlowski krzysztof.kozlowski at linaro.org
Thu Dec 22 01:43:31 PST 2022


On 22/12/2022 10:35, JiaJie Ho wrote:
> 
> 
>> -----Original Message-----
>> From: Krzysztof Kozlowski <krzysztof.kozlowski at linaro.org>
>> Sent: Wednesday, December 21, 2022 5:49 PM
>> To: JiaJie Ho <jiajie.ho at starfivetech.com>; Olivia Mackall
>> <olivia at selenic.com>; Herbert Xu <herbert at gondor.apana.org.au>; Rob
>> Herring <robh+dt at kernel.org>; Krzysztof Kozlowski
>> <krzysztof.kozlowski+dt at linaro.org>
>> Cc: Emil Renner Berthing <kernel at esmil.dk>; Conor Dooley
>> <conor.dooley at microchip.com>; linux-crypto at vger.kernel.org;
>> devicetree at vger.kernel.org; linux-kernel at vger.kernel.org; linux-
>> riscv at lists.infradead.org
>> Subject: Re: [PATCH 2/3] hwrng: starfive - Add TRNG driver for StarFive SoC
>>
>> On 21/12/2022 10:08, Jia Jie Ho wrote:
>>> This adds driver support for the hardware random number generator in
>>> Starfive SoCs and adds StarFive TRNG entry to MAINTAINERS.
>>>
>>> Co-developed-by: Jenny Zhang <jenny.zhang at starfivetech.com>
>>> Signed-off-by: Jenny Zhang <jenny.zhang at starfivetech.com>
>>> Signed-off-by: Jia Jie Ho <jiajie.ho at starfivetech.com>
>>> ---
>>>  MAINTAINERS                            |   6 +
>>>  drivers/char/hw_random/Kconfig         |  11 +
>>>  drivers/char/hw_random/Makefile        |   1 +
>>>  drivers/char/hw_random/starfive-trng.c | 403
>>> +++++++++++++++++++++++++
>>>  4 files changed, 421 insertions(+)
>>>  create mode 100644 drivers/char/hw_random/starfive-trng.c
>>>
>>
>> (...)
>>
>>> +static const struct of_device_id trng_dt_ids[] = {
>>> +	{ .compatible = "starfive,jh7110-trng" },
>>> +	{ }
>>> +};
>>> +MODULE_DEVICE_TABLE(of, trng_dt_ids);
>>> +
>>> +static struct platform_driver starfive_trng_driver = {
>>> +	.probe	= starfive_trng_probe,
>>> +	.driver	= {
>>> +		.name		= "starfive-trng",
>>> +		.pm		= &starfive_trng_pm_ops,
>>> +		.of_match_table	= of_match_ptr(trng_dt_ids),
>>
>> of_match_ptr goes with __maybe_unused. You will have now warnings, so
>> please test more your patches (W=1, sparse, smatch).
>>
> 
> Hi Krzysztof,
> 
> Thanks for reviewing this patch.
> How do I properly handle __maybe_unused functions in this scenario?

The same as in other files. Use `git grep`

> Will it help if I add #define as follows:
> 
> #ifdef CONFIG_PM
> #define STARFIVE_RNG_PM_OPS (&starfive_rng_pm_ops)
> #else
> #define STARFIVE_RNG_PM_OPS NULL
> #endif

I talked only about of_match_ptr(). This is not of_match_ptr and should
have its own syntax (pm_sleep_ptr + static DEFINE_SIMPLE_DEV_PM_OPS)

> 
> static struct platform_driver starfive_trng_driver = {
>         .probe  = starfive_trng_probe,
>         .driver = {
>                 .name           = "starfive-trng",
>                 .pm             = STARFIVE_RNG_PM_OPS,
>                 .of_match_table = of_match_ptr(trng_dt_ids),
>         },
> };
> 
> I did build the patches with the tools mentioned but did not get warnings.
> Do I need a specific version, or have I done something wrong?

You just need proper COMPILE_TEST config with OF disabled.

Best regards,
Krzysztof




More information about the linux-riscv mailing list