[<prev] [next>] [day] [month] [year] [list]
Message-ID:
<MEYP282MB269796C1FA2468CBD7DF3B17BB692@MEYP282MB2697.AUSP282.PROD.OUTLOOK.COM>
Date: Wed, 10 Jan 2024 03:40:18 +0000
From: Jinjian Song <SongJinJian@...mail.com>
To: "Nelson, Shannon" <shannon.nelson@....com>, Sergey Ryazanov
<ryazanov.s.a@...il.com>
CC: "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
"chandrashekar.devegowda@...el.com" <chandrashekar.devegowda@...el.com>,
"chiranjeevi.rapolu@...ux.intel.com" <chiranjeevi.rapolu@...ux.intel.com>,
"haijun.liu@...iatek.com" <haijun.liu@...iatek.com>,
"m.chetan.kumar@...ux.intel.com" <m.chetan.kumar@...ux.intel.com>,
"ricardo.martinez@...ux.intel.com" <ricardo.martinez@...ux.intel.com>,
"loic.poulain@...aro.org" <loic.poulain@...aro.org>,
"johannes@...solutions.net" <johannes@...solutions.net>,
"davem@...emloft.net" <davem@...emloft.net>, "edumazet@...gle.com"
<edumazet@...gle.com>, "kuba@...nel.org" <kuba@...nel.org>,
"pabeni@...hat.com" <pabeni@...hat.com>, "linux-kernel@...r.kernel.com"
<linux-kernel@...r.kernel.com>, "vsankar@...ovo.com" <vsankar@...ovo.com>,
"danielwinkler@...gle.com" <danielwinkler@...gle.com>, "nmarupaka@...gle.com"
<nmarupaka@...gle.com>, "joey.zhao@...ocom.com" <joey.zhao@...ocom.com>,
"liuqf@...ocom.com" <liuqf@...ocom.com>, "felix.yan@...ocom.com"
<felix.yan@...ocom.com>, Jinjian Song <jinjian.song@...ocom.com>
Subject: Re: [net-next v3 2/3] net: wwan: t7xx: Add sysfs attribute for device
state machine
>On 1/8/2024 1:37 PM, Sergey Ryazanov wrote:
>>
>> On 28.12.2023 11:44, Jinjian Song wrote:
>>
>> [skipped]
>>
>>> + switch (mode) {
>>> + case T7XX_READY:
>>> + return sprintf(buf, "T7XX_MODEM_READY\n");
>>> + case T7XX_RESET:
>>> + return sprintf(buf, "T7XX_MODEM_RESET\n");
>>> + case T7XX_FASTBOOT_DL_SWITCHING:
>>> + return sprintf(buf,
>>> +"T7XX_MODEM_FASTBOOT_DL_SWITCHING\n");
>>> + case T7XX_FASTBOOT_DL_MODE:
>>> + return sprintf(buf, "T7XX_MODEM_FASTBOOT_DL_MODE\n");
>>> + case T7XX_FASTBOOT_DUMP_MODE:
>>> + return sprintf(buf, "T7XX_MODEM_FASTBOOT_DUMP_MODE\n");
>>> + default:
>>> + return sprintf(buf, "T7XX_UNKNOWN\n");
>>
>> Out of curiosity, what the purpose of this common prefix "T7XX_MODEM_"?
>> Do you have a plan to support more then T7xx modems?
>>
>> And BTW, can we use a lighter method of string copying like strncpy()?
>A quick note from the sidelines: better would be strscpy() See https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings
>sln
I will remove the common prefix "T7XX_MODEM_" which using only for T7XX modems.
Thanks, got it, let me do that using strscpy() instead of sprintf().
And BTW, should switch case structure be adjusted like follow:
static const char* modes[] = {
[T7XX_READY] = "READY ",
[T7XX_RESET] = "RESET",
...
}
t7xx_mode_show() {
...
/*mode = T7XX_READY;*/
return strscpy(buff, modes[mode], sizeof(modes[mode]));
}
Best Regards,
Jinjian
Powered by blists - more mailing lists