From: R Sundar <prosunofficial@gmail.com>
To: Alex Deucher <alexdeucher@gmail.com>
Cc: alexander.deucher@amd.com, christian.koenig@amd.com,
Xinhui.Pan@amd.com, airlied@gmail.com, simona@ffwll.ch,
tao.zhou1@amd.com, kevinyang.wang@amd.com, Hawking.Zhang@amd.com,
amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org, luben.tuikov@amd.com,
kernel test robot <lkp@intel.com>,
Julia Lawall <julia.lawall@inria.fr>
Subject: Re: [PATCH linux-next] drm/amdgpu: use string choice helpers
Date: Tue, 29 Oct 2024 22:35:25 +0530 [thread overview]
Message-ID: <3d38112f-9235-4643-ae2c-ffb9fae7a5d2@gmail.com> (raw)
In-Reply-To: <CADnq5_M4QwRfROybHrQfNuiXNhHH7VFAUVZMWkriwZs7K4KLUQ@mail.gmail.com>
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
>>
next prev parent reply other threads:[~2024-10-30 8:42 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-27 14:05 [PATCH linux-next] drm/amdgpu: use string choice helpers R Sundar
2024-10-29 13:41 ` Alex Deucher
2024-10-29 17:05 ` R Sundar [this message]
2024-10-29 17:13 ` Alex Deucher
-- strict thread matches above, loose matches on Subject: below --
2025-04-27 9:45 R Sundar
2025-04-28 17:24 ` Alex Deucher
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3d38112f-9235-4643-ae2c-ffb9fae7a5d2@gmail.com \
--to=prosunofficial@gmail.com \
--cc=Hawking.Zhang@amd.com \
--cc=Xinhui.Pan@amd.com \
--cc=airlied@gmail.com \
--cc=alexander.deucher@amd.com \
--cc=alexdeucher@gmail.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=julia.lawall@inria.fr \
--cc=kevinyang.wang@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@intel.com \
--cc=luben.tuikov@amd.com \
--cc=simona@ffwll.ch \
--cc=tao.zhou1@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox