From patchwork Wed Jul 1 01:56:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Seymour, Shane M" X-Patchwork-Id: 6699061 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C4628C05AC for ; Wed, 1 Jul 2015 01:58:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D2B102041E for ; Wed, 1 Jul 2015 01:58:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 742902042A for ; Wed, 1 Jul 2015 01:58:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753149AbbGAB6G (ORCPT ); Tue, 30 Jun 2015 21:58:06 -0400 Received: from g9t5009.houston.hp.com ([15.240.92.67]:44419 "EHLO g9t5009.houston.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753001AbbGAB6D convert rfc822-to-8bit (ORCPT ); Tue, 30 Jun 2015 21:58:03 -0400 Received: from G9W0364.americas.hpqcorp.net (g9w0364.houston.hp.com [16.216.193.45]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by g9t5009.houston.hp.com (Postfix) with ESMTPS id 51315D5; Wed, 1 Jul 2015 01:58:02 +0000 (UTC) Received: from G9W3613.americas.hpqcorp.net (16.216.186.48) by G9W0364.americas.hpqcorp.net (16.216.193.45) with Microsoft SMTP Server (TLS) id 14.3.169.1; Wed, 1 Jul 2015 01:56:04 +0000 Received: from G9W0766.americas.hpqcorp.net ([169.254.4.103]) by G9W3613.americas.hpqcorp.net ([16.216.186.48]) with mapi id 14.03.0169.001; Wed, 1 Jul 2015 01:56:04 +0000 From: "Seymour, Shane M" To: ISS StorageDev , "James Bottomley (JBottomley@Odin.com)" , Greg KH CC: "linux-api@vger.kernel.org" , "linux-scsi@vger.kernel.org" Subject: [PATCH v2] hpsa: convert DEVICE_ATTR to RO|WO|RW and show methods must not use snprintf Thread-Topic: [PATCH v2] hpsa: convert DEVICE_ATTR to RO|WO|RW and show methods must not use snprintf Thread-Index: AdCzoN2D4nI7fk0USGitz1c+CrFUNw== Date: Wed, 1 Jul 2015 01:56:03 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [16.210.48.15] MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 snprintf() usage to scnprintf() per Documentation/filesystems/sysfs.txt. Signed-off-by: Shane Seymour --- Changes from v1: Dropped one sprintf() to scnprintf() change in show method. -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- a/drivers/scsi/hpsa.c 2015-06-25 15:52:15.633031319 -0500 +++ b/drivers/scsi/hpsa.c 2015-06-30 15:06:14.664263348 -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; @@ -389,7 +389,7 @@ static ssize_t host_show_lockup_detected return sprintf(buf, "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 raid_level_show(struct de spin_unlock_irqrestore(&h->lock, flags); if (rlevel > RAID_UNKNOWN) rlevel = RAID_UNKNOWN; - l = snprintf(buf, PAGE_SIZE, "RAID %s\n", raid_label[rlevel]); + l = scnprintf(buf, PAGE_SIZE, "RAID %s\n", raid_label[rlevel]); return l; } @@ -662,7 +662,7 @@ static ssize_t lunid_show(struct device } memcpy(lunid, hdev->scsi3addr, sizeof(lunid)); spin_unlock_irqrestore(&h->lock, flags); - return snprintf(buf, 20, "0x%02x%02x%02x%02x%02x%02x%02x%02x\n", + return scnprintf(buf, 20, "0x%02x%02x%02x%02x%02x%02x%02x%02x\n", lunid[0], lunid[1], lunid[2], lunid[3], lunid[4], lunid[5], lunid[6], lunid[7]); } @@ -686,7 +686,7 @@ static ssize_t unique_id_show(struct dev } memcpy(sn, hdev->device_id, sizeof(sn)); spin_unlock_irqrestore(&h->lock, flags); - return snprintf(buf, 16 * 2 + 2, + return scnprintf(buf, 16 * 2 + 2, "%02X%02X%02X%02X%02X%02X%02X%02X" "%02X%02X%02X%02X%02X%02X%02X%02X\n", sn[0], sn[1], sn[2], sn[3], @@ -695,7 +695,7 @@ static ssize_t unique_id_show(struct dev sn[12], sn[13], sn[14], sn[15]); } -static ssize_t host_show_hp_ssd_smart_path_enabled(struct device *dev, +static ssize_t hp_ssd_smart_path_enabled_show(struct device *dev, struct device_attribute *attr, char *buf) { struct ctlr_info *h; @@ -714,30 +714,21 @@ static ssize_t host_show_hp_ssd_smart_pa } offload_enabled = hdev->offload_enabled; spin_unlock_irqrestore(&h->lock, flags); - return snprintf(buf, 20, "%d\n", offload_enabled); + return scnprintf(buf, 20, "%d\n", offload_enabled); } -static DEVICE_ATTR(raid_level, S_IRUGO, raid_level_show, NULL); -static DEVICE_ATTR(lunid, S_IRUGO, lunid_show, NULL); -static DEVICE_ATTR(unique_id, S_IRUGO, unique_id_show, NULL); -static DEVICE_ATTR(rescan, S_IWUSR, NULL, host_store_rescan); -static DEVICE_ATTR(hp_ssd_smart_path_enabled, S_IRUGO, - host_show_hp_ssd_smart_path_enabled, NULL); -static DEVICE_ATTR(hp_ssd_smart_path_status, S_IWUSR|S_IRUGO|S_IROTH, - host_show_hp_ssd_smart_path_status, - host_store_hp_ssd_smart_path_status); -static DEVICE_ATTR(raid_offload_debug, S_IWUSR, NULL, - host_store_raid_offload_debug); -static DEVICE_ATTR(firmware_revision, S_IRUGO, - host_show_firmware_revision, NULL); -static DEVICE_ATTR(commands_outstanding, S_IRUGO, - host_show_commands_outstanding, NULL); -static DEVICE_ATTR(transport_mode, S_IRUGO, - host_show_transport_mode, NULL); -static DEVICE_ATTR(resettable, S_IRUGO, - host_show_resettable, NULL); -static DEVICE_ATTR(lockup_detected, S_IRUGO, - host_show_lockup_detected, NULL); +static DEVICE_ATTR_RO(raid_level); +static DEVICE_ATTR_RO(lunid); +static DEVICE_ATTR_RO(unique_id); +static DEVICE_ATTR_WO(rescan); +static DEVICE_ATTR_RO(hp_ssd_smart_path_enabled); +static DEVICE_ATTR_RW(hp_ssd_smart_path_status); +static DEVICE_ATTR_WO(raid_offload_debug); +static DEVICE_ATTR_RO(firmware_revision); +static DEVICE_ATTR_RO(commands_outstanding); +static DEVICE_ATTR_RO(transport_mode); +static DEVICE_ATTR_RO(resettable); +static DEVICE_ATTR_RO(lockup_detected); static struct device_attribute *hpsa_sdev_attrs[] = { &dev_attr_raid_level,