Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: Deepak R Varma <drv@mailo.com>
To: Jack Wang <jinpu.wang@cloud.ionos.com>,
	"James E.J. Bottomley" <jejb@linux.ibm.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Saurabh Singh Sengar <ssengar@microsoft.com>,
	Praveen Kumar <kumarpraveen@linux.microsoft.com>,
	drv@mailo.com
Subject: Re: [PATCH] scsi: pm8001: Use sysfs_emit in show function callsbacks
Date: Wed, 28 Dec 2022 15:45:10 +0530	[thread overview]
Message-ID: <Y6wXLu8bOax5DHrP@qemulion> (raw)
In-Reply-To: <Y53ZzSvDz8w7fZyr@qemulion>

On Sat, Dec 17, 2022 at 08:31:33PM +0530, Deepak R Varma wrote:
> On Fri, Dec 09, 2022 at 01:41:43AM +0530, Deepak R Varma wrote:
> > According to Documentation/filesystems/sysfs.rst, the show() callback
> > function of kobject attributes should strictly use sysfs_emit instead
> > of sprintf family functions.
> > Issue identified using the coccinelle device_attr_show.cocci script.
> >
> > Signed-off-by: Deepak R Varma <drv@mailo.com>
> > ---
>
> Hello All,
> Just wanted to follow up on this patch submitted earlier. May I please request
> a review and feedback on this patch.

Hello,
Requesting a review and feedback on this patch proposal please.

Thank you,
./drv

>
> Thank you,
> ./drv
>
> >  drivers/scsi/pm8001/pm8001_ctl.c | 48 +++++++++++++++-----------------
> >  1 file changed, 22 insertions(+), 26 deletions(-)
> >
> > diff --git a/drivers/scsi/pm8001/pm8001_ctl.c b/drivers/scsi/pm8001/pm8001_ctl.c
> > index 73f036bed128..8cfdf9b412c9 100644
> > --- a/drivers/scsi/pm8001/pm8001_ctl.c
> > +++ b/drivers/scsi/pm8001/pm8001_ctl.c
> > @@ -61,10 +61,10 @@ static ssize_t pm8001_ctl_mpi_interface_rev_show(struct device *cdev,
> >  	struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
> >
> >  	if (pm8001_ha->chip_id == chip_8001) {
> > -		return snprintf(buf, PAGE_SIZE, "%d\n",
> > +		return sysfs_emit(buf, "%d\n",
> >  			pm8001_ha->main_cfg_tbl.pm8001_tbl.interface_rev);
> >  	} else {
> > -		return snprintf(buf, PAGE_SIZE, "%d\n",
> > +		return sysfs_emit(buf, "%d\n",
> >  			pm8001_ha->main_cfg_tbl.pm80xx_tbl.interface_rev);
> >  	}
> >  }
> > @@ -86,7 +86,7 @@ static ssize_t controller_fatal_error_show(struct device *cdev,
> >  	struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
> >  	struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
> >
> > -	return snprintf(buf, PAGE_SIZE, "%d\n",
> > +	return sysfs_emit(buf, "%d\n",
> >  			pm8001_ha->controller_fatal_error);
> >  }
> >  static DEVICE_ATTR_RO(controller_fatal_error);
> > @@ -107,13 +107,13 @@ static ssize_t pm8001_ctl_fw_version_show(struct device *cdev,
> >  	struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
> >
> >  	if (pm8001_ha->chip_id == chip_8001) {
> > -		return snprintf(buf, PAGE_SIZE, "%02x.%02x.%02x.%02x\n",
> > +		return sysfs_emit(buf, "%02x.%02x.%02x.%02x\n",
> >  		(u8)(pm8001_ha->main_cfg_tbl.pm8001_tbl.firmware_rev >> 24),
> >  		(u8)(pm8001_ha->main_cfg_tbl.pm8001_tbl.firmware_rev >> 16),
> >  		(u8)(pm8001_ha->main_cfg_tbl.pm8001_tbl.firmware_rev >> 8),
> >  		(u8)(pm8001_ha->main_cfg_tbl.pm8001_tbl.firmware_rev));
> >  	} else {
> > -		return snprintf(buf, PAGE_SIZE, "%02x.%02x.%02x.%02x\n",
> > +		return sysfs_emit(buf, "%02x.%02x.%02x.%02x\n",
> >  		(u8)(pm8001_ha->main_cfg_tbl.pm80xx_tbl.firmware_rev >> 24),
> >  		(u8)(pm8001_ha->main_cfg_tbl.pm80xx_tbl.firmware_rev >> 16),
> >  		(u8)(pm8001_ha->main_cfg_tbl.pm80xx_tbl.firmware_rev >> 8),
> > @@ -138,7 +138,7 @@ static ssize_t pm8001_ctl_ila_version_show(struct device *cdev,
> >  	struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
> >
> >  	if (pm8001_ha->chip_id != chip_8001) {
> > -		return snprintf(buf, PAGE_SIZE, "%02x.%02x.%02x.%02x\n",
> > +		return sysfs_emit(buf, "%02x.%02x.%02x.%02x\n",
> >  		(u8)(pm8001_ha->main_cfg_tbl.pm80xx_tbl.ila_version >> 24),
> >  		(u8)(pm8001_ha->main_cfg_tbl.pm80xx_tbl.ila_version >> 16),
> >  		(u8)(pm8001_ha->main_cfg_tbl.pm80xx_tbl.ila_version >> 8),
> > @@ -164,7 +164,7 @@ static ssize_t pm8001_ctl_inactive_fw_version_show(struct device *cdev,
> >  	struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
> >
> >  	if (pm8001_ha->chip_id != chip_8001) {
> > -		return snprintf(buf, PAGE_SIZE, "%02x.%02x.%02x.%02x\n",
> > +		return sysfs_emit(buf, "%02x.%02x.%02x.%02x\n",
> >  		(u8)(pm8001_ha->main_cfg_tbl.pm80xx_tbl.inc_fw_version >> 24),
> >  		(u8)(pm8001_ha->main_cfg_tbl.pm80xx_tbl.inc_fw_version >> 16),
> >  		(u8)(pm8001_ha->main_cfg_tbl.pm80xx_tbl.inc_fw_version >> 8),
> > @@ -191,10 +191,10 @@ static ssize_t pm8001_ctl_max_out_io_show(struct device *cdev,
> >  	struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
> >
> >  	if (pm8001_ha->chip_id == chip_8001) {
> > -		return snprintf(buf, PAGE_SIZE, "%d\n",
> > +		return sysfs_emit(buf, "%d\n",
> >  			pm8001_ha->main_cfg_tbl.pm8001_tbl.max_out_io);
> >  	} else {
> > -		return snprintf(buf, PAGE_SIZE, "%d\n",
> > +		return sysfs_emit(buf, "%d\n",
> >  			pm8001_ha->main_cfg_tbl.pm80xx_tbl.max_out_io);
> >  	}
> >  }
> > @@ -215,13 +215,11 @@ static ssize_t pm8001_ctl_max_devices_show(struct device *cdev,
> >  	struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
> >
> >  	if (pm8001_ha->chip_id == chip_8001) {
> > -		return snprintf(buf, PAGE_SIZE, "%04d\n",
> > -			(u16)(pm8001_ha->main_cfg_tbl.pm8001_tbl.max_sgl >> 16)
> > -			);
> > +		return sysfs_emit(buf, "%04d\n",
> > +			(u16)(pm8001_ha->main_cfg_tbl.pm8001_tbl.max_sgl >> 16));
> >  	} else {
> > -		return snprintf(buf, PAGE_SIZE, "%04d\n",
> > -			(u16)(pm8001_ha->main_cfg_tbl.pm80xx_tbl.max_sgl >> 16)
> > -			);
> > +		return sysfs_emit(buf, "%04d\n",
> > +			(u16)(pm8001_ha->main_cfg_tbl.pm80xx_tbl.max_sgl >> 16));
> >  	}
> >  }
> >  static DEVICE_ATTR(max_devices, S_IRUGO, pm8001_ctl_max_devices_show, NULL);
> > @@ -242,13 +240,11 @@ static ssize_t pm8001_ctl_max_sg_list_show(struct device *cdev,
> >  	struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
> >
> >  	if (pm8001_ha->chip_id == chip_8001) {
> > -		return snprintf(buf, PAGE_SIZE, "%04d\n",
> > -			pm8001_ha->main_cfg_tbl.pm8001_tbl.max_sgl & 0x0000FFFF
> > -			);
> > +		return sysfs_emit(buf, "%04d\n",
> > +			pm8001_ha->main_cfg_tbl.pm8001_tbl.max_sgl & 0x0000FFFF);
> >  	} else {
> > -		return snprintf(buf, PAGE_SIZE, "%04d\n",
> > -			pm8001_ha->main_cfg_tbl.pm80xx_tbl.max_sgl & 0x0000FFFF
> > -			);
> > +		return sysfs_emit(buf, "%04d\n",
> > +			pm8001_ha->main_cfg_tbl.pm80xx_tbl.max_sgl & 0x0000FFFF);
> >  	}
> >  }
> >  static DEVICE_ATTR(max_sg_list, S_IRUGO, pm8001_ctl_max_sg_list_show, NULL);
> > @@ -315,7 +311,7 @@ static ssize_t pm8001_ctl_host_sas_address_show(struct device *cdev,
> >  	struct Scsi_Host *shost = class_to_shost(cdev);
> >  	struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
> >  	struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
> > -	return snprintf(buf, PAGE_SIZE, "0x%016llx\n",
> > +	return sysfs_emit(buf, "0x%016llx\n",
> >  			be64_to_cpu(*(__be64 *)pm8001_ha->sas_addr));
> >  }
> >  static DEVICE_ATTR(host_sas_address, S_IRUGO,
> > @@ -336,7 +332,7 @@ static ssize_t pm8001_ctl_logging_level_show(struct device *cdev,
> >  	struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
> >  	struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
> >
> > -	return snprintf(buf, PAGE_SIZE, "%08xh\n", pm8001_ha->logging_level);
> > +	return sysfs_emit(buf, "%08xh\n", pm8001_ha->logging_level);
> >  }
> >
> >  static ssize_t pm8001_ctl_logging_level_store(struct device *cdev,
> > @@ -517,7 +513,7 @@ static ssize_t event_log_size_show(struct device *cdev,
> >  	struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
> >  	struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
> >
> > -	return snprintf(buf, PAGE_SIZE, "%d\n",
> > +	return sysfs_emit(buf, "%d\n",
> >  		pm8001_ha->main_cfg_tbl.pm80xx_tbl.event_log_size);
> >  }
> >  static DEVICE_ATTR_RO(event_log_size);
> > @@ -604,7 +600,7 @@ static ssize_t non_fatal_count_show(struct device *cdev,
> >  	struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
> >  	struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
> >
> > -	return snprintf(buf, PAGE_SIZE, "%08x",
> > +	return sysfs_emit(buf, "%08x",
> >  			pm8001_ha->non_fatal_count);
> >  }
> >
> > @@ -884,7 +880,7 @@ static ssize_t pm8001_show_update_fw(struct device *cdev,
> >  	if (pm8001_ha->fw_status != FLASH_IN_PROGRESS)
> >  		pm8001_ha->fw_status = FLASH_OK;
> >
> > -	return snprintf(buf, PAGE_SIZE, "status=%x %s\n",
> > +	return sysfs_emit(buf, "status=%x %s\n",
> >  			flash_error_table[i].err_code,
> >  			flash_error_table[i].reason);
> >  }
> > --
> > 2.34.1
> >



       reply	other threads:[~2022-12-28 10:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <Y5JE/xI2NNbnox/A@qemulion>
     [not found] ` <Y53ZzSvDz8w7fZyr@qemulion>
2022-12-28 10:15   ` Deepak R Varma [this message]
2023-01-02 14:33 ` [PATCH] scsi: pm8001: Use sysfs_emit in show function callsbacks Jinpu Wang

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=Y6wXLu8bOax5DHrP@qemulion \
    --to=drv@mailo.com \
    --cc=jejb@linux.ibm.com \
    --cc=jinpu.wang@cloud.ionos.com \
    --cc=kumarpraveen@linux.microsoft.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=ssengar@microsoft.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