@@ -1558,13 +1558,147 @@ void mpi3mr_bsg_init(struct mpi3mr_ioc *mrioc)
1558
1558
kfree (mrioc -> bsg_dev );
1559
1559
}
1560
1560
1561
+ /**
1562
+ * version_fw_show - SysFS callback for firmware version read
1563
+ * @dev: class device
1564
+ * @attr: Device attributes
1565
+ * @buf: Buffer to copy
1566
+ *
1567
+ * Return: sysfs_emit() return after copying firmware version
1568
+ */
1569
+ static ssize_t
1570
+ version_fw_show (struct device * dev , struct device_attribute * attr ,
1571
+ char * buf )
1572
+ {
1573
+ struct Scsi_Host * shost = class_to_shost (dev );
1574
+ struct mpi3mr_ioc * mrioc = shost_priv (shost );
1575
+ struct mpi3mr_compimg_ver * fwver = & mrioc -> facts .fw_ver ;
1576
+
1577
+ return sysfs_emit (buf , "%d.%d.%d.%d.%05d-%05d\n" ,
1578
+ fwver -> gen_major , fwver -> gen_minor , fwver -> ph_major ,
1579
+ fwver -> ph_minor , fwver -> cust_id , fwver -> build_num );
1580
+ }
1581
+ static DEVICE_ATTR_RO (version_fw );
1582
+
1583
+ /**
1584
+ * fw_queue_depth_show - SysFS callback for firmware max cmds
1585
+ * @dev: class device
1586
+ * @attr: Device attributes
1587
+ * @buf: Buffer to copy
1588
+ *
1589
+ * Return: sysfs_emit() return after copying firmware max commands
1590
+ */
1591
+ static ssize_t
1592
+ fw_queue_depth_show (struct device * dev , struct device_attribute * attr ,
1593
+ char * buf )
1594
+ {
1595
+ struct Scsi_Host * shost = class_to_shost (dev );
1596
+ struct mpi3mr_ioc * mrioc = shost_priv (shost );
1597
+
1598
+ return sysfs_emit (buf , "%d\n" , mrioc -> facts .max_reqs );
1599
+ }
1600
+ static DEVICE_ATTR_RO (fw_queue_depth );
1601
+
1602
+ /**
1603
+ * op_req_q_count_show - SysFS callback for request queue count
1604
+ * @dev: class device
1605
+ * @attr: Device attributes
1606
+ * @buf: Buffer to copy
1607
+ *
1608
+ * Return: sysfs_emit() return after copying request queue count
1609
+ */
1610
+ static ssize_t
1611
+ op_req_q_count_show (struct device * dev , struct device_attribute * attr ,
1612
+ char * buf )
1613
+ {
1614
+ struct Scsi_Host * shost = class_to_shost (dev );
1615
+ struct mpi3mr_ioc * mrioc = shost_priv (shost );
1616
+
1617
+ return sysfs_emit (buf , "%d\n" , mrioc -> num_op_req_q );
1618
+ }
1619
+ static DEVICE_ATTR_RO (op_req_q_count );
1620
+
1621
+ /**
1622
+ * reply_queue_count_show - SysFS callback for reply queue count
1623
+ * @dev: class device
1624
+ * @attr: Device attributes
1625
+ * @buf: Buffer to copy
1626
+ *
1627
+ * Return: sysfs_emit() return after copying reply queue count
1628
+ */
1629
+ static ssize_t
1630
+ reply_queue_count_show (struct device * dev , struct device_attribute * attr ,
1631
+ char * buf )
1632
+ {
1633
+ struct Scsi_Host * shost = class_to_shost (dev );
1634
+ struct mpi3mr_ioc * mrioc = shost_priv (shost );
1635
+
1636
+ return sysfs_emit (buf , "%d\n" , mrioc -> num_op_reply_q );
1637
+ }
1638
+
1639
+ static DEVICE_ATTR_RO (reply_queue_count );
1640
+
1641
+ /**
1642
+ * logging_level_show - Show controller debug level
1643
+ * @dev: class device
1644
+ * @attr: Device attributes
1645
+ * @buf: Buffer to copy
1646
+ *
1647
+ * A sysfs 'read/write' shost attribute, to show the current
1648
+ * debug log level used by the driver for the specific
1649
+ * controller.
1650
+ *
1651
+ * Return: sysfs_emit() return
1652
+ */
1653
+ static ssize_t
1654
+ logging_level_show (struct device * dev ,
1655
+ struct device_attribute * attr , char * buf )
1656
+
1657
+ {
1658
+ struct Scsi_Host * shost = class_to_shost (dev );
1659
+ struct mpi3mr_ioc * mrioc = shost_priv (shost );
1660
+
1661
+ return sysfs_emit (buf , "%08xh\n" , mrioc -> logging_level );
1662
+ }
1663
+
1664
+ /**
1665
+ * logging_level_store- Change controller debug level
1666
+ * @dev: class device
1667
+ * @attr: Device attributes
1668
+ * @buf: Buffer to copy
1669
+ * @count: size of the buffer
1670
+ *
1671
+ * A sysfs 'read/write' shost attribute, to change the current
1672
+ * debug log level used by the driver for the specific
1673
+ * controller.
1674
+ *
1675
+ * Return: strlen() return
1676
+ */
1677
+ static ssize_t
1678
+ logging_level_store (struct device * dev ,
1679
+ struct device_attribute * attr ,
1680
+ const char * buf , size_t count )
1681
+ {
1682
+ struct Scsi_Host * shost = class_to_shost (dev );
1683
+ struct mpi3mr_ioc * mrioc = shost_priv (shost );
1684
+ int val = 0 ;
1685
+
1686
+ if (kstrtoint (buf , 0 , & val ) != 0 )
1687
+ return - EINVAL ;
1688
+
1689
+ mrioc -> logging_level = val ;
1690
+ ioc_info (mrioc , "logging_level=%08xh\n" , mrioc -> logging_level );
1691
+ return strlen (buf );
1692
+ }
1693
+ static DEVICE_ATTR_RW (logging_level );
1694
+
1561
1695
/**
1562
1696
* adapter_state_show - SysFS callback for adapter state show
1563
1697
* @dev: class device
1564
1698
* @attr: Device attributes
1565
1699
* @buf: Buffer to copy
1566
1700
*
1567
- * Return: snprintf () return after copying adapter state
1701
+ * Return: sysfs_emit () return after copying adapter state
1568
1702
*/
1569
1703
static ssize_t
1570
1704
adp_state_show (struct device * dev , struct device_attribute * attr ,
@@ -1585,12 +1719,17 @@ adp_state_show(struct device *dev, struct device_attribute *attr,
1585
1719
else
1586
1720
adp_state = MPI3MR_BSG_ADPSTATE_OPERATIONAL ;
1587
1721
1588
- return snprintf (buf , PAGE_SIZE , "%u\n" , adp_state );
1722
+ return sysfs_emit (buf , "%u\n" , adp_state );
1589
1723
}
1590
1724
1591
1725
static DEVICE_ATTR_RO (adp_state );
1592
1726
1593
1727
static struct attribute * mpi3mr_host_attrs [] = {
1728
+ & dev_attr_version_fw .attr ,
1729
+ & dev_attr_fw_queue_depth .attr ,
1730
+ & dev_attr_op_req_q_count .attr ,
1731
+ & dev_attr_reply_queue_count .attr ,
1732
+ & dev_attr_logging_level .attr ,
1594
1733
& dev_attr_adp_state .attr ,
1595
1734
NULL ,
1596
1735
};
0 commit comments