aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-09-13 14:32:49 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-09-26 12:01:15 -0400
commit03f3a9107f5e848a42f25e3ab133db9f3b6546c7 (patch)
treee42554ce998801ea3d10cbaf856be86fc2f86d21 /drivers
parent7d19143fe6bc928aab9968fd47fe39b4996a3297 (diff)
hv: use dev_groups for device attributes
This patch is the first in a series that moves the hv bus code to use the dev_groups field instead of dev_attrs, as dev_attrs is going away in future kernel releases. It moves the id sysfs file to the dev_groups structure, and creates the needed show/store functions, instead of relying on one "universal" function for this. By doing this, it removes the need for this to be in a temporary structure. Tested-by: "K. Y. Srinivasan" <kys@microsoft.com> Cc: Haiyang Zhang <haiyangz@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/hv/channel.c1
-rw-r--r--drivers/hv/vmbus_drv.c23
2 files changed, 18 insertions, 6 deletions
diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
index 6de6c98ce6eb..b58a1785d038 100644
--- a/drivers/hv/channel.c
+++ b/drivers/hv/channel.c
@@ -69,7 +69,6 @@ void vmbus_get_debug_info(struct vmbus_channel *channel,
69 u8 monitor_group = (u8)channel->offermsg.monitorid / 32; 69 u8 monitor_group = (u8)channel->offermsg.monitorid / 32;
70 u8 monitor_offset = (u8)channel->offermsg.monitorid % 32; 70 u8 monitor_offset = (u8)channel->offermsg.monitorid % 32;
71 71
72 debuginfo->relid = channel->offermsg.child_relid;
73 debuginfo->state = channel->state; 72 debuginfo->state = channel->state;
74 memcpy(&debuginfo->interfacetype, 73 memcpy(&debuginfo->interfacetype,
75 &channel->offermsg.offer.if_type, sizeof(uuid_le)); 74 &channel->offermsg.offer.if_type, sizeof(uuid_le));
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index f9fe46f52cfa..5c21b22860af 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -47,7 +47,6 @@ static struct completion probe_event;
47static int irq; 47static int irq;
48 48
49struct hv_device_info { 49struct hv_device_info {
50 u32 chn_id;
51 u32 chn_state; 50 u32 chn_state;
52 uuid_le chn_type; 51 uuid_le chn_type;
53 uuid_le chn_instance; 52 uuid_le chn_instance;
@@ -83,7 +82,6 @@ static void get_channel_info(struct hv_device *device,
83 82
84 vmbus_get_debug_info(device->channel, &debug_info); 83 vmbus_get_debug_info(device->channel, &debug_info);
85 84
86 info->chn_id = debug_info.relid;
87 info->chn_state = debug_info.state; 85 info->chn_state = debug_info.state;
88 memcpy(&info->chn_type, &debug_info.interfacetype, 86 memcpy(&info->chn_type, &debug_info.interfacetype,
89 sizeof(uuid_le)); 87 sizeof(uuid_le));
@@ -156,8 +154,6 @@ static ssize_t vmbus_show_device_attr(struct device *dev,
156 ret = sprintf(buf, "vmbus:%s\n", alias_name); 154 ret = sprintf(buf, "vmbus:%s\n", alias_name);
157 } else if (!strcmp(dev_attr->attr.name, "state")) { 155 } else if (!strcmp(dev_attr->attr.name, "state")) {
158 ret = sprintf(buf, "%d\n", device_info->chn_state); 156 ret = sprintf(buf, "%d\n", device_info->chn_state);
159 } else if (!strcmp(dev_attr->attr.name, "id")) {
160 ret = sprintf(buf, "%d\n", device_info->chn_id);
161 } else if (!strcmp(dev_attr->attr.name, "out_intr_mask")) { 157 } else if (!strcmp(dev_attr->attr.name, "out_intr_mask")) {
162 ret = sprintf(buf, "%d\n", device_info->outbound.int_mask); 158 ret = sprintf(buf, "%d\n", device_info->outbound.int_mask);
163 } else if (!strcmp(dev_attr->attr.name, "out_read_index")) { 159 } else if (!strcmp(dev_attr->attr.name, "out_read_index")) {
@@ -204,9 +200,25 @@ static ssize_t vmbus_show_device_attr(struct device *dev,
204 return ret; 200 return ret;
205} 201}
206 202
203static ssize_t id_show(struct device *dev, struct device_attribute *dev_attr,
204 char *buf)
205{
206 struct hv_device *hv_dev = device_to_hv_device(dev);
207
208 if (!hv_dev->channel)
209 return -ENODEV;
210 return sprintf(buf, "%d\n", hv_dev->channel->offermsg.child_relid);
211}
212static DEVICE_ATTR_RO(id);
213
214static struct attribute *vmbus_attrs[] = {
215 &dev_attr_id.attr,
216 NULL,
217};
218ATTRIBUTE_GROUPS(vmbus);
219
207/* Set up per device attributes in /sys/bus/vmbus/devices/<bus device> */ 220/* Set up per device attributes in /sys/bus/vmbus/devices/<bus device> */
208static struct device_attribute vmbus_device_attrs[] = { 221static struct device_attribute vmbus_device_attrs[] = {
209 __ATTR(id, S_IRUGO, vmbus_show_device_attr, NULL),
210 __ATTR(state, S_IRUGO, vmbus_show_device_attr, NULL), 222 __ATTR(state, S_IRUGO, vmbus_show_device_attr, NULL),
211 __ATTR(class_id, S_IRUGO, vmbus_show_device_attr, NULL), 223 __ATTR(class_id, S_IRUGO, vmbus_show_device_attr, NULL),
212 __ATTR(device_id, S_IRUGO, vmbus_show_device_attr, NULL), 224 __ATTR(device_id, S_IRUGO, vmbus_show_device_attr, NULL),
@@ -384,6 +396,7 @@ static struct bus_type hv_bus = {
384 .probe = vmbus_probe, 396 .probe = vmbus_probe,
385 .uevent = vmbus_uevent, 397 .uevent = vmbus_uevent,
386 .dev_attrs = vmbus_device_attrs, 398 .dev_attrs = vmbus_device_attrs,
399 .dev_groups = vmbus_groups,
387}; 400};
388 401
389static const char *driver_name = "hyperv"; 402static const char *driver_name = "hyperv";