netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch net v3] net: fec: fix compile with CONFIG_M5272
@ 2016-12-05 17:41 Nikita Yushchenko
       [not found] ` <CAMJBoFNd==OugwCjwT-q1MkooFr+Ed7AF00ifdimTk_DFVJO9Q@mail.gmail.com>
  2016-12-06  0:56 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Nikita Yushchenko @ 2016-12-05 17:41 UTC (permalink / raw)
  To: David S. Miller, Fugang Duan, Troy Kisky, Andrew Lunn,
	Eric Nelson, Philippe Reynes, Johannes Berg, netdev
  Cc: Chris Healy, Fabio Estevam, linux-kernel, Nikita Yushchenko

Commit 4dfb80d18d05 ("net: fec: cache statistics while device is down")
introduced unconditional statistics-related actions.

However, when driver is compiled with CONFIG_M5272, staticsics-related
definitions do not exist, which results into build errors.

Fix that by adding explicit handling of !defined(CONFIG_M5272) case.

Fixes: 4dfb80d18d05 ("net: fec: cache statistics while device is down")
Signed-off-by: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
---
Changes since v2:
- fix typo that caused compile problem, double-check that it compiles
  and works as expected.

 drivers/net/ethernet/freescale/fec_main.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 5f77caa59534..12aef1b15356 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -2313,6 +2313,8 @@ static const struct fec_stat {
 	{ "IEEE_rx_octets_ok", IEEE_R_OCTETS_OK },
 };
 
+#define FEC_STATS_SIZE		(ARRAY_SIZE(fec_stats) * sizeof(u64))
+
 static void fec_enet_update_ethtool_stats(struct net_device *dev)
 {
 	struct fec_enet_private *fep = netdev_priv(dev);
@@ -2330,7 +2332,7 @@ static void fec_enet_get_ethtool_stats(struct net_device *dev,
 	if (netif_running(dev))
 		fec_enet_update_ethtool_stats(dev);
 
-	memcpy(data, fep->ethtool_stats, ARRAY_SIZE(fec_stats) * sizeof(u64));
+	memcpy(data, fep->ethtool_stats, FEC_STATS_SIZE);
 }
 
 static void fec_enet_get_strings(struct net_device *netdev,
@@ -2355,6 +2357,12 @@ static int fec_enet_get_sset_count(struct net_device *dev, int sset)
 		return -EOPNOTSUPP;
 	}
 }
+
+#else	/* !defined(CONFIG_M5272) */
+#define FEC_STATS_SIZE	0
+static inline void fec_enet_update_ethtool_stats(struct net_device *dev)
+{
+}
 #endif /* !defined(CONFIG_M5272) */
 
 static int fec_enet_nway_reset(struct net_device *dev)
@@ -3293,8 +3301,7 @@ fec_probe(struct platform_device *pdev)
 
 	/* Init network device */
 	ndev = alloc_etherdev_mqs(sizeof(struct fec_enet_private) +
-				  ARRAY_SIZE(fec_stats) * sizeof(u64),
-				  num_tx_qs, num_rx_qs);
+				  FEC_STATS_SIZE, num_tx_qs, num_rx_qs);
 	if (!ndev)
 		return -ENOMEM;
 
-- 
2.1.4

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

* Re: [patch net v3] net: fec: fix compile with CONFIG_M5272
       [not found] ` <CAMJBoFNd==OugwCjwT-q1MkooFr+Ed7AF00ifdimTk_DFVJO9Q@mail.gmail.com>
@ 2016-12-05 18:06   ` Nikita Yushchenko
  0 siblings, 0 replies; 3+ messages in thread
From: Nikita Yushchenko @ 2016-12-05 18:06 UTC (permalink / raw)
  To: Vitaly Wool
  Cc: Johannes Berg, Troy Kisky, linux-kernel, Chris Healy,
	David S. Miller, Fugang Duan, Eric Nelson, Andrew Lunn,
	Fabio Estevam, netdev, Philippe Reynes

>     +#define FEC_STATS_SIZE         (ARRAY_SIZE(fec_stats) * sizeof(u64))
> 
> 
> Do I take it right this actually translates to (sizeof(fec_stats) /
> sizeof(u64) * sizeof(u64))?

No.

fec_stats is an array of structs, each struct has car arrsy and integer,
and size of that is definitely not bytes.


ARRAY_SIZE(fec_stats) is number of stats, i.e. it is returned from
fec_enet_get_sset_count()

Each stat in blob is u64. Thus (ARRAY_SIZE(fec_stats) * sizeof(u64)) is
size of stats blob.

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

* Re: [patch net v3] net: fec: fix compile with CONFIG_M5272
  2016-12-05 17:41 [patch net v3] net: fec: fix compile with CONFIG_M5272 Nikita Yushchenko
       [not found] ` <CAMJBoFNd==OugwCjwT-q1MkooFr+Ed7AF00ifdimTk_DFVJO9Q@mail.gmail.com>
@ 2016-12-06  0:56 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2016-12-06  0:56 UTC (permalink / raw)
  To: nikita.yoush
  Cc: fugang.duan, troy.kisky, andrew, eric, tremyfr, johannes, netdev,
	cphealy, fabio.estevam, linux-kernel

From: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
Date: Mon,  5 Dec 2016 20:41:01 +0300

> Commit 4dfb80d18d05 ("net: fec: cache statistics while device is down")
> introduced unconditional statistics-related actions.

I do not see this commit in any of my trees:

[davem@localhost net-next]$ git describe 4dfb80d18d05
fatal: Not a valid object name 4dfb80d18d05
[davem@localhost net-next]$ cd ../net
[davem@localhost net]$ git describe 4dfb80d18d05
fatal: Not a valid object name 4dfb80d18d05
[davem@localhost net]$

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

end of thread, other threads:[~2016-12-06  0:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-05 17:41 [patch net v3] net: fec: fix compile with CONFIG_M5272 Nikita Yushchenko
     [not found] ` <CAMJBoFNd==OugwCjwT-q1MkooFr+Ed7AF00ifdimTk_DFVJO9Q@mail.gmail.com>
2016-12-05 18:06   ` Nikita Yushchenko
2016-12-06  0:56 ` 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).