* [PATCH] scsi_dh: convert __ATTR macro to DEVICE_ATTR_RW and snprintf show method cleanup
@ 2015-06-26 6:38 Seymour, Shane M
2015-06-29 11:40 ` Hannes Reinecke
0 siblings, 1 reply; 2+ messages in thread
From: Seymour, Shane M @ 2015-06-26 6:38 UTC (permalink / raw)
To: linux-scsi@vger.kernel.org, James Bottomley (JBottomley@Odin.com)
Converted dh_state to use DEVICE_ATTR_RW macro
instead of __ATTR. That forced a change to the associated
show/store function names and the name of the attribute.
Changed usage of snprintf in show function to scnprintf per
Documentation/filesystems/sysfs.txt.
Signed-off-by: Shane Seymour <shane.seymour@hp.com>
---
--- a/drivers/scsi/device_handler/scsi_dh.c 2015-06-25 15:52:15.616031320 -0500
+++ b/drivers/scsi/device_handler/scsi_dh.c 2015-06-25 18:10:54.246839220 -0500
@@ -174,7 +174,7 @@ static void scsi_dh_handler_detach(struc
* Functions for sysfs attribute 'dh_state'
*/
static ssize_t
-store_dh_state(struct device *dev, struct device_attribute *attr,
+dh_state_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
struct scsi_device *sdev = to_scsi_device(dev);
@@ -215,19 +215,17 @@ store_dh_state(struct device *dev, struc
}
static ssize_t
-show_dh_state(struct device *dev, struct device_attribute *attr, char *buf)
+dh_state_show(struct device *dev, struct device_attribute *attr, char *buf)
{
struct scsi_device *sdev = to_scsi_device(dev);
if (!sdev->scsi_dh_data)
- return snprintf(buf, 20, "detached\n");
+ return scnprintf(buf, 20, "detached\n");
- return snprintf(buf, 20, "%s\n", sdev->scsi_dh_data->scsi_dh->name);
+ return scnprintf(buf, 20, "%s\n", sdev->scsi_dh_data->scsi_dh->name);
}
-static struct device_attribute scsi_dh_state_attr =
- __ATTR(dh_state, S_IRUGO | S_IWUSR, show_dh_state,
- store_dh_state);
+static DEVICE_ATTR_RW(dh_state);
/*
* scsi_dh_sysfs_attr_add - Callback for scsi_init_dh
@@ -243,7 +241,7 @@ static int scsi_dh_sysfs_attr_add(struct
sdev = to_scsi_device(dev);
err = device_create_file(&sdev->sdev_gendev,
- &scsi_dh_state_attr);
+ &dev_attr_dh_state);
return 0;
}
@@ -261,7 +259,7 @@ static int scsi_dh_sysfs_attr_remove(str
sdev = to_scsi_device(dev);
device_remove_file(&sdev->sdev_gendev,
- &scsi_dh_state_attr);
+ &dev_attr_dh_state);
return 0;
}
@@ -283,13 +281,13 @@ static int scsi_dh_notifier(struct notif
sdev = to_scsi_device(dev);
if (action == BUS_NOTIFY_ADD_DEVICE) {
- err = device_create_file(dev, &scsi_dh_state_attr);
+ err = device_create_file(dev, &dev_attr_dh_state);
/* don't care about err */
devinfo = device_handler_match(NULL, sdev);
if (devinfo)
err = scsi_dh_handler_attach(sdev, devinfo);
} else if (action == BUS_NOTIFY_DEL_DEVICE) {
- device_remove_file(dev, &scsi_dh_state_attr);
+ device_remove_file(dev, &dev_attr_dh_state);
scsi_dh_handler_detach(sdev, NULL);
}
return err;
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] scsi_dh: convert __ATTR macro to DEVICE_ATTR_RW and snprintf show method cleanup
2015-06-26 6:38 [PATCH] scsi_dh: convert __ATTR macro to DEVICE_ATTR_RW and snprintf show method cleanup Seymour, Shane M
@ 2015-06-29 11:40 ` Hannes Reinecke
0 siblings, 0 replies; 2+ messages in thread
From: Hannes Reinecke @ 2015-06-29 11:40 UTC (permalink / raw)
To: Seymour, Shane M, linux-scsi@vger.kernel.org,
James Bottomley (JBottomley@Odin.com)
On 06/26/2015 08:38 AM, Seymour, Shane M wrote:
>
> Converted dh_state to use DEVICE_ATTR_RW macro
> instead of __ATTR. That forced a change to the associated
> show/store function names and the name of the attribute.
>
> Changed usage of snprintf in show function to scnprintf per
> Documentation/filesystems/sysfs.txt.
>
> Signed-off-by: Shane Seymour <shane.seymour@hp.com>
> ---
Reviewed-by: Hannes Reinecke <hare@suse.de>
Note that I'm currently preparing a device handler update, based
upon an earlier patchset from hch.
I'll be folding this patch into it, unless it'll be picked up earlier.
Cheers,
Hannes
--
Dr. Hannes Reinecke zSeries & Storage
hare@suse.de +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)
--
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-06-29 11:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-26 6:38 [PATCH] scsi_dh: convert __ATTR macro to DEVICE_ATTR_RW and snprintf show method cleanup Seymour, Shane M
2015-06-29 11:40 ` Hannes Reinecke
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).