Re: [PATCH] hpsa: convert DEVICE_ATTR to RO|WO|RW and show methods must use scnprintf

2015-06-30 Thread Greg KH
On Tue, Jun 30, 2015 at 05:22:20AM +, Seymour, Shane M wrote:
 
 Changed DEVICE_ATTR macro usage to DEVICE_ATTR_RO|WO|RW.
 This also forced some show/store function names to change.
 
 Changed all show method sprint/snprintf usage to scnprintf per
 Documentation/filesystems/sysfs.txt.

There's no need to change sprintf() to scnprintf() at all, that's just
useless churn.

 
 Signed-off-by: Shane Seymour shane.seym...@hp.com
 ---
 --- a/drivers/scsi/hpsa.c 2015-06-25 15:52:15.633031319 -0500
 +++ b/drivers/scsi/hpsa.c 2015-06-29 17:28:24.628475369 -0500
 @@ -376,7 +376,7 @@ static int check_for_busy(struct ctlr_in
  }
  
  static u32 lockup_detected(struct ctlr_info *h);
 -static ssize_t host_show_lockup_detected(struct device *dev,
 +static ssize_t lockup_detected_show(struct device *dev,
   struct device_attribute *attr, char *buf)
  {
   int ld;
 @@ -386,10 +386,10 @@ static ssize_t host_show_lockup_detected
   h = shost_to_hba(shost);
   ld = lockup_detected(h);
  
 - return sprintf(buf, ld=%d\n, ld);
 + return scnprintf(buf, PAGE_SIZE, ld=%d\n, ld);

Like here, it's obvious that the original will never overflow, so don't
even worry about checking, it's pointless.

So please don't change this.

greg k-h
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] hpsa: convert DEVICE_ATTR to RO|WO|RW and show methods must use scnprintf

2015-06-29 Thread Seymour, Shane M

Changed DEVICE_ATTR macro usage to DEVICE_ATTR_RO|WO|RW.
This also forced some show/store function names to change.

Changed all show method sprint/snprintf usage to scnprintf per
Documentation/filesystems/sysfs.txt.

Signed-off-by: Shane Seymour shane.seym...@hp.com
---
--- a/drivers/scsi/hpsa.c   2015-06-25 15:52:15.633031319 -0500
+++ b/drivers/scsi/hpsa.c   2015-06-29 17:28:24.628475369 -0500
@@ -376,7 +376,7 @@ static int check_for_busy(struct ctlr_in
 }
 
 static u32 lockup_detected(struct ctlr_info *h);
-static ssize_t host_show_lockup_detected(struct device *dev,
+static ssize_t lockup_detected_show(struct device *dev,
struct device_attribute *attr, char *buf)
 {
int ld;
@@ -386,10 +386,10 @@ static ssize_t host_show_lockup_detected
h = shost_to_hba(shost);
ld = lockup_detected(h);
 
-   return sprintf(buf, ld=%d\n, ld);
+   return scnprintf(buf, PAGE_SIZE, ld=%d\n, ld);
 }
 
-static ssize_t host_store_hp_ssd_smart_path_status(struct device *dev,
+static ssize_t hp_ssd_smart_path_status_store(struct device *dev,
 struct device_attribute *attr,
 const char *buf, size_t count)
 {
@@ -413,7 +413,7 @@ static ssize_t host_store_hp_ssd_smart_p
return count;
 }
 
-static ssize_t host_store_raid_offload_debug(struct device *dev,
+static ssize_t raid_offload_debug_store(struct device *dev,
 struct device_attribute *attr,
 const char *buf, size_t count)
 {
@@ -438,7 +438,7 @@ static ssize_t host_store_raid_offload_d
return count;
 }
 
-static ssize_t host_store_rescan(struct device *dev,
+static ssize_t rescan_store(struct device *dev,
 struct device_attribute *attr,
 const char *buf, size_t count)
 {
@@ -449,7 +449,7 @@ static ssize_t host_store_rescan(struct
return count;
 }
 
-static ssize_t host_show_firmware_revision(struct device *dev,
+static ssize_t firmware_revision_show(struct device *dev,
 struct device_attribute *attr, char *buf)
 {
struct ctlr_info *h;
@@ -460,40 +460,40 @@ static ssize_t host_show_firmware_revisi
if (!h-hba_inquiry_data)
return 0;
fwrev = h-hba_inquiry_data[32];
-   return snprintf(buf, 20, %c%c%c%c\n,
+   return scnprintf(buf, 20, %c%c%c%c\n,
fwrev[0], fwrev[1], fwrev[2], fwrev[3]);
 }
 
-static ssize_t host_show_commands_outstanding(struct device *dev,
+static ssize_t commands_outstanding_show(struct device *dev,
 struct device_attribute *attr, char *buf)
 {
struct Scsi_Host *shost = class_to_shost(dev);
struct ctlr_info *h = shost_to_hba(shost);
 
-   return snprintf(buf, 20, %d\n,
+   return scnprintf(buf, 20, %d\n,
atomic_read(h-commands_outstanding));
 }
 
-static ssize_t host_show_transport_mode(struct device *dev,
+static ssize_t transport_mode_show(struct device *dev,
struct device_attribute *attr, char *buf)
 {
struct ctlr_info *h;
struct Scsi_Host *shost = class_to_shost(dev);
 
h = shost_to_hba(shost);
-   return snprintf(buf, 20, %s\n,
+   return scnprintf(buf, 20, %s\n,
h-transMethod  CFGTBL_Trans_Performant ?
performant : simple);
 }
 
-static ssize_t host_show_hp_ssd_smart_path_status(struct device *dev,
+static ssize_t hp_ssd_smart_path_status_show(struct device *dev,
struct device_attribute *attr, char *buf)
 {
struct ctlr_info *h;
struct Scsi_Host *shost = class_to_shost(dev);
 
h = shost_to_hba(shost);
-   return snprintf(buf, 30, HP SSD Smart Path %s\n,
+   return scnprintf(buf, 30, HP SSD Smart Path %s\n,
(h-acciopath_status == 1) ?  enabled : disabled);
 }
 
@@ -582,14 +582,14 @@ static int ctlr_needs_abort_tags_swizzle
ARRAY_SIZE(needs_abort_tags_swizzled), board_id);
 }
 
-static ssize_t host_show_resettable(struct device *dev,
+static ssize_t resettable_show(struct device *dev,
struct device_attribute *attr, char *buf)
 {
struct ctlr_info *h;
struct Scsi_Host *shost = class_to_shost(dev);
 
h = shost_to_hba(shost);
-   return snprintf(buf, 20, %d\n, ctlr_is_resettable(h-board_id));
+   return scnprintf(buf, 20, %d\n, ctlr_is_resettable(h-board_id));
 }
 
 static inline int is_logical_dev_addr_mode(unsigned char scsi3addr[])
@@ -631,7 +631,7 @@ static ssize_t raid_level_show(struct de
/* Is this even a logical drive? */
if (!is_logical_dev_addr_mode(hdev-scsi3addr)) {
spin_unlock_irqrestore(h-lock, flags);
-   l = snprintf(buf, PAGE_SIZE, N/A\n);
+   l = scnprintf(buf, PAGE_SIZE, N/A\n);
return l;
}
 
@@ -639,7 +639,7 @@ static ssize_t