* [PATCH 1/1] Staging: hv: netvsc: Cleanup the name and type of link_stat variable
@ 2011-09-13 22:21 K. Y. Srinivasan
0 siblings, 0 replies; 4+ messages in thread
From: K. Y. Srinivasan @ 2011-09-13 22:21 UTC (permalink / raw)
To: gregkh, linux-kernel, devel, virtualization, joe
Cc: K. Y. Srinivasan, Haiyang Zhang
Consistently name the variable tracking the link status. Use a consistent
type for this variable and get rid of some unnecessary parentheses as well.
I would like to thank Joe Perches <joe@perches.com> for suggesting these
changes and patiently helping me get here!
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
drivers/staging/hv/rndis_filter.c | 17 +++++++++++------
1 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c
index 963582a..ef43f2e 100644
--- a/drivers/staging/hv/rndis_filter.c
+++ b/drivers/staging/hv/rndis_filter.c
@@ -41,7 +41,7 @@ struct rndis_device {
struct netvsc_device *net_dev;
enum rndis_device_state state;
- u32 link_stat;
+ bool link_state;
atomic_t new_req_id;
spinlock_t request_lock;
@@ -511,10 +511,15 @@ static int rndis_filter_query_device_mac(struct rndis_device *dev)
static int rndis_filter_query_device_link_status(struct rndis_device *dev)
{
u32 size = sizeof(u32);
+ u32 link_status;
+ int ret;
- return rndis_filter_query_device(dev,
+ ret = rndis_filter_query_device(dev,
RNDIS_OID_GEN_MEDIA_CONNECT_STATUS,
- &dev->link_stat, &size);
+ &link_status, &size);
+ dev->link_state = (link_status != 0) ? true : false;
+
+ return ret;
}
static int rndis_filter_set_packet_filter(struct rndis_device *dev,
@@ -736,11 +741,11 @@ int rndis_filter_device_add(struct hv_device *dev,
rndis_filter_query_device_link_status(rndis_device);
- device_info->link_state = rndis_device->link_stat;
+ device_info->link_state = rndis_device->link_state;
- dev_info(&dev->device, "Device MAC %pM link state %s",
+ dev_info(&dev->device, "Device MAC %pM link state %s\n",
rndis_device->hw_mac_adr,
- ((device_info->link_state) ? ("down\n") : ("up\n")));
+ device_info->link_state ? "down" : "up");
return ret;
}
--
1.7.4.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH 1/1] Staging: hv: netvsc: Cleanup the name and type of link_stat variable
@ 2011-09-13 19:53 K. Y. Srinivasan
2011-09-13 20:04 ` Joe Perches
0 siblings, 1 reply; 4+ messages in thread
From: K. Y. Srinivasan @ 2011-09-13 19:53 UTC (permalink / raw)
To: gregkh, linux-kernel, devel, virtualization
Cc: K. Y. Srinivasan, Haiyang Zhang
Consistently name the variable tracking the link status. Use a consistent
type for this variable and get rid of some unnecessary parentheses as well.
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
drivers/staging/hv/rndis_filter.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c
index 963582a..696d2c5 100644
--- a/drivers/staging/hv/rndis_filter.c
+++ b/drivers/staging/hv/rndis_filter.c
@@ -41,7 +41,7 @@ struct rndis_device {
struct netvsc_device *net_dev;
enum rndis_device_state state;
- u32 link_stat;
+ bool link_state;
atomic_t new_req_id;
spinlock_t request_lock;
@@ -514,7 +514,7 @@ static int rndis_filter_query_device_link_status(struct rndis_device *dev)
return rndis_filter_query_device(dev,
RNDIS_OID_GEN_MEDIA_CONNECT_STATUS,
- &dev->link_stat, &size);
+ &dev->link_state, &size);
}
static int rndis_filter_set_packet_filter(struct rndis_device *dev,
@@ -736,11 +736,11 @@ int rndis_filter_device_add(struct hv_device *dev,
rndis_filter_query_device_link_status(rndis_device);
- device_info->link_state = rndis_device->link_stat;
+ device_info->link_state = rndis_device->link_state;
dev_info(&dev->device, "Device MAC %pM link state %s",
rndis_device->hw_mac_adr,
- ((device_info->link_state) ? ("down\n") : ("up\n")));
+ device_info->link_state ? "down\n" : "up\n");
return ret;
}
--
1.7.4.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH 1/1] Staging: hv: netvsc: Cleanup the name and type of link_stat variable
2011-09-13 19:53 K. Y. Srinivasan
@ 2011-09-13 20:04 ` Joe Perches
2011-09-13 20:57 ` KY Srinivasan
0 siblings, 1 reply; 4+ messages in thread
From: Joe Perches @ 2011-09-13 20:04 UTC (permalink / raw)
To: K. Y. Srinivasan
Cc: gregkh, linux-kernel, devel, virtualization, Haiyang Zhang
On Tue, 2011-09-13 at 12:53 -0700, K. Y. Srinivasan wrote:
> Consistently name the variable tracking the link status. Use a consistent
> type for this variable and get rid of some unnecessary parentheses as well.
>
> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> ---
> drivers/staging/hv/rndis_filter.c | 8 ++++----
> 1 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c
> index 963582a..696d2c5 100644
> --- a/drivers/staging/hv/rndis_filter.c
> +++ b/drivers/staging/hv/rndis_filter.c
> @@ -41,7 +41,7 @@ struct rndis_device {
> struct netvsc_device *net_dev;
>
> enum rndis_device_state state;
> - u32 link_stat;
> + bool link_state;
> atomic_t new_req_id;
>
> spinlock_t request_lock;
> @@ -514,7 +514,7 @@ static int rndis_filter_query_device_link_status(struct rndis_device *dev)
>
> return rndis_filter_query_device(dev,
> RNDIS_OID_GEN_MEDIA_CONNECT_STATUS,
> - &dev->link_stat, &size);
> + &dev->link_state, &size);
Are you sure you can do this?
You're changing the info request from u32 to bool
without changing the size above it
u32 size = sizeof(u32);
> }
>
> static int rndis_filter_set_packet_filter(struct rndis_device *dev,
> @@ -736,11 +736,11 @@ int rndis_filter_device_add(struct hv_device *dev,
>
> rndis_filter_query_device_link_status(rndis_device);
>
> - device_info->link_state = rndis_device->link_stat;
> + device_info->link_state = rndis_device->link_state;
>
> dev_info(&dev->device, "Device MAC %pM link state %s",
> rndis_device->hw_mac_adr,
> - ((device_info->link_state) ? ("down\n") : ("up\n")));
> + device_info->link_state ? "down\n" : "up\n");
It's better to remove the multiple "\n"s from "up" and "down"
and move it to the format string as I suggested.
^ permalink raw reply [flat|nested] 4+ messages in thread* RE: [PATCH 1/1] Staging: hv: netvsc: Cleanup the name and type of link_stat variable
2011-09-13 20:04 ` Joe Perches
@ 2011-09-13 20:57 ` KY Srinivasan
0 siblings, 0 replies; 4+ messages in thread
From: KY Srinivasan @ 2011-09-13 20:57 UTC (permalink / raw)
To: Joe Perches
Cc: gregkh@suse.de, linux-kernel@vger.kernel.org,
devel@linuxdriverproject.org, virtualization@lists.osdl.org,
Haiyang Zhang
> -----Original Message-----
> From: Joe Perches [mailto:joe@perches.com]
> Sent: Tuesday, September 13, 2011 4:05 PM
> To: KY Srinivasan
> Cc: gregkh@suse.de; linux-kernel@vger.kernel.org;
> devel@linuxdriverproject.org; virtualization@lists.osdl.org; Haiyang Zhang
> Subject: Re: [PATCH 1/1] Staging: hv: netvsc: Cleanup the name and type of
> link_stat variable
>
> On Tue, 2011-09-13 at 12:53 -0700, K. Y. Srinivasan wrote:
> > Consistently name the variable tracking the link status. Use a consistent
> > type for this variable and get rid of some unnecessary parentheses as well.
> >
> > Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> > Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> > ---
> > drivers/staging/hv/rndis_filter.c | 8 ++++----
> > 1 files changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c
> > index 963582a..696d2c5 100644
> > --- a/drivers/staging/hv/rndis_filter.c
> > +++ b/drivers/staging/hv/rndis_filter.c
> > @@ -41,7 +41,7 @@ struct rndis_device {
> > struct netvsc_device *net_dev;
> >
> > enum rndis_device_state state;
> > - u32 link_stat;
> > + bool link_state;
> > atomic_t new_req_id;
> >
> > spinlock_t request_lock;
> > @@ -514,7 +514,7 @@ static int rndis_filter_query_device_link_status(struct
> rndis_device *dev)
> >
> > return rndis_filter_query_device(dev,
> > RNDIS_OID_GEN_MEDIA_CONNECT_STATUS,
> > - &dev->link_stat, &size);
> > + &dev->link_state, &size);
>
> Are you sure you can do this?
> You're changing the info request from u32 to bool
> without changing the size above it
Oops! I will fix this.
>
> u32 size = sizeof(u32);
>
>
> > }
> >
> > static int rndis_filter_set_packet_filter(struct rndis_device *dev,
> > @@ -736,11 +736,11 @@ int rndis_filter_device_add(struct hv_device *dev,
> >
> > rndis_filter_query_device_link_status(rndis_device);
> >
> > - device_info->link_state = rndis_device->link_stat;
> > + device_info->link_state = rndis_device->link_state;
> >
> > dev_info(&dev->device, "Device MAC %pM link state %s",
> > rndis_device->hw_mac_adr,
> > - ((device_info->link_state) ? ("down\n") : ("up\n")));
> > + device_info->link_state ? "down\n" : "up\n");
>
> It's better to remove the multiple "\n"s from "up" and "down"
> and move it to the format string as I suggested.
I will fix it.
Thank you,
K. Y
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-09-13 22:21 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-13 22:21 [PATCH 1/1] Staging: hv: netvsc: Cleanup the name and type of link_stat variable K. Y. Srinivasan
-- strict thread matches above, loose matches on Subject: below --
2011-09-13 19:53 K. Y. Srinivasan
2011-09-13 20:04 ` Joe Perches
2011-09-13 20:57 ` KY Srinivasan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox