Re: [PATCH] amba: make amba_bustype constant

Kunwu Chan
2024-08-26T10:08:42Z

On 2024/8/23 21:48, Andy Shevchenko wrote:
> On Fri, Aug 23, 2024 at 02:42:03PM +0800, Kunwu Chan wrote:
>> From: Kunwu Chan <chentao@kylinos.cn>
>>
>> Since commit d492cc2573a0 ("driver core: device.h: make struct
>> bus_type a const *"), the driver core can properly handle constant
>> struct bus_type, move the amba_bustype variable to be a constant
>> structure as well, placing it into read-only memory which can not be
>> modified at runtime.
> ...
>
>> -extern struct bus_type amba_bustype;
>> +extern const struct bus_type amba_bustype;
> Can we actually hide this from the outside, i.e. make it static in the C file,
> and introduce the dev_is_amba() helper instead?
>
> P.S. You may look at the PNP bus case (some of the latest patches there)

I found it problematic in the process of making changes.

There have some usage of amba_bustype outside the AMBA code ,i.e:
https://elixir.bootlin.com/linux/v6.10.4/source/drivers/iommu/iommu.c#L155

So, If we make the amba_bustype inside the AMBA code, the outside cannot
access.

If only internal access is allowed, it will compile and report an error,
how should I modify it next, and any suggestions?

--
Thanks,
Kunwu.Chan