* [PATCH] hwmon: lm70: simplify with spi_get_device_match_data()
@ 2024-06-06 14:25 Krzysztof Kozlowski
2024-06-06 15:56 ` Guenter Roeck
0 siblings, 1 reply; 3+ messages in thread
From: Krzysztof Kozlowski @ 2024-06-06 14:25 UTC (permalink / raw)
To: Jean Delvare, Guenter Roeck, linux-hwmon, linux-kernel
Cc: Krzysztof Kozlowski
Use spi_get_device_match_data() helper to simplify a bit the driver.
Also kernel_ulong_t type is preferred for kernel code over uintptr_t
(needed for the cast).
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
drivers/hwmon/lm70.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/drivers/hwmon/lm70.c b/drivers/hwmon/lm70.c
index 481e4e1f8f4f..0d5a250cb672 100644
--- a/drivers/hwmon/lm70.c
+++ b/drivers/hwmon/lm70.c
@@ -169,11 +169,7 @@ static int lm70_probe(struct spi_device *spi)
struct lm70 *p_lm70;
int chip;
- if (dev_fwnode(&spi->dev))
- chip = (int)(uintptr_t)device_get_match_data(&spi->dev);
- else
- chip = spi_get_device_id(spi)->driver_data;
-
+ chip = (kernel_ulong_t)spi_get_device_match_data(spi);
/* signaling is SPI_MODE_0 */
if ((spi->mode & SPI_MODE_X_MASK) != SPI_MODE_0)
--
2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] hwmon: lm70: simplify with spi_get_device_match_data()
2024-06-06 14:25 [PATCH] hwmon: lm70: simplify with spi_get_device_match_data() Krzysztof Kozlowski
@ 2024-06-06 15:56 ` Guenter Roeck
2024-06-07 6:53 ` Krzysztof Kozlowski
0 siblings, 1 reply; 3+ messages in thread
From: Guenter Roeck @ 2024-06-06 15:56 UTC (permalink / raw)
To: Krzysztof Kozlowski, Jean Delvare, linux-hwmon, linux-kernel
On 6/6/24 07:25, Krzysztof Kozlowski wrote:
> Use spi_get_device_match_data() helper to simplify a bit the driver.
> Also kernel_ulong_t type is preferred for kernel code over uintptr_t
> (needed for the cast).
>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> ---
> drivers/hwmon/lm70.c | 6 +-----
> 1 file changed, 1 insertion(+), 5 deletions(-)
>
> diff --git a/drivers/hwmon/lm70.c b/drivers/hwmon/lm70.c
> index 481e4e1f8f4f..0d5a250cb672 100644
> --- a/drivers/hwmon/lm70.c
> +++ b/drivers/hwmon/lm70.c
> @@ -169,11 +169,7 @@ static int lm70_probe(struct spi_device *spi)
> struct lm70 *p_lm70;
> int chip;
>
> - if (dev_fwnode(&spi->dev))
> - chip = (int)(uintptr_t)device_get_match_data(&spi->dev);
> - else
> - chip = spi_get_device_id(spi)->driver_data;
> -
> + chip = (kernel_ulong_t)spi_get_device_match_data(spi);
>
> /* signaling is SPI_MODE_0 */
> if ((spi->mode & SPI_MODE_X_MASK) != SPI_MODE_0)
I'll apply this patch, but ...
I take it that the earlier claims that driver_data must not be
something like "(void *) LM70_CHIP_LM70", where LM70_CHIP_LM70 is 0,
was wrong. I'll start reverting all patches which changed starting
enum values from 0 to 1 based on that wrong claim.
Guenter
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] hwmon: lm70: simplify with spi_get_device_match_data()
2024-06-06 15:56 ` Guenter Roeck
@ 2024-06-07 6:53 ` Krzysztof Kozlowski
0 siblings, 0 replies; 3+ messages in thread
From: Krzysztof Kozlowski @ 2024-06-07 6:53 UTC (permalink / raw)
To: Guenter Roeck, Jean Delvare, linux-hwmon, linux-kernel
On 06/06/2024 17:56, Guenter Roeck wrote:
> On 6/6/24 07:25, Krzysztof Kozlowski wrote:
>> Use spi_get_device_match_data() helper to simplify a bit the driver.
>> Also kernel_ulong_t type is preferred for kernel code over uintptr_t
>> (needed for the cast).
>>
>> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
>> ---
>> drivers/hwmon/lm70.c | 6 +-----
>> 1 file changed, 1 insertion(+), 5 deletions(-)
>>
>> diff --git a/drivers/hwmon/lm70.c b/drivers/hwmon/lm70.c
>> index 481e4e1f8f4f..0d5a250cb672 100644
>> --- a/drivers/hwmon/lm70.c
>> +++ b/drivers/hwmon/lm70.c
>> @@ -169,11 +169,7 @@ static int lm70_probe(struct spi_device *spi)
>> struct lm70 *p_lm70;
>> int chip;
>>
>> - if (dev_fwnode(&spi->dev))
>> - chip = (int)(uintptr_t)device_get_match_data(&spi->dev);
>> - else
>> - chip = spi_get_device_id(spi)->driver_data;
>> -
>> + chip = (kernel_ulong_t)spi_get_device_match_data(spi);
>>
>> /* signaling is SPI_MODE_0 */
>> if ((spi->mode & SPI_MODE_X_MASK) != SPI_MODE_0)
>
> I'll apply this patch, but ...
>
> I take it that the earlier claims that driver_data must not be
> something like "(void *) LM70_CHIP_LM70", where LM70_CHIP_LM70 is 0,
> was wrong. I'll start reverting all patches which changed starting
> enum values from 0 to 1 based on that wrong claim.
Yeah, they should not be 0. I think Jonathan also brought it some time
ago for iio drivers:
https://lore.kernel.org/linux-iio/20240226192555.14aa178e@jic23-huawei/
but if all the ID tables are complete, the 0 will work fine:
https://lore.kernel.org/all/20240413154511.52576-1-krzysztof.kozlowski@linaro.org/
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-06-07 6:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-06 14:25 [PATCH] hwmon: lm70: simplify with spi_get_device_match_data() Krzysztof Kozlowski
2024-06-06 15:56 ` Guenter Roeck
2024-06-07 6:53 ` Krzysztof Kozlowski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®