netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] net: drivers: use bool type instead of double negation
@ 2011-11-17  0:05 Michał Mirosław
  2011-11-17  0:05 ` [PATCH 2/2] net: verify GSO flag bits against netdev features Michał Mirosław
  2011-11-17  1:40 ` [PATCH 1/2] net: drivers: use bool type instead of double negation David Miller
  0 siblings, 2 replies; 7+ messages in thread
From: Michał Mirosław @ 2011-11-17  0:05 UTC (permalink / raw)
  To: netdev; +Cc: David S. Miller, Ben Hutchings

Save some punctuation by using bool type's property equivalent to
doubled negation operator.

Reported-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
 drivers/net/ethernet/jme.c                 |    4 ++--
 drivers/net/ethernet/marvell/mv643xx_eth.c |    2 +-
 drivers/net/ethernet/marvell/sky2.c        |    2 +-
 drivers/net/xen-netfront.c                 |    4 ++--
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/jme.c b/drivers/net/ethernet/jme.c
index df3ab83..5c0b531 100644
--- a/drivers/net/ethernet/jme.c
+++ b/drivers/net/ethernet/jme.c
@@ -1883,7 +1883,7 @@ jme_fill_tx_map(struct pci_dev *pdev,
 		struct page *page,
 		u32 page_offset,
 		u32 len,
-		u8 hidma)
+		bool hidma)
 {
 	dma_addr_t dmaaddr;
 
@@ -1917,7 +1917,7 @@ jme_map_tx_skb(struct jme_adapter *jme, struct sk_buff *skb, int idx)
 	struct jme_ring *txring = &(jme->txring[0]);
 	struct txdesc *txdesc = txring->desc, *ctxdesc;
 	struct jme_buffer_info *txbi = txring->bufinf, *ctxbi;
-	u8 hidma = !!(jme->dev->features & NETIF_F_HIGHDMA);
+	bool hidma = jme->dev->features & NETIF_F_HIGHDMA;
 	int i, nr_frags = skb_shinfo(skb)->nr_frags;
 	int mask = jme->tx_ring_mask;
 	const struct skb_frag_struct *frag;
diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c
index 157c5c1..43e3e61 100644
--- a/drivers/net/ethernet/marvell/mv643xx_eth.c
+++ b/drivers/net/ethernet/marvell/mv643xx_eth.c
@@ -1582,7 +1582,7 @@ static int
 mv643xx_eth_set_features(struct net_device *dev, netdev_features_t features)
 {
 	struct mv643xx_eth_private *mp = netdev_priv(dev);
-	int rx_csum = !!(features & NETIF_F_RXCSUM);
+	bool rx_csum = features & NETIF_F_RXCSUM;
 
 	wrlp(mp, PORT_CONFIG, rx_csum ? 0x02000000 : 0x00000000);
 
diff --git a/drivers/net/ethernet/marvell/sky2.c b/drivers/net/ethernet/marvell/sky2.c
index c79dc54..7db6e36 100644
--- a/drivers/net/ethernet/marvell/sky2.c
+++ b/drivers/net/ethernet/marvell/sky2.c
@@ -4313,7 +4313,7 @@ static int sky2_set_features(struct net_device *dev, netdev_features_t features)
 	netdev_features_t changed = dev->features ^ features;
 
 	if (changed & NETIF_F_RXCSUM) {
-		int on = !!(features & NETIF_F_RXCSUM);
+		bool on = features & NETIF_F_RXCSUM;
 		sky2_write32(sky2->hw, Q_ADDR(rxqaddr[sky2->port], Q_CSR),
 			     on ? BMU_ENA_RX_CHKSUM : BMU_DIS_RX_CHKSUM);
 	}
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index a6e379f..4312db8 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -201,9 +201,9 @@ static void xennet_sysfs_delif(struct net_device *netdev);
 #define xennet_sysfs_delif(dev) do { } while (0)
 #endif
 
-static int xennet_can_sg(struct net_device *dev)
+static bool xennet_can_sg(struct net_device *dev)
 {
-	return !!(dev->features & NETIF_F_SG);
+	return dev->features & NETIF_F_SG;
 }
 
 
-- 
1.7.7.1

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

* [PATCH 2/2] net: verify GSO flag bits against netdev features
  2011-11-17  0:05 [PATCH 1/2] net: drivers: use bool type instead of double negation Michał Mirosław
@ 2011-11-17  0:05 ` Michał Mirosław
  2011-11-17  0:09   ` Ben Hutchings
  2011-11-17  1:41   ` David Miller
  2011-11-17  1:40 ` [PATCH 1/2] net: drivers: use bool type instead of double negation David Miller
  1 sibling, 2 replies; 7+ messages in thread
From: Michał Mirosław @ 2011-11-17  0:05 UTC (permalink / raw)
  To: netdev; +Cc: David S. Miller, Ben Hutchings

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
 include/linux/netdevice.h |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index b35ffd7..31da3bb 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -2492,6 +2492,15 @@ netdev_features_t netif_skb_features(struct sk_buff *skb);
 static inline int net_gso_ok(netdev_features_t features, int gso_type)
 {
 	netdev_features_t feature = gso_type << NETIF_F_GSO_SHIFT;
+
+	/* check flags correspondence */
+	BUILD_BUG_ON(SKB_GSO_TCPV4   != (NETIF_F_TSO >> NETIF_F_GSO_SHIFT));
+	BUILD_BUG_ON(SKB_GSO_UDP     != (NETIF_F_UFO >> NETIF_F_GSO_SHIFT));
+	BUILD_BUG_ON(SKB_GSO_DODGY   != (NETIF_F_GSO_ROBUST >> NETIF_F_GSO_SHIFT));
+	BUILD_BUG_ON(SKB_GSO_TCP_ECN != (NETIF_F_TSO_ECN >> NETIF_F_GSO_SHIFT));
+	BUILD_BUG_ON(SKB_GSO_TCPV6   != (NETIF_F_TSO6 >> NETIF_F_GSO_SHIFT));
+	BUILD_BUG_ON(SKB_GSO_FCOE    != (NETIF_F_FSO >> NETIF_F_GSO_SHIFT));
+
 	return (features & feature) == feature;
 }
 
-- 
1.7.7.1

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

* Re: [PATCH 2/2] net: verify GSO flag bits against netdev features
  2011-11-17  0:05 ` [PATCH 2/2] net: verify GSO flag bits against netdev features Michał Mirosław
@ 2011-11-17  0:09   ` Ben Hutchings
  2011-11-17  0:13     ` Michał Mirosław
  2011-11-17  1:41   ` David Miller
  1 sibling, 1 reply; 7+ messages in thread
From: Ben Hutchings @ 2011-11-17  0:09 UTC (permalink / raw)
  To: Michał Mirosław; +Cc: netdev, David S. Miller

On Thu, 2011-11-17 at 01:05 +0100, Michał Mirosław wrote:
> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> ---
>  include/linux/netdevice.h |    9 +++++++++
>  1 files changed, 9 insertions(+), 0 deletions(-)
> 
> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> index b35ffd7..31da3bb 100644
> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -2492,6 +2492,15 @@ netdev_features_t netif_skb_features(struct sk_buff *skb);
>  static inline int net_gso_ok(netdev_features_t features, int gso_type)
>  {
>  	netdev_features_t feature = gso_type << NETIF_F_GSO_SHIFT;
> +
> +	/* check flags correspondence */
> +	BUILD_BUG_ON(SKB_GSO_TCPV4   != (NETIF_F_TSO >> NETIF_F_GSO_SHIFT));
> +	BUILD_BUG_ON(SKB_GSO_UDP     != (NETIF_F_UFO >> NETIF_F_GSO_SHIFT));
> +	BUILD_BUG_ON(SKB_GSO_DODGY   != (NETIF_F_GSO_ROBUST >> NETIF_F_GSO_SHIFT));
> +	BUILD_BUG_ON(SKB_GSO_TCP_ECN != (NETIF_F_TSO_ECN >> NETIF_F_GSO_SHIFT));
> +	BUILD_BUG_ON(SKB_GSO_TCPV6   != (NETIF_F_TSO6 >> NETIF_F_GSO_SHIFT));
> +	BUILD_BUG_ON(SKB_GSO_FCOE    != (NETIF_F_FSO >> NETIF_F_GSO_SHIFT));
> +
>  	return (features & feature) == feature;
>  }

This is fine but should still be done at the same time as changing the
definitions.

Ben.

-- 
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.

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

* Re: [PATCH 2/2] net: verify GSO flag bits against netdev features
  2011-11-17  0:09   ` Ben Hutchings
@ 2011-11-17  0:13     ` Michał Mirosław
  2011-11-17  0:35       ` Ben Hutchings
  0 siblings, 1 reply; 7+ messages in thread
From: Michał Mirosław @ 2011-11-17  0:13 UTC (permalink / raw)
  To: Ben Hutchings; +Cc: netdev, David S. Miller

On Thu, Nov 17, 2011 at 12:09:56AM +0000, Ben Hutchings wrote:
> On Thu, 2011-11-17 at 01:05 +0100, Michał Mirosław wrote:
> > Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> > ---
> >  include/linux/netdevice.h |    9 +++++++++
> >  1 files changed, 9 insertions(+), 0 deletions(-)
> > 
> > diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> > index b35ffd7..31da3bb 100644
> > --- a/include/linux/netdevice.h
> > +++ b/include/linux/netdevice.h
> > @@ -2492,6 +2492,15 @@ netdev_features_t netif_skb_features(struct sk_buff *skb);
> >  static inline int net_gso_ok(netdev_features_t features, int gso_type)
> >  {
> >  	netdev_features_t feature = gso_type << NETIF_F_GSO_SHIFT;
> > +
> > +	/* check flags correspondence */
> > +	BUILD_BUG_ON(SKB_GSO_TCPV4   != (NETIF_F_TSO >> NETIF_F_GSO_SHIFT));
> > +	BUILD_BUG_ON(SKB_GSO_UDP     != (NETIF_F_UFO >> NETIF_F_GSO_SHIFT));
> > +	BUILD_BUG_ON(SKB_GSO_DODGY   != (NETIF_F_GSO_ROBUST >> NETIF_F_GSO_SHIFT));
> > +	BUILD_BUG_ON(SKB_GSO_TCP_ECN != (NETIF_F_TSO_ECN >> NETIF_F_GSO_SHIFT));
> > +	BUILD_BUG_ON(SKB_GSO_TCPV6   != (NETIF_F_TSO6 >> NETIF_F_GSO_SHIFT));
> > +	BUILD_BUG_ON(SKB_GSO_FCOE    != (NETIF_F_FSO >> NETIF_F_GSO_SHIFT));
> > +
> >  	return (features & feature) == feature;
> >  }
> This is fine but should still be done at the same time as changing the
> definitions.

Agreed. But as Dave was quicker, we need to fix this in separate patch.

Best Regards,
Michał Mirosław

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

* Re: [PATCH 2/2] net: verify GSO flag bits against netdev features
  2011-11-17  0:13     ` Michał Mirosław
@ 2011-11-17  0:35       ` Ben Hutchings
  0 siblings, 0 replies; 7+ messages in thread
From: Ben Hutchings @ 2011-11-17  0:35 UTC (permalink / raw)
  To: Michał Mirosław; +Cc: netdev, David S. Miller

On Thu, 2011-11-17 at 01:13 +0100, Michał Mirosław wrote:
> On Thu, Nov 17, 2011 at 12:09:56AM +0000, Ben Hutchings wrote:
> > On Thu, 2011-11-17 at 01:05 +0100, Michał Mirosław wrote:
> > > Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> > > ---
> > >  include/linux/netdevice.h |    9 +++++++++
> > >  1 files changed, 9 insertions(+), 0 deletions(-)
> > > 
> > > diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> > > index b35ffd7..31da3bb 100644
> > > --- a/include/linux/netdevice.h
> > > +++ b/include/linux/netdevice.h
> > > @@ -2492,6 +2492,15 @@ netdev_features_t netif_skb_features(struct sk_buff *skb);
> > >  static inline int net_gso_ok(netdev_features_t features, int gso_type)
> > >  {
> > >  	netdev_features_t feature = gso_type << NETIF_F_GSO_SHIFT;
> > > +
> > > +	/* check flags correspondence */
> > > +	BUILD_BUG_ON(SKB_GSO_TCPV4   != (NETIF_F_TSO >> NETIF_F_GSO_SHIFT));
> > > +	BUILD_BUG_ON(SKB_GSO_UDP     != (NETIF_F_UFO >> NETIF_F_GSO_SHIFT));
> > > +	BUILD_BUG_ON(SKB_GSO_DODGY   != (NETIF_F_GSO_ROBUST >> NETIF_F_GSO_SHIFT));
> > > +	BUILD_BUG_ON(SKB_GSO_TCP_ECN != (NETIF_F_TSO_ECN >> NETIF_F_GSO_SHIFT));
> > > +	BUILD_BUG_ON(SKB_GSO_TCPV6   != (NETIF_F_TSO6 >> NETIF_F_GSO_SHIFT));
> > > +	BUILD_BUG_ON(SKB_GSO_FCOE    != (NETIF_F_FSO >> NETIF_F_GSO_SHIFT));
> > > +
> > >  	return (features & feature) == feature;
> > >  }
> > This is fine but should still be done at the same time as changing the
> > definitions.
> 
> Agreed. But as Dave was quicker, we need to fix this in separate patch.

Sorry, I somehow failed to spot that.

Ben.

-- 
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.

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

* Re: [PATCH 1/2] net: drivers: use bool type instead of double negation
  2011-11-17  0:05 [PATCH 1/2] net: drivers: use bool type instead of double negation Michał Mirosław
  2011-11-17  0:05 ` [PATCH 2/2] net: verify GSO flag bits against netdev features Michał Mirosław
@ 2011-11-17  1:40 ` David Miller
  1 sibling, 0 replies; 7+ messages in thread
From: David Miller @ 2011-11-17  1:40 UTC (permalink / raw)
  To: mirq-linux; +Cc: netdev, bhutchings

From: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Date: Thu, 17 Nov 2011 01:05:33 +0100 (CET)

> Save some punctuation by using bool type's property equivalent to
> doubled negation operator.
> 
> Reported-by: Ben Hutchings <bhutchings@solarflare.com>
> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>

Applied.

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

* Re: [PATCH 2/2] net: verify GSO flag bits against netdev features
  2011-11-17  0:05 ` [PATCH 2/2] net: verify GSO flag bits against netdev features Michał Mirosław
  2011-11-17  0:09   ` Ben Hutchings
@ 2011-11-17  1:41   ` David Miller
  1 sibling, 0 replies; 7+ messages in thread
From: David Miller @ 2011-11-17  1:41 UTC (permalink / raw)
  To: mirq-linux; +Cc: netdev, bhutchings

From: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Date: Thu, 17 Nov 2011 01:05:33 +0100 (CET)

> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>

Applied.

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

end of thread, other threads:[~2011-11-17  1:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-17  0:05 [PATCH 1/2] net: drivers: use bool type instead of double negation Michał Mirosław
2011-11-17  0:05 ` [PATCH 2/2] net: verify GSO flag bits against netdev features Michał Mirosław
2011-11-17  0:09   ` Ben Hutchings
2011-11-17  0:13     ` Michał Mirosław
2011-11-17  0:35       ` Ben Hutchings
2011-11-17  1:41   ` David Miller
2011-11-17  1:40 ` [PATCH 1/2] net: drivers: use bool type instead of double negation David Miller

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