netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* resend [PATCH 2.6.4-rc2] netdevice.h add netif_msg_init helper
@ 2004-03-05 17:43 Don Fry
  2004-03-05 19:25 ` Jeff Garzik
  0 siblings, 1 reply; 3+ messages in thread
From: Don Fry @ 2004-03-05 17:43 UTC (permalink / raw)
  To: jgarzik, netdev

This patch adds a helper function to initialize the debug bit mask
for use with netif_msg_*.  When the debug_value is out of range
it returns the default_msg_enable_bits.

--- linux-2.6.4-rc2/include/linux/orig.netdevice.h	Thu Mar  4 09:59:08 2004
+++ linux-2.6.4-rc2/include/linux/netdevice.h	Thu Mar  4 10:56:19 2004
@@ -774,6 +774,17 @@
 #define netif_msg_hw(p)		((p)->msg_enable & NETIF_MSG_HW)
 #define netif_msg_wol(p)	((p)->msg_enable & NETIF_MSG_WOL)
 
+static inline u32 netif_msg_init(int debug_value, int default_msg_enable_bits)
+{
+	/* use default */
+	if (debug_value < 0 || debug_value > (sizeof(u32) * 8))
+		return default_msg_enable_bits;
+	if (debug_value == 0)	/* no output */
+		return 0;
+	/* set low N bits */
+	return(((debug_value == (sizeof(u32)*8)) ? 0 : (1 << debug_value)) - 1);
+}
+
 /* Schedule rx intr now? */
 
 static inline int netif_rx_schedule_prep(struct net_device *dev)

-- 
Don Fry
brazilnut@us.ibm.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: resend [PATCH 2.6.4-rc2] netdevice.h add netif_msg_init helper
  2004-03-05 17:43 resend [PATCH 2.6.4-rc2] netdevice.h add netif_msg_init helper Don Fry
@ 2004-03-05 19:25 ` Jeff Garzik
  2004-03-05 20:30   ` Don Fry
  0 siblings, 1 reply; 3+ messages in thread
From: Jeff Garzik @ 2004-03-05 19:25 UTC (permalink / raw)
  To: Don Fry; +Cc: netdev

Don Fry wrote:
> This patch adds a helper function to initialize the debug bit mask
> for use with netif_msg_*.  When the debug_value is out of range
> it returns the default_msg_enable_bits.
> 
> --- linux-2.6.4-rc2/include/linux/orig.netdevice.h	Thu Mar  4 09:59:08 2004
> +++ linux-2.6.4-rc2/include/linux/netdevice.h	Thu Mar  4 10:56:19 2004
> @@ -774,6 +774,17 @@
>  #define netif_msg_hw(p)		((p)->msg_enable & NETIF_MSG_HW)
>  #define netif_msg_wol(p)	((p)->msg_enable & NETIF_MSG_WOL)
>  
> +static inline u32 netif_msg_init(int debug_value, int default_msg_enable_bits)
> +{
> +	/* use default */
> +	if (debug_value < 0 || debug_value > (sizeof(u32) * 8))
> +		return default_msg_enable_bits;
> +	if (debug_value == 0)	/* no output */
> +		return 0;
> +	/* set low N bits */
> +	return(((debug_value == (sizeof(u32)*8)) ? 0 : (1 << debug_value)) - 1);
> +}
> +

Oh, my apologies.  I didn't see you had made the additional change I 
requested.

This version looks better, but we still have an out of range value (32) 
resulting in no-messages, rather than the default value.  I would change 
the first ">" to ">=", and simply eliminate the final test.

	Jeff

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: resend [PATCH 2.6.4-rc2] netdevice.h add netif_msg_init helper
  2004-03-05 19:25 ` Jeff Garzik
@ 2004-03-05 20:30   ` Don Fry
  0 siblings, 0 replies; 3+ messages in thread
From: Don Fry @ 2004-03-05 20:30 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: netdev

With the value 32, all bits would be set not none.  0 -1 sets all the
bits.  Is that not the correct operation?

> > This patch adds a helper function to initialize the debug bit mask
> > for use with netif_msg_*.  When the debug_value is out of range
> > it returns the default_msg_enable_bits.
> > 
> > --- linux-2.6.4-rc2/include/linux/orig.netdevice.h	Thu Mar  4 09:59:08 2004
> > +++ linux-2.6.4-rc2/include/linux/netdevice.h	Thu Mar  4 10:56:19 2004
> > @@ -774,6 +774,17 @@
> >  #define netif_msg_hw(p)		((p)->msg_enable & NETIF_MSG_HW)
> >  #define netif_msg_wol(p)	((p)->msg_enable & NETIF_MSG_WOL)
> >  
> > +static inline u32 netif_msg_init(int debug_value, int default_msg_enable_bits)
> > +{
> > +	/* use default */
> > +	if (debug_value < 0 || debug_value > (sizeof(u32) * 8))
> > +		return default_msg_enable_bits;
> > +	if (debug_value == 0)	/* no output */
> > +		return 0;
> > +	/* set low N bits */
> > +	return(((debug_value == (sizeof(u32)*8)) ? 0 : (1 << debug_value)) - 1);
> > +}
> > +
> 
> Oh, my apologies.  I didn't see you had made the additional change I 
> requested.
> 
> This version looks better, but we still have an out of range value (32) 
> resulting in no-messages, rather than the default value.  I would change 
> the first ">" to ">=", and simply eliminate the final test.
> 
> 	Jeff
> 


-- 
Don Fry
brazilnut@us.ibm.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-03-05 20:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-03-05 17:43 resend [PATCH 2.6.4-rc2] netdevice.h add netif_msg_init helper Don Fry
2004-03-05 19:25 ` Jeff Garzik
2004-03-05 20:30   ` Don Fry

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).