On 02/01/2020 12:07, Jinpu Wang wrote:
On Tue, Dec 24, 2019 at 5:41 AM Deepak Ukey <deepak.ukey@xxxxxxxxxxxxx> wrote:
From: Viswas G <Viswas.G@xxxxxxxxxxxxx>
Added sysfs attribute to show number of phys.
Signed-off-by: Deepak Ukey <deepak.ukey@xxxxxxxxxxxxx>
Signed-off-by: Viswas G <Viswas.G@xxxxxxxxxxxxx>
Signed-off-by: Vishakha Channapattan <vishakhavc@xxxxxxxxxx>
Signed-off-by: Bhavesh Jashnani <bjashnani@xxxxxxxxxx>
Signed-off-by: Radha Ramachandran <radha@xxxxxxxxxx>
Signed-off-by: Akshat Jain <akshatzen@xxxxxxxxxx>
Signed-off-by: Yu Zheng <yuuzheng@xxxxxxxxxx>
---
drivers/scsi/pm8001/pm8001_ctl.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/drivers/scsi/pm8001/pm8001_ctl.c b/drivers/scsi/pm8001/pm8001_ctl.c
index 69458b318a20..704c0daa7937 100644
--- a/drivers/scsi/pm8001/pm8001_ctl.c
+++ b/drivers/scsi/pm8001/pm8001_ctl.c
@@ -89,6 +89,25 @@ static ssize_t controller_fatal_error_show(struct device *cdev,
}
static DEVICE_ATTR_RO(controller_fatal_error);
+/**
+ * pm8001_ctl_num_phys_show - Number of phys
+ * @cdev:pointer to embedded class device
+ * @buf:the buffer returned
+ * A sysfs 'read-only' shost attribute.
+ */
+static ssize_t num_phys_show(struct device *cdev,
+ struct device_attribute *attr, char *buf)
please use pm8001_ctl_num_phys_show as function name, so it follows
same conversion as other functions.
Better also rename controller_fatal_error too.
If you don't mind me saying, this info is already available in sysfs for
any libsas or even SAS host (using scsi_transport_sas.c), like this:
john@ubuntu:/sys/class/sas_phy$ ls
phy-0:0 phy-0:0:12 phy-0:0:17 phy-0:0:21 phy-0:0:4 phy-0:0:9
phy-0:5
phy-0:0:0 phy-0:0:13 phy-0:0:18 phy-0:0:22 phy-0:0:5 phy-0:1
phy-0:6
phy-0:0:1 phy-0:0:14 phy-0:0:19 phy-0:0:23 phy-0:0:6 phy-0:2
phy-0:7
phy-0:0:10 phy-0:0:15 phy-0:0:2 phy-0:0:24 phy-0:0:7 phy-0:3
phy-0:0:11 phy-0:0:16 phy-0:0:20 phy-0:0:3 phy-0:0:8 phy-0:4
Any phy-X:Y is a root phy, and X denotes the host index and Y is the phy
index.
Thanks
+{
+ int ret;
+ 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;
+
+ ret = sprintf(buf, "%d", pm8001_ha->chip->n_phy);
+ return ret;
+}
+static DEVICE_ATTR_RO(num_phys);
+
/**
* pm8001_ctl_fw_version_show - firmware version
* @cdev: pointer to embedded class device
@@ -825,6 +844,7 @@ static DEVICE_ATTR(update_fw, S_IRUGO|S_IWUSR|S_IWGRP,
struct device_attribute *pm8001_host_attrs[] = {
&dev_attr_interface_rev,
&dev_attr_controller_fatal_error,
+ &dev_attr_num_phys,
&dev_attr_fw_version,
&dev_attr_update_fw,
&dev_attr_aap_log,
--
2.16.3
.