* [PATCH linux-next] drm/amdgpu: use string choice helpers
@ 2025-04-27 9:45 R Sundar
2025-04-28 17:24 ` Alex Deucher
0 siblings, 1 reply; 6+ messages in thread
From: R Sundar @ 2025-04-27 9:45 UTC (permalink / raw)
To: Alex Deucher, Christian König, David Airlie, Simona Vetter,
Sunil Khatri, Tim Huang, Jesse . zhang @ amd . com, Boyuan Zhang,
Pierre-Eric Pelloux-Prayer, Yang Wang, Peyton Lee
Cc: amd-gfx, dri-devel, linux-kernel, R Sundar, kernel test robot,
Julia Lawall
Use string choice helpers for better readability.
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Julia Lawall <julia.lawall@inria.fr>
Closes: https://lore.kernel.org/r/202503222049.sUXL3q6w-lkp@intel.com/
Signed-off-by: R Sundar <prosunofficial@gmail.com>
---
Reported in linux repository.
cocci warnings: (new ones prefixed by >>)
>> drivers/gpu/drm/amd/amdgpu/amdgpu_vpe.c:311:49-70: opportunity for str_true_false(vpe -> collaborate_mode)
vim +311 drivers/gpu/drm/amd/amdgpu/amdgpu_vpe.c
for linux-next:
drivers/gpu/drm/amd/amdgpu/amdgpu_vpe.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vpe.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vpe.c
index 121ee17b522b..442d137e0fed 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vpe.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vpe.c
@@ -317,7 +317,7 @@ static int vpe_early_init(struct amdgpu_ip_block *ip_block)
vpe_set_ring_funcs(adev);
vpe_set_regs(vpe);
- dev_info(adev->dev, "VPE: collaborate mode %s", vpe->collaborate_mode ? "true" : "false");
+ dev_info(adev->dev, "VPE: collaborate mode %s", str_true_false(vpe->collaborate_mode));
return 0;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH linux-next] drm/amdgpu: use string choice helpers
2025-04-27 9:45 [PATCH linux-next] drm/amdgpu: use string choice helpers R Sundar
@ 2025-04-28 17:24 ` Alex Deucher
0 siblings, 0 replies; 6+ messages in thread
From: Alex Deucher @ 2025-04-28 17:24 UTC (permalink / raw)
To: R Sundar
Cc: Alex Deucher, Christian König, David Airlie, Simona Vetter,
Sunil Khatri, Tim Huang, Jesse . zhang @ amd . com, Boyuan Zhang,
Pierre-Eric Pelloux-Prayer, Yang Wang, Peyton Lee, amd-gfx,
dri-devel, linux-kernel, kernel test robot, Julia Lawall
On Sun, Apr 27, 2025 at 5:46 AM R Sundar <prosunofficial@gmail.com> wrote:
>
> Use string choice helpers for better readability.
>
> Reported-by: kernel test robot <lkp@intel.com>
> Reported-by: Julia Lawall <julia.lawall@inria.fr>
> Closes: https://lore.kernel.org/r/202503222049.sUXL3q6w-lkp@intel.com/
> Signed-off-by: R Sundar <prosunofficial@gmail.com>
> ---
>
> Reported in linux repository.
>
> cocci warnings: (new ones prefixed by >>)
> >> drivers/gpu/drm/amd/amdgpu/amdgpu_vpe.c:311:49-70: opportunity for str_true_false(vpe -> collaborate_mode)
>
> vim +311 drivers/gpu/drm/amd/amdgpu/amdgpu_vpe.c
>
> for linux-next:
>
> drivers/gpu/drm/amd/amdgpu/amdgpu_vpe.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vpe.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vpe.c
> index 121ee17b522b..442d137e0fed 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vpe.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vpe.c
> @@ -317,7 +317,7 @@ static int vpe_early_init(struct amdgpu_ip_block *ip_block)
> vpe_set_ring_funcs(adev);
> vpe_set_regs(vpe);
>
> - dev_info(adev->dev, "VPE: collaborate mode %s", vpe->collaborate_mode ? "true" : "false");
> + dev_info(adev->dev, "VPE: collaborate mode %s", str_true_false(vpe->collaborate_mode));
I'm not opposed to this change if there is a general initiative to
convert everyone over to using this for some useful reason, but I
personally don't think it helps readability at all. If anything it
makes it worse in my opinion.
Alex
>
> return 0;
> }
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH linux-next] drm/amdgpu: use string choice helpers
@ 2024-10-27 14:05 R Sundar
2024-10-29 13:41 ` Alex Deucher
0 siblings, 1 reply; 6+ messages in thread
From: R Sundar @ 2024-10-27 14:05 UTC (permalink / raw)
To: alexander.deucher, christian.koenig, Xinhui.Pan, airlied, simona,
tao.zhou1, kevinyang.wang, Hawking.Zhang
Cc: amd-gfx, dri-devel, linux-kernel, luben.tuikov, R Sundar,
kernel test robot, Julia Lawall
Use string choice helpers for better readability.
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Julia Lawall <julia.lawall@inria.fr>
Closes: https://lore.kernel.org/r/202410161814.I6p2Nnux-lkp@intel.com/
Signed-off-by: R Sundar <prosunofficial@gmail.com>
---
reported in linux repository.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
cocci warnings: (new ones prefixed by >>)
>> drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c:145:8-12: opportunity for str_read_write(read)
vim +145 drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c
drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c
index 35fee3e8cde2..8cd69836dd99 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c
@@ -200,7 +200,7 @@ static int amdgpu_eeprom_xfer(struct i2c_adapter *i2c_adap, u32 eeprom_addr,
dev_err_ratelimited(&i2c_adap->dev,
"maddr:0x%04X size:0x%02X:quirk max_%s_len must be > %d",
eeprom_addr, buf_size,
- read ? "read" : "write", EEPROM_OFFSET_SIZE);
+ str_read_write(read), EEPROM_OFFSET_SIZE);
return -EINVAL;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH linux-next] drm/amdgpu: use string choice helpers
2024-10-27 14:05 R Sundar
@ 2024-10-29 13:41 ` Alex Deucher
2024-10-29 17:05 ` R Sundar
0 siblings, 1 reply; 6+ messages in thread
From: Alex Deucher @ 2024-10-29 13:41 UTC (permalink / raw)
To: R Sundar
Cc: alexander.deucher, christian.koenig, Xinhui.Pan, airlied, simona,
tao.zhou1, kevinyang.wang, Hawking.Zhang, amd-gfx, dri-devel,
linux-kernel, luben.tuikov, kernel test robot, Julia Lawall
On Sun, Oct 27, 2024 at 10:18 AM R Sundar <prosunofficial@gmail.com> wrote:
>
> Use string choice helpers for better readability.
I personally find this less readable, but if this is the preferred
method going forward, I'm fine to take the patch.
Alex
>
> Reported-by: kernel test robot <lkp@intel.com>
> Reported-by: Julia Lawall <julia.lawall@inria.fr>
> Closes: https://lore.kernel.org/r/202410161814.I6p2Nnux-lkp@intel.com/
> Signed-off-by: R Sundar <prosunofficial@gmail.com>
> ---
>
> reported in linux repository.
>
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
>
> cocci warnings: (new ones prefixed by >>)
> >> drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c:145:8-12: opportunity for str_read_write(read)
>
> vim +145 drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c
>
> drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c
> index 35fee3e8cde2..8cd69836dd99 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c
> @@ -200,7 +200,7 @@ static int amdgpu_eeprom_xfer(struct i2c_adapter *i2c_adap, u32 eeprom_addr,
> dev_err_ratelimited(&i2c_adap->dev,
> "maddr:0x%04X size:0x%02X:quirk max_%s_len must be > %d",
> eeprom_addr, buf_size,
> - read ? "read" : "write", EEPROM_OFFSET_SIZE);
> + str_read_write(read), EEPROM_OFFSET_SIZE);
> return -EINVAL;
> }
>
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH linux-next] drm/amdgpu: use string choice helpers
2024-10-29 13:41 ` Alex Deucher
@ 2024-10-29 17:05 ` R Sundar
2024-10-29 17:13 ` Alex Deucher
0 siblings, 1 reply; 6+ messages in thread
From: R Sundar @ 2024-10-29 17:05 UTC (permalink / raw)
To: Alex Deucher
Cc: alexander.deucher, christian.koenig, Xinhui.Pan, airlied, simona,
tao.zhou1, kevinyang.wang, Hawking.Zhang, amd-gfx, dri-devel,
linux-kernel, luben.tuikov, kernel test robot, Julia Lawall
On 29/10/24 19:11, Alex Deucher wrote:
> On Sun, Oct 27, 2024 at 10:18 AM R Sundar <prosunofficial@gmail.com> wrote:
>>
>> Use string choice helpers for better readability.
>
> I personally find this less readable, but if this is the preferred
> method going forward, I'm fine to take the patch.
>
> Alex
>
Hi,
Thanks for the comments.
I came across this comments in string_choices.h files, where
str_read_write() helpers are present.
Using these helpers offers the following benefits:
1) Reducing the hardcoding of strings, which makes the code more
elegant through these simple literal-meaning helpers.
2) Unifying the output, which prevents the same string from being
printed in various forms, such as enable/disable, enabled/disabled,
en/dis.
3) Deduping by the linker, which results in a smaller binary file.
Kindly, I'm leaving the decision to maintainers.
Thanks,
Sundar
>>
>> Reported-by: kernel test robot <lkp@intel.com>
>> Reported-by: Julia Lawall <julia.lawall@inria.fr>
>> Closes: https://lore.kernel.org/r/202410161814.I6p2Nnux-lkp@intel.com/
>> Signed-off-by: R Sundar <prosunofficial@gmail.com>
>> ---
>>
>> reported in linux repository.
>>
>> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
>>
>> cocci warnings: (new ones prefixed by >>)
>>>> drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c:145:8-12: opportunity for str_read_write(read)
>>
>> vim +145 drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c
>>
>> drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c
>> index 35fee3e8cde2..8cd69836dd99 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c
>> @@ -200,7 +200,7 @@ static int amdgpu_eeprom_xfer(struct i2c_adapter *i2c_adap, u32 eeprom_addr,
>> dev_err_ratelimited(&i2c_adap->dev,
>> "maddr:0x%04X size:0x%02X:quirk max_%s_len must be > %d",
>> eeprom_addr, buf_size,
>> - read ? "read" : "write", EEPROM_OFFSET_SIZE);
>> + str_read_write(read), EEPROM_OFFSET_SIZE);
>> return -EINVAL;
>> }
>>
>> --
>> 2.34.1
>>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH linux-next] drm/amdgpu: use string choice helpers
2024-10-29 17:05 ` R Sundar
@ 2024-10-29 17:13 ` Alex Deucher
0 siblings, 0 replies; 6+ messages in thread
From: Alex Deucher @ 2024-10-29 17:13 UTC (permalink / raw)
To: R Sundar
Cc: alexander.deucher, christian.koenig, Xinhui.Pan, airlied, simona,
tao.zhou1, kevinyang.wang, Hawking.Zhang, amd-gfx, dri-devel,
linux-kernel, luben.tuikov, kernel test robot, Julia Lawall
On Tue, Oct 29, 2024 at 1:05 PM R Sundar <prosunofficial@gmail.com> wrote:
>
> On 29/10/24 19:11, Alex Deucher wrote:
> > On Sun, Oct 27, 2024 at 10:18 AM R Sundar <prosunofficial@gmail.com> wrote:
> >>
> >> Use string choice helpers for better readability.
> >
> > I personally find this less readable, but if this is the preferred
> > method going forward, I'm fine to take the patch.
> >
> > Alex
> >
>
> Hi,
>
> Thanks for the comments.
>
> I came across this comments in string_choices.h files, where
> str_read_write() helpers are present.
>
> Using these helpers offers the following benefits:
>
> 1) Reducing the hardcoding of strings, which makes the code more
> elegant through these simple literal-meaning helpers.
>
> 2) Unifying the output, which prevents the same string from being
> printed in various forms, such as enable/disable, enabled/disabled,
> en/dis.
> 3) Deduping by the linker, which results in a smaller binary file.
>
Thanks. I've applied it.
Alex
> Kindly, I'm leaving the decision to maintainers.
>
> Thanks,
> Sundar
>
> >>
> >> Reported-by: kernel test robot <lkp@intel.com>
> >> Reported-by: Julia Lawall <julia.lawall@inria.fr>
> >> Closes: https://lore.kernel.org/r/202410161814.I6p2Nnux-lkp@intel.com/
> >> Signed-off-by: R Sundar <prosunofficial@gmail.com>
> >> ---
> >>
> >> reported in linux repository.
> >>
> >> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> >>
> >> cocci warnings: (new ones prefixed by >>)
> >>>> drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c:145:8-12: opportunity for str_read_write(read)
> >>
> >> vim +145 drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c
> >>
> >> drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c | 2 +-
> >> 1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c
> >> index 35fee3e8cde2..8cd69836dd99 100644
> >> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c
> >> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c
> >> @@ -200,7 +200,7 @@ static int amdgpu_eeprom_xfer(struct i2c_adapter *i2c_adap, u32 eeprom_addr,
> >> dev_err_ratelimited(&i2c_adap->dev,
> >> "maddr:0x%04X size:0x%02X:quirk max_%s_len must be > %d",
> >> eeprom_addr, buf_size,
> >> - read ? "read" : "write", EEPROM_OFFSET_SIZE);
> >> + str_read_write(read), EEPROM_OFFSET_SIZE);
> >> return -EINVAL;
> >> }
> >>
> >> --
> >> 2.34.1
> >>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-04-28 17:24 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-27 9:45 [PATCH linux-next] drm/amdgpu: use string choice helpers R Sundar
2025-04-28 17:24 ` Alex Deucher
-- strict thread matches above, loose matches on Subject: below --
2024-10-27 14:05 R Sundar
2024-10-29 13:41 ` Alex Deucher
2024-10-29 17:05 ` R Sundar
2024-10-29 17:13 ` Alex Deucher
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox