* [PATCH] Staging: hv: vmbus: Show the modalias in /sys/bus/vmbus/devices/*/
@ 2011-09-02 16:25 Olaf Hering
2011-09-02 16:35 ` Greg KH
2011-09-02 17:50 ` KY Srinivasan
0 siblings, 2 replies; 6+ messages in thread
From: Olaf Hering @ 2011-09-02 16:25 UTC (permalink / raw)
To: K. Y. Srinivasan; +Cc: gregkh, linux-kernel, devel, virtualization
Show a modalias file in /sys/bus/vmbus/devices/*/
Add a helper function to print the same content in modalias and uevent.
Signed-off-by: Olaf Hering <olaf@aepfle.de>
---
drivers/staging/hv/vmbus_drv.c | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -93,6 +93,14 @@ static void get_channel_info(struct hv_d
debug_info.outbound.bytes_avail_towrite;
}
+#define VMBUS_ALIAS_LEN ((sizeof((struct hv_vmbus_device_id *)0)->guid) * 2)
+static void print_alias_name(struct hv_device *hv_dev, char *alias_name)
+{
+ int i;
+ for (i = 0; i < VMBUS_ALIAS_LEN; i += 2)
+ sprintf(&alias_name[i], "%02x", hv_dev->dev_type.b[i/2]);
+}
+
/*
* vmbus_show_device_attr - Show the device attribute in sysfs.
*
@@ -105,6 +113,7 @@ static ssize_t vmbus_show_device_attr(st
{
struct hv_device *hv_dev = device_to_hv_device(dev);
struct hv_device_info device_info;
+ char alias_name[VMBUS_ALIAS_LEN + 1];
memset(&device_info, 0, sizeof(struct hv_device_info));
@@ -148,6 +157,9 @@ static ssize_t vmbus_show_device_attr(st
device_info.chn_instance.b[13],
device_info.chn_instance.b[14],
device_info.chn_instance.b[15]);
+ } else if (!strcmp(dev_attr->attr.name, "modalias")) {
+ print_alias_name(hv_dev, alias_name);
+ return sprintf(buf, "vmbus:%s\n", alias_name);
} else if (!strcmp(dev_attr->attr.name, "state")) {
return sprintf(buf, "%d\n", device_info.chn_state);
} else if (!strcmp(dev_attr->attr.name, "id")) {
@@ -204,6 +216,7 @@ static struct device_attribute vmbus_dev
__ATTR(class_id, S_IRUGO, vmbus_show_device_attr, NULL),
__ATTR(device_id, S_IRUGO, vmbus_show_device_attr, NULL),
__ATTR(monitor_id, S_IRUGO, vmbus_show_device_attr, NULL),
+ __ATTR(modalias, S_IRUGO, vmbus_show_device_attr, NULL),
__ATTR(server_monitor_pending, S_IRUGO, vmbus_show_device_attr, NULL),
__ATTR(server_monitor_latency, S_IRUGO, vmbus_show_device_attr, NULL),
@@ -242,12 +255,10 @@ static struct device_attribute vmbus_dev
static int vmbus_uevent(struct device *device, struct kobj_uevent_env *env)
{
struct hv_device *dev = device_to_hv_device(device);
- int i, ret;
- char alias_name[((sizeof((struct hv_vmbus_device_id *)0)->guid) + 1) * 2];
-
- for (i = 0; i < ((sizeof((struct hv_vmbus_device_id *)0)->guid) * 2); i += 2)
- sprintf(&alias_name[i], "%02x", dev->dev_type.b[i/2]);
+ int ret;
+ char alias_name[VMBUS_ALIAS_LEN + 1];
+ print_alias_name(dev, alias_name);
ret = add_uevent_var(env, "MODALIAS=vmbus:%s", alias_name);
return ret;
}
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Staging: hv: vmbus: Show the modalias in /sys/bus/vmbus/devices/*/
2011-09-02 16:25 [PATCH] Staging: hv: vmbus: Show the modalias in /sys/bus/vmbus/devices/*/ Olaf Hering
@ 2011-09-02 16:35 ` Greg KH
2011-09-02 16:38 ` Olaf Hering
2011-09-02 17:53 ` KY Srinivasan
2011-09-02 17:50 ` KY Srinivasan
1 sibling, 2 replies; 6+ messages in thread
From: Greg KH @ 2011-09-02 16:35 UTC (permalink / raw)
To: Olaf Hering; +Cc: K. Y. Srinivasan, linux-kernel, devel, virtualization
On Fri, Sep 02, 2011 at 06:25:56PM +0200, Olaf Hering wrote:
> Show a modalias file in /sys/bus/vmbus/devices/*/
> Add a helper function to print the same content in modalias and uevent.
>
> Signed-off-by: Olaf Hering <olaf@aepfle.de>
Nice idea, thanks for this, one minor nit below:
> ---
> drivers/staging/hv/vmbus_drv.c | 21 ++++++++++++++++-----
> 1 file changed, 16 insertions(+), 5 deletions(-)
>
> --- a/drivers/staging/hv/vmbus_drv.c
> +++ b/drivers/staging/hv/vmbus_drv.c
> @@ -93,6 +93,14 @@ static void get_channel_info(struct hv_d
> debug_info.outbound.bytes_avail_towrite;
> }
>
> +#define VMBUS_ALIAS_LEN ((sizeof((struct hv_vmbus_device_id *)0)->guid) * 2)
> +static void print_alias_name(struct hv_device *hv_dev, char *alias_name)
> +{
> + int i;
> + for (i = 0; i < VMBUS_ALIAS_LEN; i += 2)
> + sprintf(&alias_name[i], "%02x", hv_dev->dev_type.b[i/2]);
> +}
> +
> /*
> * vmbus_show_device_attr - Show the device attribute in sysfs.
> *
> @@ -105,6 +113,7 @@ static ssize_t vmbus_show_device_attr(st
> {
> struct hv_device *hv_dev = device_to_hv_device(dev);
> struct hv_device_info device_info;
> + char alias_name[VMBUS_ALIAS_LEN + 1];
Is that too big to put on the stack? 64 bytes, right? Hm, maybe not.
Wait, hv_device_info is huge, that should be dynamic in the first place.
Olaf, not your issue, but KY, want to fix that up?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Staging: hv: vmbus: Show the modalias in /sys/bus/vmbus/devices/*/
2011-09-02 16:35 ` Greg KH
@ 2011-09-02 16:38 ` Olaf Hering
2011-09-02 17:53 ` KY Srinivasan
1 sibling, 0 replies; 6+ messages in thread
From: Olaf Hering @ 2011-09-02 16:38 UTC (permalink / raw)
To: Greg KH; +Cc: K. Y. Srinivasan, linux-kernel, devel, virtualization
On Fri, Sep 02, Greg KH wrote:
> On Fri, Sep 02, 2011 at 06:25:56PM +0200, Olaf Hering wrote:
> > +#define VMBUS_ALIAS_LEN ((sizeof((struct hv_vmbus_device_id *)0)->guid) * 2)
> > + char alias_name[VMBUS_ALIAS_LEN + 1];
>
> Is that too big to put on the stack? 64 bytes, right? Hm, maybe not.
16 * 2 + 1 = 33 bytes.
Olaf
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PATCH] Staging: hv: vmbus: Show the modalias in /sys/bus/vmbus/devices/*/
2011-09-02 16:25 [PATCH] Staging: hv: vmbus: Show the modalias in /sys/bus/vmbus/devices/*/ Olaf Hering
2011-09-02 16:35 ` Greg KH
@ 2011-09-02 17:50 ` KY Srinivasan
1 sibling, 0 replies; 6+ messages in thread
From: KY Srinivasan @ 2011-09-02 17:50 UTC (permalink / raw)
To: Olaf Hering
Cc: gregkh@suse.de, linux-kernel@vger.kernel.org,
devel@linuxdriverproject.org, virtualization@lists.osdl.org
> -----Original Message-----
> From: Olaf Hering [mailto:olaf@aepfle.de]
> Sent: Friday, September 02, 2011 12:26 PM
> To: KY Srinivasan
> Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> devel@linuxdriverproject.org; virtualization@lists.osdl.org
> Subject: [PATCH] Staging: hv: vmbus: Show the modalias in
> /sys/bus/vmbus/devices/*/
>
> Show a modalias file in /sys/bus/vmbus/devices/*/
> Add a helper function to print the same content in modalias and uevent.
>
> Signed-off-by: Olaf Hering <olaf@aepfle.de>
>
> ---
> drivers/staging/hv/vmbus_drv.c | 21 ++++++++++++++++-----
> 1 file changed, 16 insertions(+), 5 deletions(-)
>
> --- a/drivers/staging/hv/vmbus_drv.c
> +++ b/drivers/staging/hv/vmbus_drv.c
> @@ -93,6 +93,14 @@ static void get_channel_info(struct hv_d
> debug_info.outbound.bytes_avail_towrite;
> }
>
> +#define VMBUS_ALIAS_LEN ((sizeof((struct hv_vmbus_device_id *)0)->guid) *
> 2)
> +static void print_alias_name(struct hv_device *hv_dev, char *alias_name)
> +{
> + int i;
> + for (i = 0; i < VMBUS_ALIAS_LEN; i += 2)
> + sprintf(&alias_name[i], "%02x", hv_dev->dev_type.b[i/2]);
> +}
> +
> /*
> * vmbus_show_device_attr - Show the device attribute in sysfs.
> *
> @@ -105,6 +113,7 @@ static ssize_t vmbus_show_device_attr(st
> {
> struct hv_device *hv_dev = device_to_hv_device(dev);
> struct hv_device_info device_info;
> + char alias_name[VMBUS_ALIAS_LEN + 1];
>
> memset(&device_info, 0, sizeof(struct hv_device_info));
>
> @@ -148,6 +157,9 @@ static ssize_t vmbus_show_device_attr(st
> device_info.chn_instance.b[13],
> device_info.chn_instance.b[14],
> device_info.chn_instance.b[15]);
> + } else if (!strcmp(dev_attr->attr.name, "modalias")) {
> + print_alias_name(hv_dev, alias_name);
> + return sprintf(buf, "vmbus:%s\n", alias_name);
> } else if (!strcmp(dev_attr->attr.name, "state")) {
> return sprintf(buf, "%d\n", device_info.chn_state);
> } else if (!strcmp(dev_attr->attr.name, "id")) {
> @@ -204,6 +216,7 @@ static struct device_attribute vmbus_dev
> __ATTR(class_id, S_IRUGO, vmbus_show_device_attr, NULL),
> __ATTR(device_id, S_IRUGO, vmbus_show_device_attr, NULL),
> __ATTR(monitor_id, S_IRUGO, vmbus_show_device_attr, NULL),
> + __ATTR(modalias, S_IRUGO, vmbus_show_device_attr, NULL),
>
> __ATTR(server_monitor_pending, S_IRUGO, vmbus_show_device_attr,
> NULL),
> __ATTR(server_monitor_latency, S_IRUGO, vmbus_show_device_attr,
> NULL),
> @@ -242,12 +255,10 @@ static struct device_attribute vmbus_dev
> static int vmbus_uevent(struct device *device, struct kobj_uevent_env *env)
> {
> struct hv_device *dev = device_to_hv_device(device);
> - int i, ret;
> - char alias_name[((sizeof((struct hv_vmbus_device_id *)0)->guid) + 1) *
> 2];
> -
> - for (i = 0; i < ((sizeof((struct hv_vmbus_device_id *)0)->guid) * 2); i += 2)
> - sprintf(&alias_name[i], "%02x", dev->dev_type.b[i/2]);
> + int ret;
> + char alias_name[VMBUS_ALIAS_LEN + 1];
>
> + print_alias_name(dev, alias_name);
> ret = add_uevent_var(env, "MODALIAS=vmbus:%s", alias_name);
> return ret;
> }
Acked-by: K. Y. Srinivasan <kys@microsoft.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PATCH] Staging: hv: vmbus: Show the modalias in /sys/bus/vmbus/devices/*/
2011-09-02 16:35 ` Greg KH
2011-09-02 16:38 ` Olaf Hering
@ 2011-09-02 17:53 ` KY Srinivasan
2011-09-02 18:12 ` Greg KH
1 sibling, 1 reply; 6+ messages in thread
From: KY Srinivasan @ 2011-09-02 17:53 UTC (permalink / raw)
To: Greg KH, Olaf Hering
Cc: linux-kernel@vger.kernel.org, devel@linuxdriverproject.org,
virtualization@lists.osdl.org
> -----Original Message-----
> From: Greg KH [mailto:gregkh@suse.de]
> Sent: Friday, September 02, 2011 12:36 PM
> To: Olaf Hering
> Cc: KY Srinivasan; linux-kernel@vger.kernel.org; devel@linuxdriverproject.org;
> virtualization@lists.osdl.org
> Subject: Re: [PATCH] Staging: hv: vmbus: Show the modalias in
> /sys/bus/vmbus/devices/*/
>
> On Fri, Sep 02, 2011 at 06:25:56PM +0200, Olaf Hering wrote:
> > Show a modalias file in /sys/bus/vmbus/devices/*/
> > Add a helper function to print the same content in modalias and uevent.
> >
> > Signed-off-by: Olaf Hering <olaf@aepfle.de>
>
> Nice idea, thanks for this, one minor nit below:
>
> > ---
> > drivers/staging/hv/vmbus_drv.c | 21 ++++++++++++++++-----
> > 1 file changed, 16 insertions(+), 5 deletions(-)
> >
> > --- a/drivers/staging/hv/vmbus_drv.c
> > +++ b/drivers/staging/hv/vmbus_drv.c
> > @@ -93,6 +93,14 @@ static void get_channel_info(struct hv_d
> > debug_info.outbound.bytes_avail_towrite;
> > }
> >
> > +#define VMBUS_ALIAS_LEN ((sizeof((struct hv_vmbus_device_id *)0)->guid)
> * 2)
> > +static void print_alias_name(struct hv_device *hv_dev, char *alias_name)
> > +{
> > + int i;
> > + for (i = 0; i < VMBUS_ALIAS_LEN; i += 2)
> > + sprintf(&alias_name[i], "%02x", hv_dev->dev_type.b[i/2]);
> > +}
> > +
> > /*
> > * vmbus_show_device_attr - Show the device attribute in sysfs.
> > *
> > @@ -105,6 +113,7 @@ static ssize_t vmbus_show_device_attr(st
> > {
> > struct hv_device *hv_dev = device_to_hv_device(dev);
> > struct hv_device_info device_info;
> > + char alias_name[VMBUS_ALIAS_LEN + 1];
>
> Is that too big to put on the stack? 64 bytes, right? Hm, maybe not.
>
> Wait, hv_device_info is huge, that should be dynamic in the first place.
> Olaf, not your issue, but KY, want to fix that up?
hv_device_info is about 101 bytes. I will fix this. Greg, if you are applying Olaf's patch,
I will generate my patch on top of Olaf's. Let me know.
Regards,
K. Y
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Staging: hv: vmbus: Show the modalias in /sys/bus/vmbus/devices/*/
2011-09-02 17:53 ` KY Srinivasan
@ 2011-09-02 18:12 ` Greg KH
0 siblings, 0 replies; 6+ messages in thread
From: Greg KH @ 2011-09-02 18:12 UTC (permalink / raw)
To: KY Srinivasan
Cc: devel@linuxdriverproject.org, Olaf Hering,
linux-kernel@vger.kernel.org, virtualization@lists.osdl.org
On Fri, Sep 02, 2011 at 05:53:37PM +0000, KY Srinivasan wrote:
>
>
> > -----Original Message-----
> > From: Greg KH [mailto:gregkh@suse.de]
> > Sent: Friday, September 02, 2011 12:36 PM
> > To: Olaf Hering
> > Cc: KY Srinivasan; linux-kernel@vger.kernel.org; devel@linuxdriverproject.org;
> > virtualization@lists.osdl.org
> > Subject: Re: [PATCH] Staging: hv: vmbus: Show the modalias in
> > /sys/bus/vmbus/devices/*/
> >
> > On Fri, Sep 02, 2011 at 06:25:56PM +0200, Olaf Hering wrote:
> > > Show a modalias file in /sys/bus/vmbus/devices/*/
> > > Add a helper function to print the same content in modalias and uevent.
> > >
> > > Signed-off-by: Olaf Hering <olaf@aepfle.de>
> >
> > Nice idea, thanks for this, one minor nit below:
> >
> > > ---
> > > drivers/staging/hv/vmbus_drv.c | 21 ++++++++++++++++-----
> > > 1 file changed, 16 insertions(+), 5 deletions(-)
> > >
> > > --- a/drivers/staging/hv/vmbus_drv.c
> > > +++ b/drivers/staging/hv/vmbus_drv.c
> > > @@ -93,6 +93,14 @@ static void get_channel_info(struct hv_d
> > > debug_info.outbound.bytes_avail_towrite;
> > > }
> > >
> > > +#define VMBUS_ALIAS_LEN ((sizeof((struct hv_vmbus_device_id *)0)->guid)
> > * 2)
> > > +static void print_alias_name(struct hv_device *hv_dev, char *alias_name)
> > > +{
> > > + int i;
> > > + for (i = 0; i < VMBUS_ALIAS_LEN; i += 2)
> > > + sprintf(&alias_name[i], "%02x", hv_dev->dev_type.b[i/2]);
> > > +}
> > > +
> > > /*
> > > * vmbus_show_device_attr - Show the device attribute in sysfs.
> > > *
> > > @@ -105,6 +113,7 @@ static ssize_t vmbus_show_device_attr(st
> > > {
> > > struct hv_device *hv_dev = device_to_hv_device(dev);
> > > struct hv_device_info device_info;
> > > + char alias_name[VMBUS_ALIAS_LEN + 1];
> >
> > Is that too big to put on the stack? 64 bytes, right? Hm, maybe not.
> >
> > Wait, hv_device_info is huge, that should be dynamic in the first place.
> > Olaf, not your issue, but KY, want to fix that up?
>
> hv_device_info is about 101 bytes. I will fix this. Greg, if you are applying Olaf's patch,
> I will generate my patch on top of Olaf's. Let me know.
I'll take his, and then feel free to send me one on top of that fixing
this.
But again, as kernel.org is still down, I can't apply anything until
next week at the earliest, sorry.
greg k-h
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-09-02 18:12 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-02 16:25 [PATCH] Staging: hv: vmbus: Show the modalias in /sys/bus/vmbus/devices/*/ Olaf Hering
2011-09-02 16:35 ` Greg KH
2011-09-02 16:38 ` Olaf Hering
2011-09-02 17:53 ` KY Srinivasan
2011-09-02 18:12 ` Greg KH
2011-09-02 17:50 ` KY Srinivasan
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).