[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <25caed0d-ec42-54f5-5b62-8159979dadb9@canonical.com>
Date: Tue, 8 Mar 2022 09:06:55 +0100
From: Krzysztof Kozlowski <krzysztof.kozlowski@...onical.com>
To: Jiri Slaby <jirislaby@...nel.org>,
Alim Akhtar <alim.akhtar@...sung.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
linux-arm-kernel@...ts.infradead.org,
linux-samsung-soc@...r.kernel.org, linux-serial@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 3/7] tty: serial: samsung: constify
s3c24xx_serial_drv_data
On 07/03/2022 09:40, Krzysztof Kozlowski wrote:
> On 07/03/2022 09:33, Jiri Slaby wrote:
>> On 07. 03. 22, 9:09, Krzysztof Kozlowski wrote:
>>> The driver data (struct s3c24xx_serial_drv_data) is only used to
>>> initialize the driver properly and is not modified. Make it const.
>> ...
>>> @@ -2755,9 +2755,9 @@ static struct s3c24xx_serial_drv_data s5pv210_serial_drv_data = {
>>> },
>>> .fifosize = { 256, 64, 16, 16 },
>>> };
>>> -#define S5PV210_SERIAL_DRV_DATA ((kernel_ulong_t)&s5pv210_serial_drv_data)
>>> +#define S5PV210_SERIAL_DRV_DATA (&s5pv210_serial_drv_data)
>>> #else
>>> -#define S5PV210_SERIAL_DRV_DATA (kernel_ulong_t)NULL
>>> +#define S5PV210_SERIAL_DRV_DATA NULL
>>
>> Yet, I still don't see why the switch from ulong->ptr happens in this
>> "constify it" patch?
>
> All these defines S5PV210_SERIAL_DRV_DATA and so on are now const and
> are assigned to of_device_id.data (s3c24xx_uart_dt_match). Before, these
> were assigned with a cast:
>
> static const struct of_device_id s3c24xx_uart_dt_match[] = {
> { .compatible = "samsung,s5pv210-uart",
>
> .data = (void *)S5PV210_SERIAL_DRV_DATA }
>
> but since the actual data structure is const, I want to drop the cast.
> Casting const via (void *) might hide some possible issues, e.g. if
> of_device_id.data becomes actually non-const. There is no particular
> issue here, because of_device_id.data and S5PV210_SERIAL_DRV_DATA are
> const. But also because they are both const now, I want to drop the cast
> via void *.
>
> When (void *) is dropped, the S5PV210_SERIAL_DRV_DATA cannot be
> kernel_ulong_t:
>
> ../drivers/tty/serial/samsung_tty.c:2753:33: warning: initialization of
> ‘const void *’ from ‘long unsigned int’ makes pointer from integer
> without a cast [-Wint-conversion]
>
> 2753 | #define S5PV210_SERIAL_DRV_DATA (kernel_ulong_t)NULL
>
I will split the casts removal to separate patch. I hope this clarifies
a bit.
Best regards,
Krzysztof
Powered by blists - more mailing lists