netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [net-next v3 2/3] net: wwan: t7xx: Add sysfs attribute for device state machine
@ 2024-01-10  3:40 Jinjian Song
  0 siblings, 0 replies; 9+ messages in thread
From: Jinjian Song @ 2024-01-10  3:40 UTC (permalink / raw)
  To: Nelson, Shannon, Sergey Ryazanov
  Cc: netdev@vger.kernel.org, chandrashekar.devegowda@intel.com,
	chiranjeevi.rapolu@linux.intel.com, haijun.liu@mediatek.com,
	m.chetan.kumar@linux.intel.com, ricardo.martinez@linux.intel.com,
	loic.poulain@linaro.org, johannes@sipsolutions.net,
	davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, linux-kernel@vger.kernel.com,
	vsankar@lenovo.com, danielwinkler@google.com,
	nmarupaka@google.com, joey.zhao@fibocom.com, liuqf@fibocom.com,
	felix.yan@fibocom.com, Jinjian Song


>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
 

^ permalink raw reply	[flat|nested] 9+ messages in thread
* Re: [net-next v3 2/3] net: wwan: t7xx: Add sysfs attribute for device state machine
@ 2024-01-10  7:15 Jinjian Song
  0 siblings, 0 replies; 9+ messages in thread
From: Jinjian Song @ 2024-01-10  7:15 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: netdev@vger.kernel.org, chandrashekar.devegowda@intel.com,
	chiranjeevi.rapolu@linux.intel.com, haijun.liu@mediatek.com,
	m.chetan.kumar@linux.intel.com, ricardo.martinez@linux.intel.com,
	loic.poulain@linaro.org, ryazanov.s.a@gmail.com,
	johannes@sipsolutions.net, davem@davemloft.net,
	edumazet@google.com, pabeni@redhat.com,
	linux-kernel@vger.kernel.com, vsankar@lenovo.com,
	danielwinkler@google.com, nmarupaka@google.com,
	joey.zhao@fibocom.com, liuqf@fibocom.com, felix.yan@fibocom.com,
	Jinjian Song


>On Thu, 28 Dec 2023 17:44:10 +0800 Jinjian Song wrote:
>> From: Jinjian Song <jinjian.song@fibocom.com>
>> 
>> Add support for userspace to get the device mode, e.g., 
>> reset/ready/fastboot mode.

>We need some info under Documentation/ describing the file / attr and how it's supposed to be used.

Yes, please let me add to the t7xx.rst document

>> diff --git a/drivers/net/wwan/t7xx/t7xx_modem_ops.c 
>> b/drivers/net/wwan/t7xx/t7xx_modem_ops.c
>> index 24e7d491468e..ae4578905a8d 100644
>> --- a/drivers/net/wwan/t7xx/t7xx_modem_ops.c
>> +++ b/drivers/net/wwan/t7xx/t7xx_modem_ops.c
>> @@ -192,6 +192,7 @@ static irqreturn_t t7xx_rgu_isr_thread(int irq, 
>> void *data)  {
>>  	struct t7xx_pci_dev *t7xx_dev = data;
>>  
>> +	atomic_set(&t7xx_dev->mode, T7XX_RESET);

>Why is ->mode atomic? There seem to be no RMW operations on it.
>You can use READ_ONCE() / WRITE_ONCE() on a normal integer.

Please let me modify as suggested.

>>  	msleep(RGU_RESET_DELAY_MS);
>>  	t7xx_reset_device_via_pmic(t7xx_dev);
>>  	return IRQ_HANDLED;
>> diff --git a/drivers/net/wwan/t7xx/t7xx_pci.c 
>> b/drivers/net/wwan/t7xx/t7xx_pci.c
>> index 91256e005b84..d5f6a8638aba 100644
>> --- a/drivers/net/wwan/t7xx/t7xx_pci.c
>> +++ b/drivers/net/wwan/t7xx/t7xx_pci.c
>> @@ -52,6 +52,68 @@
>>  #define PM_RESOURCE_POLL_TIMEOUT_US	10000
>>  #define PM_RESOURCE_POLL_STEP_US	100
>>  
>> +static ssize_t t7xx_mode_store(struct device *dev,
>> +			       struct device_attribute *attr,
>> +			       const char *buf, size_t count) {
>> +	struct pci_dev *pdev;
>> +	struct t7xx_pci_dev *t7xx_dev;
>> +
>> +	pdev = to_pci_dev(dev);
>> +	t7xx_dev = pci_get_drvdata(pdev);
>> +	if (!t7xx_dev)
>> +		return -ENODEV;
>> +
>> +	atomic_set(&t7xx_dev->mode, T7XX_FASTBOOT_DL_SWITCHING);

>This function doesn't use @buf at all. So whenever user does write() to the file we set to SWITCHING? Shouldn't we narrow down the set of accepted values to be able to add more functionality later?

Yes, it doesn't use buff, just now only allows user setting SWITCHING.
Please let me narrow down the set to be more functionality.

>> +	return count;
>> +};

>unnecessary semi-colon

Best Regards,
Jinjian

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-01-10  7:15 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20231228094411.13224-1-songjinjian@hotmail.com>
2023-12-28  9:44 ` [net-next v3 1/3] wwan: core: Add WWAN fastboot port type Jinjian Song
2023-12-28  9:44 ` [net-next v3 2/3] net: wwan: t7xx: Add sysfs attribute for device state machine Jinjian Song
2024-01-08 15:19   ` Jakub Kicinski
2024-01-08 21:37   ` Sergey Ryazanov
2024-01-09 19:56     ` Nelson, Shannon
2023-12-28  9:44 ` [net-next v3 3/3] net: wwan: t7xx: Add fastboot WWAN port Jinjian Song
2024-01-08 21:30   ` Sergey Ryazanov
2024-01-10  3:40 [net-next v3 2/3] net: wwan: t7xx: Add sysfs attribute for device state machine Jinjian Song
  -- strict thread matches above, loose matches on Subject: below --
2024-01-10  7:15 Jinjian Song

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).