Re: TJA1100 100Base-T1 PHY features via ethtool?

2018-08-14 Thread Michael Grzeschik
On Mon, Aug 13, 2018 at 12:53:35PM -0700, Florian Fainelli wrote:
> On 08/13/2018 12:35 PM, Michael Grzeschik wrote:
> > Hi David,
> > 
> > I use a special 100Base-T1 phy (NXP TJA1100 [1]) that has some features
> > like:
> > 
> > - enabling/disabling test modes
> > - fault detection
> > - switching managed/autonomous mode
> > - signal quality indication
> > - ...
> > 
> > I already implemented the support of the features with the
> > ethtool --get/set-phy-tunables features by adding ethtool_phy_tunables:
> > 
> > ETHTOOL_PHY_TEST_MODE
> > ETHTOOL_PHY_FAULT_DETECTION
> > ETHTOOL_PHY_MANAGED_MODE
> > ETHTOOL_PHY_SIGNAL_QUALITY
> > 
> > Before posting my series I wanted to ensure that this is the preferred
> > interface for those options.
> 
> The tunable interface is there, but is very limited. A few months ago, I
> had started proposing an interface to support PHY test modes [1] (the
> standard IEEE 802.3 defined ones) but a lot of it should now be migrated
> to the work that Michal is doing on the conversion of ethtool to netlink
> [2].
> 
> [1]: https://lkml.org/lkml/2018/4/27/1172
> [2]: https://www.spinics.net/lists/netdev/msg516233.html

The ethtool userspace tool is somehow odd to program on,
so switching to netlink is definitively a great idea!

> > 
> > I found a series from 2016 [2] that implements the userspace part for
> > the loopback feature of some phys, that did not get mainline so far
> > which makes me wonder if ethtool is still the way to go.
> 
> ethtool is being converted to netlink, and that will be a much more
> flexible interface to work with since it is basically easily extensible
> (unlike the current ethtool + ioctl approach).

Yes, netlink sounds absolutely more useful here.

> Back when the patches were proposed, we just had mild disagreement on
> the loopback terminology being used, and then nothing happened.

Right, thanks for clarification!

> 
> > 
> > [1] https://www.nxp.com/docs/en/data-sheet/TJA1100.pdf
> > [2] https://www.spinics.net/lists/netdev/msg406614.html
> > 
> > Thanks,
> > Michael
> > 
> 
> 
> -- 
> Florian
> 

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |


signature.asc
Description: PGP signature


TJA1100 100Base-T1 PHY features via ethtool?

2018-08-13 Thread Michael Grzeschik
Hi David,

I use a special 100Base-T1 phy (NXP TJA1100 [1]) that has some features
like:

- enabling/disabling test modes
- fault detection
- switching managed/autonomous mode
- signal quality indication
- ...

I already implemented the support of the features with the
ethtool --get/set-phy-tunables features by adding ethtool_phy_tunables:

ETHTOOL_PHY_TEST_MODE
ETHTOOL_PHY_FAULT_DETECTION
ETHTOOL_PHY_MANAGED_MODE
ETHTOOL_PHY_SIGNAL_QUALITY

Before posting my series I wanted to ensure that this is the preferred
interface for those options.

I found a series from 2016 [2] that implements the userspace part for
the loopback feature of some phys, that did not get mainline so far
which makes me wonder if ethtool is still the way to go.

[1] https://www.nxp.com/docs/en/data-sheet/TJA1100.pdf
[2] https://www.spinics.net/lists/netdev/msg406614.html

Thanks,
Michael

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |


signature.asc
Description: PGP signature


[PATCH v2 0/2] net: macb: add error handling on probe and

2017-11-08 Thread Michael Grzeschik
This series adds more error handling to the macb driver.

Michael Grzeschik (2):
  net: macb: add of_phy_deregister_fixed_link to error paths
  net: macb: add of_node_put to error paths

 drivers/net/ethernet/cadence/macb_main.c | 9 +
 1 file changed, 9 insertions(+)

-- 
2.11.0



[PATCH v2 1/2] net: macb: add of_phy_deregister_fixed_link to error paths

2017-11-08 Thread Michael Grzeschik
We add the call of_phy_deregister_fixed_link to all associated
error paths for memory clean up.

Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
v2: removed extra parenthesis

drivers/net/ethernet/cadence/macb_main.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/net/ethernet/cadence/macb_main.c 
b/drivers/net/ethernet/cadence/macb_main.c
index 6df2cad61647a..b7846d6e9234e 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -611,6 +611,8 @@ static int macb_mii_init(struct macb *bp)
 err_out_unregister_bus:
mdiobus_unregister(bp->mii_bus);
 err_out_free_mdiobus:
+   if (np && of_phy_is_fixed_link(np))
+   of_phy_deregister_fixed_link(np);
mdiobus_free(bp->mii_bus);
 err_out:
return err;
@@ -3552,6 +3554,8 @@ static int macb_probe(struct platform_device *pdev)
 err_out_unregister_mdio:
phy_disconnect(dev->phydev);
mdiobus_unregister(bp->mii_bus);
+   if (np && of_phy_is_fixed_link(np))
+   of_phy_deregister_fixed_link(np);
mdiobus_free(bp->mii_bus);
 
/* Shutdown the PHY if there is a GPIO reset */
@@ -3574,6 +3578,7 @@ static int macb_remove(struct platform_device *pdev)
 {
struct net_device *dev;
struct macb *bp;
+   struct device_node *np = pdev->dev.of_node;
 
dev = platform_get_drvdata(pdev);
 
@@ -3582,6 +3587,8 @@ static int macb_remove(struct platform_device *pdev)
if (dev->phydev)
phy_disconnect(dev->phydev);
mdiobus_unregister(bp->mii_bus);
+   if (np && of_phy_is_fixed_link(np))
+   of_phy_deregister_fixed_link(np);
dev->phydev = NULL;
mdiobus_free(bp->mii_bus);
 
-- 
2.11.0



[PATCH v2 2/2] net: macb: add of_node_put to error paths

2017-11-08 Thread Michael Grzeschik
We add the call of_node_put(bp->phy_node) to all associated error
paths for memory clean up.

Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
v2: removed extra of_node_put from macb_remove

 drivers/net/ethernet/cadence/macb_main.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/cadence/macb_main.c 
b/drivers/net/ethernet/cadence/macb_main.c
index b7846d6e9234e..0f24ca5a24b53 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -611,6 +611,7 @@ static int macb_mii_init(struct macb *bp)
 err_out_unregister_bus:
mdiobus_unregister(bp->mii_bus);
 err_out_free_mdiobus:
+   of_node_put(bp->phy_node);
if (np && of_phy_is_fixed_link(np))
of_phy_deregister_fixed_link(np);
mdiobus_free(bp->mii_bus);
@@ -3554,6 +3555,7 @@ static int macb_probe(struct platform_device *pdev)
 err_out_unregister_mdio:
phy_disconnect(dev->phydev);
mdiobus_unregister(bp->mii_bus);
+   of_node_put(bp->phy_node);
if (np && of_phy_is_fixed_link(np))
of_phy_deregister_fixed_link(np);
mdiobus_free(bp->mii_bus);
-- 
2.11.0



Re: [PATCH 1/2] net: macb: add of_phy_deregister_fixed_link to error paths

2017-11-08 Thread Michael Grzeschik
On Wed, Nov 08, 2017 at 01:22:57PM +0900, David Miller wrote:
> From: Michael Grzeschik <m.grzesc...@pengutronix.de>
> Date: Mon,  6 Nov 2017 12:10:04 +0100
> 
> > We add the call of_phy_deregister_fixed_link to all associated
> > error paths for memory clean up.
> > 
> > Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
> > ---
> >  drivers/net/ethernet/cadence/macb_main.c | 7 +++
> >  1 file changed, 7 insertions(+)
> > 
> > diff --git a/drivers/net/ethernet/cadence/macb_main.c 
> > b/drivers/net/ethernet/cadence/macb_main.c
> > index 6df2cad61647a..2c2acd011329a 100644
> > --- a/drivers/net/ethernet/cadence/macb_main.c
> > +++ b/drivers/net/ethernet/cadence/macb_main.c
> > @@ -611,6 +611,8 @@ static int macb_mii_init(struct macb *bp)
> >  err_out_unregister_bus:
> > mdiobus_unregister(bp->mii_bus);
> >  err_out_free_mdiobus:
> > +   if ((np) && (of_phy_is_fixed_link(np)))
> 
> Please don't use so many parenthesis in your conditionals:
> 
>   if (np && of_phy_is_fixed_link(np))
> 
> is more than sufficient.
> 
> Please fix this in your entire set of patches.

There are only two patches and not even in one series.
I will resend them both with this one fixed and create
a series. As the second one depends on this one.

Thanks,
Michael

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |


signature.asc
Description: PGP signature


[PATCH v2] net: macb: add of_node_put to error paths

2017-11-07 Thread Michael Grzeschik
We add the call of_node_put(bp->phy_node) to all associated error
paths for memory clean up.

Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
v1 -> v2: removed extra of_node_put from macb_remove

 drivers/net/ethernet/cadence/macb_main.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/cadence/macb_main.c 
b/drivers/net/ethernet/cadence/macb_main.c
index 2c2acd011329a..c66df096e81a5 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -611,6 +611,7 @@ static int macb_mii_init(struct macb *bp)
 err_out_unregister_bus:
mdiobus_unregister(bp->mii_bus);
 err_out_free_mdiobus:
+   of_node_put(bp->phy_node);
if ((np) && (of_phy_is_fixed_link(np)))
of_phy_deregister_fixed_link(np);
mdiobus_free(bp->mii_bus);
@@ -3554,6 +3555,7 @@ static int macb_probe(struct platform_device *pdev)
 err_out_unregister_mdio:
phy_disconnect(dev->phydev);
mdiobus_unregister(bp->mii_bus);
+   of_node_put(bp->phy_node);
if ((np) && (of_phy_is_fixed_link(np)))
of_phy_deregister_fixed_link(np);
mdiobus_free(bp->mii_bus);
-- 
2.11.0



Re: [PATCH 2/2] net: macb: add of_node_put to error paths

2017-11-07 Thread Michael Grzeschik
On Tue, Nov 07, 2017 at 10:27:20AM +0100, Nicolas Ferre wrote:
> On 06/11/2017 at 12:10, Michael Grzeschik wrote:
> > We add the call of_node_put(bp->phy_node) to all associated error
> > paths for memory clean up.
> > 
> > Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
> > ---
> >  drivers/net/ethernet/cadence/macb_main.c | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/drivers/net/ethernet/cadence/macb_main.c 
> > b/drivers/net/ethernet/cadence/macb_main.c
> > index 2c2acd011329a..2698a1fde39c7 100644
> > --- a/drivers/net/ethernet/cadence/macb_main.c
> > +++ b/drivers/net/ethernet/cadence/macb_main.c
> > @@ -611,6 +611,7 @@ static int macb_mii_init(struct macb *bp)
> >  err_out_unregister_bus:
> > mdiobus_unregister(bp->mii_bus);
> >  err_out_free_mdiobus:
> > +   of_node_put(bp->phy_node);
> 
> okay
> 
> > if ((np) && (of_phy_is_fixed_link(np)))
> > of_phy_deregister_fixed_link(np);
> > mdiobus_free(bp->mii_bus);
> > @@ -3554,6 +3555,7 @@ static int macb_probe(struct platform_device *pdev)
> >  err_out_unregister_mdio:
> > phy_disconnect(dev->phydev);
> > mdiobus_unregister(bp->mii_bus);
> > +   of_node_put(bp->phy_node);
> 
> yes
> 
> > if ((np) && (of_phy_is_fixed_link(np)))
> > of_phy_deregister_fixed_link(np);
> > mdiobus_free(bp->mii_bus);
> > @@ -3587,6 +3589,7 @@ static int macb_remove(struct platform_device *pdev)
> > if (dev->phydev)
> > phy_disconnect(dev->phydev);
> > mdiobus_unregister(bp->mii_bus);
> > +   of_node_put(bp->phy_node);
> 
> Isn't this call already done some lines below, just before
> "free_netdev(dev);"?

You are absolutely right. Will send v2.

> > if ((np) && (of_phy_is_fixed_link(np)))
> > of_phy_deregister_fixed_link(np);
> > dev->phydev = NULL;
> > 
> 
> Thanks for your patch.
Thanks,
Michael

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |


signature.asc
Description: PGP signature


[PATCH 2/2] net: macb: add of_node_put to error paths

2017-11-06 Thread Michael Grzeschik
We add the call of_node_put(bp->phy_node) to all associated error
paths for memory clean up.

Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/ethernet/cadence/macb_main.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/cadence/macb_main.c 
b/drivers/net/ethernet/cadence/macb_main.c
index 2c2acd011329a..2698a1fde39c7 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -611,6 +611,7 @@ static int macb_mii_init(struct macb *bp)
 err_out_unregister_bus:
mdiobus_unregister(bp->mii_bus);
 err_out_free_mdiobus:
+   of_node_put(bp->phy_node);
if ((np) && (of_phy_is_fixed_link(np)))
of_phy_deregister_fixed_link(np);
mdiobus_free(bp->mii_bus);
@@ -3554,6 +3555,7 @@ static int macb_probe(struct platform_device *pdev)
 err_out_unregister_mdio:
phy_disconnect(dev->phydev);
mdiobus_unregister(bp->mii_bus);
+   of_node_put(bp->phy_node);
if ((np) && (of_phy_is_fixed_link(np)))
of_phy_deregister_fixed_link(np);
mdiobus_free(bp->mii_bus);
@@ -3587,6 +3589,7 @@ static int macb_remove(struct platform_device *pdev)
if (dev->phydev)
phy_disconnect(dev->phydev);
mdiobus_unregister(bp->mii_bus);
+   of_node_put(bp->phy_node);
if ((np) && (of_phy_is_fixed_link(np)))
of_phy_deregister_fixed_link(np);
dev->phydev = NULL;
-- 
2.11.0



[PATCH 1/2] net: macb: add of_phy_deregister_fixed_link to error paths

2017-11-06 Thread Michael Grzeschik
We add the call of_phy_deregister_fixed_link to all associated
error paths for memory clean up.

Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/ethernet/cadence/macb_main.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/net/ethernet/cadence/macb_main.c 
b/drivers/net/ethernet/cadence/macb_main.c
index 6df2cad61647a..2c2acd011329a 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -611,6 +611,8 @@ static int macb_mii_init(struct macb *bp)
 err_out_unregister_bus:
mdiobus_unregister(bp->mii_bus);
 err_out_free_mdiobus:
+   if ((np) && (of_phy_is_fixed_link(np)))
+   of_phy_deregister_fixed_link(np);
mdiobus_free(bp->mii_bus);
 err_out:
return err;
@@ -3552,6 +3554,8 @@ static int macb_probe(struct platform_device *pdev)
 err_out_unregister_mdio:
phy_disconnect(dev->phydev);
mdiobus_unregister(bp->mii_bus);
+   if ((np) && (of_phy_is_fixed_link(np)))
+   of_phy_deregister_fixed_link(np);
mdiobus_free(bp->mii_bus);
 
/* Shutdown the PHY if there is a GPIO reset */
@@ -3574,6 +3578,7 @@ static int macb_remove(struct platform_device *pdev)
 {
struct net_device *dev;
struct macb *bp;
+   struct device_node *np = pdev->dev.of_node;
 
dev = platform_get_drvdata(pdev);
 
@@ -3582,6 +3587,8 @@ static int macb_remove(struct platform_device *pdev)
if (dev->phydev)
phy_disconnect(dev->phydev);
mdiobus_unregister(bp->mii_bus);
+   if ((np) && (of_phy_is_fixed_link(np)))
+   of_phy_deregister_fixed_link(np);
dev->phydev = NULL;
mdiobus_free(bp->mii_bus);
 
-- 
2.11.0



[PATCH 1/4] arcnet: add err_skb package for package status feedback

2017-06-28 Thread Michael Grzeschik
We need to track the status of our queued packages. This way the driving
process knows if failed packages need to be retransmitted. For this
purpose we queue the transferred/failed packages back into the err_skb
message queue added with some status information.

Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/arcdevice.h |  4 +++
 drivers/net/arcnet/arcnet.c| 74 --
 2 files changed, 68 insertions(+), 10 deletions(-)

diff --git a/drivers/net/arcnet/arcdevice.h b/drivers/net/arcnet/arcdevice.h
index 20bfb9ba83ea2..cbb4f8566bbe5 100644
--- a/drivers/net/arcnet/arcdevice.h
+++ b/drivers/net/arcnet/arcdevice.h
@@ -269,6 +269,10 @@ struct arcnet_local {
 
struct timer_list   timer;
 
+   struct net_device *dev;
+   int reply_status;
+   struct tasklet_struct reply_tasklet;
+
/*
 * Buffer management: an ARCnet card has 4 x 512-byte buffers, each of
 * which can be used for either sending or receiving.  The new dynamic
diff --git a/drivers/net/arcnet/arcnet.c b/drivers/net/arcnet/arcnet.c
index 62ee439d58829..d87f4da29f113 100644
--- a/drivers/net/arcnet/arcnet.c
+++ b/drivers/net/arcnet/arcnet.c
@@ -51,6 +51,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -391,6 +392,52 @@ static void arcnet_timer(unsigned long data)
}
 }
 
+static void arcnet_reply_tasklet(unsigned long data)
+{
+   struct arcnet_local *lp = (struct arcnet_local *)data;
+
+   struct sk_buff *ackskb, *skb;
+   struct sock_exterr_skb *serr;
+   struct sock *sk;
+   int ret;
+
+   local_irq_disable();
+   skb = lp->outgoing.skb;
+   if (!skb || !skb->sk) {
+   local_irq_enable();
+   return;
+   }
+
+   sock_hold(skb->sk);
+   sk = skb->sk;
+   ackskb = skb_clone_sk(skb);
+   sock_put(skb->sk);
+
+   if (!ackskb) {
+   local_irq_enable();
+   return;
+   }
+
+   serr = SKB_EXT_ERR(ackskb);
+   memset(serr, 0, sizeof(*serr));
+   serr->ee.ee_errno = ENOMSG;
+   serr->ee.ee_origin = SO_EE_ORIGIN_TXSTATUS;
+   serr->ee.ee_data = skb_shinfo(skb)->tskey;
+   serr->ee.ee_info = lp->reply_status;
+
+   /* finally erasing outgoing skb */
+   dev_kfree_skb(lp->outgoing.skb);
+   lp->outgoing.skb = NULL;
+
+   ackskb->dev = lp->dev;
+
+   ret = sock_queue_err_skb(sk, ackskb);
+   if (ret)
+   kfree_skb(ackskb);
+
+   local_irq_enable();
+};
+
 struct net_device *alloc_arcdev(const char *name)
 {
struct net_device *dev;
@@ -401,6 +448,7 @@ struct net_device *alloc_arcdev(const char *name)
if (dev) {
struct arcnet_local *lp = netdev_priv(dev);
 
+   lp->dev = dev;
spin_lock_init(>lock);
init_timer(>timer);
lp->timer.data = (unsigned long) dev;
@@ -436,6 +484,9 @@ int arcnet_open(struct net_device *dev)
arc_cont(D_PROTO, "\n");
}
 
+   tasklet_init(>reply_tasklet, arcnet_reply_tasklet,
+(unsigned long)lp);
+
arc_printk(D_INIT, dev, "arcnet_open: resetting card.\n");
 
/* try to put the card in a defined state - if it fails the first
@@ -527,6 +578,8 @@ int arcnet_close(struct net_device *dev)
netif_stop_queue(dev);
netif_carrier_off(dev);
 
+   tasklet_kill(>reply_tasklet);
+
/* flush TX and disable RX */
lp->hw.intmask(dev, 0);
lp->hw.command(dev, NOTXcmd);   /* stop transmit */
@@ -635,13 +688,13 @@ netdev_tx_t arcnet_send_packet(struct sk_buff *skb,
txbuf = -1;
 
if (txbuf != -1) {
+   lp->outgoing.skb = skb;
if (proto->prepare_tx(dev, pkt, skb->len, txbuf) &&
!proto->ack_tx) {
/* done right away and we don't want to acknowledge
 *  the package later - forget about it now
 */
dev->stats.tx_bytes += skb->len;
-   dev_kfree_skb(skb);
} else {
/* do it the 'split' way */
lp->outgoing.proto = proto;
@@ -842,8 +895,16 @@ irqreturn_t arcnet_interrupt(int irq, void *dev_id)
 
/* a transmit finished, and we're interested in it. */
if ((status & lp->intmask & TXFREEflag) || lp->timed_out) {
+   int ackstatus;
lp->intmask &= ~(TXFREEflag | EXCNAKflag);
 
+   if (status & TXACKflag)
+   ackstatus = 2;
+   else if (lp->excnak_pending)
+   ackstatus =

[PATCH 2/4] arcnet: com20020-pci: add attribute to readback backplane status

2017-06-28 Thread Michael Grzeschik
We add the sysfs interface the read back the backplane
status of the interface.

Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/com20020-pci.c | 22 ++
 1 file changed, 22 insertions(+)

diff --git a/drivers/net/arcnet/com20020-pci.c 
b/drivers/net/arcnet/com20020-pci.c
index 239de38fbd6a5..dec300cac55f9 100644
--- a/drivers/net/arcnet/com20020-pci.c
+++ b/drivers/net/arcnet/com20020-pci.c
@@ -93,6 +93,27 @@ static void led_recon_set(struct led_classdev *led_cdev,
outb(!!value, priv->misc + ci->leds[card->index].red);
 }
 
+static ssize_t backplane_mode_show(struct device *dev,
+  struct device_attribute *attr,
+  char *buf)
+{
+   struct net_device *net_dev = to_net_dev(dev);
+   struct arcnet_local *lp = netdev_priv(net_dev);
+
+   return sprintf(buf, "%s\n", lp->backplane ? "true" : "false");
+}
+static DEVICE_ATTR_RO(backplane_mode);
+
+static struct attribute *com20020_state_attrs[] = {
+   _attr_backplane_mode.attr,
+   NULL,
+};
+
+static struct attribute_group com20020_state_group = {
+   .name = NULL,
+   .attrs = com20020_state_attrs,
+};
+
 static void com20020pci_remove(struct pci_dev *pdev);
 
 static int com20020pci_probe(struct pci_dev *pdev,
@@ -168,6 +189,7 @@ static int com20020pci_probe(struct pci_dev *pdev,
 
dev->base_addr = ioaddr;
dev->dev_addr[0] = node;
+   dev->sysfs_groups[0] = _state_group;
dev->irq = pdev->irq;
lp->card_name = "PCI COM20020";
lp->card_flags = ci->flags;
-- 
2.11.0



[PATCH 0/4] arcnet: Collection of latest features

2017-06-28 Thread Michael Grzeschik
Here we sum up the latest features to improve the arcnet framework. One
patch is used to get feedback from the transfer queue about failed xfers
by adding the err_skb message queue. Beside that we improve the
backplane status that can be read by the PCI-based cards and offer that
status via an extra sysfs attribute. In the last patch we add another
card type PCIFB2.

Michael Grzeschik (4):
  arcnet: add err_skb package for package status feedback
  arcnet: com20020-pci: add attribute to readback backplane status
  arcnet: com20020-pci: handle backplane mode depending on card type
  arcnet: com20020-pci: add support for PCIFB2 card

 drivers/net/arcnet/arcdevice.h|  4 +++
 drivers/net/arcnet/arcnet.c   | 74 +--
 drivers/net/arcnet/com20020-pci.c | 58 ++
 3 files changed, 126 insertions(+), 10 deletions(-)

-- 
2.11.0



[PATCH 3/4] arcnet: com20020-pci: handle backplane mode depending on card type

2017-06-28 Thread Michael Grzeschik
We read the backplane mode of each subcard from bits 2 and 3 of the misc
register.

Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/com20020-pci.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/arcnet/com20020-pci.c 
b/drivers/net/arcnet/com20020-pci.c
index dec300cac55f9..f5854ab7dc326 100644
--- a/drivers/net/arcnet/com20020-pci.c
+++ b/drivers/net/arcnet/com20020-pci.c
@@ -199,6 +199,8 @@ static int com20020pci_probe(struct pci_dev *pdev,
lp->timeout = timeout;
lp->hw.owner = THIS_MODULE;
 
+   lp->backplane = (inb(priv->misc) >> (2 + i)) & 0x1;
+
/* Get the dev_id from the PLX rotary coder */
if (!strncmp(ci->name, "EAE PLX-PCI MA1", 15))
dev->dev_id = 0xc;
-- 
2.11.0



[PATCH 4/4] arcnet: com20020-pci: add support for PCIFB2 card

2017-06-28 Thread Michael Grzeschik
We add support for the PCIFB2 card from EAE.

Beside other cards, this card has the backplane mode enabled by default.

Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/com20020-pci.c | 34 ++
 1 file changed, 34 insertions(+)

diff --git a/drivers/net/arcnet/com20020-pci.c 
b/drivers/net/arcnet/com20020-pci.c
index f5854ab7dc326..24deb88a37f06 100644
--- a/drivers/net/arcnet/com20020-pci.c
+++ b/drivers/net/arcnet/com20020-pci.c
@@ -201,6 +201,9 @@ static int com20020pci_probe(struct pci_dev *pdev,
 
lp->backplane = (inb(priv->misc) >> (2 + i)) & 0x1;
 
+   if (!strncmp(ci->name, "EAE PLX-PCI FB2", 15))
+   lp->backplane = 1;
+
/* Get the dev_id from the PLX rotary coder */
if (!strncmp(ci->name, "EAE PLX-PCI MA1", 15))
dev->dev_id = 0xc;
@@ -385,6 +388,31 @@ static struct com20020_pci_card_info card_info_eae_ma1 = {
.flags = ARC_CAN_10MBIT,
 };
 
+static struct com20020_pci_card_info card_info_eae_fb2 = {
+   .name = "EAE PLX-PCI FB2",
+   .devcount = 1,
+   .chan_map_tbl = {
+   {
+   .bar = 2,
+   .offset = 0x00,
+   .size = 0x08,
+   },
+   },
+   .misc_map = {
+   .bar = 2,
+   .offset = 0x10,
+   .size = 0x04,
+   },
+   .leds = {
+   {
+   .green = 0x0,
+   .red = 0x1,
+   },
+   },
+   .rotary = 0x0,
+   .flags = ARC_CAN_10MBIT,
+};
+
 static const struct pci_device_id com20020pci_id_table[] = {
{
0x1571, 0xa001,
@@ -531,6 +559,12 @@ static const struct pci_device_id com20020pci_id_table[] = 
{
(kernel_ulong_t)_info_eae_ma1
},
{
+   0x10B5, 0x9050,
+   0x10B5, 0x3294,
+   0, 0,
+   (kernel_ulong_t)_info_eae_fb2
+   },
+   {
0x14BA, 0x6000,
PCI_ANY_ID, PCI_ANY_ID,
0, 0,
-- 
2.11.0



[PATCH 1/5] arcnet: change irq handler to lock irqsave

2017-06-28 Thread Michael Grzeschik
 }
[   41.780945]  ... key  at: [] netdev_xmit_lock_key+0x38/0x1c8
[   41.788192]  ... acquired at:
[   41.791309][] lock_acquire+0x70/0x90
[   41.796361][] _raw_spin_lock_irqsave+0x40/0x54
[   41.802324][] arcnet_send_packet+0x60/0x1c0 [arcnet]
[   41.808844][] packet_direct_xmit+0x130/0x1c8
[   41.814622][] packet_sendmsg+0x3b8/0x680
[   41.820034][] sock_sendmsg+0x14/0x24
[   41.825091][] SyS_sendto+0xb8/0xe0
[   41.829956][] SyS_send+0x18/0x20
[   41.834638][] ret_fast_syscall+0x0/0x1c
[   41.839954]
[   41.841514]
the dependencies between the lock to be acquired and SOFTIRQ-irq-unsafe lock:
[   41.850302] -> (&(>lock)->rlock){+.+...} ops: 5 {
[   41.855644]HARDIRQ-ON-W at:
[   41.858945] [] _raw_spin_lock+0x30/0x40
[   41.865726] [] arcnet_interrupt+0x2c/0x800 
[arcnet]
[   41.873607] [] handle_nested_irq+0x8c/0xec
[   41.880666] [] regmap_irq_thread+0x190/0x314
[   41.887901] [] irq_thread_fn+0x1c/0x34
[   41.894593] [] irq_thread+0x13c/0x1dc
[   41.901195] [] kthread+0xe4/0xf8
[   41.907338] [] ret_from_fork+0x14/0x24
[   41.914025]SOFTIRQ-ON-W at:
[   41.917328] [] _raw_spin_lock+0x30/0x40
[   41.924106] [] arcnet_interrupt+0x2c/0x800 
[arcnet]
[   41.931981] [] handle_nested_irq+0x8c/0xec
[   41.939028] [] regmap_irq_thread+0x190/0x314
[   41.946264] [] irq_thread_fn+0x1c/0x34
[   41.952954] [] irq_thread+0x13c/0x1dc
[   41.959548] [] kthread+0xe4/0xf8
[   41.965689] [] ret_from_fork+0x14/0x24
[   41.972379]INITIAL USE at:
[   41.975595][] _raw_spin_lock+0x30/0x40
[   41.982283][] arcnet_interrupt+0x2c/0x800 
[arcnet]
[   41.990063][] handle_nested_irq+0x8c/0xec
[   41.997027][] regmap_irq_thread+0x190/0x314
[   42.004172][] irq_thread_fn+0x1c/0x34
[   42.010766][] irq_thread+0x13c/0x1dc
[   42.017267][] kthread+0xe4/0xf8
[   42.023314][] ret_from_fork+0x14/0x24
[   42.029903]  }
[   42.031648]  ... key  at: [] __key.42091+0x0/0xf0f8 
[arcnet]
[   42.039255]  ... acquired at:
[   42.042372][] lock_acquire+0x70/0x90
[   42.047413][] _raw_spin_lock_irqsave+0x40/0x54
[   42.053364][] arcnet_send_packet+0x60/0x1c0 [arcnet]
[   42.059872][] packet_direct_xmit+0x130/0x1c8
[   42.065634][] packet_sendmsg+0x3b8/0x680
[   42.071030][] sock_sendmsg+0x14/0x24
[   42.076069][] SyS_sendto+0xb8/0xe0
[   42.080926][] SyS_send+0x18/0x20
[   42.085601][] ret_fast_syscall+0x0/0x1c
[   42.090918]
[   42.092481]
[   42.092481] stack backtrace:
[   42.097065] CPU: 0 PID: 233 Comm: arcecho Not tainted 4.4.0-00034-gc0ae784 
#536
[   42.104751] Hardware name: Generic AM33XX (Flattened Device Tree)
[   42.83] [] (unwind_backtrace) from [] 
(show_stack+0x10/0x14)
[   42.119337] [] (show_stack) from [] 
(dump_stack+0x8c/0x9c)
[   42.126937] [] (dump_stack) from [] 
(check_usage+0x4bc/0x63c)
[   42.134815] [] (check_usage) from [] 
(check_irq_usage+0x58/0xb0)
[   42.142964] [] (check_irq_usage) from [] 
(__lock_acquire+0x1524/0x20b0)
[   42.151740] [] (__lock_acquire) from [] 
(lock_acquire+0x70/0x90)
[   42.159886] [] (lock_acquire) from [] 
(_raw_spin_lock_irqsave+0x40/0x54)
[   42.168768] [] (_raw_spin_lock_irqsave) from [] 
(arcnet_send_packet+0x60/0x1c0 [arcnet])
[   42.179115] [] (arcnet_send_packet [arcnet]) from [] 
(packet_direct_xmit+0x130/0x1c8)
[   42.189182] [] (packet_direct_xmit) from [] 
(packet_sendmsg+0x3b8/0x680)
[   42.198059] [] (packet_sendmsg) from [] 
(sock_sendmsg+0x14/0x24)
[   42.206199] [] (sock_sendmsg) from [] 
(SyS_sendto+0xb8/0xe0)
[   42.213978] [] (SyS_sendto) from [] (SyS_send+0x18/0x20)
[   42.221388] [] (SyS_send) from [] 
(ret_fast_syscall+0x0/0x1c)

Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>

   ---
   v1 -> v2: removed unneeded zero assignment of flags
---
 drivers/net/arcnet/arcnet.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/arcnet/arcnet.c b/drivers/net/arcnet/arcnet.c
index 62ee439d58829..53a1cb551defa 100644
--- a/drivers/net/arcnet/arcnet.c
+++ b/drivers/net/arcnet/arcnet.c
@@ -756,6 +756,7 @@ irqreturn_t arcnet_interrupt(int irq, void *dev_id)
struct net_device *dev = dev_id;
struct arcnet_local *lp;
int recbuf, status, diagstatus, didsomething, boguscount;
+   unsigned long flags;
int retval = IRQ_NONE;
 
arc_printk(D_DURING, dev, "\n");
@@ -765,7 +766,7 @@ irqreturn_t arcnet_interrupt(int irq, void *dev_id)
lp = netdev_priv(dev);
BUG_ON(!lp);
 
-   spi

[PATCH 0/5] arcnet: Collection of latest fixes

2017-06-28 Thread Michael Grzeschik
Here we sum up the recent fixes I collected on the way to use and
stabilise the framework. Part of it is an possible deadlock that we
prevent as well to fix the calculation of the dev_id that can be setup
by an rotary encoder. Beside that we added an trivial spelling patch and
fix some wrong and missing assignments that improves the code footprint.

Colin Ian King (1):
  Trivial fix to spelling mistake in arc_printk message

Michael Grzeschik (4):
  arcnet: change irq handler to lock irqsave
  arcnet: com20020: remove needless base_addr assignment
  arcnet: com20020-pci: fix dev_id calculation
  arcnet: com20020-pci: add missing pdev setup in netdev structure

 drivers/net/arcnet/arcnet.c   | 7 ---
 drivers/net/arcnet/capmode.c  | 2 +-
 drivers/net/arcnet/com20020-pci.c | 6 --
 drivers/net/arcnet/com20020.c | 2 --
 4 files changed, 9 insertions(+), 8 deletions(-)

-- 
2.11.0



[PATCH 3/5] arcnet: com20020: remove needless base_addr assignment

2017-06-28 Thread Michael Grzeschik
The assignment is superfluous.

Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/com20020.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/net/arcnet/com20020.c b/drivers/net/arcnet/com20020.c
index 13d9ad4b3f5c9..78043a9c5981e 100644
--- a/drivers/net/arcnet/com20020.c
+++ b/drivers/net/arcnet/com20020.c
@@ -246,8 +246,6 @@ int com20020_found(struct net_device *dev, int shared)
return -ENODEV;
}
 
-   dev->base_addr = ioaddr;
-
arc_printk(D_NORMAL, dev, "%s: station %02Xh found at %03lXh, IRQ 
%d.\n",
   lp->card_name, dev->dev_addr[0], dev->base_addr, dev->irq);
 
-- 
2.11.0



[PATCH 4/5] arcnet: com20020-pci: fix dev_id calculation

2017-06-28 Thread Michael Grzeschik
The dev_id was miscalculated. Only the two bits 4-5 are relevant for the
MA1 card. PCIARC1 and PCIFB2 use the four bits 4-7 for id selection.

Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/com20020-pci.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/arcnet/com20020-pci.c 
b/drivers/net/arcnet/com20020-pci.c
index 239de38fbd6a5..fec2df2c869fe 100644
--- a/drivers/net/arcnet/com20020-pci.c
+++ b/drivers/net/arcnet/com20020-pci.c
@@ -135,6 +135,7 @@ static int com20020pci_probe(struct pci_dev *pdev,
for (i = 0; i < ci->devcount; i++) {
struct com20020_pci_channel_map *cm = >chan_map_tbl[i];
struct com20020_dev *card;
+   int dev_id_mask = 0xf;
 
dev = alloc_arcdev(device);
if (!dev) {
@@ -179,8 +180,8 @@ static int com20020pci_probe(struct pci_dev *pdev,
 
/* Get the dev_id from the PLX rotary coder */
if (!strncmp(ci->name, "EAE PLX-PCI MA1", 15))
-   dev->dev_id = 0xc;
-   dev->dev_id ^= inb(priv->misc + ci->rotary) >> 4;
+   dev_id_mask = 0x3;
+   dev->dev_id = (inb(priv->misc + ci->rotary) >> 4) & dev_id_mask;
 
snprintf(dev->name, sizeof(dev->name), "arc%d-%d", dev->dev_id, 
i);
 
-- 
2.11.0



[PATCH 5/5] arcnet: com20020-pci: add missing pdev setup in netdev structure

2017-06-28 Thread Michael Grzeschik
We add the pdev data to the pci devices netdev structure. This way
the interface get consistent device names in the userspace (udev).

Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/com20020-pci.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/arcnet/com20020-pci.c 
b/drivers/net/arcnet/com20020-pci.c
index fec2df2c869fe..47f80b83dcf42 100644
--- a/drivers/net/arcnet/com20020-pci.c
+++ b/drivers/net/arcnet/com20020-pci.c
@@ -167,6 +167,7 @@ static int com20020pci_probe(struct pci_dev *pdev,
arcnet_outb(0x00, ioaddr, COM20020_REG_W_COMMAND);
arcnet_inb(ioaddr, COM20020_REG_R_DIAGSTAT);
 
+   SET_NETDEV_DEV(dev, >dev);
dev->base_addr = ioaddr;
dev->dev_addr[0] = node;
dev->irq = pdev->irq;
-- 
2.11.0



[PATCH 2/5] Trivial fix to spelling mistake in arc_printk message

2017-06-28 Thread Michael Grzeschik
From: Colin Ian King <colin.k...@canonical.com>

Signed-off-by: Colin Ian King <colin.k...@canonical.com>
Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/capmode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/arcnet/capmode.c b/drivers/net/arcnet/capmode.c
index a80f4eb9262d5..b780be6f41ff9 100644
--- a/drivers/net/arcnet/capmode.c
+++ b/drivers/net/arcnet/capmode.c
@@ -212,7 +212,7 @@ static int ack_tx(struct net_device *dev, int acked)
ackpkt->soft.cap.proto = 0; /* using protocol 0 for acknowledge */
ackpkt->soft.cap.mes.ack = acked;
 
-   arc_printk(D_PROTO, dev, "Ackknowledge for cap packet %x.\n",
+   arc_printk(D_PROTO, dev, "Acknowledge for cap packet %x.\n",
   *((int *)>soft.cap.cookie[0]));
 
ackskb->protocol = cpu_to_be16(ETH_P_ARCNET);
-- 
2.11.0



Re: [GIT PULL] arcnet: fixes and features

2017-06-28 Thread Michael Grzeschik
Hi,

On Fri, Jun 23, 2017 at 01:54:03PM -0400, David Miller wrote:
> From: Michael Grzeschik <m.grzesc...@pengutronix.de>
> Date: Thu, 22 Jun 2017 17:31:02 +0200
> 
> > are available in the git repository at:
> > 
> >   pub...@git.pengutronix.de:/mgr/linux.git tags/arcnet-for-mainline
> 
> I'm not pulling from that address, either setup a properl kernel.org
> GIT account or we work with just plain patches.

Since helpd...@kernel.org does not seem to respond for
my account request I will resend the series as plain patches.

> Next, you need to provide a proper commit message in a
> "[PATCH 0/N] " posting explaining at a high level what
> the patch series is doing as a unit, how it is doing it,
> and why it is doing it that way.

Will do.

> Finally, in patch #1 the assignment of "flags" to "0" in the
> declaration is unnecessary please remove it.

Fixed that.

Thanks,
Michael

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |


signature.asc
Description: PGP signature


Re: [PATCH] arcnet: fix spelling mistake "Ackknowledge" -> "Acknowledge"

2017-06-26 Thread Michael Grzeschik
On Sun, Jun 25, 2017 at 10:15:06PM +0100, Colin King wrote:
> From: Colin Ian King 
> 
> Trivial fix to spelling mistake in arc_printk message
> 
> Signed-off-by: Colin Ian King 
> ---
>  drivers/net/arcnet/capmode.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/arcnet/capmode.c b/drivers/net/arcnet/capmode.c
> index a80f4eb9262d..b780be6f41ff 100644
> --- a/drivers/net/arcnet/capmode.c
> +++ b/drivers/net/arcnet/capmode.c
> @@ -212,7 +212,7 @@ static int ack_tx(struct net_device *dev, int acked)
>   ackpkt->soft.cap.proto = 0; /* using protocol 0 for acknowledge */
>   ackpkt->soft.cap.mes.ack = acked;
>  
> - arc_printk(D_PROTO, dev, "Ackknowledge for cap packet %x.\n",
> + arc_printk(D_PROTO, dev, "Acknowledge for cap packet %x.\n",
>  *((int *)>soft.cap.cookie[0]));
>  
>   ackskb->protocol = cpu_to_be16(ETH_P_ARCNET);

I will take it into my next pull request.

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |


[PATCH v2] net: macb: add fixed-link node support

2017-06-23 Thread Michael Grzeschik
In case the MACB is directly connected to a
non-mdio PHY/device, it should be possible to provide
a fixed link configuration in the DT.

Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
  v1 -> v2: - moved of_phy_connect case and phy_connect_direct into if else 
cases
- moved of_pphy_register_fixed_link into if(np) case
- added of_node_put(bp->phy_node); into macb_remove
---
 drivers/net/ethernet/cadence/macb.c | 98 ++---
 drivers/net/ethernet/cadence/macb.h |  1 +
 2 files changed, 60 insertions(+), 39 deletions(-)

diff --git a/drivers/net/ethernet/cadence/macb.c 
b/drivers/net/ethernet/cadence/macb.c
index 91f7492623d3f..5781f1ede8c6e 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -425,32 +425,40 @@ static int macb_mii_probe(struct net_device *dev)
int phy_irq;
int ret;
 
-   phydev = phy_find_first(bp->mii_bus);
-   if (!phydev) {
-   netdev_err(dev, "no PHY found\n");
-   return -ENXIO;
-   }
+   if (bp->phy_node) {
+   phydev = of_phy_connect(dev, bp->phy_node,
+   _handle_link_change, 0,
+   bp->phy_interface);
+   if (!phydev)
+   return -ENODEV;
+   } else {
+   phydev = phy_find_first(bp->mii_bus);
+   if (!phydev) {
+   netdev_err(dev, "no PHY found\n");
+   return -ENXIO;
+   }
 
-   pdata = dev_get_platdata(>pdev->dev);
-   if (pdata) {
-   if (gpio_is_valid(pdata->phy_irq_pin)) {
-   ret = devm_gpio_request(>pdev->dev,
-   pdata->phy_irq_pin, "phy int");
-   if (!ret) {
-   phy_irq = gpio_to_irq(pdata->phy_irq_pin);
-   phydev->irq = (phy_irq < 0) ? PHY_POLL : 
phy_irq;
+   pdata = dev_get_platdata(>pdev->dev);
+   if (pdata) {
+   if (gpio_is_valid(pdata->phy_irq_pin)) {
+   ret = devm_gpio_request(>pdev->dev,
+   pdata->phy_irq_pin, 
"phy int");
+   if (!ret) {
+   phy_irq = 
gpio_to_irq(pdata->phy_irq_pin);
+   phydev->irq = (phy_irq < 0) ? PHY_POLL 
: phy_irq;
+   }
+   } else {
+   phydev->irq = PHY_POLL;
}
-   } else {
-   phydev->irq = PHY_POLL;
}
-   }
 
-   /* attach the mac to the phy */
-   ret = phy_connect_direct(dev, phydev, _handle_link_change,
-bp->phy_interface);
-   if (ret) {
-   netdev_err(dev, "Could not attach to PHY\n");
-   return ret;
+   /* attach the mac to the phy */
+   ret = phy_connect_direct(dev, phydev, _handle_link_change,
+bp->phy_interface);
+   if (ret) {
+   netdev_err(dev, "Could not attach to PHY\n");
+   return ret;
+   }
}
 
/* mask with MAC supported features */
@@ -499,26 +507,37 @@ static int macb_mii_init(struct macb *bp)
 
np = bp->pdev->dev.of_node;
if (np) {
-   /* try dt phy registration */
-   err = of_mdiobus_register(bp->mii_bus, np);
+   if (of_phy_is_fixed_link(np)) {
+   if (of_phy_register_fixed_link(np) < 0) {
+   dev_err(>pdev->dev,
+   "broken fixed-link specification\n");
+   goto err_out_unregister_bus;
+   }
+   bp->phy_node = of_node_get(np);
 
-   /* fallback to standard phy registration if no phy were
-* found during dt phy registration
-*/
-   if (!err && !phy_find_first(bp->mii_bus)) {
-   for (i = 0; i < PHY_MAX_ADDR; i++) {
-   struct phy_device *phydev;
-
-   phydev = mdiobus_scan(bp->mii_bus, i);
-   if (IS_ERR(phydev) &&
-   PTR_ERR(phydev) != -ENODEV) {
-   err = PTR_ERR(phydev);
-   break;
+   err = mdiobus_register(bp->mii_bus);
+

[PATCH 8/8] arcnet: com20020-pci: add support for PCIFB2 card

2017-06-22 Thread Michael Grzeschik
We add support for the PCIFB2 card from EAE.

Beside other cards, this card has the backplane mode enabled by default.

Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/com20020-pci.c | 34 ++
 1 file changed, 34 insertions(+)

diff --git a/drivers/net/arcnet/com20020-pci.c 
b/drivers/net/arcnet/com20020-pci.c
index 7a2d64739fe58..2d956cb59d06d 100644
--- a/drivers/net/arcnet/com20020-pci.c
+++ b/drivers/net/arcnet/com20020-pci.c
@@ -203,6 +203,9 @@ static int com20020pci_probe(struct pci_dev *pdev,
 
lp->backplane = (inb(priv->misc) >> (2 + i)) & 0x1;
 
+   if (!strncmp(ci->name, "EAE PLX-PCI FB2", 15))
+   lp->backplane = 1;
+
/* Get the dev_id from the PLX rotary coder */
if (!strncmp(ci->name, "EAE PLX-PCI MA1", 15))
dev_id_mask = 0x3;
@@ -387,6 +390,31 @@ static struct com20020_pci_card_info card_info_eae_ma1 = {
.flags = ARC_CAN_10MBIT,
 };
 
+static struct com20020_pci_card_info card_info_eae_fb2 = {
+   .name = "EAE PLX-PCI FB2",
+   .devcount = 1,
+   .chan_map_tbl = {
+   {
+   .bar = 2,
+   .offset = 0x00,
+   .size = 0x08,
+   },
+   },
+   .misc_map = {
+   .bar = 2,
+   .offset = 0x10,
+   .size = 0x04,
+   },
+   .leds = {
+   {
+   .green = 0x0,
+   .red = 0x1,
+   },
+   },
+   .rotary = 0x0,
+   .flags = ARC_CAN_10MBIT,
+};
+
 static const struct pci_device_id com20020pci_id_table[] = {
{
0x1571, 0xa001,
@@ -533,6 +561,12 @@ static const struct pci_device_id com20020pci_id_table[] = 
{
(kernel_ulong_t)_info_eae_ma1
},
{
+   0x10B5, 0x9050,
+   0x10B5, 0x3294,
+   0, 0,
+   (kernel_ulong_t)_info_eae_fb2
+   },
+   {
0x14BA, 0x6000,
PCI_ANY_ID, PCI_ANY_ID,
0, 0,
-- 
2.11.0



[PATCH 7/8] arcnet: com20020-pci: handle backplane mode depending on card type

2017-06-22 Thread Michael Grzeschik
We read the backplane mode of each subcard from bits 2 and 3 of the misc
register.

Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/com20020-pci.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/arcnet/com20020-pci.c 
b/drivers/net/arcnet/com20020-pci.c
index 3f85a4d5f8c90..7a2d64739fe58 100644
--- a/drivers/net/arcnet/com20020-pci.c
+++ b/drivers/net/arcnet/com20020-pci.c
@@ -201,6 +201,8 @@ static int com20020pci_probe(struct pci_dev *pdev,
lp->timeout = timeout;
lp->hw.owner = THIS_MODULE;
 
+   lp->backplane = (inb(priv->misc) >> (2 + i)) & 0x1;
+
/* Get the dev_id from the PLX rotary coder */
if (!strncmp(ci->name, "EAE PLX-PCI MA1", 15))
dev_id_mask = 0x3;
-- 
2.11.0



[PATCH 4/8] arcnet: com20020-pci: add missing pdev setup in netdev structure

2017-06-22 Thread Michael Grzeschik
We add the pdev data to the pci devices netdev structure. This way
the interface get consistent device names in the userspace (udev).

Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/com20020-pci.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/arcnet/com20020-pci.c 
b/drivers/net/arcnet/com20020-pci.c
index 239de38fbd6a5..bfbde568e7dc6 100644
--- a/drivers/net/arcnet/com20020-pci.c
+++ b/drivers/net/arcnet/com20020-pci.c
@@ -166,6 +166,7 @@ static int com20020pci_probe(struct pci_dev *pdev,
arcnet_outb(0x00, ioaddr, COM20020_REG_W_COMMAND);
arcnet_inb(ioaddr, COM20020_REG_R_DIAGSTAT);
 
+   SET_NETDEV_DEV(dev, >dev);
dev->base_addr = ioaddr;
dev->dev_addr[0] = node;
dev->irq = pdev->irq;
-- 
2.11.0



[PATCH 3/8] arcnet: com20020: remove needless base_addr assignment

2017-06-22 Thread Michael Grzeschik
The assignment is superfluous.

Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/com20020.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/net/arcnet/com20020.c b/drivers/net/arcnet/com20020.c
index 13d9ad4b3f5c9..78043a9c5981e 100644
--- a/drivers/net/arcnet/com20020.c
+++ b/drivers/net/arcnet/com20020.c
@@ -246,8 +246,6 @@ int com20020_found(struct net_device *dev, int shared)
return -ENODEV;
}
 
-   dev->base_addr = ioaddr;
-
arc_printk(D_NORMAL, dev, "%s: station %02Xh found at %03lXh, IRQ 
%d.\n",
   lp->card_name, dev->dev_addr[0], dev->base_addr, dev->irq);
 
-- 
2.11.0



[PATCH 5/8] arcnet: com20020-pci: fix dev_id calculation

2017-06-22 Thread Michael Grzeschik
The dev_id was miscalculated. Only the two bits 4-5 are relevant for the
MA1 card. PCIARC1 and PCIFB2 use the four bits 4-7 for id selection.

Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/com20020-pci.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/arcnet/com20020-pci.c 
b/drivers/net/arcnet/com20020-pci.c
index bfbde568e7dc6..47f80b83dcf42 100644
--- a/drivers/net/arcnet/com20020-pci.c
+++ b/drivers/net/arcnet/com20020-pci.c
@@ -135,6 +135,7 @@ static int com20020pci_probe(struct pci_dev *pdev,
for (i = 0; i < ci->devcount; i++) {
struct com20020_pci_channel_map *cm = >chan_map_tbl[i];
struct com20020_dev *card;
+   int dev_id_mask = 0xf;
 
dev = alloc_arcdev(device);
if (!dev) {
@@ -180,8 +181,8 @@ static int com20020pci_probe(struct pci_dev *pdev,
 
/* Get the dev_id from the PLX rotary coder */
if (!strncmp(ci->name, "EAE PLX-PCI MA1", 15))
-   dev->dev_id = 0xc;
-   dev->dev_id ^= inb(priv->misc + ci->rotary) >> 4;
+   dev_id_mask = 0x3;
+   dev->dev_id = (inb(priv->misc + ci->rotary) >> 4) & dev_id_mask;
 
snprintf(dev->name, sizeof(dev->name), "arc%d-%d", dev->dev_id, 
i);
 
-- 
2.11.0



[PATCH 1/8] arcnet: change irq handler to lock irqsave

2017-06-22 Thread Michael Grzeschik
 }
[   41.780945]  ... key  at: [] netdev_xmit_lock_key+0x38/0x1c8
[   41.788192]  ... acquired at:
[   41.791309][] lock_acquire+0x70/0x90
[   41.796361][] _raw_spin_lock_irqsave+0x40/0x54
[   41.802324][] arcnet_send_packet+0x60/0x1c0 [arcnet]
[   41.808844][] packet_direct_xmit+0x130/0x1c8
[   41.814622][] packet_sendmsg+0x3b8/0x680
[   41.820034][] sock_sendmsg+0x14/0x24
[   41.825091][] SyS_sendto+0xb8/0xe0
[   41.829956][] SyS_send+0x18/0x20
[   41.834638][] ret_fast_syscall+0x0/0x1c
[   41.839954]
[   41.841514]
the dependencies between the lock to be acquired and SOFTIRQ-irq-unsafe lock:
[   41.850302] -> (&(>lock)->rlock){+.+...} ops: 5 {
[   41.855644]HARDIRQ-ON-W at:
[   41.858945] [] _raw_spin_lock+0x30/0x40
[   41.865726] [] arcnet_interrupt+0x2c/0x800 
[arcnet]
[   41.873607] [] handle_nested_irq+0x8c/0xec
[   41.880666] [] regmap_irq_thread+0x190/0x314
[   41.887901] [] irq_thread_fn+0x1c/0x34
[   41.894593] [] irq_thread+0x13c/0x1dc
[   41.901195] [] kthread+0xe4/0xf8
[   41.907338] [] ret_from_fork+0x14/0x24
[   41.914025]SOFTIRQ-ON-W at:
[   41.917328] [] _raw_spin_lock+0x30/0x40
[   41.924106] [] arcnet_interrupt+0x2c/0x800 
[arcnet]
[   41.931981] [] handle_nested_irq+0x8c/0xec
[   41.939028] [] regmap_irq_thread+0x190/0x314
[   41.946264] [] irq_thread_fn+0x1c/0x34
[   41.952954] [] irq_thread+0x13c/0x1dc
[   41.959548] [] kthread+0xe4/0xf8
[   41.965689] [] ret_from_fork+0x14/0x24
[   41.972379]INITIAL USE at:
[   41.975595][] _raw_spin_lock+0x30/0x40
[   41.982283][] arcnet_interrupt+0x2c/0x800 
[arcnet]
[   41.990063][] handle_nested_irq+0x8c/0xec
[   41.997027][] regmap_irq_thread+0x190/0x314
[   42.004172][] irq_thread_fn+0x1c/0x34
[   42.010766][] irq_thread+0x13c/0x1dc
[   42.017267][] kthread+0xe4/0xf8
[   42.023314][] ret_from_fork+0x14/0x24
[   42.029903]  }
[   42.031648]  ... key  at: [] __key.42091+0x0/0xf0f8 
[arcnet]
[   42.039255]  ... acquired at:
[   42.042372][] lock_acquire+0x70/0x90
[   42.047413][] _raw_spin_lock_irqsave+0x40/0x54
[   42.053364][] arcnet_send_packet+0x60/0x1c0 [arcnet]
[   42.059872][] packet_direct_xmit+0x130/0x1c8
[   42.065634][] packet_sendmsg+0x3b8/0x680
[   42.071030][] sock_sendmsg+0x14/0x24
[   42.076069][] SyS_sendto+0xb8/0xe0
[   42.080926][] SyS_send+0x18/0x20
[   42.085601][] ret_fast_syscall+0x0/0x1c
[   42.090918]
[   42.092481]
[   42.092481] stack backtrace:
[   42.097065] CPU: 0 PID: 233 Comm: arcecho Not tainted 4.4.0-00034-gc0ae784 
#536
[   42.104751] Hardware name: Generic AM33XX (Flattened Device Tree)
[   42.83] [] (unwind_backtrace) from [] 
(show_stack+0x10/0x14)
[   42.119337] [] (show_stack) from [] 
(dump_stack+0x8c/0x9c)
[   42.126937] [] (dump_stack) from [] 
(check_usage+0x4bc/0x63c)
[   42.134815] [] (check_usage) from [] 
(check_irq_usage+0x58/0xb0)
[   42.142964] [] (check_irq_usage) from [] 
(__lock_acquire+0x1524/0x20b0)
[   42.151740] [] (__lock_acquire) from [] 
(lock_acquire+0x70/0x90)
[   42.159886] [] (lock_acquire) from [] 
(_raw_spin_lock_irqsave+0x40/0x54)
[   42.168768] [] (_raw_spin_lock_irqsave) from [] 
(arcnet_send_packet+0x60/0x1c0 [arcnet])
[   42.179115] [] (arcnet_send_packet [arcnet]) from [] 
(packet_direct_xmit+0x130/0x1c8)
[   42.189182] [] (packet_direct_xmit) from [] 
(packet_sendmsg+0x3b8/0x680)
[   42.198059] [] (packet_sendmsg) from [] 
(sock_sendmsg+0x14/0x24)
[   42.206199] [] (sock_sendmsg) from [] 
(SyS_sendto+0xb8/0xe0)
[   42.213978] [] (SyS_sendto) from [] (SyS_send+0x18/0x20)
[   42.221388] [] (SyS_send) from [] 
(ret_fast_syscall+0x0/0x1c)

Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/arcnet.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/arcnet/arcnet.c b/drivers/net/arcnet/arcnet.c
index 62ee439d58829..794faa8ee1d20 100644
--- a/drivers/net/arcnet/arcnet.c
+++ b/drivers/net/arcnet/arcnet.c
@@ -756,6 +756,7 @@ irqreturn_t arcnet_interrupt(int irq, void *dev_id)
struct net_device *dev = dev_id;
struct arcnet_local *lp;
int recbuf, status, diagstatus, didsomething, boguscount;
+   unsigned long flags = 0;
int retval = IRQ_NONE;
 
arc_printk(D_DURING, dev, "\n");
@@ -765,7 +766,7 @@ irqreturn_t arcnet_interrupt(int irq, void *dev_id)
lp = netdev_priv(dev);
BUG_ON(!lp);
 
-   spin_lock(>lock);
+   spin_lock_irqsave(>lock, flags);
 
 

[GIT PULL] arcnet: fixes and features

2017-06-22 Thread Michael Grzeschik
The following changes since commit 3d09198243b89457649241fb63f809a96a22a8ce:

  Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net (2017-06-21 
17:35:22 -0400)

are available in the git repository at:

  pub...@git.pengutronix.de:/mgr/linux.git tags/arcnet-for-mainline

for you to fetch changes up to 496890c2c34787290adaa50e204293d4fc4c98fc:

  arcnet: com20020-pci: add support for PCIFB2 card (2017-06-22 17:21:16 +0200)


arcnet: fixes and features


Michael Grzeschik (8):
  arcnet: change irq handler to lock irqsave
  arcnet: add err_skb package for package status feedback
  arcnet: com20020: remove needless base_addr assignment
  arcnet: com20020-pci: add missing pdev setup in netdev structure
  arcnet: com20020-pci: fix dev_id calculation
  arcnet: com20020-pci: add attribute to readback backplane status
  arcnet: com20020-pci: handle backplane mode depending on card type
  arcnet: com20020-pci: add support for PCIFB2 card

 drivers/net/arcnet/arcdevice.h|  4 
 drivers/net/arcnet/arcnet.c   | 81 
-
 drivers/net/arcnet/com20020-pci.c | 64 
++--
 drivers/net/arcnet/com20020.c |  2 --
 4 files changed, 134 insertions(+), 17 deletions(-)

-- 
2.11.0



[PATCH 2/8] arcnet: add err_skb package for package status feedback

2017-06-22 Thread Michael Grzeschik
We need to track the status of our queued packages. This way the driving
process knows if failed packages need to be retransmitted. For this
purpose we queue the transferred/failed packages back into the err_skb
message queue added with some status information.

Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/arcdevice.h |  4 +++
 drivers/net/arcnet/arcnet.c| 74 --
 2 files changed, 68 insertions(+), 10 deletions(-)

diff --git a/drivers/net/arcnet/arcdevice.h b/drivers/net/arcnet/arcdevice.h
index 20bfb9ba83ea2..cbb4f8566bbe5 100644
--- a/drivers/net/arcnet/arcdevice.h
+++ b/drivers/net/arcnet/arcdevice.h
@@ -269,6 +269,10 @@ struct arcnet_local {
 
struct timer_list   timer;
 
+   struct net_device *dev;
+   int reply_status;
+   struct tasklet_struct reply_tasklet;
+
/*
 * Buffer management: an ARCnet card has 4 x 512-byte buffers, each of
 * which can be used for either sending or receiving.  The new dynamic
diff --git a/drivers/net/arcnet/arcnet.c b/drivers/net/arcnet/arcnet.c
index 794faa8ee1d20..1197c0c1bd6ae 100644
--- a/drivers/net/arcnet/arcnet.c
+++ b/drivers/net/arcnet/arcnet.c
@@ -51,6 +51,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -391,6 +392,52 @@ static void arcnet_timer(unsigned long data)
}
 }
 
+static void arcnet_reply_tasklet(unsigned long data)
+{
+   struct arcnet_local *lp = (struct arcnet_local *)data;
+
+   struct sk_buff *ackskb, *skb;
+   struct sock_exterr_skb *serr;
+   struct sock *sk;
+   int ret;
+
+   local_irq_disable();
+   skb = lp->outgoing.skb;
+   if (!skb || !skb->sk) {
+   local_irq_enable();
+   return;
+   }
+
+   sock_hold(skb->sk);
+   sk = skb->sk;
+   ackskb = skb_clone_sk(skb);
+   sock_put(skb->sk);
+
+   if (!ackskb) {
+   local_irq_enable();
+   return;
+   }
+
+   serr = SKB_EXT_ERR(ackskb);
+   memset(serr, 0, sizeof(*serr));
+   serr->ee.ee_errno = ENOMSG;
+   serr->ee.ee_origin = SO_EE_ORIGIN_TXSTATUS;
+   serr->ee.ee_data = skb_shinfo(skb)->tskey;
+   serr->ee.ee_info = lp->reply_status;
+
+   /* finally erasing outgoing skb */
+   dev_kfree_skb(lp->outgoing.skb);
+   lp->outgoing.skb = NULL;
+
+   ackskb->dev = lp->dev;
+
+   ret = sock_queue_err_skb(sk, ackskb);
+   if (ret)
+   kfree_skb(ackskb);
+
+   local_irq_enable();
+};
+
 struct net_device *alloc_arcdev(const char *name)
 {
struct net_device *dev;
@@ -401,6 +448,7 @@ struct net_device *alloc_arcdev(const char *name)
if (dev) {
struct arcnet_local *lp = netdev_priv(dev);
 
+   lp->dev = dev;
spin_lock_init(>lock);
init_timer(>timer);
lp->timer.data = (unsigned long) dev;
@@ -436,6 +484,9 @@ int arcnet_open(struct net_device *dev)
arc_cont(D_PROTO, "\n");
}
 
+   tasklet_init(>reply_tasklet, arcnet_reply_tasklet,
+(unsigned long)lp);
+
arc_printk(D_INIT, dev, "arcnet_open: resetting card.\n");
 
/* try to put the card in a defined state - if it fails the first
@@ -527,6 +578,8 @@ int arcnet_close(struct net_device *dev)
netif_stop_queue(dev);
netif_carrier_off(dev);
 
+   tasklet_kill(>reply_tasklet);
+
/* flush TX and disable RX */
lp->hw.intmask(dev, 0);
lp->hw.command(dev, NOTXcmd);   /* stop transmit */
@@ -635,13 +688,13 @@ netdev_tx_t arcnet_send_packet(struct sk_buff *skb,
txbuf = -1;
 
if (txbuf != -1) {
+   lp->outgoing.skb = skb;
if (proto->prepare_tx(dev, pkt, skb->len, txbuf) &&
!proto->ack_tx) {
/* done right away and we don't want to acknowledge
 *  the package later - forget about it now
 */
dev->stats.tx_bytes += skb->len;
-   dev_kfree_skb(skb);
} else {
/* do it the 'split' way */
lp->outgoing.proto = proto;
@@ -843,8 +896,16 @@ irqreturn_t arcnet_interrupt(int irq, void *dev_id)
 
/* a transmit finished, and we're interested in it. */
if ((status & lp->intmask & TXFREEflag) || lp->timed_out) {
+   int ackstatus;
lp->intmask &= ~(TXFREEflag | EXCNAKflag);
 
+   if (status & TXACKflag)
+   ackstatus = 2;
+   else if (lp->excnak_pending)
+   ackstatus =

[PATCH 6/8] arcnet: com20020-pci: add attribute to readback backplane status

2017-06-22 Thread Michael Grzeschik
We add the sysfs interface the read back the backplane
status of the interface.

Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/com20020-pci.c | 22 ++
 1 file changed, 22 insertions(+)

diff --git a/drivers/net/arcnet/com20020-pci.c 
b/drivers/net/arcnet/com20020-pci.c
index 47f80b83dcf42..3f85a4d5f8c90 100644
--- a/drivers/net/arcnet/com20020-pci.c
+++ b/drivers/net/arcnet/com20020-pci.c
@@ -93,6 +93,27 @@ static void led_recon_set(struct led_classdev *led_cdev,
outb(!!value, priv->misc + ci->leds[card->index].red);
 }
 
+static ssize_t backplane_mode_show(struct device *dev,
+  struct device_attribute *attr,
+  char *buf)
+{
+   struct net_device *net_dev = to_net_dev(dev);
+   struct arcnet_local *lp = netdev_priv(net_dev);
+
+   return sprintf(buf, "%s\n", lp->backplane ? "true" : "false");
+}
+static DEVICE_ATTR_RO(backplane_mode);
+
+static struct attribute *com20020_state_attrs[] = {
+   _attr_backplane_mode.attr,
+   NULL,
+};
+
+static struct attribute_group com20020_state_group = {
+   .name = NULL,
+   .attrs = com20020_state_attrs,
+};
+
 static void com20020pci_remove(struct pci_dev *pdev);
 
 static int com20020pci_probe(struct pci_dev *pdev,
@@ -170,6 +191,7 @@ static int com20020pci_probe(struct pci_dev *pdev,
SET_NETDEV_DEV(dev, >dev);
dev->base_addr = ioaddr;
dev->dev_addr[0] = node;
+   dev->sysfs_groups[0] = _state_group;
dev->irq = pdev->irq;
lp->card_name = "PCI COM20020";
lp->card_flags = ci->flags;
-- 
2.11.0



Re: [PATCH] net: macb: add fixed-link node support

2017-06-20 Thread Michael Grzeschik
Hi Nicolas,

On Mon, Jun 19, 2017 at 12:54:10PM +0200, Nicolas Ferre wrote:
> Le 16/06/2017 à 10:55, Michael Grzeschik a écrit :
> > In case the MACB is directly connected to a
> > non-mdio PHY/device, it should be possible to provide
> > a fixed link configuration in the DT.
> > 
> > Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
> > ---

I just found a similar patch from Moritz Fischer today:

Would you prefer to take his instead?

http://www.spinics.net/lists/kernel/msg2205491.html

Thanks for the review!
Michael


-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |


[PATCH] net: macb: add fixed-link node support

2017-06-16 Thread Michael Grzeschik
In case the MACB is directly connected to a
non-mdio PHY/device, it should be possible to provide
a fixed link configuration in the DT.

Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/ethernet/cadence/macb.c | 21 +
 drivers/net/ethernet/cadence/macb.h |  2 +-
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/cadence/macb.c 
b/drivers/net/ethernet/cadence/macb.c
index 91f7492623d3f..91e36efe1d5fb 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -425,6 +425,16 @@ static int macb_mii_probe(struct net_device *dev)
int phy_irq;
int ret;
 
+   if (bp->phy_node) {
+   phydev = of_phy_connect(dev, bp->phy_node,
+   _handle_link_change, 0,
+   bp->phy_interface);
+   if (!phydev)
+   return -ENODEV;
+
+   return 0;
+   }
+
phydev = phy_find_first(bp->mii_bus);
if (!phydev) {
netdev_err(dev, "no PHY found\n");
@@ -498,6 +508,17 @@ static int macb_mii_init(struct macb *bp)
dev_set_drvdata(>dev->dev, bp->mii_bus);
 
np = bp->pdev->dev.of_node;
+   if (of_phy_is_fixed_link(np)) {
+   if (of_phy_register_fixed_link(np) < 0) {
+   dev_err(>pdev->dev,
+   "broken fixed-link specification\n");
+   goto err_out_unregister_bus;
+   }
+   bp->phy_node = of_node_get(np);
+
+   np = NULL;
+   }
+
if (np) {
/* try dt phy registration */
err = of_mdiobus_register(bp->mii_bus, np);
diff --git a/drivers/net/ethernet/cadence/macb.h 
b/drivers/net/ethernet/cadence/macb.h
index ec037b0fa2a4d..7efc726e0a113 100644
--- a/drivers/net/ethernet/cadence/macb.h
+++ b/drivers/net/ethernet/cadence/macb.h
@@ -928,7 +928,7 @@ struct macb {
dma_addr_t  rx_buffers_dma;
 
struct macb_or_gem_ops  macbgem_ops;
-
+   struct device_node  *phy_node;
struct mii_bus  *mii_bus;
int link;
int speed;
-- 
2.11.0



Re: [PATCH 2/5] arcnet: com90xx: add __init attribute

2016-04-19 Thread Michael Grzeschik
On Mon, Apr 18, 2016 at 04:55:35PM +0200, Julia Lawall wrote:
> Add __init attribute on a function that is only called from other __init
> functions and that is not inlined, at least with gcc version 4.8.4 on an
> x86 machine with allyesconfig.  Currently, the function is put in the
> .text.unlikely segment.  Declaring it as __init will cause it to be put in
> the .init.text and to disappear after initialization.
> 
> The result of objdump -x on the function before the change is as follows:
> 
>  l F .text.unlikely 00bf check_mirror
> 
> And after the change it is as follows:
> 
>  l F .init.text   00ba check_mirror
> 
> Done with the help of Coccinelle.  The semantic patch checks for local
> static non-init functions that are called from an __init function and are
> not called from any other function.
> 
> Signed-off-by: Julia Lawall <julia.law...@lip6.fr>
> 

Acked-by: Michael Grzeschik <m...@pengutronix.de>

> ---
>  drivers/net/arcnet/com90xx.c |2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/arcnet/com90xx.c b/drivers/net/arcnet/com90xx.c
> index 0d9b45f..81f90c4 100644
> --- a/drivers/net/arcnet/com90xx.c
> +++ b/drivers/net/arcnet/com90xx.c
> @@ -433,7 +433,7 @@ static void __init com90xx_probe(void)
>   kfree(iomem);
>  }
>  
> -static int check_mirror(unsigned long addr, size_t size)
> +static int __init check_mirror(unsigned long addr, size_t size)
>  {
>   void __iomem *p;
>   int res = -1;
> 
> 

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |


[PATCH v3] can: c_can: add xceiver enable/disable support

2016-01-21 Thread Michael Grzeschik
This patch adds support to enable and disable the xceiver
in case it's switchable by the regulator framework.

Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
v1 -> v2:
 - always returning PTR_ERR in case devm_regulator_get fails
 - removed inline wrapper functions with checks for xceiver == NULL
v2 -> v3:
 - adding documentation for the devicetree binding (already generic)

 Documentation/devicetree/bindings/net/can/c_can.txt |  2 ++
 drivers/net/can/c_can/c_can.c   | 12 
 drivers/net/can/c_can/c_can.h   |  1 +
 3 files changed, 15 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/can/c_can.txt 
b/Documentation/devicetree/bindings/net/can/c_can.txt
index 5a1d8b0..a36fea2 100644
--- a/Documentation/devicetree/bindings/net/can/c_can.txt
+++ b/Documentation/devicetree/bindings/net/can/c_can.txt
@@ -18,6 +18,8 @@ Optional properties:
  RAMINIT register, register offset to the RAMINIT
  register and the CAN instance number (0 offset).
 
+- xceiver-supply: Regulator that powers the CAN transceiver
+
 Note: "ti,hwmods" field is used to fetch the base address and irq
 resources from TI, omap hwmod data base during device registration.
 Future plan is to migrate hwmod data base contents into device tree
diff --git a/drivers/net/can/c_can/c_can.c b/drivers/net/can/c_can/c_can.c
index f91b094..0723aeb 100644
--- a/drivers/net/can/c_can/c_can.c
+++ b/drivers/net/can/c_can/c_can.c
@@ -36,6 +36,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -612,6 +613,10 @@ static int c_can_start(struct net_device *dev)
else
pinctrl_pm_select_default_state(priv->device);
 
+   err = regulator_enable(priv->reg_xceiver);
+   if (err)
+   return err;
+
return 0;
 }
 
@@ -626,6 +631,9 @@ static void c_can_stop(struct net_device *dev)
 
/* deactivate pins */
pinctrl_pm_select_sleep_state(dev->dev.parent);
+
+   regulator_disable(priv->reg_xceiver);
+
priv->can.state = CAN_STATE_STOPPED;
 }
 
@@ -1263,6 +1271,10 @@ int register_c_can_dev(struct net_device *dev)
 */
pinctrl_pm_select_sleep_state(dev->dev.parent);
 
+   priv->reg_xceiver = devm_regulator_get(priv->device, "xceiver");
+   if (IS_ERR(priv->reg_xceiver))
+   return PTR_ERR(priv->reg_xceiver);
+
c_can_pm_runtime_enable(priv);
 
dev->flags |= IFF_ECHO; /* we support local echo */
diff --git a/drivers/net/can/c_can/c_can.h b/drivers/net/can/c_can/c_can.h
index 8acdc7f..59246e3 100644
--- a/drivers/net/can/c_can/c_can.h
+++ b/drivers/net/can/c_can/c_can.h
@@ -213,6 +213,7 @@ struct c_can_priv {
u32 comm_rcv_high;
u32 rxmasked;
u32 dlc[C_CAN_MSG_OBJ_TX_NUM];
+   struct regulator *reg_xceiver;
 };
 
 struct net_device *alloc_c_can_dev(void);
-- 
2.7.0.rc3



Re: [PATCH v2] can: c_can: add xceiver enable/disable support

2016-01-20 Thread Michael Grzeschik
Hi,

On Wed, Jan 20, 2016 at 05:19:18PM +0100, Bjørn Mork wrote:
> Michael Grzeschik <m.grzesc...@pengutronix.de> writes:
> 
> > @@ -1263,6 +1271,10 @@ int register_c_can_dev(struct net_device *dev)
> >  */
> > pinctrl_pm_select_sleep_state(dev->dev.parent);
> >  
> > +   priv->reg_xceiver = devm_regulator_get(priv->device, "xceiver");
> > +   if (IS_ERR(priv->reg_xceiver))
> > +   return PTR_ERR(priv->reg_xceiver);
> > +
> > c_can_pm_runtime_enable(priv);
> >  
> > dev->flags |= IFF_ECHO; /* we support local echo */
> 
> Do you really want to leave priv->reg_xceiver pointing to an ERR_PTR in
> case of error?

No, therefore the priv->reg_xceiver will be returned in case of error.
This codepath is called once on device registration.

Michael

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |


[PATCHv2 net-next 2/6] arcnet: com20020: add enable and disable device on open/close

2015-10-26 Thread Michael Grzeschik
This patch changes the driver to properly work with the linux netif
interface. The controller gets enabled on open and disabled on close.
Therefor it removes every bogus start of the xceiver. It only gets
enabled on com20020_open and disabled on com20020_close.

Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
v1 -> v2: kbuild test robot: declared com20020_netdev_{open,close} static

 drivers/net/arcnet/com20020.c | 39 +--
 1 file changed, 29 insertions(+), 10 deletions(-)

diff --git a/drivers/net/arcnet/com20020.c b/drivers/net/arcnet/com20020.c
index c82f323..13d9ad4 100644
--- a/drivers/net/arcnet/com20020.c
+++ b/drivers/net/arcnet/com20020.c
@@ -118,7 +118,7 @@ int com20020_check(struct net_device *dev)
arcnet_outb(STARTIOcmd, ioaddr, COM20020_REG_W_COMMAND);
}
 
-   lp->config = TXENcfg | (lp->timeout << 3) | (lp->backplane << 2) | 
SUB_NODE;
+   lp->config = (lp->timeout << 3) | (lp->backplane << 2) | SUB_NODE;
/* set node ID to 0x42 (but transmitter is disabled, so it's okay) */
arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
arcnet_outb(0x42, ioaddr, COM20020_REG_W_XREG);
@@ -131,11 +131,6 @@ int com20020_check(struct net_device *dev)
}
arc_printk(D_INIT_REASONS, dev, "status after reset: %X\n", status);
 
-   /* Enable TX */
-   lp->config |= TXENcfg;
-   arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
-   arcnet_outb(arcnet_inb(ioaddr, 8), ioaddr, COM20020_REG_W_XREG);
-
arcnet_outb(CFLAGScmd | RESETclear | CONFIGclear,
ioaddr, COM20020_REG_W_COMMAND);
status = arcnet_inb(ioaddr, COM20020_REG_R_STATUS);
@@ -169,9 +164,33 @@ static int com20020_set_hwaddr(struct net_device *dev, 
void *addr)
return 0;
 }
 
+static int com20020_netdev_open(struct net_device *dev)
+{
+   int ioaddr = dev->base_addr;
+   struct arcnet_local *lp = netdev_priv(dev);
+
+   lp->config |= TXENcfg;
+   arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
+
+   return arcnet_open(dev);
+}
+
+static int com20020_netdev_close(struct net_device *dev)
+{
+   int ioaddr = dev->base_addr;
+   struct arcnet_local *lp = netdev_priv(dev);
+
+   arcnet_close(dev);
+
+   /* disable transmitter */
+   lp->config &= ~TXENcfg;
+   arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
+   return 0;
+}
+
 const struct net_device_ops com20020_netdev_ops = {
-   .ndo_open   = arcnet_open,
-   .ndo_stop   = arcnet_close,
+   .ndo_open   = com20020_netdev_open,
+   .ndo_stop   = com20020_netdev_close,
.ndo_start_xmit = arcnet_send_packet,
.ndo_tx_timeout = arcnet_timeout,
.ndo_set_mac_address = com20020_set_hwaddr,
@@ -215,7 +234,7 @@ int com20020_found(struct net_device *dev, int shared)
arcnet_outb(STARTIOcmd, ioaddr, COM20020_REG_W_COMMAND);
}
 
-   lp->config = TXENcfg | (lp->timeout << 3) | (lp->backplane << 2) | 
SUB_NODE;
+   lp->config = (lp->timeout << 3) | (lp->backplane << 2) | SUB_NODE;
/* Default 0x38 + register: Node ID */
arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
arcnet_outb(dev->dev_addr[0], ioaddr, COM20020_REG_W_XREG);
@@ -274,7 +293,7 @@ static int com20020_reset(struct net_device *dev, int 
really_reset)
   dev->name, arcnet_inb(ioaddr, COM20020_REG_R_STATUS));
 
arc_printk(D_DEBUG, dev, "%s: %d: %s\n", __FILE__, __LINE__, __func__);
-   lp->config = TXENcfg | (lp->timeout << 3) | (lp->backplane << 2);
+   lp->config |= (lp->timeout << 3) | (lp->backplane << 2);
/* power-up defaults */
arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
arc_printk(D_DEBUG, dev, "%s: %d: %s\n", __FILE__, __LINE__, __func__);
-- 
2.6.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv2 net-next 1/6] arcnet: move dev_free_skb to its only user

2015-10-26 Thread Michael Grzeschik
The call for dev_free_skb is done only once. This patch
moves its call to its only user and removes the obsolete
condition variable.

Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/arcnet.c | 10 ++
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/net/arcnet/arcnet.c b/drivers/net/arcnet/arcnet.c
index e41dd36..542e2b4 100644
--- a/drivers/net/arcnet/arcnet.c
+++ b/drivers/net/arcnet/arcnet.c
@@ -515,7 +515,7 @@ netdev_tx_t arcnet_send_packet(struct sk_buff *skb,
struct ArcProto *proto;
int txbuf;
unsigned long flags;
-   int freeskb, retval;
+   int retval;
 
arc_printk(D_DURING, dev,
   "transmit requested (status=%Xh, txbufs=%d/%d, len=%d, 
protocol %x)\n",
@@ -554,15 +554,13 @@ netdev_tx_t arcnet_send_packet(struct sk_buff *skb,
 *  the package later - forget about it now
 */
dev->stats.tx_bytes += skb->len;
-   freeskb = 1;
+   dev_kfree_skb(skb);
} else {
/* do it the 'split' way */
lp->outgoing.proto = proto;
lp->outgoing.skb = skb;
lp->outgoing.pkt = pkt;
 
-   freeskb = 0;
-
if (proto->continue_tx &&
proto->continue_tx(dev, txbuf)) {
arc_printk(D_NORMAL, dev,
@@ -574,7 +572,6 @@ netdev_tx_t arcnet_send_packet(struct sk_buff *skb,
lp->next_tx = txbuf;
} else {
retval = NETDEV_TX_BUSY;
-   freeskb = 0;
}
 
arc_printk(D_DEBUG, dev, "%s: %d: %s, status: %x\n",
@@ -589,9 +586,6 @@ netdev_tx_t arcnet_send_packet(struct sk_buff *skb,
   __FILE__, __LINE__, __func__, lp->hw.status(dev));
 
spin_unlock_irqrestore(>lock, flags);
-   if (freeskb)
-   dev_kfree_skb(skb);
-
return retval;  /* no need to try again */
 }
 EXPORT_SYMBOL(arcnet_send_packet);
-- 
2.6.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv2 net-next 4/6] arcnet: com20020-pci: add rotary index support

2015-10-26 Thread Michael Grzeschik
The EAE PLX-PCI card has a special rotary encoder
to configure the address of every card individually.
We take this information for the initial setup of
the cards dev_id.

Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
v1 -> v2: kbuild test robot: fixed type of misc variable to resource_size_t

 drivers/net/arcnet/com20020-pci.c | 33 +
 drivers/net/arcnet/com20020.h |  4 
 2 files changed, 37 insertions(+)

diff --git a/drivers/net/arcnet/com20020-pci.c 
b/drivers/net/arcnet/com20020-pci.c
index e3b7c14e..637a611 100644
--- a/drivers/net/arcnet/com20020-pci.c
+++ b/drivers/net/arcnet/com20020-pci.c
@@ -68,6 +68,7 @@ static int com20020pci_probe(struct pci_dev *pdev,
 const struct pci_device_id *id)
 {
struct com20020_pci_card_info *ci;
+   struct com20020_pci_channel_map *mm;
struct net_device *dev;
struct arcnet_local *lp;
struct com20020_priv *priv;
@@ -84,9 +85,22 @@ static int com20020pci_probe(struct pci_dev *pdev,
 
ci = (struct com20020_pci_card_info *)id->driver_data;
priv->ci = ci;
+   mm = >misc_map;
 
INIT_LIST_HEAD(>list_dev);
 
+   if (mm->size) {
+   ioaddr = pci_resource_start(pdev, mm->bar) + mm->offset;
+   r = devm_request_region(>dev, ioaddr, mm->size,
+   "com20020-pci");
+   if (!r) {
+   pr_err("IO region %xh-%xh already allocated.\n",
+  ioaddr, ioaddr + mm->size - 1);
+   return -EBUSY;
+   }
+   priv->misc = ioaddr;
+   }
+
for (i = 0; i < ci->devcount; i++) {
struct com20020_pci_channel_map *cm = >chan_map_tbl[i];
struct com20020_dev *card;
@@ -132,6 +146,13 @@ static int com20020pci_probe(struct pci_dev *pdev,
lp->timeout = timeout;
lp->hw.owner = THIS_MODULE;
 
+   /* Get the dev_id from the PLX rotary coder */
+   if (!strncmp(ci->name, "EAE PLX-PCI MA1", 15))
+   dev->dev_id = 0xc;
+   dev->dev_id ^= inb(priv->misc + ci->rotary) >> 4;
+
+   snprintf(dev->name, sizeof(dev->name), "arc%d-%d", dev->dev_id, 
i);
+
if (arcnet_inb(ioaddr, COM20020_REG_R_STATUS) == 0xFF) {
pr_err("IO address %Xh is empty!\n", ioaddr);
ret = -EIO;
@@ -235,6 +256,12 @@ static struct com20020_pci_card_info card_info_eae_arc1 = {
.size = 0x08,
},
},
+   .misc_map = {
+   .bar = 2,
+   .offset = 0x10,
+   .size = 0x04,
+   },
+   .rotary = 0x0,
.flags = ARC_CAN_10MBIT,
 };
 
@@ -252,6 +279,12 @@ static struct com20020_pci_card_info card_info_eae_ma1 = {
.size = 0x08,
}
},
+   .misc_map = {
+   .bar = 2,
+   .offset = 0x10,
+   .size = 0x04,
+   },
+   .rotary = 0x0,
.flags = ARC_CAN_10MBIT,
 };
 
diff --git a/drivers/net/arcnet/com20020.h b/drivers/net/arcnet/com20020.h
index 22a460f..f2ed2ef 100644
--- a/drivers/net/arcnet/com20020.h
+++ b/drivers/net/arcnet/com20020.h
@@ -47,6 +47,9 @@ struct com20020_pci_card_info {
int devcount;
 
struct com20020_pci_channel_map chan_map_tbl[PLX_PCI_MAX_CARDS];
+   struct com20020_pci_channel_map misc_map;
+
+   int rotary;
 
unsigned int flags;
 };
@@ -54,6 +57,7 @@ struct com20020_pci_card_info {
 struct com20020_priv {
struct com20020_pci_card_info *ci;
struct list_head list_dev;
+   resource_size_t misc;
 };
 
 struct com20020_dev {
-- 
2.6.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[GIT PULL v2] ARCNET: code simplification and features

2015-10-26 Thread Michael Grzeschik
The following changes since commit d1611c3aba11ffa281bdd027aace52f5a370b8c5:

  bnxt_en: Fix compile warnings when CONFIG_INET is not set. (2015-10-25 
22:36:15 -0700)

are available in the git repository at:

  git://git.pengutronix.de/git/mgr/linux.git tags/arcnet-for-4.4-rc1

for you to fetch changes up to 59fbcbc61e1f0fd9acdf3efb09faca0320049718:

  arcnet: add netif_carrier_on/off for reconnect (2015-10-26 09:10:56 +0100)


This series includes code simplifaction. The main changes are the correct
xceiver handling (enable/disable) of the com20020 cards. The driver now handles
link status change detection. The EAE PCI-ARCNET cards now make use of the
rotary encoded subdevice indexing and got support for led triggers on transmit
and reconnection events.


Michael Grzeschik (6):
  arcnet: move dev_free_skb to its only user
  arcnet: com20020: add enable and disable device on open/close
  arcnet: com20020-pci: set dev_port to the subdevice index
  arcnet: com20020-pci: add rotary index support
  arcnet: com20020-pci: add led trigger support
  arcnet: add netif_carrier_on/off for reconnect

 drivers/net/arcnet/arcdevice.h|  21 
 drivers/net/arcnet/arcnet.c   | 107 
+++
 drivers/net/arcnet/com20020-pci.c | 107 
+++
 drivers/net/arcnet/com20020.c |  39 ++--
 drivers/net/arcnet/com20020.h |  14 +
 include/linux/leds.h  |   7 +++
 6 files changed, 277 insertions(+), 18 deletions(-)

Michael Grzeschik (6):
  arcnet: move dev_free_skb to its only user
  arcnet: com20020: add enable and disable device on open/close
  arcnet: com20020-pci: set dev_port to the subdevice index
  arcnet: com20020-pci: add rotary index support
  arcnet: com20020-pci: add led trigger support
  arcnet: add netif_carrier_on/off for reconnect

 drivers/net/arcnet/arcdevice.h|  21 
 drivers/net/arcnet/arcnet.c   | 107 +++---
 drivers/net/arcnet/com20020-pci.c | 107 ++
 drivers/net/arcnet/com20020.c |  39 ++
 drivers/net/arcnet/com20020.h |  14 +
 include/linux/leds.h  |   7 +++
 6 files changed, 277 insertions(+), 18 deletions(-)

-- 
2.6.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv2 net-next 5/6] arcnet: com20020-pci: add led trigger support

2015-10-26 Thread Michael Grzeschik
The EAE PLX-PCI card has special leds on the the main io pci resource
bar. This patch adds support to trigger the conflict and data leds with
the packages.

Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
v1 -> v2: kbuild test robot: added dummy inline functions for 
led_trigger_blink{,_oneshot}

 drivers/net/arcnet/arcdevice.h| 19 ++
 drivers/net/arcnet/arcnet.c   | 72 ++
 drivers/net/arcnet/com20020-pci.c | 73 +++
 drivers/net/arcnet/com20020.h | 10 ++
 include/linux/leds.h  |  7 
 5 files changed, 181 insertions(+)

diff --git a/drivers/net/arcnet/arcdevice.h b/drivers/net/arcnet/arcdevice.h
index d7fdea1..2edc0c0 100644
--- a/drivers/net/arcnet/arcdevice.h
+++ b/drivers/net/arcnet/arcdevice.h
@@ -237,6 +237,8 @@ struct Outgoing {
numsegs;/* number of segments */
 };
 
+#define ARCNET_LED_NAME_SZ (IFNAMSIZ + 6)
+
 struct arcnet_local {
uint8_t config, /* current value of CONFIG register */
timeout,/* Extended timeout for COM20020 */
@@ -260,6 +262,11 @@ struct arcnet_local {
/* On preemtive and SMB a lock is needed */
spinlock_t lock;
 
+   struct led_trigger *tx_led_trig;
+   char tx_led_trig_name[ARCNET_LED_NAME_SZ];
+   struct led_trigger *recon_led_trig;
+   char recon_led_trig_name[ARCNET_LED_NAME_SZ];
+
/*
 * Buffer management: an ARCnet card has 4 x 512-byte buffers, each of
 * which can be used for either sending or receiving.  The new dynamic
@@ -309,6 +316,8 @@ struct arcnet_local {
int (*reset)(struct net_device *dev, int really_reset);
void (*open)(struct net_device *dev);
void (*close)(struct net_device *dev);
+   void (*datatrigger) (struct net_device * dev, int enable);
+   void (*recontrigger) (struct net_device * dev, int enable);
 
void (*copy_to_card)(struct net_device *dev, int bufnum,
 int offset, void *buf, int count);
@@ -319,6 +328,16 @@ struct arcnet_local {
void __iomem *mem_start;/* pointer to ioremap'ed MMIO */
 };
 
+enum arcnet_led_event {
+   ARCNET_LED_EVENT_RECON,
+   ARCNET_LED_EVENT_OPEN,
+   ARCNET_LED_EVENT_STOP,
+   ARCNET_LED_EVENT_TX,
+};
+
+void arcnet_led_event(struct net_device *netdev, enum arcnet_led_event event);
+void devm_arcnet_led_init(struct net_device *netdev, int index, int subid);
+
 #if ARCNET_DEBUG_MAX & D_SKB
 void arcnet_dump_skb(struct net_device *dev, struct sk_buff *skb, char *desc);
 #else
diff --git a/drivers/net/arcnet/arcnet.c b/drivers/net/arcnet/arcnet.c
index 542e2b4..4242522 100644
--- a/drivers/net/arcnet/arcnet.c
+++ b/drivers/net/arcnet/arcnet.c
@@ -52,6 +52,8 @@
 #include 
 #include 
 
+#include 
+
 #include "arcdevice.h"
 #include "com9026.h"
 
@@ -189,6 +191,71 @@ static void arcnet_dump_packet(struct net_device *dev, int 
bufnum,
 
 #endif
 
+/* Trigger a LED event in response to a ARCNET device event */
+void arcnet_led_event(struct net_device *dev, enum arcnet_led_event event)
+{
+   struct arcnet_local *lp = netdev_priv(dev);
+   unsigned long led_delay = 350;
+   unsigned long tx_delay = 50;
+
+   switch (event) {
+   case ARCNET_LED_EVENT_RECON:
+   led_trigger_blink_oneshot(lp->recon_led_trig,
+ _delay, _delay, 0);
+   break;
+   case ARCNET_LED_EVENT_OPEN:
+   led_trigger_event(lp->tx_led_trig, LED_OFF);
+   led_trigger_event(lp->recon_led_trig, LED_OFF);
+   break;
+   case ARCNET_LED_EVENT_STOP:
+   led_trigger_event(lp->tx_led_trig, LED_OFF);
+   led_trigger_event(lp->recon_led_trig, LED_OFF);
+   break;
+   case ARCNET_LED_EVENT_TX:
+   led_trigger_blink_oneshot(lp->tx_led_trig,
+ _delay, _delay, 0);
+   break;
+   }
+}
+EXPORT_SYMBOL_GPL(arcnet_led_event);
+
+static void arcnet_led_release(struct device *gendev, void *res)
+{
+   struct arcnet_local *lp = netdev_priv(to_net_dev(gendev));
+
+   led_trigger_unregister_simple(lp->tx_led_trig);
+   led_trigger_unregister_simple(lp->recon_led_trig);
+}
+
+/* Register ARCNET LED triggers for a arcnet device
+ *
+ * This is normally called from a driver's probe function
+ */
+void devm_arcnet_led_init(struct net_device *netdev, int index, int subid)
+{
+   struct arcnet_local *lp = netdev_priv(netdev);
+   void *res;
+
+   res = devres_alloc(arcnet_led_release, 0, GFP_KERNEL);
+   if (!res) {
+   netdev_err(netdev, "cannot register LED triggers\n");
+   return;
+   }
+
+   snprintf(lp->tx_led_trig_name, size

[PATCHv2 net-next 3/6] arcnet: com20020-pci: set dev_port to the subdevice index

2015-10-26 Thread Michael Grzeschik
This patch sets the dev_port according to the index of
the card. This can be used by udev to name the ports
in userspace.

Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/com20020-pci.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/arcnet/com20020-pci.c 
b/drivers/net/arcnet/com20020-pci.c
index a12bf83..e3b7c14e 100644
--- a/drivers/net/arcnet/com20020-pci.c
+++ b/drivers/net/arcnet/com20020-pci.c
@@ -96,6 +96,7 @@ static int com20020pci_probe(struct pci_dev *pdev,
ret = -ENOMEM;
goto out_port;
}
+   dev->dev_port = i;
 
dev->netdev_ops = _netdev_ops;
 
-- 
2.6.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv2 net-next 6/6] arcnet: add netif_carrier_on/off for reconnect

2015-10-26 Thread Michael Grzeschik
The arcnet device has no interrupt to detect if the link has changed
from disconnected to connected. This patch adds an timer to toggle the
link detection. The timer will get retriggered as long as the
reconnection interrupts accure. If the recon interrupts hold off
for >1s we define the connection stable again.

Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/arcdevice.h |  2 ++
 drivers/net/arcnet/arcnet.c| 25 +
 2 files changed, 27 insertions(+)

diff --git a/drivers/net/arcnet/arcdevice.h b/drivers/net/arcnet/arcdevice.h
index 2edc0c0..20bfb9b 100644
--- a/drivers/net/arcnet/arcdevice.h
+++ b/drivers/net/arcnet/arcdevice.h
@@ -267,6 +267,8 @@ struct arcnet_local {
struct led_trigger *recon_led_trig;
char recon_led_trig_name[ARCNET_LED_NAME_SZ];
 
+   struct timer_list   timer;
+
/*
 * Buffer management: an ARCnet card has 4 x 512-byte buffers, each of
 * which can be used for either sending or receiving.  The new dynamic
diff --git a/drivers/net/arcnet/arcnet.c b/drivers/net/arcnet/arcnet.c
index 4242522..6ea963e 100644
--- a/drivers/net/arcnet/arcnet.c
+++ b/drivers/net/arcnet/arcnet.c
@@ -381,6 +381,16 @@ static void arcdev_setup(struct net_device *dev)
dev->flags = IFF_BROADCAST;
 }
 
+static void arcnet_timer(unsigned long data)
+{
+   struct net_device *dev = (struct net_device *)data;
+
+   if (!netif_carrier_ok(dev)) {
+   netif_carrier_on(dev);
+   netdev_info(dev, "link up\n");
+   }
+}
+
 struct net_device *alloc_arcdev(const char *name)
 {
struct net_device *dev;
@@ -392,6 +402,9 @@ struct net_device *alloc_arcdev(const char *name)
struct arcnet_local *lp = netdev_priv(dev);
 
spin_lock_init(>lock);
+   init_timer(>timer);
+   lp->timer.data = (unsigned long) dev;
+   lp->timer.function = arcnet_timer;
}
 
return dev;
@@ -490,7 +503,9 @@ int arcnet_open(struct net_device *dev)
lp->hw.intmask(dev, lp->intmask);
arc_printk(D_DEBUG, dev, "%s: %d: %s\n", __FILE__, __LINE__, __func__);
 
+   netif_carrier_off(dev);
netif_start_queue(dev);
+   mod_timer(>timer, jiffies + msecs_to_jiffies(1000));
 
arcnet_led_event(dev, ARCNET_LED_EVENT_OPEN);
return 0;
@@ -507,7 +522,10 @@ int arcnet_close(struct net_device *dev)
struct arcnet_local *lp = netdev_priv(dev);
 
arcnet_led_event(dev, ARCNET_LED_EVENT_STOP);
+   del_timer_sync(>timer);
+
netif_stop_queue(dev);
+   netif_carrier_off(dev);
 
/* flush TX and disable RX */
lp->hw.intmask(dev, 0);
@@ -908,6 +926,12 @@ irqreturn_t arcnet_interrupt(int irq, void *dev_id)
 
arc_printk(D_RECON, dev, "Network reconfiguration 
detected (status=%Xh)\n",
   status);
+   if (netif_carrier_ok(dev)) {
+   netif_carrier_off(dev);
+   netdev_info(dev, "link down\n");
+   }
+   mod_timer(>timer, jiffies + msecs_to_jiffies(1000));
+
arcnet_led_event(dev, ARCNET_LED_EVENT_RECON);
/* MYRECON bit is at bit 7 of diagstatus */
if (diagstatus & 0x80)
@@ -959,6 +983,7 @@ irqreturn_t arcnet_interrupt(int irq, void *dev_id)
lp->num_recons = lp->network_down = 0;
 
arc_printk(D_DURING, dev, "not recon: clearing counters 
anyway.\n");
+   netif_carrier_on(dev);
}
 
if (didsomething)
-- 
2.6.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next 4/6] arcnet: com20020-pci: add rotary index support

2015-10-21 Thread Michael Grzeschik
The EAE PLX-PCI card has a special rotary encoder
to configure the address of every card individually.
We take this information for the initial setup of
the cards dev_id.

Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/com20020-pci.c | 33 +
 drivers/net/arcnet/com20020.h |  4 
 2 files changed, 37 insertions(+)

diff --git a/drivers/net/arcnet/com20020-pci.c 
b/drivers/net/arcnet/com20020-pci.c
index e3b7c14e..637a611 100644
--- a/drivers/net/arcnet/com20020-pci.c
+++ b/drivers/net/arcnet/com20020-pci.c
@@ -68,6 +68,7 @@ static int com20020pci_probe(struct pci_dev *pdev,
 const struct pci_device_id *id)
 {
struct com20020_pci_card_info *ci;
+   struct com20020_pci_channel_map *mm;
struct net_device *dev;
struct arcnet_local *lp;
struct com20020_priv *priv;
@@ -84,9 +85,22 @@ static int com20020pci_probe(struct pci_dev *pdev,
 
ci = (struct com20020_pci_card_info *)id->driver_data;
priv->ci = ci;
+   mm = >misc_map;
 
INIT_LIST_HEAD(>list_dev);
 
+   if (mm->size) {
+   ioaddr = pci_resource_start(pdev, mm->bar) + mm->offset;
+   r = devm_request_region(>dev, ioaddr, mm->size,
+   "com20020-pci");
+   if (!r) {
+   pr_err("IO region %xh-%xh already allocated.\n",
+  ioaddr, ioaddr + mm->size - 1);
+   return -EBUSY;
+   }
+   priv->misc = ioaddr;
+   }
+
for (i = 0; i < ci->devcount; i++) {
struct com20020_pci_channel_map *cm = >chan_map_tbl[i];
struct com20020_dev *card;
@@ -132,6 +146,13 @@ static int com20020pci_probe(struct pci_dev *pdev,
lp->timeout = timeout;
lp->hw.owner = THIS_MODULE;
 
+   /* Get the dev_id from the PLX rotary coder */
+   if (!strncmp(ci->name, "EAE PLX-PCI MA1", 15))
+   dev->dev_id = 0xc;
+   dev->dev_id ^= inb(priv->misc + ci->rotary) >> 4;
+
+   snprintf(dev->name, sizeof(dev->name), "arc%d-%d", dev->dev_id, 
i);
+
if (arcnet_inb(ioaddr, COM20020_REG_R_STATUS) == 0xFF) {
pr_err("IO address %Xh is empty!\n", ioaddr);
ret = -EIO;
@@ -235,6 +256,12 @@ static struct com20020_pci_card_info card_info_eae_arc1 = {
.size = 0x08,
},
},
+   .misc_map = {
+   .bar = 2,
+   .offset = 0x10,
+   .size = 0x04,
+   },
+   .rotary = 0x0,
.flags = ARC_CAN_10MBIT,
 };
 
@@ -252,6 +279,12 @@ static struct com20020_pci_card_info card_info_eae_ma1 = {
.size = 0x08,
}
},
+   .misc_map = {
+   .bar = 2,
+   .offset = 0x10,
+   .size = 0x04,
+   },
+   .rotary = 0x0,
.flags = ARC_CAN_10MBIT,
 };
 
diff --git a/drivers/net/arcnet/com20020.h b/drivers/net/arcnet/com20020.h
index 22a460f..4363b65 100644
--- a/drivers/net/arcnet/com20020.h
+++ b/drivers/net/arcnet/com20020.h
@@ -47,6 +47,9 @@ struct com20020_pci_card_info {
int devcount;
 
struct com20020_pci_channel_map chan_map_tbl[PLX_PCI_MAX_CARDS];
+   struct com20020_pci_channel_map misc_map;
+
+   int rotary;
 
unsigned int flags;
 };
@@ -54,6 +57,7 @@ struct com20020_pci_card_info {
 struct com20020_priv {
struct com20020_pci_card_info *ci;
struct list_head list_dev;
+   int __iomem misc;
 };
 
 struct com20020_dev {
-- 
2.6.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next 5/6] arcnet: com20020-pci: add led trigger support

2015-10-21 Thread Michael Grzeschik
The EAE PLX-PCI card has special leds on the the main io pci resource
bar. This patch adds support to trigger the conflict and data leds with
the packages.

Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/arcdevice.h| 19 ++
 drivers/net/arcnet/arcnet.c   | 72 ++
 drivers/net/arcnet/com20020-pci.c | 73 +++
 drivers/net/arcnet/com20020.h | 10 ++
 4 files changed, 174 insertions(+)

diff --git a/drivers/net/arcnet/arcdevice.h b/drivers/net/arcnet/arcdevice.h
index d7fdea1..2edc0c0 100644
--- a/drivers/net/arcnet/arcdevice.h
+++ b/drivers/net/arcnet/arcdevice.h
@@ -237,6 +237,8 @@ struct Outgoing {
numsegs;/* number of segments */
 };
 
+#define ARCNET_LED_NAME_SZ (IFNAMSIZ + 6)
+
 struct arcnet_local {
uint8_t config, /* current value of CONFIG register */
timeout,/* Extended timeout for COM20020 */
@@ -260,6 +262,11 @@ struct arcnet_local {
/* On preemtive and SMB a lock is needed */
spinlock_t lock;
 
+   struct led_trigger *tx_led_trig;
+   char tx_led_trig_name[ARCNET_LED_NAME_SZ];
+   struct led_trigger *recon_led_trig;
+   char recon_led_trig_name[ARCNET_LED_NAME_SZ];
+
/*
 * Buffer management: an ARCnet card has 4 x 512-byte buffers, each of
 * which can be used for either sending or receiving.  The new dynamic
@@ -309,6 +316,8 @@ struct arcnet_local {
int (*reset)(struct net_device *dev, int really_reset);
void (*open)(struct net_device *dev);
void (*close)(struct net_device *dev);
+   void (*datatrigger) (struct net_device * dev, int enable);
+   void (*recontrigger) (struct net_device * dev, int enable);
 
void (*copy_to_card)(struct net_device *dev, int bufnum,
 int offset, void *buf, int count);
@@ -319,6 +328,16 @@ struct arcnet_local {
void __iomem *mem_start;/* pointer to ioremap'ed MMIO */
 };
 
+enum arcnet_led_event {
+   ARCNET_LED_EVENT_RECON,
+   ARCNET_LED_EVENT_OPEN,
+   ARCNET_LED_EVENT_STOP,
+   ARCNET_LED_EVENT_TX,
+};
+
+void arcnet_led_event(struct net_device *netdev, enum arcnet_led_event event);
+void devm_arcnet_led_init(struct net_device *netdev, int index, int subid);
+
 #if ARCNET_DEBUG_MAX & D_SKB
 void arcnet_dump_skb(struct net_device *dev, struct sk_buff *skb, char *desc);
 #else
diff --git a/drivers/net/arcnet/arcnet.c b/drivers/net/arcnet/arcnet.c
index 542e2b4..4242522 100644
--- a/drivers/net/arcnet/arcnet.c
+++ b/drivers/net/arcnet/arcnet.c
@@ -52,6 +52,8 @@
 #include 
 #include 
 
+#include 
+
 #include "arcdevice.h"
 #include "com9026.h"
 
@@ -189,6 +191,71 @@ static void arcnet_dump_packet(struct net_device *dev, int 
bufnum,
 
 #endif
 
+/* Trigger a LED event in response to a ARCNET device event */
+void arcnet_led_event(struct net_device *dev, enum arcnet_led_event event)
+{
+   struct arcnet_local *lp = netdev_priv(dev);
+   unsigned long led_delay = 350;
+   unsigned long tx_delay = 50;
+
+   switch (event) {
+   case ARCNET_LED_EVENT_RECON:
+   led_trigger_blink_oneshot(lp->recon_led_trig,
+ _delay, _delay, 0);
+   break;
+   case ARCNET_LED_EVENT_OPEN:
+   led_trigger_event(lp->tx_led_trig, LED_OFF);
+   led_trigger_event(lp->recon_led_trig, LED_OFF);
+   break;
+   case ARCNET_LED_EVENT_STOP:
+   led_trigger_event(lp->tx_led_trig, LED_OFF);
+   led_trigger_event(lp->recon_led_trig, LED_OFF);
+   break;
+   case ARCNET_LED_EVENT_TX:
+   led_trigger_blink_oneshot(lp->tx_led_trig,
+ _delay, _delay, 0);
+   break;
+   }
+}
+EXPORT_SYMBOL_GPL(arcnet_led_event);
+
+static void arcnet_led_release(struct device *gendev, void *res)
+{
+   struct arcnet_local *lp = netdev_priv(to_net_dev(gendev));
+
+   led_trigger_unregister_simple(lp->tx_led_trig);
+   led_trigger_unregister_simple(lp->recon_led_trig);
+}
+
+/* Register ARCNET LED triggers for a arcnet device
+ *
+ * This is normally called from a driver's probe function
+ */
+void devm_arcnet_led_init(struct net_device *netdev, int index, int subid)
+{
+   struct arcnet_local *lp = netdev_priv(netdev);
+   void *res;
+
+   res = devres_alloc(arcnet_led_release, 0, GFP_KERNEL);
+   if (!res) {
+   netdev_err(netdev, "cannot register LED triggers\n");
+   return;
+   }
+
+   snprintf(lp->tx_led_trig_name, sizeof(lp->tx_led_trig_name),
+"arc%d-%d-tx", index, subid);
+   snprintf(lp->recon_led_trig_nam

[PATCH net-next 3/6] arcnet: com20020-pci: set dev_port to the subdevice index

2015-10-21 Thread Michael Grzeschik
This patch sets the dev_port according to the index of
the card. This can be used by udev to name the ports
in userspace.

Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/com20020-pci.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/arcnet/com20020-pci.c 
b/drivers/net/arcnet/com20020-pci.c
index a12bf83..e3b7c14e 100644
--- a/drivers/net/arcnet/com20020-pci.c
+++ b/drivers/net/arcnet/com20020-pci.c
@@ -96,6 +96,7 @@ static int com20020pci_probe(struct pci_dev *pdev,
ret = -ENOMEM;
goto out_port;
}
+   dev->dev_port = i;
 
dev->netdev_ops = _netdev_ops;
 
-- 
2.6.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next 6/6] arcnet: add netif_carrier_on/off for reconnect

2015-10-21 Thread Michael Grzeschik
The arcnet device has no interrupt to detect if the link has changed
from disconnected to connected. This patch adds an timer to toggle the
link detection. The timer will get retriggered as long as the
reconnection interrupts accure. If the recon interrupts hold off
for >1s we define the connection stable again.

Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/arcdevice.h |  2 ++
 drivers/net/arcnet/arcnet.c| 25 +
 2 files changed, 27 insertions(+)

diff --git a/drivers/net/arcnet/arcdevice.h b/drivers/net/arcnet/arcdevice.h
index 2edc0c0..20bfb9b 100644
--- a/drivers/net/arcnet/arcdevice.h
+++ b/drivers/net/arcnet/arcdevice.h
@@ -267,6 +267,8 @@ struct arcnet_local {
struct led_trigger *recon_led_trig;
char recon_led_trig_name[ARCNET_LED_NAME_SZ];
 
+   struct timer_list   timer;
+
/*
 * Buffer management: an ARCnet card has 4 x 512-byte buffers, each of
 * which can be used for either sending or receiving.  The new dynamic
diff --git a/drivers/net/arcnet/arcnet.c b/drivers/net/arcnet/arcnet.c
index 4242522..6ea963e 100644
--- a/drivers/net/arcnet/arcnet.c
+++ b/drivers/net/arcnet/arcnet.c
@@ -381,6 +381,16 @@ static void arcdev_setup(struct net_device *dev)
dev->flags = IFF_BROADCAST;
 }
 
+static void arcnet_timer(unsigned long data)
+{
+   struct net_device *dev = (struct net_device *)data;
+
+   if (!netif_carrier_ok(dev)) {
+   netif_carrier_on(dev);
+   netdev_info(dev, "link up\n");
+   }
+}
+
 struct net_device *alloc_arcdev(const char *name)
 {
struct net_device *dev;
@@ -392,6 +402,9 @@ struct net_device *alloc_arcdev(const char *name)
struct arcnet_local *lp = netdev_priv(dev);
 
spin_lock_init(>lock);
+   init_timer(>timer);
+   lp->timer.data = (unsigned long) dev;
+   lp->timer.function = arcnet_timer;
}
 
return dev;
@@ -490,7 +503,9 @@ int arcnet_open(struct net_device *dev)
lp->hw.intmask(dev, lp->intmask);
arc_printk(D_DEBUG, dev, "%s: %d: %s\n", __FILE__, __LINE__, __func__);
 
+   netif_carrier_off(dev);
netif_start_queue(dev);
+   mod_timer(>timer, jiffies + msecs_to_jiffies(1000));
 
arcnet_led_event(dev, ARCNET_LED_EVENT_OPEN);
return 0;
@@ -507,7 +522,10 @@ int arcnet_close(struct net_device *dev)
struct arcnet_local *lp = netdev_priv(dev);
 
arcnet_led_event(dev, ARCNET_LED_EVENT_STOP);
+   del_timer_sync(>timer);
+
netif_stop_queue(dev);
+   netif_carrier_off(dev);
 
/* flush TX and disable RX */
lp->hw.intmask(dev, 0);
@@ -908,6 +926,12 @@ irqreturn_t arcnet_interrupt(int irq, void *dev_id)
 
arc_printk(D_RECON, dev, "Network reconfiguration 
detected (status=%Xh)\n",
   status);
+   if (netif_carrier_ok(dev)) {
+   netif_carrier_off(dev);
+   netdev_info(dev, "link down\n");
+   }
+   mod_timer(>timer, jiffies + msecs_to_jiffies(1000));
+
arcnet_led_event(dev, ARCNET_LED_EVENT_RECON);
/* MYRECON bit is at bit 7 of diagstatus */
if (diagstatus & 0x80)
@@ -959,6 +983,7 @@ irqreturn_t arcnet_interrupt(int irq, void *dev_id)
lp->num_recons = lp->network_down = 0;
 
arc_printk(D_DURING, dev, "not recon: clearing counters 
anyway.\n");
+   netif_carrier_on(dev);
}
 
if (didsomething)
-- 
2.6.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next 2/6] arcnet: com20020: add enable and disable device on open/close

2015-10-21 Thread Michael Grzeschik
This patch changes the driver to properly work with the linux netif
interface. The controller gets enabled on open and disabled on close.
Therefor it removes every bogus start of the xceiver. It only gets
enabled on com20020_open and disabled on com20020_close.

Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/com20020.c | 39 +--
 1 file changed, 29 insertions(+), 10 deletions(-)

diff --git a/drivers/net/arcnet/com20020.c b/drivers/net/arcnet/com20020.c
index c82f323..436951b 100644
--- a/drivers/net/arcnet/com20020.c
+++ b/drivers/net/arcnet/com20020.c
@@ -118,7 +118,7 @@ int com20020_check(struct net_device *dev)
arcnet_outb(STARTIOcmd, ioaddr, COM20020_REG_W_COMMAND);
}
 
-   lp->config = TXENcfg | (lp->timeout << 3) | (lp->backplane << 2) | 
SUB_NODE;
+   lp->config = (lp->timeout << 3) | (lp->backplane << 2) | SUB_NODE;
/* set node ID to 0x42 (but transmitter is disabled, so it's okay) */
arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
arcnet_outb(0x42, ioaddr, COM20020_REG_W_XREG);
@@ -131,11 +131,6 @@ int com20020_check(struct net_device *dev)
}
arc_printk(D_INIT_REASONS, dev, "status after reset: %X\n", status);
 
-   /* Enable TX */
-   lp->config |= TXENcfg;
-   arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
-   arcnet_outb(arcnet_inb(ioaddr, 8), ioaddr, COM20020_REG_W_XREG);
-
arcnet_outb(CFLAGScmd | RESETclear | CONFIGclear,
ioaddr, COM20020_REG_W_COMMAND);
status = arcnet_inb(ioaddr, COM20020_REG_R_STATUS);
@@ -169,9 +164,33 @@ static int com20020_set_hwaddr(struct net_device *dev, 
void *addr)
return 0;
 }
 
+int com20020_netdev_open(struct net_device *dev)
+{
+   int ioaddr = dev->base_addr;
+   struct arcnet_local *lp = netdev_priv(dev);
+
+   lp->config |= TXENcfg;
+   arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
+
+   return arcnet_open(dev);
+}
+
+int com20020_netdev_close(struct net_device *dev)
+{
+   int ioaddr = dev->base_addr;
+   struct arcnet_local *lp = netdev_priv(dev);
+
+   arcnet_close(dev);
+
+   /* disable transmitter */
+   lp->config &= ~TXENcfg;
+   arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
+   return 0;
+}
+
 const struct net_device_ops com20020_netdev_ops = {
-   .ndo_open   = arcnet_open,
-   .ndo_stop   = arcnet_close,
+   .ndo_open   = com20020_netdev_open,
+   .ndo_stop   = com20020_netdev_close,
.ndo_start_xmit = arcnet_send_packet,
.ndo_tx_timeout = arcnet_timeout,
.ndo_set_mac_address = com20020_set_hwaddr,
@@ -215,7 +234,7 @@ int com20020_found(struct net_device *dev, int shared)
arcnet_outb(STARTIOcmd, ioaddr, COM20020_REG_W_COMMAND);
}
 
-   lp->config = TXENcfg | (lp->timeout << 3) | (lp->backplane << 2) | 
SUB_NODE;
+   lp->config = (lp->timeout << 3) | (lp->backplane << 2) | SUB_NODE;
/* Default 0x38 + register: Node ID */
arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
arcnet_outb(dev->dev_addr[0], ioaddr, COM20020_REG_W_XREG);
@@ -274,7 +293,7 @@ static int com20020_reset(struct net_device *dev, int 
really_reset)
   dev->name, arcnet_inb(ioaddr, COM20020_REG_R_STATUS));
 
arc_printk(D_DEBUG, dev, "%s: %d: %s\n", __FILE__, __LINE__, __func__);
-   lp->config = TXENcfg | (lp->timeout << 3) | (lp->backplane << 2);
+   lp->config |= (lp->timeout << 3) | (lp->backplane << 2);
/* power-up defaults */
arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
arc_printk(D_DEBUG, dev, "%s: %d: %s\n", __FILE__, __LINE__, __func__);
-- 
2.6.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[GIT PULL] ARCNET: code simplification and features

2015-10-21 Thread Michael Grzeschik
The following changes since commit 6ac311ae8bfb47de09f349e781e26373944d2ee3:
  
  Adding switchdev ageing notification on port bridged (2015-10-21 07:50:57 
-0700)

are available in the git repository at:
  
  ssh+git://git.pengutronix.de/git/mgr/linux.git tags/arcnet-for-4.4-rc1

for you to fetch changes up to d68c66a32f8176c27b9a395d07ba8a8e374f6111:
  
  arcnet: add netif_carrier_on/off for reconnect (2015-10-21 17:27:59 +0200)


This series includes code simplifaction. The main changes are the correct
xceiver handling (enable/disable) of the com20020 cards. The driver now handles
link status change detection. The EAE PCI-ARCNET cards now make use of the
rotary encoded subdevice indexing and got support for led triggers on transmit
and reconnection events.


Michael Grzeschik (6):
  arcnet: move dev_free_skb to its only user
  arcnet: com20020: add enable and disable device on open/close
  arcnet: com20020-pci: set dev_port to the subdevice index
  arcnet: com20020-pci: add rotary index support
  arcnet: com20020-pci: add led trigger support
  arcnet: add netif_carrier_on/off for reconnect
 
 drivers/net/arcnet/arcdevice.h|  21 
 drivers/net/arcnet/arcnet.c   | 107 
+++
 drivers/net/arcnet/com20020-pci.c | 107 
+++
 drivers/net/arcnet/com20020.c |  39 ++--
 drivers/net/arcnet/com20020.h |  14 +
 5 files changed, 270 insertions(+), 18 deletions(-)

Michael Grzeschik (6):
  arcnet: move dev_free_skb to its only user
  arcnet: com20020: add enable and disable device on open/close
  arcnet: com20020-pci: set dev_port to the subdevice index
  arcnet: com20020-pci: add rotary index support
  arcnet: com20020-pci: add led trigger support
  arcnet: add netif_carrier_on/off for reconnect

 drivers/net/arcnet/arcdevice.h|  21 
 drivers/net/arcnet/arcnet.c   | 107 +++---
 drivers/net/arcnet/com20020-pci.c | 107 ++
 drivers/net/arcnet/com20020.c |  39 ++
 drivers/net/arcnet/com20020.h |  14 +
 5 files changed, 270 insertions(+), 18 deletions(-)

-- 
2.6.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next 1/6] arcnet: move dev_free_skb to its only user

2015-10-21 Thread Michael Grzeschik
The call for dev_free_skb is done only once. This patch
moves its call to its only user and removes the obsolete
condition variable.

Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/arcnet.c | 10 ++
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/net/arcnet/arcnet.c b/drivers/net/arcnet/arcnet.c
index e41dd36..542e2b4 100644
--- a/drivers/net/arcnet/arcnet.c
+++ b/drivers/net/arcnet/arcnet.c
@@ -515,7 +515,7 @@ netdev_tx_t arcnet_send_packet(struct sk_buff *skb,
struct ArcProto *proto;
int txbuf;
unsigned long flags;
-   int freeskb, retval;
+   int retval;
 
arc_printk(D_DURING, dev,
   "transmit requested (status=%Xh, txbufs=%d/%d, len=%d, 
protocol %x)\n",
@@ -554,15 +554,13 @@ netdev_tx_t arcnet_send_packet(struct sk_buff *skb,
 *  the package later - forget about it now
 */
dev->stats.tx_bytes += skb->len;
-   freeskb = 1;
+   dev_kfree_skb(skb);
} else {
/* do it the 'split' way */
lp->outgoing.proto = proto;
lp->outgoing.skb = skb;
lp->outgoing.pkt = pkt;
 
-   freeskb = 0;
-
if (proto->continue_tx &&
proto->continue_tx(dev, txbuf)) {
arc_printk(D_NORMAL, dev,
@@ -574,7 +572,6 @@ netdev_tx_t arcnet_send_packet(struct sk_buff *skb,
lp->next_tx = txbuf;
} else {
retval = NETDEV_TX_BUSY;
-   freeskb = 0;
}
 
arc_printk(D_DEBUG, dev, "%s: %d: %s, status: %x\n",
@@ -589,9 +586,6 @@ netdev_tx_t arcnet_send_packet(struct sk_buff *skb,
   __FILE__, __LINE__, __func__, lp->hw.status(dev));
 
spin_unlock_irqrestore(>lock, flags);
-   if (freeskb)
-   dev_kfree_skb(skb);
-
return retval;  /* no need to try again */
 }
 EXPORT_SYMBOL(arcnet_send_packet);
-- 
2.6.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [GIT PULL] ARCNET: features and fixes

2015-10-19 Thread Michael Grzeschik
Hi David,

On Sun, Oct 18, 2015 at 08:19:42PM -0700, David Miller wrote:
> From: Michael Grzeschik <m.grzesc...@pengutronix.de>
> Date: Fri, 16 Oct 2015 13:00:54 +0200
> 
> > This series includes some small fixes. The main changes are the correct
> > xceiver handling (enable/disable) of the com20020 cards. The driver now 
> > handles
> > link status change detection. The EAE PCI-ARCNET cards now make use of the
> > rotary encoded subdevice indexing and got support for led triggers on 
> > transmit
> > and reconnection events.
> 
> If you mix features and bug fixes, then it's ambiguous which tree these
> changes should go into.
> 
> If it's just fixes, then it's clearly 'net',
> 
> But once you add feature changes and cleanups, then 'net' is not
> appropriate.
> 
> Please split this up properly and submit things targetting the
> correct GIT tree.

OK. You are right. Regarding this series I was a little bit imprecise
about the topic. Actually only the first patch is no fix but adds code
simplification. I forget that one in the last pull request. The other
four are all adding features. The whole series sits on top of net-next.

Sorry for the confusion. I hope this series can be applied as is.

Thanks,
Michael

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 6/6] arcnet: add netif_carrier_on/off for reconnect

2015-10-16 Thread Michael Grzeschik
The arcnet device has no interrupt to detect if the link has changed
from disconnected to connected. This patch adds an timer to toggle the
link detection. The timer will get retriggered as long as the
reconnection interrupts accure. If the recon interrupts hold off
for >1s we define the connection stable again.

Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/arcdevice.h |  2 ++
 drivers/net/arcnet/arcnet.c| 25 +
 2 files changed, 27 insertions(+)

diff --git a/drivers/net/arcnet/arcdevice.h b/drivers/net/arcnet/arcdevice.h
index 2edc0c0..20bfb9b 100644
--- a/drivers/net/arcnet/arcdevice.h
+++ b/drivers/net/arcnet/arcdevice.h
@@ -267,6 +267,8 @@ struct arcnet_local {
struct led_trigger *recon_led_trig;
char recon_led_trig_name[ARCNET_LED_NAME_SZ];
 
+   struct timer_list   timer;
+
/*
 * Buffer management: an ARCnet card has 4 x 512-byte buffers, each of
 * which can be used for either sending or receiving.  The new dynamic
diff --git a/drivers/net/arcnet/arcnet.c b/drivers/net/arcnet/arcnet.c
index 4242522..6ea963e 100644
--- a/drivers/net/arcnet/arcnet.c
+++ b/drivers/net/arcnet/arcnet.c
@@ -381,6 +381,16 @@ static void arcdev_setup(struct net_device *dev)
dev->flags = IFF_BROADCAST;
 }
 
+static void arcnet_timer(unsigned long data)
+{
+   struct net_device *dev = (struct net_device *)data;
+
+   if (!netif_carrier_ok(dev)) {
+   netif_carrier_on(dev);
+   netdev_info(dev, "link up\n");
+   }
+}
+
 struct net_device *alloc_arcdev(const char *name)
 {
struct net_device *dev;
@@ -392,6 +402,9 @@ struct net_device *alloc_arcdev(const char *name)
struct arcnet_local *lp = netdev_priv(dev);
 
spin_lock_init(>lock);
+   init_timer(>timer);
+   lp->timer.data = (unsigned long) dev;
+   lp->timer.function = arcnet_timer;
}
 
return dev;
@@ -490,7 +503,9 @@ int arcnet_open(struct net_device *dev)
lp->hw.intmask(dev, lp->intmask);
arc_printk(D_DEBUG, dev, "%s: %d: %s\n", __FILE__, __LINE__, __func__);
 
+   netif_carrier_off(dev);
netif_start_queue(dev);
+   mod_timer(>timer, jiffies + msecs_to_jiffies(1000));
 
arcnet_led_event(dev, ARCNET_LED_EVENT_OPEN);
return 0;
@@ -507,7 +522,10 @@ int arcnet_close(struct net_device *dev)
struct arcnet_local *lp = netdev_priv(dev);
 
arcnet_led_event(dev, ARCNET_LED_EVENT_STOP);
+   del_timer_sync(>timer);
+
netif_stop_queue(dev);
+   netif_carrier_off(dev);
 
/* flush TX and disable RX */
lp->hw.intmask(dev, 0);
@@ -908,6 +926,12 @@ irqreturn_t arcnet_interrupt(int irq, void *dev_id)
 
arc_printk(D_RECON, dev, "Network reconfiguration 
detected (status=%Xh)\n",
   status);
+   if (netif_carrier_ok(dev)) {
+   netif_carrier_off(dev);
+   netdev_info(dev, "link down\n");
+   }
+   mod_timer(>timer, jiffies + msecs_to_jiffies(1000));
+
arcnet_led_event(dev, ARCNET_LED_EVENT_RECON);
/* MYRECON bit is at bit 7 of diagstatus */
if (diagstatus & 0x80)
@@ -959,6 +983,7 @@ irqreturn_t arcnet_interrupt(int irq, void *dev_id)
lp->num_recons = lp->network_down = 0;
 
arc_printk(D_DURING, dev, "not recon: clearing counters 
anyway.\n");
+   netif_carrier_on(dev);
}
 
if (didsomething)
-- 
2.6.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/6] arcnet: com20020: add enable and disable device on open/close

2015-10-16 Thread Michael Grzeschik
This patch changes the driver to properly work with the linux netif
interface. The controller gets enabled on open and disabled on close.
Therefor it removes every bogus start of the xceiver. It only gets
enabled on com20020_open and disabled on com20020_close.

Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/com20020.c | 39 +--
 1 file changed, 29 insertions(+), 10 deletions(-)

diff --git a/drivers/net/arcnet/com20020.c b/drivers/net/arcnet/com20020.c
index c82f323..436951b 100644
--- a/drivers/net/arcnet/com20020.c
+++ b/drivers/net/arcnet/com20020.c
@@ -118,7 +118,7 @@ int com20020_check(struct net_device *dev)
arcnet_outb(STARTIOcmd, ioaddr, COM20020_REG_W_COMMAND);
}
 
-   lp->config = TXENcfg | (lp->timeout << 3) | (lp->backplane << 2) | 
SUB_NODE;
+   lp->config = (lp->timeout << 3) | (lp->backplane << 2) | SUB_NODE;
/* set node ID to 0x42 (but transmitter is disabled, so it's okay) */
arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
arcnet_outb(0x42, ioaddr, COM20020_REG_W_XREG);
@@ -131,11 +131,6 @@ int com20020_check(struct net_device *dev)
}
arc_printk(D_INIT_REASONS, dev, "status after reset: %X\n", status);
 
-   /* Enable TX */
-   lp->config |= TXENcfg;
-   arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
-   arcnet_outb(arcnet_inb(ioaddr, 8), ioaddr, COM20020_REG_W_XREG);
-
arcnet_outb(CFLAGScmd | RESETclear | CONFIGclear,
ioaddr, COM20020_REG_W_COMMAND);
status = arcnet_inb(ioaddr, COM20020_REG_R_STATUS);
@@ -169,9 +164,33 @@ static int com20020_set_hwaddr(struct net_device *dev, 
void *addr)
return 0;
 }
 
+int com20020_netdev_open(struct net_device *dev)
+{
+   int ioaddr = dev->base_addr;
+   struct arcnet_local *lp = netdev_priv(dev);
+
+   lp->config |= TXENcfg;
+   arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
+
+   return arcnet_open(dev);
+}
+
+int com20020_netdev_close(struct net_device *dev)
+{
+   int ioaddr = dev->base_addr;
+   struct arcnet_local *lp = netdev_priv(dev);
+
+   arcnet_close(dev);
+
+   /* disable transmitter */
+   lp->config &= ~TXENcfg;
+   arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
+   return 0;
+}
+
 const struct net_device_ops com20020_netdev_ops = {
-   .ndo_open   = arcnet_open,
-   .ndo_stop   = arcnet_close,
+   .ndo_open   = com20020_netdev_open,
+   .ndo_stop   = com20020_netdev_close,
.ndo_start_xmit = arcnet_send_packet,
.ndo_tx_timeout = arcnet_timeout,
.ndo_set_mac_address = com20020_set_hwaddr,
@@ -215,7 +234,7 @@ int com20020_found(struct net_device *dev, int shared)
arcnet_outb(STARTIOcmd, ioaddr, COM20020_REG_W_COMMAND);
}
 
-   lp->config = TXENcfg | (lp->timeout << 3) | (lp->backplane << 2) | 
SUB_NODE;
+   lp->config = (lp->timeout << 3) | (lp->backplane << 2) | SUB_NODE;
/* Default 0x38 + register: Node ID */
arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
arcnet_outb(dev->dev_addr[0], ioaddr, COM20020_REG_W_XREG);
@@ -274,7 +293,7 @@ static int com20020_reset(struct net_device *dev, int 
really_reset)
   dev->name, arcnet_inb(ioaddr, COM20020_REG_R_STATUS));
 
arc_printk(D_DEBUG, dev, "%s: %d: %s\n", __FILE__, __LINE__, __func__);
-   lp->config = TXENcfg | (lp->timeout << 3) | (lp->backplane << 2);
+   lp->config |= (lp->timeout << 3) | (lp->backplane << 2);
/* power-up defaults */
arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
arc_printk(D_DEBUG, dev, "%s: %d: %s\n", __FILE__, __LINE__, __func__);
-- 
2.6.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 5/6] arcnet: com20020-pci: add led trigger support

2015-10-16 Thread Michael Grzeschik
The EAE PLX-PCI card has special leds on the the main io pci resource
bar. This patch adds support to trigger the conflict and data leds with
the packages.

Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/arcdevice.h| 19 ++
 drivers/net/arcnet/arcnet.c   | 72 ++
 drivers/net/arcnet/com20020-pci.c | 73 +++
 drivers/net/arcnet/com20020.h | 10 ++
 4 files changed, 174 insertions(+)

diff --git a/drivers/net/arcnet/arcdevice.h b/drivers/net/arcnet/arcdevice.h
index d7fdea1..2edc0c0 100644
--- a/drivers/net/arcnet/arcdevice.h
+++ b/drivers/net/arcnet/arcdevice.h
@@ -237,6 +237,8 @@ struct Outgoing {
numsegs;/* number of segments */
 };
 
+#define ARCNET_LED_NAME_SZ (IFNAMSIZ + 6)
+
 struct arcnet_local {
uint8_t config, /* current value of CONFIG register */
timeout,/* Extended timeout for COM20020 */
@@ -260,6 +262,11 @@ struct arcnet_local {
/* On preemtive and SMB a lock is needed */
spinlock_t lock;
 
+   struct led_trigger *tx_led_trig;
+   char tx_led_trig_name[ARCNET_LED_NAME_SZ];
+   struct led_trigger *recon_led_trig;
+   char recon_led_trig_name[ARCNET_LED_NAME_SZ];
+
/*
 * Buffer management: an ARCnet card has 4 x 512-byte buffers, each of
 * which can be used for either sending or receiving.  The new dynamic
@@ -309,6 +316,8 @@ struct arcnet_local {
int (*reset)(struct net_device *dev, int really_reset);
void (*open)(struct net_device *dev);
void (*close)(struct net_device *dev);
+   void (*datatrigger) (struct net_device * dev, int enable);
+   void (*recontrigger) (struct net_device * dev, int enable);
 
void (*copy_to_card)(struct net_device *dev, int bufnum,
 int offset, void *buf, int count);
@@ -319,6 +328,16 @@ struct arcnet_local {
void __iomem *mem_start;/* pointer to ioremap'ed MMIO */
 };
 
+enum arcnet_led_event {
+   ARCNET_LED_EVENT_RECON,
+   ARCNET_LED_EVENT_OPEN,
+   ARCNET_LED_EVENT_STOP,
+   ARCNET_LED_EVENT_TX,
+};
+
+void arcnet_led_event(struct net_device *netdev, enum arcnet_led_event event);
+void devm_arcnet_led_init(struct net_device *netdev, int index, int subid);
+
 #if ARCNET_DEBUG_MAX & D_SKB
 void arcnet_dump_skb(struct net_device *dev, struct sk_buff *skb, char *desc);
 #else
diff --git a/drivers/net/arcnet/arcnet.c b/drivers/net/arcnet/arcnet.c
index 542e2b4..4242522 100644
--- a/drivers/net/arcnet/arcnet.c
+++ b/drivers/net/arcnet/arcnet.c
@@ -52,6 +52,8 @@
 #include 
 #include 
 
+#include 
+
 #include "arcdevice.h"
 #include "com9026.h"
 
@@ -189,6 +191,71 @@ static void arcnet_dump_packet(struct net_device *dev, int 
bufnum,
 
 #endif
 
+/* Trigger a LED event in response to a ARCNET device event */
+void arcnet_led_event(struct net_device *dev, enum arcnet_led_event event)
+{
+   struct arcnet_local *lp = netdev_priv(dev);
+   unsigned long led_delay = 350;
+   unsigned long tx_delay = 50;
+
+   switch (event) {
+   case ARCNET_LED_EVENT_RECON:
+   led_trigger_blink_oneshot(lp->recon_led_trig,
+ _delay, _delay, 0);
+   break;
+   case ARCNET_LED_EVENT_OPEN:
+   led_trigger_event(lp->tx_led_trig, LED_OFF);
+   led_trigger_event(lp->recon_led_trig, LED_OFF);
+   break;
+   case ARCNET_LED_EVENT_STOP:
+   led_trigger_event(lp->tx_led_trig, LED_OFF);
+   led_trigger_event(lp->recon_led_trig, LED_OFF);
+   break;
+   case ARCNET_LED_EVENT_TX:
+   led_trigger_blink_oneshot(lp->tx_led_trig,
+ _delay, _delay, 0);
+   break;
+   }
+}
+EXPORT_SYMBOL_GPL(arcnet_led_event);
+
+static void arcnet_led_release(struct device *gendev, void *res)
+{
+   struct arcnet_local *lp = netdev_priv(to_net_dev(gendev));
+
+   led_trigger_unregister_simple(lp->tx_led_trig);
+   led_trigger_unregister_simple(lp->recon_led_trig);
+}
+
+/* Register ARCNET LED triggers for a arcnet device
+ *
+ * This is normally called from a driver's probe function
+ */
+void devm_arcnet_led_init(struct net_device *netdev, int index, int subid)
+{
+   struct arcnet_local *lp = netdev_priv(netdev);
+   void *res;
+
+   res = devres_alloc(arcnet_led_release, 0, GFP_KERNEL);
+   if (!res) {
+   netdev_err(netdev, "cannot register LED triggers\n");
+   return;
+   }
+
+   snprintf(lp->tx_led_trig_name, sizeof(lp->tx_led_trig_name),
+"arc%d-%d-tx", index, subid);
+   snprintf(lp->recon_led_trig_nam

[PATCH 1/6] arcnet: move dev_free_skb to its only user

2015-10-16 Thread Michael Grzeschik
The call for dev_free_skb is done only once. This patch
moves its call to its only user and removes the obsolete
condition variable.

Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/arcnet.c | 10 ++
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/net/arcnet/arcnet.c b/drivers/net/arcnet/arcnet.c
index e41dd36..542e2b4 100644
--- a/drivers/net/arcnet/arcnet.c
+++ b/drivers/net/arcnet/arcnet.c
@@ -515,7 +515,7 @@ netdev_tx_t arcnet_send_packet(struct sk_buff *skb,
struct ArcProto *proto;
int txbuf;
unsigned long flags;
-   int freeskb, retval;
+   int retval;
 
arc_printk(D_DURING, dev,
   "transmit requested (status=%Xh, txbufs=%d/%d, len=%d, 
protocol %x)\n",
@@ -554,15 +554,13 @@ netdev_tx_t arcnet_send_packet(struct sk_buff *skb,
 *  the package later - forget about it now
 */
dev->stats.tx_bytes += skb->len;
-   freeskb = 1;
+   dev_kfree_skb(skb);
} else {
/* do it the 'split' way */
lp->outgoing.proto = proto;
lp->outgoing.skb = skb;
lp->outgoing.pkt = pkt;
 
-   freeskb = 0;
-
if (proto->continue_tx &&
proto->continue_tx(dev, txbuf)) {
arc_printk(D_NORMAL, dev,
@@ -574,7 +572,6 @@ netdev_tx_t arcnet_send_packet(struct sk_buff *skb,
lp->next_tx = txbuf;
} else {
retval = NETDEV_TX_BUSY;
-   freeskb = 0;
}
 
arc_printk(D_DEBUG, dev, "%s: %d: %s, status: %x\n",
@@ -589,9 +586,6 @@ netdev_tx_t arcnet_send_packet(struct sk_buff *skb,
   __FILE__, __LINE__, __func__, lp->hw.status(dev));
 
spin_unlock_irqrestore(>lock, flags);
-   if (freeskb)
-   dev_kfree_skb(skb);
-
return retval;  /* no need to try again */
 }
 EXPORT_SYMBOL(arcnet_send_packet);
-- 
2.6.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/6] arcnet: com20020-pci: add rotary index support

2015-10-16 Thread Michael Grzeschik
The EAE PLX-PCI card has a special rotary encoder
to configure the address of every card individually.
We take this information for the initial setup of
the cards dev_id.

Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/com20020-pci.c | 33 +
 drivers/net/arcnet/com20020.h |  4 
 2 files changed, 37 insertions(+)

diff --git a/drivers/net/arcnet/com20020-pci.c 
b/drivers/net/arcnet/com20020-pci.c
index e3b7c14e..637a611 100644
--- a/drivers/net/arcnet/com20020-pci.c
+++ b/drivers/net/arcnet/com20020-pci.c
@@ -68,6 +68,7 @@ static int com20020pci_probe(struct pci_dev *pdev,
 const struct pci_device_id *id)
 {
struct com20020_pci_card_info *ci;
+   struct com20020_pci_channel_map *mm;
struct net_device *dev;
struct arcnet_local *lp;
struct com20020_priv *priv;
@@ -84,9 +85,22 @@ static int com20020pci_probe(struct pci_dev *pdev,
 
ci = (struct com20020_pci_card_info *)id->driver_data;
priv->ci = ci;
+   mm = >misc_map;
 
INIT_LIST_HEAD(>list_dev);
 
+   if (mm->size) {
+   ioaddr = pci_resource_start(pdev, mm->bar) + mm->offset;
+   r = devm_request_region(>dev, ioaddr, mm->size,
+   "com20020-pci");
+   if (!r) {
+   pr_err("IO region %xh-%xh already allocated.\n",
+  ioaddr, ioaddr + mm->size - 1);
+   return -EBUSY;
+   }
+   priv->misc = ioaddr;
+   }
+
for (i = 0; i < ci->devcount; i++) {
struct com20020_pci_channel_map *cm = >chan_map_tbl[i];
struct com20020_dev *card;
@@ -132,6 +146,13 @@ static int com20020pci_probe(struct pci_dev *pdev,
lp->timeout = timeout;
lp->hw.owner = THIS_MODULE;
 
+   /* Get the dev_id from the PLX rotary coder */
+   if (!strncmp(ci->name, "EAE PLX-PCI MA1", 15))
+   dev->dev_id = 0xc;
+   dev->dev_id ^= inb(priv->misc + ci->rotary) >> 4;
+
+   snprintf(dev->name, sizeof(dev->name), "arc%d-%d", dev->dev_id, 
i);
+
if (arcnet_inb(ioaddr, COM20020_REG_R_STATUS) == 0xFF) {
pr_err("IO address %Xh is empty!\n", ioaddr);
ret = -EIO;
@@ -235,6 +256,12 @@ static struct com20020_pci_card_info card_info_eae_arc1 = {
.size = 0x08,
},
},
+   .misc_map = {
+   .bar = 2,
+   .offset = 0x10,
+   .size = 0x04,
+   },
+   .rotary = 0x0,
.flags = ARC_CAN_10MBIT,
 };
 
@@ -252,6 +279,12 @@ static struct com20020_pci_card_info card_info_eae_ma1 = {
.size = 0x08,
}
},
+   .misc_map = {
+   .bar = 2,
+   .offset = 0x10,
+   .size = 0x04,
+   },
+   .rotary = 0x0,
.flags = ARC_CAN_10MBIT,
 };
 
diff --git a/drivers/net/arcnet/com20020.h b/drivers/net/arcnet/com20020.h
index 22a460f..4363b65 100644
--- a/drivers/net/arcnet/com20020.h
+++ b/drivers/net/arcnet/com20020.h
@@ -47,6 +47,9 @@ struct com20020_pci_card_info {
int devcount;
 
struct com20020_pci_channel_map chan_map_tbl[PLX_PCI_MAX_CARDS];
+   struct com20020_pci_channel_map misc_map;
+
+   int rotary;
 
unsigned int flags;
 };
@@ -54,6 +57,7 @@ struct com20020_pci_card_info {
 struct com20020_priv {
struct com20020_pci_card_info *ci;
struct list_head list_dev;
+   int __iomem misc;
 };
 
 struct com20020_dev {
-- 
2.6.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[GIT PULL] ARCNET: features and fixes

2015-10-16 Thread Michael Grzeschik
The following changes since commit 51161aa98d0aa4eb20952e16d6c6dbb1d085330e:

  net: Fix suspicious RCU usage in fib_rebalance (2015-10-16 00:57:55 -0700)

are available in the git repository at:

  git://git.pengutronix.de/git/mgr/linux.git tags/arcnet-v4.3-rc5

for you to fetch changes up to 908baca22086a76c7afa6e883f9aafef05fe9a01:

  arcnet: add netif_carrier_on/off for reconnect (2015-10-16 12:53:57 +0200)


This series includes some small fixes. The main changes are the correct
xceiver handling (enable/disable) of the com20020 cards. The driver now handles
link status change detection. The EAE PCI-ARCNET cards now make use of the
rotary encoded subdevice indexing and got support for led triggers on transmit
and reconnection events.


Michael Grzeschik (6):
  arcnet: move dev_free_skb to its only user
  arcnet: com20020: add enable and disable device on open/close
  arcnet: com20020-pci: set dev_port to the subdevice index
  arcnet: com20020-pci: add rotary index support
  arcnet: com20020-pci: add led trigger support
  arcnet: add netif_carrier_on/off for reconnect

 drivers/net/arcnet/arcdevice.h|  21 
 drivers/net/arcnet/arcnet.c   | 107 
+++
 drivers/net/arcnet/com20020-pci.c | 107 
+++
 drivers/net/arcnet/com20020.c |  39 ++--
 drivers/net/arcnet/com20020.h |  14 +
 5 files changed, 270 insertions(+), 18 deletions(-)

Michael Grzeschik (6):
  arcnet: move dev_free_skb to its only user
  arcnet: com20020: add enable and disable device on open/close
  arcnet: com20020-pci: set dev_port to the subdevice index
  arcnet: com20020-pci: add rotary index support
  arcnet: com20020-pci: add led trigger support
  arcnet: add netif_carrier_on/off for reconnect

 drivers/net/arcnet/arcdevice.h|  21 
 drivers/net/arcnet/arcnet.c   | 107 +++---
 drivers/net/arcnet/com20020-pci.c | 107 ++
 drivers/net/arcnet/com20020.c |  39 ++
 drivers/net/arcnet/com20020.h |  14 +
 5 files changed, 270 insertions(+), 18 deletions(-)

-- 
2.6.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [GIT PULL] ARCNET: refactoring and cleanup

2015-09-23 Thread Michael Grzeschik
On Tue, Sep 22, 2015 at 05:25:03PM -0700, David Miller wrote:
> From: Michael Grzeschik <m.grzesc...@pengutronix.de>
> Date: Tue, 22 Sep 2015 11:01:41 +0200
> 
> >   git://git.pengutronix.de/git/mgr/linux.git tags/arcnet-cleanup-v4.3-rc2
> 
> Please build this tree against net-next, thanks.

Done that now. Shall I resend the pull?


-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 01/33] arcnet: fix indentation of if_arcnet.h

2015-09-22 Thread Michael Grzeschik
From: Joe Perches <j...@perches.com>

Standardized spacing is easier to read.

Signed-off-by: Joe Perches <j...@perches.com>
Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 include/uapi/linux/if_arcnet.h | 55 --
 1 file changed, 26 insertions(+), 29 deletions(-)

diff --git a/include/uapi/linux/if_arcnet.h b/include/uapi/linux/if_arcnet.h
index 46e34bd..cfb642f 100644
--- a/include/uapi/linux/if_arcnet.h
+++ b/include/uapi/linux/if_arcnet.h
@@ -19,7 +19,6 @@
 #include 
 #include 
 
-
 /*
  *These are the defined ARCnet Protocol ID's.
  */
@@ -57,42 +56,40 @@
  * The RFC1201-specific components of an arcnet packet header.
  */
 struct arc_rfc1201 {
-__u8  proto;   /* protocol ID field - varies   */
-__u8  split_flag;  /* for use with split packets   */
-__be16   sequence; /* sequence number  */
-__u8  payload[0];  /* space remaining in packet (504 bytes)*/
+   __u8  proto;/* protocol ID field - varies   */
+   __u8  split_flag;   /* for use with split packets   */
+   __be16   sequence;  /* sequence number  */
+   __u8  payload[0];   /* space remaining in packet (504 bytes)*/
 };
 #define RFC1201_HDR_SIZE 4
 
-
 /*
  * The RFC1051-specific components.
  */
 struct arc_rfc1051 {
-__u8 proto;/* ARC_P_RFC1051_ARP/RFC1051_IP */
-__u8 payload[0];   /* 507 bytes*/
+   __u8 proto; /* ARC_P_RFC1051_ARP/RFC1051_IP */
+   __u8 payload[0];/* 507 bytes*/
 };
 #define RFC1051_HDR_SIZE 1
 
-
 /*
  * The ethernet-encap-specific components.  We have a real ethernet header
  * and some data.
  */
 struct arc_eth_encap {
-__u8 proto;/* Always ARC_P_ETHER   */
-struct ethhdr eth; /* standard ethernet header (yuck!) */
-__u8 payload[0];   /* 493 bytes*/
+   __u8 proto; /* Always ARC_P_ETHER   */
+   struct ethhdr eth;  /* standard ethernet header (yuck!) */
+   __u8 payload[0];/* 493 bytes*/
 };
 #define ETH_ENCAP_HDR_SIZE 14
 
-
 struct arc_cap {
__u8 proto;
-   __u8 cookie[sizeof(int)];   /* Actually NOT sent over the network */
+   __u8 cookie[sizeof(int)];
+   /* Actually NOT sent over the network */
union {
__u8 ack;
-   __u8 raw[0];/* 507 bytes */
+   __u8 raw[0];/* 507 bytes */
} mes;
 };
 
@@ -105,9 +102,9 @@ struct arc_cap {
  * driver.
  */
 struct arc_hardware {
-__u8  source,  /* source ARCnet - filled in automagically */
- dest, /* destination ARCnet - 0 for broadcast*/
-offset[2]; /* offset bytes (some weird semantics) */
+   __u8 source;/* source ARCnet - filled in automagically */
+   __u8 dest;  /* destination ARCnet - 0 for broadcast*/
+   __u8 offset[2]; /* offset bytes (some weird semantics) */
 };
 #define ARC_HDR_SIZE 4
 
@@ -116,17 +113,17 @@ struct arc_hardware {
  * when you do a raw packet capture).
  */
 struct archdr {
-/* hardware requirements */
-struct arc_hardware hard;
- 
-/* arcnet encapsulation-specific bits */
-union {
-   struct arc_rfc1201   rfc1201;
-   struct arc_rfc1051   rfc1051;
-   struct arc_eth_encap eth_encap;
-   struct arc_cap   cap;
-   __u8 raw[0];/* 508 bytes*/
-} soft;
+   /* hardware requirements */
+   struct arc_hardware hard;
+
+   /* arcnet encapsulation-specific bits */
+   union {
+   struct arc_rfc1201   rfc1201;
+   struct arc_rfc1051   rfc1051;
+   struct arc_eth_encap eth_encap;
+   struct arc_cap   cap;
+   __u8 raw[0];/* 508 bytes*/
+   } soft;
 };
 
 #endif /* _LINUX_IF_ARCNET_H */
-- 
2.5.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 05/33] arcnet: Coalesce string fragments

2015-09-22 Thread Michael Grzeschik
From: Joe Perches <j...@perches.com>

Using coalesced strings helps grep for specific messages.

Signed-off-by: Joe Perches <j...@perches.com>
Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/arc-rimi.c |  9 +++--
 drivers/net/arcnet/arcnet.c   | 23 +--
 drivers/net/arcnet/com20020-isa.c |  3 +--
 drivers/net/arcnet/com90io.c  |  7 +++
 drivers/net/arcnet/com90xx.c  |  3 +--
 drivers/net/arcnet/rfc1201.c  | 13 +
 6 files changed, 22 insertions(+), 36 deletions(-)

diff --git a/drivers/net/arcnet/arc-rimi.c b/drivers/net/arcnet/arc-rimi.c
index e8c1501..6eedd6b 100644
--- a/drivers/net/arcnet/arc-rimi.c
+++ b/drivers/net/arcnet/arc-rimi.c
@@ -90,13 +90,11 @@ static int __init arcrimi_probe(struct net_device *dev)
dev->dev_addr[0], dev->mem_start, dev->irq);
 
if (dev->mem_start <= 0 || dev->irq <= 0) {
-   BUGLVL(D_NORMAL) printk("No autoprobe for RIM I; you "
-  "must specify the shmem and irq!\n");
+   BUGLVL(D_NORMAL) printk("No autoprobe for RIM I; you must 
specify the shmem and irq!\n");
return -ENODEV;
}
if (dev->dev_addr[0] == 0) {
-   BUGLVL(D_NORMAL) printk("You need to specify your card's 
station "
-  "ID!\n");
+   BUGLVL(D_NORMAL) printk("You need to specify your card's 
station ID!\n");
return -ENODEV;
}
/*
@@ -225,8 +223,7 @@ static int __init arcrimi_found(struct net_device *dev)
/* get and check the station ID from offset 1 in shmem */
dev->dev_addr[0] = readb(lp->mem_start + 1);
 
-   BUGMSG(D_NORMAL, "ARCnet RIM I: station %02Xh found at IRQ %d, "
-  "ShMem %lXh (%ld*%d bytes).\n",
+   BUGMSG(D_NORMAL, "ARCnet RIM I: station %02Xh found at IRQ %d, ShMem 
%lXh (%ld*%d bytes)\n",
   dev->dev_addr[0],
   dev->irq, dev->mem_start,
 (dev->mem_end - dev->mem_start + 1) / mirror_size, mirror_size);
diff --git a/drivers/net/arcnet/arcnet.c b/drivers/net/arcnet/arcnet.c
index 24c0a64..d70efda 100644
--- a/drivers/net/arcnet/arcnet.c
+++ b/drivers/net/arcnet/arcnet.c
@@ -416,11 +416,9 @@ int arcnet_open(struct net_device *dev)
lp->hw.open(dev);
 
if (dev->dev_addr[0] == 0)
-   BUGMSG(D_NORMAL, "WARNING!  Station address 00 is reserved "
-  "for broadcasts!\n");
+   BUGMSG(D_NORMAL, "WARNING!  Station address 00 is reserved for 
broadcasts!\n");
else if (dev->dev_addr[0] == 255)
-   BUGMSG(D_NORMAL, "WARNING!  Station address FF may confuse "
-  "DOS networking programs!\n");
+   BUGMSG(D_NORMAL, "WARNING!  Station address FF may confuse DOS 
networking programs!\n");
 
BUGMSG(D_DEBUG, "%s: %d: %s\n", __FILE__, __LINE__, __func__);
if (ASTATUS() & RESETflag) {
@@ -580,8 +578,8 @@ netdev_tx_t arcnet_send_packet(struct sk_buff *skb,
if (proto->continue_tx &&
proto->continue_tx(dev, txbuf)) {
BUGMSG(D_NORMAL,
-  "bug! continue_tx finished the first 
time! "
-  "(proto='%c')\n", proto->suffix);
+  "bug! continue_tx finished the first 
time! (proto='%c')\n",
+  proto->suffix);
}
}
retval = NETDEV_TX_OK;
@@ -779,15 +777,13 @@ irqreturn_t arcnet_interrupt(int irq, void *dev_id)
if (!(status & TXACKflag)) {
if (lp->lasttrans_dest != 0) {
BUGMSG(D_EXTRA,
-  "transmit was not 
acknowledged! "
-  "(status=%Xh, 
dest=%02Xh)\n",
+  "transmit was not 
acknowledged! (status=%Xh, dest=%02Xh)\n",
   status, 
lp->lasttrans_dest);
dev->stats.tx_errors++;
dev->stats.tx_carrier_errors++;
} else {
BUGMSG(D_DURING,
-  "broadcast wa

[GIT PULL] ARCNET: refactoring and cleanup

2015-09-22 Thread Michael Grzeschik
The following changes since commit 1f93e4a96c9109378204c147b3eec0d0e8100fde:

  Linux 4.3-rc2 (2015-09-20 14:32:34 -0700)

are available in the git repository at:

  git://git.pengutronix.de/git/mgr/linux.git tags/arcnet-cleanup-v4.3-rc2

for you to fetch changes up to 9ac23e159ab81450d7c644b13a271b514d2bcc23:

  arcnet: capmode: remove extra function (2015-09-21 16:36:30 +0200)


ARCNET: refactoring and cleanup

This series cleans up the code in drivers/net/arcnet
and include/uapi/linux/if_arcnet.h . It doesn't change
the runtime behaviour of the code. Its only purpose
is to improve the code maintenance and readability.


Joe Perches (29):
  arcnet: fix indentation of if_arcnet.h
  arcnet: Use normal kernel spacing style
  arcnet: Add and remove blank lines
  arcnet: Use normal kernel brace style
  arcnet: Coalesce string fragments
  arcnet: Use include/linux path for asm
  arcnet: Use network block comment style
  arcnet: Neaten BUGMSG macro defines
  arcnet: Expand odd BUGLVL macro with if and uses
  arcnet: Convert BUGMSG and BUGMSG2 to arc_prink and arc_cont
  arcnet: Convert printk to pr_
  arcnet: Move EXPORT_SYMBOL after declarations
  arcnet: Remove unnecessary OOM messages
  arcnet: Remove assignments from ifs
  arcnet: Remove pointer comparisons to NULL
  arcnet: Convert arcnet_dump_skb macro to static inline
  arcnet: Wrap some long lines
  arcnet: Move files out of include/linux
  arcnet: Make a char * array const char * const
  arcnet: Add arcnet_ macros
  arcnet: com20020: Use arcnet_ routines
  arcnet: com90io: Use arcnet_ routines
  arcnet: com90xx: Use arcnet_ routines
  arcnet: arcdevice.h: Add arcnet_readb and arcnet_writeb
  arcnet: arc-rimi: Use arcnet_ routines
  arcnet: com90xx: Use arcnet_readb/writeb routines
  arcnet: Remove function pointer macro indirections
  arcnet: Add com9026.h to standardize COM9026_REG_
  arcnet: Remove unused arcnet_w macros

Michael Grzeschik (4):
  arcnet: reformat structs to C99 format
  arcnet: com20020: replace magic numbers with readable macros
  arcnet: arc-rawmode: reorder module functions
  arcnet: capmode: remove extra function

 MAINTAINERS   |   1 -
 drivers/net/arcnet/arc-rawmode.c  | 142 +++--
 drivers/net/arcnet/arc-rimi.c | 145 +++---
 {include/linux => drivers/net/arcnet}/arcdevice.h | 152 +++---
 drivers/net/arcnet/arcnet.c   | 601 ++
 drivers/net/arcnet/capmode.c  | 138 +++--
 drivers/net/arcnet/com20020-isa.c |  54 +-
 drivers/net/arcnet/com20020-pci.c |  70 ++-
 drivers/net/arcnet/com20020.c | 234 +
 {include/linux => drivers/net/arcnet}/com20020.h  |  75 +--
 drivers/net/arcnet/com20020_cs.c  | 325 ++--
 drivers/net/arcnet/com9026.h  |  17 +
 drivers/net/arcnet/com90io.c  | 209 
 drivers/net/arcnet/com90xx.c  | 323 ++--
 drivers/net/arcnet/rfc1051.c  |  77 ++-
 drivers/net/arcnet/rfc1201.c  | 238 -
 include/uapi/linux/if_arcnet.h|  55 +-
 17 files changed, 1410 insertions(+), 1446 deletions(-)
 rename {include/linux => drivers/net/arcnet}/arcdevice.h (79%)
 rename {include/linux => drivers/net/arcnet}/com20020.h (61%)
 create mode 100644 drivers/net/arcnet/com9026.h

-- 
2.5.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 08/33] arcnet: Neaten BUGMSG macro defines

2015-09-22 Thread Michael Grzeschik
From: Joe Perches <j...@perches.com>

These macros are actually printk and pr_cont uses with a flag.

Add a new BUGLVL_TEST macro which is just the "should use" test
and not an odd "if ()" macro to simplify uses in a new patch.

Signed-off-by: Joe Perches <j...@perches.com>
Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 include/linux/arcdevice.h | 24 +---
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/include/linux/arcdevice.h b/include/linux/arcdevice.h
index 7868788..ad61020 100644
--- a/include/linux/arcdevice.h
+++ b/include/linux/arcdevice.h
@@ -78,14 +78,24 @@
 #endif
 extern int arcnet_debug;
 
+#define BUGLVL_TEST(x) ((x) & ARCNET_DEBUG_MAX & arcnet_debug)
+#define BUGLVL(x)  if (BUGLVL_TEST(x))
+
 /* macros to simplify debug checking */
-#define BUGLVL(x) if ((ARCNET_DEBUG_MAX) & arcnet_debug & (x))
-#define BUGMSG2(x, msg, args...) do { BUGLVL(x) printk(msg, ## args); } while 
(0)
-#define BUGMSG(x, msg, args...)
\
-   BUGMSG2(x, "%s%6s: " msg,   \
-   x == D_NORMAL   ? KERN_WARNING  \
-   : x < D_DURING ? KERN_INFO : KERN_DEBUG,\
-   dev->name, ## args)
+#define BUGMSG(x, fmt, ...)\
+do {   \
+   if (BUGLVL_TEST(x)) \
+   printk("%s%6s: " fmt,   \
+  (x) == D_NORMAL  ? KERN_WARNING :\
+  (x) < D_DURING ? KERN_INFO : KERN_DEBUG, \
+  dev->name, ##__VA_ARGS__);   \
+} while (0)
+
+#define BUGMSG2(x, fmt, ...)   \
+do {   \
+   if (BUGLVL_TEST(x)) \
+   printk(fmt, ##__VA_ARGS__); \
+} while (0)
 
 /* see how long a function call takes to run, expressed in CPU cycles */
 #define TIME(name, bytes, call) BUGLVL(D_TIMING) { \
-- 
2.5.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 02/33] arcnet: Use normal kernel spacing style

2015-09-22 Thread Michael Grzeschik
From: Joe Perches <j...@perches.com>

Standardized spacing is easier to read.

git diff -w shows no differences.
objdiff shows no differences.

Signed-off-by: Joe Perches <j...@perches.com>
Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/arc-rawmode.c  |  10 +-
 drivers/net/arcnet/arc-rimi.c |  30 ++--
 drivers/net/arcnet/arcnet.c   | 170 ++---
 drivers/net/arcnet/capmode.c  |  36 ++---
 drivers/net/arcnet/com20020-isa.c |   2 +-
 drivers/net/arcnet/com20020-pci.c |   2 +-
 drivers/net/arcnet/com20020.c |  38 ++---
 drivers/net/arcnet/com20020_cs.c  | 306 +++---
 drivers/net/arcnet/com90io.c  |  24 +--
 drivers/net/arcnet/com90xx.c  |  32 ++--
 drivers/net/arcnet/rfc1051.c  |  12 +-
 drivers/net/arcnet/rfc1201.c  |  36 ++---
 include/linux/arcdevice.h |  90 +--
 13 files changed, 394 insertions(+), 394 deletions(-)

diff --git a/drivers/net/arcnet/arc-rawmode.c b/drivers/net/arcnet/arc-rawmode.c
index 705e6ce..49f5819 100644
--- a/drivers/net/arcnet/arc-rawmode.c
+++ b/drivers/net/arcnet/arc-rawmode.c
@@ -1,6 +1,6 @@
 /*
  * Linux ARCnet driver - "raw mode" packet encapsulation (no soft headers)
- * 
+ *
  * Written 1994-1999 by Avery Pennarun.
  * Derived from skeleton.c by Donald Becker.
  *
@@ -109,7 +109,7 @@ static void rx(struct net_device *dev, int bufnum,
skb_put(skb, length + ARC_HDR_SIZE);
skb->dev = dev;
 
-   pkt = (struct archdr *) skb->data;
+   pkt = (struct archdr *)skb->data;
 
skb_reset_mac_header(skb);
skb_pull(skb, ARC_HDR_SIZE);
@@ -136,7 +136,7 @@ static int build_header(struct sk_buff *skb, struct 
net_device *dev,
unsigned short type, uint8_t daddr)
 {
int hdr_size = ARC_HDR_SIZE;
-   struct archdr *pkt = (struct archdr *) skb_push(skb, hdr_size);
+   struct archdr *pkt = (struct archdr *)skb_push(skb, hdr_size);
 
/*
 * Set the source hardware address.
@@ -150,7 +150,7 @@ static int build_header(struct sk_buff *skb, struct 
net_device *dev,
/* see linux/net/ethernet/eth.c to see where I got the following */
 
if (dev->flags & (IFF_LOOPBACK | IFF_NOARP)) {
-   /* 
+   /*
 * FIXME: fill in the last byte of the dest ipaddr here to 
better
 * comply with RFC1051 in "noarp" mode.
 */
@@ -192,7 +192,7 @@ static int prepare_tx(struct net_device *dev, struct archdr 
*pkt, int length,
hard->offset[0] = ofs = 256 - length;
 
BUGMSG(D_DURING, "prepare_tx: length=%d ofs=%d\n",
-  length,ofs);
+  length, ofs);
 
lp->hw.copy_to_card(dev, bufnum, 0, hard, ARC_HDR_SIZE);
lp->hw.copy_to_card(dev, bufnum, ofs, >soft, length);
diff --git a/drivers/net/arcnet/arc-rimi.c b/drivers/net/arcnet/arc-rimi.c
index b8b4c7b..4644d46 100644
--- a/drivers/net/arcnet/arc-rimi.c
+++ b/drivers/net/arcnet/arc-rimi.c
@@ -1,6 +1,6 @@
 /*
  * Linux ARCnet driver - "RIM I" (entirely mem-mapped) cards
- * 
+ *
  * Written 1994-1999 by Avery Pennarun.
  * Written 1999-2000 by Martin Mares <m...@ucw.cz>.
  * Derived from skeleton.c by Donald Becker.
@@ -56,27 +56,27 @@ static void arcrimi_copy_from_card(struct net_device *dev, 
int bufnum, int offse
 /* Handy defines for ARCnet specific stuff */
 
 /* Amount of I/O memory used by the card */
-#define BUFFER_SIZE (512)
-#define MIRROR_SIZE (BUFFER_SIZE*4)
+#define BUFFER_SIZE(512)
+#define MIRROR_SIZE(BUFFER_SIZE * 4)
 
 /* COM 9026 controller chip --> ARCnet register addresses */
-#define _INTMASK (ioaddr+0)/* writable */
-#define _STATUS  (ioaddr+0)/* readable */
-#define _COMMAND (ioaddr+1)/* writable, returns random vals on read (?) */
-#define _RESET  (ioaddr+8) /* software reset (on read) */
-#define _MEMDATA  (ioaddr+12)  /* Data port for IO-mapped memory */
-#define _ADDR_HI  (ioaddr+15)  /* Control registers for said */
-#define _ADDR_LO  (ioaddr+14)
-#define _CONFIG  (ioaddr+2)/* Configuration register */
+#define _INTMASK   (ioaddr + 0)/* writable */
+#define _STATUS(ioaddr + 0)/* readable */
+#define _COMMAND   (ioaddr + 1)/* writable, returns random vals on 
read (?) */
+#define _RESET (ioaddr + 8)/* software reset (on read) */
+#define _MEMDATA   (ioaddr + 12)   /* Data port for IO-mapped memory */
+#define _ADDR_HI   (ioaddr + 15)   /* Control registers for said */
+#define _ADDR_LO   (ioaddr + 14)
+#define _CONFIG(ioaddr + 2)/* Configuration register */
 
 #undef ASTATUS
 #undef ACOMMAND
 #undef AINTMASK
 
 #define ASTATUS()  readb(_STATUS)
-#define ACOMMAND(cmd)  writeb((cmd),_COMMAND)
-#define AINTMASK(msk)  writeb((msk),_INTMASK)
-#define SETCONF()  writeb(lp->c

[PATCH 09/33] arcnet: Expand odd BUGLVL macro with if and uses

2015-09-22 Thread Michael Grzeschik
From: Joe Perches <j...@perches.com>

Don't hide what should be obvious.

Make the macro a simple test instead of using if and test.

Signed-off-by: Joe Perches <j...@perches.com>
Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/arc-rawmode.c  |  3 ++-
 drivers/net/arcnet/arc-rimi.c | 20 +---
 drivers/net/arcnet/arcnet.c   | 29 ---
 drivers/net/arcnet/capmode.c  |  9 ---
 drivers/net/arcnet/com20020-isa.c |  3 ++-
 drivers/net/arcnet/com20020-pci.c |  3 ++-
 drivers/net/arcnet/com20020.c |  3 ++-
 drivers/net/arcnet/com90io.c  |  6 +++--
 drivers/net/arcnet/com90xx.c  | 49 +--
 drivers/net/arcnet/rfc1051.c  |  3 ++-
 drivers/net/arcnet/rfc1201.c  |  6 +++--
 include/linux/arcdevice.h | 17 +++---
 12 files changed, 93 insertions(+), 58 deletions(-)

diff --git a/drivers/net/arcnet/arc-rawmode.c b/drivers/net/arcnet/arc-rawmode.c
index efdd8e9..998c835 100644
--- a/drivers/net/arcnet/arc-rawmode.c
+++ b/drivers/net/arcnet/arc-rawmode.c
@@ -117,7 +117,8 @@ static void rx(struct net_device *dev, int bufnum,
  pkt->soft.raw + sizeof(pkt->soft),
  length - sizeof(pkt->soft));
 
-   BUGLVL(D_SKB) arcnet_dump_skb(dev, skb, "rx");
+   if (BUGLVL(D_SKB))
+   arcnet_dump_skb(dev, skb, "rx");
 
skb->protocol = cpu_to_be16(ETH_P_ARCNET);
netif_rx(skb);
diff --git a/drivers/net/arcnet/arc-rimi.c b/drivers/net/arcnet/arc-rimi.c
index c7ab23e..cd47a1b 100644
--- a/drivers/net/arcnet/arc-rimi.c
+++ b/drivers/net/arcnet/arc-rimi.c
@@ -82,18 +82,21 @@ static void arcrimi_copy_from_card(struct net_device *dev, 
int bufnum, int offse
  */
 static int __init arcrimi_probe(struct net_device *dev)
 {
-   BUGLVL(D_NORMAL) printk(VERSION);
-   BUGLVL(D_NORMAL) printk("E-mail me if you actually test the RIM I 
driver, please!\n");
-
-   BUGLVL(D_NORMAL) printk("Given: node %02Xh, shmem %lXh, irq %d\n",
-   dev->dev_addr[0], dev->mem_start, dev->irq);
+   if (BUGLVL(D_NORMAL)) {
+   printk(VERSION);
+   printk("E-mail me if you actually test the RIM I driver, 
please!\n");
+   printk("Given: node %02Xh, shmem %lXh, irq %d\n",
+  dev->dev_addr[0], dev->mem_start, dev->irq);
+   }
 
if (dev->mem_start <= 0 || dev->irq <= 0) {
-   BUGLVL(D_NORMAL) printk("No autoprobe for RIM I; you must 
specify the shmem and irq!\n");
+   if (BUGLVL(D_NORMAL))
+   printk("No autoprobe for RIM I; you must specify the 
shmem and irq!\n");
return -ENODEV;
}
if (dev->dev_addr[0] == 0) {
-   BUGLVL(D_NORMAL) printk("You need to specify your card's 
station ID!\n");
+   if (BUGLVL(D_NORMAL))
+   printk("You need to specify your card's station ID!\n");
return -ENODEV;
}
/* Grab the memory region at mem_start for MIRROR_SIZE bytes.
@@ -102,7 +105,8 @@ static int __init arcrimi_probe(struct net_device *dev)
 * will be taken.
 */
if (!request_mem_region(dev->mem_start, MIRROR_SIZE, "arcnet (90xx)")) {
-   BUGLVL(D_NORMAL) printk("Card memory already allocated\n");
+   if (BUGLVL(D_NORMAL))
+   printk("Card memory already allocated\n");
return -ENODEV;
}
return arcrimi_found(dev);
diff --git a/drivers/net/arcnet/arcnet.c b/drivers/net/arcnet/arcnet.c
index 605b4a7..7a90b8a4 100644
--- a/drivers/net/arcnet/arcnet.c
+++ b/drivers/net/arcnet/arcnet.c
@@ -117,7 +117,7 @@ static int __init arcnet_init(void)
printk("arcnet loaded.\n");
 
 #ifdef ALPHA_WARNING
-   BUGLVL(D_EXTRA) {
+   if (BUGLVL(D_EXTRA)) {
printk("arcnet: ***\n"
"arcnet: * Read arcnet.txt for important release notes!\n"
   "arcnet: *\n"
@@ -132,11 +132,11 @@ static int __init arcnet_init(void)
for (count = 0; count < 256; count++)
arc_proto_map[count] = arc_proto_default;
 
-   BUGLVL(D_DURING)
-   printk("arcnet: struct sizes: %Zd %Zd %Zd %Zd %Zd\n",
-  sizeof(struct arc_hardware), sizeof(struct arc_rfc1201),
-  sizeof(struct arc_rfc1051), sizeof(struct arc_eth_encap),
-  sizeof(struct archdr));
+   if (BUGLVL(D_DURING))
+   printk("arcnet: struct sizes: %Zd %Zd %Zd %Zd %Zd\n",
+  sizeof(struct arc_hardware), sizeof(struct arc_rfc1201),

[PATCH 26/33] arcnet: com90xx: Use arcnet_readb/writeb routines

2015-09-22 Thread Michael Grzeschik
From: Joe Perches <j...@perches.com>

Simplify and make consistent the current uses of readb/writeb
by using the newly introduced arcnet_ equivalents.

Signed-off-by: Joe Perches <j...@perches.com>
Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/com90xx.c | 29 +
 1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/drivers/net/arcnet/com90xx.c b/drivers/net/arcnet/com90xx.c
index f1cfeb0..a97d086 100644
--- a/drivers/net/arcnet/com90xx.c
+++ b/drivers/net/arcnet/com90xx.c
@@ -88,6 +88,8 @@ static int numcards;
 #define COM9026_REG_W_ADDR_LO  14  /* Control registers for said */
 #define COM9026_REG_W_ADDR_HI  15
 
+#define COM9026_REG_R_STATION  1   /* Station ID */
+
 static int com90xx_skip_probe __initdata = 0;
 
 /* Module parameters */
@@ -239,9 +241,10 @@ static void __init com90xx_probe(void)
numprint = 0;
goto out1;
}
-   if (readb(base) != TESTvalue) {
+   if (arcnet_readb(base, COM9026_REG_R_STATUS) != TESTvalue) {
arc_cont(D_INIT_REASONS, "(%02Xh != %02Xh)\n",
-readb(base), TESTvalue);
+arcnet_readb(base, COM9026_REG_R_STATUS),
+TESTvalue);
arc_cont(D_INIT_REASONS, "S3: ");
if (BUGLVL(D_INIT_REASONS))
numprint = 0;
@@ -252,8 +255,8 @@ static void __init com90xx_probe(void)
 * in another pass through this loop, they will be discarded
 * because *cptr != TESTvalue.
 */
-   writeb(0x42, base);
-   if (readb(base) != 0x42) {
+   arcnet_writeb(0x42, base, COM9026_REG_W_INTMASK);
+   if (arcnet_readb(base, COM9026_REG_R_STATUS) != 0x42) {
arc_cont(D_INIT_REASONS, "(read only)\n");
arc_cont(D_INIT_REASONS, "S3: ");
goto out2;
@@ -384,7 +387,8 @@ static void __init com90xx_probe(void)
mdelay(RESETtime);
} else {
/* just one shmem and port, assume they match */
-   writeb(TESTvalue, iomem[0]);
+   arcnet_writeb(TESTvalue, iomem[0],
+ COM9026_REG_W_INTMASK);
}
 #else
arcnet_inb(ioaddr, COM9026_REG_R_RESET);
@@ -395,7 +399,7 @@ static void __init com90xx_probe(void)
u_long ptr = shmems[index];
void __iomem *base = iomem[index];
 
-   if (readb(base) == TESTvalue) { /* found one */
+   if (arcnet_readb(base, COM9026_REG_R_STATUS) == 
TESTvalue) {/* found one */
arc_cont(D_INIT, "%lXh)\n", *p);
openparen = 0;
 
@@ -409,7 +413,8 @@ static void __init com90xx_probe(void)
iomem[index] = iomem[numshmems];
break;  /* go to the next I/O port */
} else {
-   arc_cont(D_INIT_REASONS, "%Xh-", readb(base));
+   arc_cont(D_INIT_REASONS, "%Xh-",
+arcnet_readb(base, 
COM9026_REG_R_STATUS));
}
}
 
@@ -431,7 +436,7 @@ static void __init com90xx_probe(void)
 
/* Now put back TESTvalue on all leftover shmems. */
for (index = 0; index < numshmems; index++) {
-   writeb(TESTvalue, iomem[index]);
+   arcnet_writeb(TESTvalue, iomem[index], COM9026_REG_W_INTMASK);
iounmap(iomem[index]);
release_mem_region(shmems[index], MIRROR_SIZE);
}
@@ -449,7 +454,7 @@ static int check_mirror(unsigned long addr, size_t size)
 
p = ioremap(addr, size);
if (p) {
-   if (readb(p) == TESTvalue)
+   if (arcnet_readb(p, COM9026_REG_R_STATUS) == TESTvalue)
res = 1;
else
res = 0;
@@ -487,7 +492,7 @@ static int __init com90xx_found(int ioaddr, int airq, 
u_long shmem,
 * 2k (or there are no mirrors at all) but on some, it's 4k.
 */
mirror_size = MIRROR_SIZE;
-   if (readb(p) == TESTvalue &&
+   if (arcnet_readb(p, COM9026_REG_R_STATUS) == TESTvalue &&
check_mirror(shmem - MIRROR_SIZE, MIRROR_SIZE) == 0 &&
check_mirror(shmem - 2 * MIRROR_SIZE, MIRROR_SIZE) == 1)
mirror_size = 2 * MIRROR_SIZE;
@@ -537,7 +542,7 @@ static int __init com90xx_found(int ioaddr, int airq, 
u_long shmem,
}
 
/* get 

[PATCH 18/33] arcnet: Move files out of include/linux

2015-09-22 Thread Michael Grzeschik
From: Joe Perches <j...@perches.com>

These #include files don't need to be in the include/linux directory
as they can be local to drivers/net/arcnet/

Move them and update the #include statements.

Update the MAINTAINERS file pattern by deleting arcdevice from the
NETWORKING block as arcnet is currently unmaintained.

Signed-off-by: Joe Perches <j...@perches.com>
Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 MAINTAINERS   | 1 -
 drivers/net/arcnet/arc-rawmode.c  | 3 ++-
 drivers/net/arcnet/arc-rimi.c | 3 ++-
 {include/linux => drivers/net/arcnet}/arcdevice.h | 0
 drivers/net/arcnet/arcnet.c   | 3 ++-
 drivers/net/arcnet/capmode.c  | 3 ++-
 drivers/net/arcnet/com20020-isa.c | 6 +++---
 drivers/net/arcnet/com20020-pci.c | 6 +++---
 drivers/net/arcnet/com20020.c | 6 +++---
 {include/linux => drivers/net/arcnet}/com20020.h  | 0
 drivers/net/arcnet/com20020_cs.c  | 7 +++
 drivers/net/arcnet/com90io.c  | 3 ++-
 drivers/net/arcnet/com90xx.c  | 3 ++-
 drivers/net/arcnet/rfc1051.c  | 3 ++-
 drivers/net/arcnet/rfc1201.c  | 3 ++-
 15 files changed, 28 insertions(+), 22 deletions(-)
 rename {include/linux => drivers/net/arcnet}/arcdevice.h (100%)
 rename {include/linux => drivers/net/arcnet}/com20020.h (100%)

diff --git a/MAINTAINERS b/MAINTAINERS
index 274f854..2705240 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -7300,7 +7300,6 @@ S:Odd Fixes
 F: drivers/net/
 F: include/linux/if_*
 F: include/linux/netdevice.h
-F: include/linux/arcdevice.h
 F: include/linux/etherdevice.h
 F: include/linux/fcdevice.h
 F: include/linux/fddidevice.h
diff --git a/drivers/net/arcnet/arc-rawmode.c b/drivers/net/arcnet/arc-rawmode.c
index 59b3083..35a747a 100644
--- a/drivers/net/arcnet/arc-rawmode.c
+++ b/drivers/net/arcnet/arc-rawmode.c
@@ -33,7 +33,8 @@
 #include 
 #include 
 #include 
-#include 
+
+#include "arcdevice.h"
 
 static void rx(struct net_device *dev, int bufnum,
   struct archdr *pkthdr, int length);
diff --git a/drivers/net/arcnet/arc-rimi.c b/drivers/net/arcnet/arc-rimi.c
index 8fa5eb4..37406ff 100644
--- a/drivers/net/arcnet/arc-rimi.c
+++ b/drivers/net/arcnet/arc-rimi.c
@@ -37,7 +37,8 @@
 #include 
 #include 
 #include 
-#include 
+
+#include "arcdevice.h"
 
 /* Internal function declarations */
 
diff --git a/include/linux/arcdevice.h b/drivers/net/arcnet/arcdevice.h
similarity index 100%
rename from include/linux/arcdevice.h
rename to drivers/net/arcnet/arcdevice.h
diff --git a/drivers/net/arcnet/arcnet.c b/drivers/net/arcnet/arcnet.c
index 00074e7..c8423ee 100644
--- a/drivers/net/arcnet/arcnet.c
+++ b/drivers/net/arcnet/arcnet.c
@@ -50,9 +50,10 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
+#include "arcdevice.h"
+
 /* "do nothing" functions for protocol drivers */
 static void null_rx(struct net_device *dev, int bufnum,
struct archdr *pkthdr, int length);
diff --git a/drivers/net/arcnet/capmode.c b/drivers/net/arcnet/capmode.c
index 46a76dc..2f2d0d9 100644
--- a/drivers/net/arcnet/capmode.c
+++ b/drivers/net/arcnet/capmode.c
@@ -35,7 +35,8 @@
 #include 
 #include 
 #include 
-#include 
+
+#include "arcdevice.h"
 
 /* packet receiver */
 static void rx(struct net_device *dev, int bufnum,
diff --git a/drivers/net/arcnet/com20020-isa.c 
b/drivers/net/arcnet/com20020-isa.c
index 352500b..ab5202b 100644
--- a/drivers/net/arcnet/com20020-isa.c
+++ b/drivers/net/arcnet/com20020-isa.c
@@ -39,11 +39,11 @@
 #include 
 #include 
 #include 
-#include 
-#include 
-
 #include 
 
+#include "arcdevice.h"
+#include "com20020.h"
+
 /* We cannot (yet) probe for an IO mapped card, although we can check that
  * it's where we were told it was, and even do autoirq.
  */
diff --git a/drivers/net/arcnet/com20020-pci.c 
b/drivers/net/arcnet/com20020-pci.c
index a28887d..1a75a69 100644
--- a/drivers/net/arcnet/com20020-pci.c
+++ b/drivers/net/arcnet/com20020-pci.c
@@ -39,12 +39,12 @@
 #include 
 #include 
 #include 
-#include 
-#include 
 #include 
-
 #include 
 
+#include "arcdevice.h"
+#include "com20020.h"
+
 /* Module parameters */
 
 static int node;
diff --git a/drivers/net/arcnet/com20020.c b/drivers/net/arcnet/com20020.c
index 00f910c..f46e220 100644
--- a/drivers/net/arcnet/com20020.c
+++ b/drivers/net/arcnet/com20020.c
@@ -37,11 +37,11 @@
 #include 
 #include 
 #include 
-#include 
-#include 
-
 #include 
 
+#include "arcdevice.h"
+#include "com20020.h"
+
 static char *clockrates[] = {
"XXX", "", "XX",
"2.5 Mb/s", "1.25Mb/s", "625 Kb/s&

[PATCH 19/33] arcnet: Make a char * array const char * const

2015-09-22 Thread Michael Grzeschik
From: Joe Perches <j...@perches.com>

Might as well be specific about the use of this array.

Add a commment questioning the indexing too.

Signed-off-by: Joe Perches <j...@perches.com>
Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/com20020.c | 15 ++-
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/net/arcnet/com20020.c b/drivers/net/arcnet/com20020.c
index f46e220..ddd64bb 100644
--- a/drivers/net/arcnet/com20020.c
+++ b/drivers/net/arcnet/com20020.c
@@ -42,10 +42,10 @@
 #include "arcdevice.h"
 #include "com20020.h"
 
-static char *clockrates[] = {
-   "XXX", "", "XX",
-   "2.5 Mb/s", "1.25Mb/s", "625 Kb/s", "312.5 Kb/s",
-   "156.25 Kb/s", "Reserved", "Reserved", "Reserved"
+static const char * const clockrates[] = {
+   "XXX", "", "XX", "2.5 Mb/s",
+   "1.25Mb/s", "625 Kb/s", "312.5 Kb/s", "156.25 Kb/s",
+   "Reserved", "Reserved", "Reserved"
 };
 
 static void com20020_command(struct net_device *dev, int command);
@@ -234,7 +234,12 @@ int com20020_found(struct net_device *dev, int shared)
 
arc_printk(D_NORMAL, dev, "Using CKP %d - data rate %s\n",
   lp->setup >> 1,
-  clockrates[3 - ((lp->setup2 & 0xF0) >> 4) + ((lp->setup & 
0x0F) >> 1)]);
+  clockrates[3 -
+ ((lp->setup2 & 0xF0) >> 4) +
+ ((lp->setup & 0x0F) >> 1)]);
+   /* The clockrates array index looks very fragile.
+* It seems like it could have negative indexing.
+*/
 
if (register_netdev(dev)) {
free_irq(dev->irq, dev);
-- 
2.5.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 25/33] arcnet: arc-rimi: Use arcnet_ routines

2015-09-22 Thread Michael Grzeschik
From: Joe Perches <j...@perches.com>

Simplify and make consistent the current uses of readb/writeb
by using the newly introduced arcnet_ equivalents.

o Add new #defines for register offsets
o Remove old #defines that included the ioaddr
o Remove obfuscating macros by expanding them in-place where appropriate

Signed-off-by: Joe Perches <j...@perches.com>
Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/arc-rimi.c | 55 ---
 1 file changed, 25 insertions(+), 30 deletions(-)

diff --git a/drivers/net/arcnet/arc-rimi.c b/drivers/net/arcnet/arc-rimi.c
index 37406ff..4c35a7e 100644
--- a/drivers/net/arcnet/arc-rimi.c
+++ b/drivers/net/arcnet/arc-rimi.c
@@ -60,23 +60,16 @@ static void arcrimi_copy_from_card(struct net_device *dev, 
int bufnum,
 #define MIRROR_SIZE(BUFFER_SIZE * 4)
 
 /* COM 9026 controller chip --> ARCnet register addresses */
-#define _INTMASK   (ioaddr + 0)/* writable */
-#define _STATUS(ioaddr + 0)/* readable */
-#define _COMMAND   (ioaddr + 1)/* writable, returns random vals on 
read (?) */
-#define _RESET (ioaddr + 8)/* software reset (on read) */
-#define _MEMDATA   (ioaddr + 12)   /* Data port for IO-mapped memory */
-#define _ADDR_HI   (ioaddr + 15)   /* Control registers for said */
-#define _ADDR_LO   (ioaddr + 14)
-#define _CONFIG(ioaddr + 2)/* Configuration register */
-
-#undef ASTATUS
-#undef ACOMMAND
-#undef AINTMASK
-
-#define ASTATUS()  readb(_STATUS)
-#define ACOMMAND(cmd)  writeb((cmd), _COMMAND)
-#define AINTMASK(msk)  writeb((msk), _INTMASK)
-#define SETCONF()  writeb(lp->config, _CONFIG)
+#define COM9026_REG_W_INTMASK  0   /* writable */
+#define COM9026_REG_R_STATUS   0   /* readable */
+#define COM9026_REG_W_COMMAND  1   /* writable, returns random vals on 
read (?) */
+#define COM9026_REG_RW_CONFIG  2   /* Configuration register */
+#define COM9026_REG_R_RESET8   /* software reset (on read) */
+#define COM9026_REG_RW_MEMDATA 12  /* Data port for IO-mapped memory */
+#define COM9026_REG_W_ADDR_LO  14  /* Control registers for said */
+#define COM9026_REG_W_ADDR_HI  15
+
+#define COM9026_REG_R_STATION  1   /* Station ID */
 
 /* We cannot probe for a RIM I card; one reason is I don't know how to reset
  * them.  In fact, we can't even get their node ID automatically.  So, we
@@ -124,7 +117,7 @@ static int check_mirror(unsigned long addr, size_t size)
 
p = ioremap(addr, size);
if (p) {
-   if (readb(p) == TESTvalue)
+   if (arcnet_readb(p, COM9026_REG_R_STATUS) == TESTvalue)
res = 1;
else
res = 0;
@@ -162,8 +155,9 @@ static int __init arcrimi_found(struct net_device *dev)
}
 
shmem = dev->mem_start;
-   writeb(TESTvalue, p);
-   writeb(dev->dev_addr[0], p + 1);/* actually the node ID */
+   arcnet_writeb(TESTvalue, p, COM9026_REG_W_INTMASK);
+   arcnet_writeb(TESTvalue, p, COM9026_REG_W_COMMAND);
+   /* actually the station/node ID */
 
/* find the real shared memory start/end points, including mirrors */
 
@@ -172,7 +166,7 @@ static int __init arcrimi_found(struct net_device *dev)
 * 2k (or there are no mirrors at all) but on some, it's 4k.
 */
mirror_size = MIRROR_SIZE;
-   if (readb(p) == TESTvalue &&
+   if (arcnet_readb(p, COM9026_REG_R_STATUS) == TESTvalue &&
check_mirror(shmem - MIRROR_SIZE, MIRROR_SIZE) == 0 &&
check_mirror(shmem - 2 * MIRROR_SIZE, MIRROR_SIZE) == 1)
mirror_size = 2 * MIRROR_SIZE;
@@ -224,7 +218,7 @@ static int __init arcrimi_found(struct net_device *dev)
}
 
/* get and check the station ID from offset 1 in shmem */
-   dev->dev_addr[0] = readb(lp->mem_start + 1);
+   dev->dev_addr[0] = arcnet_readb(lp->mem_start, COM9026_REG_R_STATION);
 
arc_printk(D_NORMAL, dev, "ARCnet RIM I: station %02Xh found at IRQ %d, 
ShMem %lXh (%ld*%d bytes)\n",
   dev->dev_addr[0],
@@ -260,17 +254,18 @@ static int arcrimi_reset(struct net_device *dev, int 
really_reset)
void __iomem *ioaddr = lp->mem_start + 0x800;
 
arc_printk(D_INIT, dev, "Resetting %s (status=%02Xh)\n",
-  dev->name, ASTATUS());
+  dev->name, arcnet_readb(ioaddr, COM9026_REG_R_STATUS));
 
if (really_reset) {
-   writeb(TESTvalue, ioaddr - 0x800);  /* fake reset */
+   arcnet_writeb(TESTvalue, ioaddr, -0x800);   /* fake reset */
return 0;
}
-   ACOMMAND(CFLAGScmd | RESETclear);   /* clear flags & end reset */
-   ACOMMAND(CFLAGScmd | CONFIGclear);
+   /* 

[PATCH 13/33] arcnet: Remove unnecessary OOM messages

2015-09-22 Thread Michael Grzeschik
From: Joe Perches <j...@perches.com>

Alloc failures have generic stack dumps so these are redundant.

Signed-off-by: Joe Perches <j...@perches.com>
Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/arc-rawmode.c  | 1 -
 drivers/net/arcnet/capmode.c  | 5 +
 drivers/net/arcnet/com20020-pci.c | 4 +---
 drivers/net/arcnet/rfc1051.c  | 1 -
 drivers/net/arcnet/rfc1201.c  | 1 -
 5 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/drivers/net/arcnet/arc-rawmode.c b/drivers/net/arcnet/arc-rawmode.c
index e4a2702..7fc5b042 100644
--- a/drivers/net/arcnet/arc-rawmode.c
+++ b/drivers/net/arcnet/arc-rawmode.c
@@ -98,7 +98,6 @@ static void rx(struct net_device *dev, int bufnum,
 
skb = alloc_skb(length + ARC_HDR_SIZE, GFP_ATOMIC);
if (skb == NULL) {
-   arc_printk(D_NORMAL, dev, "Memory squeeze, dropping packet\n");
dev->stats.rx_dropped++;
return;
}
diff --git a/drivers/net/arcnet/capmode.c b/drivers/net/arcnet/capmode.c
index 92b553e..de80d9e 100644
--- a/drivers/net/arcnet/capmode.c
+++ b/drivers/net/arcnet/capmode.c
@@ -57,7 +57,6 @@ static void rx(struct net_device *dev, int bufnum,
 
skb = alloc_skb(length + ARC_HDR_SIZE + sizeof(int), GFP_ATOMIC);
if (skb == NULL) {
-   arc_printk(D_NORMAL, dev, "Memory squeeze, dropping packet\n");
dev->stats.rx_dropped++;
return;
}
@@ -197,10 +196,8 @@ static int ack_tx(struct net_device *dev, int acked)
 
/* Now alloc a skb to send back up through the layers: */
ackskb = alloc_skb(length + ARC_HDR_SIZE, GFP_ATOMIC);
-   if (ackskb == NULL) {
-   arc_printk(D_NORMAL, dev, "Memory squeeze, can't 
acknowledge\n");
+   if (ackskb == NULL)
goto free_outskb;
-   }
 
skb_put(ackskb, length + ARC_HDR_SIZE);
ackskb->dev = dev;
diff --git a/drivers/net/arcnet/com20020-pci.c 
b/drivers/net/arcnet/com20020-pci.c
index 7247add..fc6809b 100644
--- a/drivers/net/arcnet/com20020-pci.c
+++ b/drivers/net/arcnet/com20020-pci.c
@@ -142,10 +142,8 @@ static int com20020pci_probe(struct pci_dev *pdev, const 
struct pci_device_id *i
 
card = devm_kzalloc(>dev, sizeof(struct com20020_dev),
GFP_KERNEL);
-   if (!card) {
-   pr_err("%s out of memory!\n", __func__);
+   if (!card)
return -ENOMEM;
-   }
 
card->index = i;
card->pci_priv = priv;
diff --git a/drivers/net/arcnet/rfc1051.c b/drivers/net/arcnet/rfc1051.c
index d5a0f90..7e7eda5 100644
--- a/drivers/net/arcnet/rfc1051.c
+++ b/drivers/net/arcnet/rfc1051.c
@@ -134,7 +134,6 @@ static void rx(struct net_device *dev, int bufnum,
 
skb = alloc_skb(length + ARC_HDR_SIZE, GFP_ATOMIC);
if (skb == NULL) {
-   arc_printk(D_NORMAL, dev, "Memory squeeze, dropping packet\n");
dev->stats.rx_dropped++;
return;
}
diff --git a/drivers/net/arcnet/rfc1201.c b/drivers/net/arcnet/rfc1201.c
index 3dae141..9040a8b 100644
--- a/drivers/net/arcnet/rfc1201.c
+++ b/drivers/net/arcnet/rfc1201.c
@@ -179,7 +179,6 @@ static void rx(struct net_device *dev, int bufnum,
 
skb = alloc_skb(length + ARC_HDR_SIZE, GFP_ATOMIC);
if (skb == NULL) {
-   arc_printk(D_NORMAL, dev, "Memory squeeze, dropping 
packet\n");
dev->stats.rx_dropped++;
return;
}
-- 
2.5.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 12/33] arcnet: Move EXPORT_SYMBOL after declarations

2015-09-22 Thread Michael Grzeschik
From: Joe Perches <j...@perches.com>

Use the normal kernel style for EXPORT_SYMBOL.

Signed-off-by: Joe Perches <j...@perches.com>
Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/arcnet.c | 33 ++---
 1 file changed, 18 insertions(+), 15 deletions(-)

diff --git a/drivers/net/arcnet/arcnet.c b/drivers/net/arcnet/arcnet.c
index 2be8ab6..a9535ec 100644
--- a/drivers/net/arcnet/arcnet.c
+++ b/drivers/net/arcnet/arcnet.c
@@ -68,8 +68,17 @@ static void arcnet_rx(struct net_device *dev, int bufnum);
  * arc_proto_default instead.  It also must not be NULL; if you would like
  * to set it to NULL, set it to _proto_null instead.
  */
-struct ArcProto *arc_proto_map[256], *arc_proto_default,
-   *arc_bcast_proto, *arc_raw_proto;
+struct ArcProto *arc_proto_map[256];
+EXPORT_SYMBOL(arc_proto_map);
+
+struct ArcProto *arc_proto_default;
+EXPORT_SYMBOL(arc_proto_default);
+
+struct ArcProto *arc_bcast_proto;
+EXPORT_SYMBOL(arc_bcast_proto);
+
+struct ArcProto *arc_raw_proto;
+EXPORT_SYMBOL(arc_raw_proto);
 
 static struct ArcProto arc_proto_null = {
.suffix = '?',
@@ -84,19 +93,7 @@ static struct ArcProto arc_proto_null = {
 
 /* Exported function prototypes */
 int arcnet_debug = ARCNET_DEBUG;
-
-EXPORT_SYMBOL(arc_proto_map);
-EXPORT_SYMBOL(arc_proto_default);
-EXPORT_SYMBOL(arc_bcast_proto);
-EXPORT_SYMBOL(arc_raw_proto);
-EXPORT_SYMBOL(arcnet_unregister_proto);
 EXPORT_SYMBOL(arcnet_debug);
-EXPORT_SYMBOL(alloc_arcdev);
-EXPORT_SYMBOL(arcnet_interrupt);
-EXPORT_SYMBOL(arcnet_open);
-EXPORT_SYMBOL(arcnet_close);
-EXPORT_SYMBOL(arcnet_send_packet);
-EXPORT_SYMBOL(arcnet_timeout);
 
 /* Internal function prototypes */
 static int arcnet_header(struct sk_buff *skb, struct net_device *dev,
@@ -151,7 +148,6 @@ void arcnet_dump_skb(struct net_device *dev,
print_hex_dump(KERN_DEBUG, hdr, DUMP_PREFIX_OFFSET,
   16, 1, skb->data, skb->len, true);
 }
-
 EXPORT_SYMBOL(arcnet_dump_skb);
 #endif
 
@@ -211,6 +207,7 @@ void arcnet_unregister_proto(struct ArcProto *proto)
arc_proto_map[count] = arc_proto_default;
}
 }
+EXPORT_SYMBOL(arcnet_unregister_proto);
 
 /* Add a buffer to the queue.  Only the interrupt handler is allowed to do
  * this, unless interrupts are disabled.
@@ -330,6 +327,7 @@ struct net_device *alloc_arcdev(const char *name)
 
return dev;
 }
+EXPORT_SYMBOL(alloc_arcdev);
 
 /* Open/initialize the board.  This is called sometime after booting when
  * the 'ifconfig' program is run.
@@ -431,6 +429,7 @@ int arcnet_open(struct net_device *dev)
module_put(lp->hw.owner);
return error;
 }
+EXPORT_SYMBOL(arcnet_open);
 
 /* The inverse routine to arcnet_open - shuts down the card. */
 int arcnet_close(struct net_device *dev)
@@ -450,6 +449,7 @@ int arcnet_close(struct net_device *dev)
module_put(lp->hw.owner);
return 0;
 }
+EXPORT_SYMBOL(arcnet_close);
 
 static int arcnet_header(struct sk_buff *skb, struct net_device *dev,
 unsigned short type, const void *daddr,
@@ -592,6 +592,7 @@ netdev_tx_t arcnet_send_packet(struct sk_buff *skb,
 
return retval;  /* no need to try again */
 }
+EXPORT_SYMBOL(arcnet_send_packet);
 
 /* Actually start transmitting a packet that was loaded into a buffer
  * by prepare_tx.  This should _only_ be called by the interrupt handler.
@@ -659,6 +660,7 @@ void arcnet_timeout(struct net_device *dev)
if (lp->cur_tx == -1)
netif_wake_queue(dev);
 }
+EXPORT_SYMBOL(arcnet_timeout);
 
 /* The typical workload of the driver: Handle the network interface
  * interrupts. Establish which device needs attention, and call the correct
@@ -902,6 +904,7 @@ irqreturn_t arcnet_interrupt(int irq, void *dev_id)
spin_unlock(>lock);
return retval;
 }
+EXPORT_SYMBOL(arcnet_interrupt);
 
 /* This is a generic packet receiver that calls arcnet??_rx depending on the
  * protocol ID found.
-- 
2.5.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 14/33] arcnet: Remove assignments from ifs

2015-09-22 Thread Michael Grzeschik
From: Joe Perches <j...@perches.com>

Move the assignment above the if like general kernel style.

Signed-off-by: Joe Perches <j...@perches.com>
Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/com20020-isa.c | 4 +++-
 drivers/net/arcnet/com20020.c | 3 ++-
 drivers/net/arcnet/com90io.c  | 3 ++-
 3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/net/arcnet/com20020-isa.c 
b/drivers/net/arcnet/com20020-isa.c
index f3b..352500b 100644
--- a/drivers/net/arcnet/com20020-isa.c
+++ b/drivers/net/arcnet/com20020-isa.c
@@ -107,7 +107,9 @@ static int __init com20020isa_probe(struct net_device *dev)
}
 
lp->card_name = "ISA COM20020";
-   if ((err = com20020_found(dev, 0)) != 0)
+
+   err = com20020_found(dev, 0);
+   if (err != 0)
goto out;
 
return 0;
diff --git a/drivers/net/arcnet/com20020.c b/drivers/net/arcnet/com20020.c
index e813fc6..bea3862 100644
--- a/drivers/net/arcnet/com20020.c
+++ b/drivers/net/arcnet/com20020.c
@@ -140,7 +140,8 @@ int com20020_check(struct net_device *dev)
outb(0 | RDDATAflag | AUTOINCflag, _ADDR_HI);
outb(0, _ADDR_LO);
 
-   if ((status = inb(_MEMDATA)) != TESTvalue) {
+   status = inb(_MEMDATA);
+   if (status != TESTvalue) {
arc_printk(D_NORMAL, dev, "Signature byte not found (%02Xh != 
D1h).\n",
   status);
return -ENODEV;
diff --git a/drivers/net/arcnet/com90io.c b/drivers/net/arcnet/com90io.c
index 32abaa8..11bc589 100644
--- a/drivers/net/arcnet/com90io.c
+++ b/drivers/net/arcnet/com90io.c
@@ -196,7 +196,8 @@ static int __init com90io_probe(struct net_device *dev)
outb(AUTOINCflag, _ADDR_HI);
outb(0, _ADDR_LO);
 
-   if ((status = inb(_MEMDATA)) != 0xd1) {
+   status = inb(_MEMDATA);
+   if (status != 0xd1) {
arc_printk(D_INIT_REASONS, dev, "Signature byte not found (%Xh 
instead).\n",
   status);
goto err_out;
-- 
2.5.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 20/33] arcnet: Add arcnet_ macros

2015-09-22 Thread Michael Grzeschik
From: Joe Perches <j...@perches.com>

arcnet uses an I/O scheme which can align I/O addresses to word boundaries
on different architectures.

Add arcnet specific macros which can hide this alignment calculation.

Signed-off-by: Joe Perches <j...@perches.com>
Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/arcdevice.h | 25 +
 1 file changed, 25 insertions(+)

diff --git a/drivers/net/arcnet/arcdevice.h b/drivers/net/arcnet/arcdevice.h
index 9ca135d..95e7ed6 100644
--- a/drivers/net/arcnet/arcdevice.h
+++ b/drivers/net/arcnet/arcdevice.h
@@ -342,5 +342,30 @@ netdev_tx_t arcnet_send_packet(struct sk_buff *skb,
   struct net_device *dev);
 void arcnet_timeout(struct net_device *dev);
 
+/* I/O equivalents */
+
+/* addr and offset allow register like names to define the actual IO  address.
+ * A configuration option multiplies the offset for alignment.
+ */
+#define arcnet_inb(addr, offset)   \
+   inb((addr) + (offset))
+#define arcnet_outb(value, addr, offset)   \
+   outb(value, (addr) + (offset))
+
+#define arcnet_insb(addr, offset, buffer, count)   \
+   insb((addr) + (offset), buffer, count)
+#define arcnet_outsb(addr, offset, buffer, count)  \
+   outsb((addr) + (offset), buffer, count)
+
+#define arcnet_inw(addr, offset)   \
+   inw((addr) + (offset))
+#define arcnet_outw(value, addr, offset)   \
+   outw(value, (addr) + (offset))
+
+#define arcnet_insw(addr, offset, buffer, count)   \
+   insw((addr) + (offset), buffer, count)
+#define arcnet_outsw(addr, offset, buffer, count)  \
+   outsw((addr) + (offset), buffer, count)
+
 #endif /* __KERNEL__ */
 #endif /* _LINUX_ARCDEVICE_H */
-- 
2.5.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 27/33] arcnet: Remove function pointer macro indirections

2015-09-22 Thread Michael Grzeschik
From: Joe Perches <j...@perches.com>

It's clearer to use function pointer calls directly instead of the
macro indirections of ARCRESET, ACOMMAND, ASTATUS, and AINTMASK.

Remove the now unused macros too.

Signed-off-by: Joe Perches <j...@perches.com>
Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/arcdevice.h |  5 
 drivers/net/arcnet/arcnet.c| 64 +-
 2 files changed, 32 insertions(+), 37 deletions(-)

diff --git a/drivers/net/arcnet/arcdevice.h b/drivers/net/arcnet/arcdevice.h
index a05a77d..2577485 100644
--- a/drivers/net/arcnet/arcdevice.h
+++ b/drivers/net/arcnet/arcdevice.h
@@ -318,11 +318,6 @@ struct arcnet_local {
void __iomem *mem_start;/* pointer to ioremap'ed MMIO */
 };
 
-#define ARCRESET(x)  (lp->hw.reset(dev, (x)))
-#define ACOMMAND(x)  (lp->hw.command(dev, (x)))
-#define ASTATUS()(lp->hw.status(dev))
-#define AINTMASK(x)  (lp->hw.intmask(dev, (x)))
-
 #if ARCNET_DEBUG_MAX & D_SKB
 void arcnet_dump_skb(struct net_device *dev, struct sk_buff *skb, char *desc);
 #else
diff --git a/drivers/net/arcnet/arcnet.c b/drivers/net/arcnet/arcnet.c
index c8423ee..bcfdd91 100644
--- a/drivers/net/arcnet/arcnet.c
+++ b/drivers/net/arcnet/arcnet.c
@@ -361,7 +361,7 @@ int arcnet_open(struct net_device *dev)
 * time, actually reset it.
 */
error = -ENODEV;
-   if (ARCRESET(0) && ARCRESET(1))
+   if (lp->hw.reset(dev, 0) && lp->hw.reset(dev, 1))
goto out_module_put;
 
newmtu = choose_mtu();
@@ -404,22 +404,22 @@ int arcnet_open(struct net_device *dev)
arc_printk(D_NORMAL, dev, "WARNING!  Station address FF may 
confuse DOS networking programs!\n");
 
arc_printk(D_DEBUG, dev, "%s: %d: %s\n", __FILE__, __LINE__, __func__);
-   if (ASTATUS() & RESETflag) {
+   if (lp->hw.status(dev) & RESETflag) {
arc_printk(D_DEBUG, dev, "%s: %d: %s\n",
   __FILE__, __LINE__, __func__);
-   ACOMMAND(CFLAGScmd | RESETclear);
+   lp->hw.command(dev, CFLAGScmd | RESETclear);
}
 
arc_printk(D_DEBUG, dev, "%s: %d: %s\n", __FILE__, __LINE__, __func__);
/* make sure we're ready to receive IRQ's. */
-   AINTMASK(0);
+   lp->hw.intmask(dev, 0);
udelay(1);  /* give it time to set the mask before
 * we reset it again. (may not even be
 * necessary)
 */
arc_printk(D_DEBUG, dev, "%s: %d: %s\n", __FILE__, __LINE__, __func__);
lp->intmask = NORXflag | RECONflag;
-   AINTMASK(lp->intmask);
+   lp->hw.intmask(dev, lp->intmask);
arc_printk(D_DEBUG, dev, "%s: %d: %s\n", __FILE__, __LINE__, __func__);
 
netif_start_queue(dev);
@@ -440,9 +440,9 @@ int arcnet_close(struct net_device *dev)
netif_stop_queue(dev);
 
/* flush TX and disable RX */
-   AINTMASK(0);
-   ACOMMAND(NOTXcmd);  /* stop transmit */
-   ACOMMAND(NORXcmd);  /* disable receive */
+   lp->hw.intmask(dev, 0);
+   lp->hw.command(dev, NOTXcmd);   /* stop transmit */
+   lp->hw.command(dev, NORXcmd);   /* disable receive */
mdelay(1);
 
/* shut down the card */
@@ -518,7 +518,7 @@ netdev_tx_t arcnet_send_packet(struct sk_buff *skb,
 
arc_printk(D_DURING, dev,
   "transmit requested (status=%Xh, txbufs=%d/%d, len=%d, 
protocol %x)\n",
-  ASTATUS(), lp->cur_tx, lp->next_tx, skb->len, skb->protocol);
+  lp->hw.status(dev), lp->cur_tx, lp->next_tx, skb->len, 
skb->protocol);
 
pkt = (struct archdr *)skb->data;
soft = >soft.rfc1201;
@@ -540,7 +540,7 @@ netdev_tx_t arcnet_send_packet(struct sk_buff *skb,
netif_stop_queue(dev);
 
spin_lock_irqsave(>lock, flags);
-   AINTMASK(0);
+   lp->hw.intmask(dev, 0);
if (lp->next_tx == -1)
txbuf = get_arcbuf(dev);
else
@@ -577,15 +577,15 @@ netdev_tx_t arcnet_send_packet(struct sk_buff *skb,
}
 
arc_printk(D_DEBUG, dev, "%s: %d: %s, status: %x\n",
-  __FILE__, __LINE__, __func__, ASTATUS());
+  __FILE__, __LINE__, __func__, lp->hw.status(dev));
/* make sure we didn't ignore a TX IRQ while we were in here */
-   AINTMASK(0);
+   lp->hw.intmask(dev, 0);
 
arc_printk(D_DEBUG, dev, "%s: %d: %s\n", __FILE__, __LINE__, __func__);
lp->intmask |= TXFREEflag | EXCNAKflag;
-   AINTMASK(lp->intmask);
+   lp->hw.intmask(dev, lp->intmask);
arc_printk(D_DEBUG, dev, "%s: %d: %s, status: %x\n",
-

[PATCH 11/33] arcnet: Convert printk to pr_

2015-09-22 Thread Michael Grzeschik
From: Joe Perches <j...@perches.com>

Use the more current logging style.

Remove #define VERSION, use pr_info normally.
Add pr_fmt with "arcnet:" prefixes and KBUILD_MODNAME.

Signed-off-by: Joe Perches <j...@perches.com>
Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/arc-rawmode.c  |  6 +++---
 drivers/net/arcnet/arc-rimi.c | 21 +++--
 drivers/net/arcnet/arcnet.c   | 25 -
 drivers/net/arcnet/capmode.c  |  6 +++---
 drivers/net/arcnet/com20020-isa.c |  9 +
 drivers/net/arcnet/com20020-pci.c |  9 +
 drivers/net/arcnet/com20020.c |  7 ---
 drivers/net/arcnet/com20020_cs.c  |  5 +++--
 drivers/net/arcnet/com90io.c  | 11 ++-
 drivers/net/arcnet/com90xx.c  | 17 +
 drivers/net/arcnet/rfc1051.c  |  7 ---
 drivers/net/arcnet/rfc1201.c  |  6 --
 12 files changed, 65 insertions(+), 64 deletions(-)

diff --git a/drivers/net/arcnet/arc-rawmode.c b/drivers/net/arcnet/arc-rawmode.c
index 034c898..e4a2702 100644
--- a/drivers/net/arcnet/arc-rawmode.c
+++ b/drivers/net/arcnet/arc-rawmode.c
@@ -24,6 +24,8 @@
  * **
  */
 
+#define pr_fmt(fmt) "arcnet:" KBUILD_MODNAME ": " fmt
+
 #include 
 #include 
 #include 
@@ -33,8 +35,6 @@
 #include 
 #include 
 
-#define VERSION "arcnet: raw mode (`r') encapsulation support loaded.\n"
-
 static void rx(struct net_device *dev, int bufnum,
   struct archdr *pkthdr, int length);
 static int build_header(struct sk_buff *skb, struct net_device *dev,
@@ -56,7 +56,7 @@ static int __init arcnet_raw_init(void)
 {
int count;
 
-   printk(VERSION);
+   pr_info("%s\n", "raw mode (`r') encapsulation support loaded");
 
for (count = 0; count < 256; count++)
if (arc_proto_map[count] == arc_proto_default)
diff --git a/drivers/net/arcnet/arc-rimi.c b/drivers/net/arcnet/arc-rimi.c
index 25f84b7..7360214 100644
--- a/drivers/net/arcnet/arc-rimi.c
+++ b/drivers/net/arcnet/arc-rimi.c
@@ -24,6 +24,9 @@
  *
  * **
  */
+
+#define pr_fmt(fmt) "arcnet:" KBUILD_MODNAME ": " fmt
+
 #include 
 #include 
 #include 
@@ -36,8 +39,6 @@
 #include 
 #include 
 
-#define VERSION "arcnet: RIM I (entirely mem-mapped) support\n"
-
 /* Internal function declarations */
 
 static int arcrimi_probe(struct net_device *dev);
@@ -83,20 +84,20 @@ static void arcrimi_copy_from_card(struct net_device *dev, 
int bufnum, int offse
 static int __init arcrimi_probe(struct net_device *dev)
 {
if (BUGLVL(D_NORMAL)) {
-   printk(VERSION);
-   printk("E-mail me if you actually test the RIM I driver, 
please!\n");
-   printk("Given: node %02Xh, shmem %lXh, irq %d\n",
-  dev->dev_addr[0], dev->mem_start, dev->irq);
+   pr_info("%s\n", "RIM I (entirely mem-mapped) support");
+   pr_info("E-mail me if you actually test the RIM I driver, 
please!\n");
+   pr_info("Given: node %02Xh, shmem %lXh, irq %d\n",
+   dev->dev_addr[0], dev->mem_start, dev->irq);
}
 
if (dev->mem_start <= 0 || dev->irq <= 0) {
if (BUGLVL(D_NORMAL))
-   printk("No autoprobe for RIM I; you must specify the 
shmem and irq!\n");
+   pr_err("No autoprobe for RIM I; you must specify the 
shmem and irq!\n");
return -ENODEV;
}
if (dev->dev_addr[0] == 0) {
if (BUGLVL(D_NORMAL))
-   printk("You need to specify your card's station ID!\n");
+   pr_err("You need to specify your card's station ID!\n");
return -ENODEV;
}
/* Grab the memory region at mem_start for MIRROR_SIZE bytes.
@@ -106,7 +107,7 @@ static int __init arcrimi_probe(struct net_device *dev)
 */
if (!request_mem_region(dev->mem_start, MIRROR_SIZE, "arcnet (90xx)")) {
if (BUGLVL(D_NORMAL))
-   printk("Card memory already allocated\n");
+   pr_notice("Card memory already allocated\n");
return -ENODEV;
}
return arcrimi_found(dev);
@@ -375,7 +376,7 @@ static int __init arcrimi_setup(char *s)
return 1;
switch (ints[0]) {
default:/* ERROR */
-   printk("arcrimi: Too many arguments.\n");
+   pr_err("Too many arguments\n");
case 3: /* Node ID */
node = ints[3];
case 2: /* IRQ */
diff --git a/drivers/net/arcnet/arcnet.c b/drivers/net/arcnet/arcnet.c
index 2

[PATCH 06/33] arcnet: Use include/linux path for asm

2015-09-22 Thread Michael Grzeschik
From: Joe Perches <j...@perches.com>

Use the preferred kernel include path for asm paths.

Signed-off-by: Joe Perches <j...@perches.com>
Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/arc-rimi.c | 2 +-
 drivers/net/arcnet/com20020-isa.c | 2 +-
 drivers/net/arcnet/com20020-pci.c | 2 +-
 drivers/net/arcnet/com20020.c | 2 +-
 drivers/net/arcnet/com20020_cs.c  | 2 +-
 drivers/net/arcnet/com90io.c  | 2 +-
 drivers/net/arcnet/com90xx.c  | 2 +-
 7 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/net/arcnet/arc-rimi.c b/drivers/net/arcnet/arc-rimi.c
index 6eedd6b..88e6157 100644
--- a/drivers/net/arcnet/arc-rimi.c
+++ b/drivers/net/arcnet/arc-rimi.c
@@ -33,7 +33,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 
 #define VERSION "arcnet: RIM I (entirely mem-mapped) support\n"
diff --git a/drivers/net/arcnet/com20020-isa.c 
b/drivers/net/arcnet/com20020-isa.c
index b8129360..d829e60 100644
--- a/drivers/net/arcnet/com20020-isa.c
+++ b/drivers/net/arcnet/com20020-isa.c
@@ -39,7 +39,7 @@
 #include 
 #include 
 
-#include 
+#include 
 
 #define VERSION "arcnet: COM20020 ISA support (by David Woodhouse et al.)\n"
 
diff --git a/drivers/net/arcnet/com20020-pci.c 
b/drivers/net/arcnet/com20020-pci.c
index 06621e9..72334b5 100644
--- a/drivers/net/arcnet/com20020-pci.c
+++ b/drivers/net/arcnet/com20020-pci.c
@@ -40,7 +40,7 @@
 #include 
 #include 
 
-#include 
+#include 
 
 #define VERSION "arcnet: COM20020 PCI support\n"
 
diff --git a/drivers/net/arcnet/com20020.c b/drivers/net/arcnet/com20020.c
index 48a45d3..bdf883f 100644
--- a/drivers/net/arcnet/com20020.c
+++ b/drivers/net/arcnet/com20020.c
@@ -37,7 +37,7 @@
 #include 
 #include 
 
-#include 
+#include 
 
 #define VERSION "arcnet: COM20020 chipset support (by David Woodhouse et 
al.)\n"
 
diff --git a/drivers/net/arcnet/com20020_cs.c b/drivers/net/arcnet/com20020_cs.c
index 532410b..437b456 100644
--- a/drivers/net/arcnet/com20020_cs.c
+++ b/drivers/net/arcnet/com20020_cs.c
@@ -45,7 +45,7 @@
 #include 
 #include 
 
-#include 
+#include 
 
 #define VERSION "arcnet: COM20020 PCMCIA support loaded.\n"
 
diff --git a/drivers/net/arcnet/com90io.c b/drivers/net/arcnet/com90io.c
index 1742fa7..3233346 100644
--- a/drivers/net/arcnet/com90io.c
+++ b/drivers/net/arcnet/com90io.c
@@ -34,7 +34,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 
 #define VERSION "arcnet: COM90xx IO-mapped mode support (by David Woodhouse et 
el.)\n"
diff --git a/drivers/net/arcnet/com90xx.c b/drivers/net/arcnet/com90xx.c
index 2e29084..0b7bc86 100644
--- a/drivers/net/arcnet/com90xx.c
+++ b/drivers/net/arcnet/com90xx.c
@@ -32,7 +32,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 
 #define VERSION "arcnet: COM90xx chipset support\n"
-- 
2.5.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 15/33] arcnet: Remove pointer comparisons to NULL

2015-09-22 Thread Michael Grzeschik
From: Joe Perches <j...@perches.com>

Use direct tests of pointer instead.

Signed-off-by: Joe Perches <j...@perches.com>
Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/arc-rawmode.c | 2 +-
 drivers/net/arcnet/capmode.c | 4 ++--
 drivers/net/arcnet/rfc1051.c | 2 +-
 drivers/net/arcnet/rfc1201.c | 4 ++--
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/arcnet/arc-rawmode.c b/drivers/net/arcnet/arc-rawmode.c
index 7fc5b042..40035ee 100644
--- a/drivers/net/arcnet/arc-rawmode.c
+++ b/drivers/net/arcnet/arc-rawmode.c
@@ -97,7 +97,7 @@ static void rx(struct net_device *dev, int bufnum,
ofs = 256 - length;
 
skb = alloc_skb(length + ARC_HDR_SIZE, GFP_ATOMIC);
-   if (skb == NULL) {
+   if (!skb) {
dev->stats.rx_dropped++;
return;
}
diff --git a/drivers/net/arcnet/capmode.c b/drivers/net/arcnet/capmode.c
index de80d9e..a898647 100644
--- a/drivers/net/arcnet/capmode.c
+++ b/drivers/net/arcnet/capmode.c
@@ -56,7 +56,7 @@ static void rx(struct net_device *dev, int bufnum,
ofs = 256 - length;
 
skb = alloc_skb(length + ARC_HDR_SIZE + sizeof(int), GFP_ATOMIC);
-   if (skb == NULL) {
+   if (!skb) {
dev->stats.rx_dropped++;
return;
}
@@ -196,7 +196,7 @@ static int ack_tx(struct net_device *dev, int acked)
 
/* Now alloc a skb to send back up through the layers: */
ackskb = alloc_skb(length + ARC_HDR_SIZE, GFP_ATOMIC);
-   if (ackskb == NULL)
+   if (!ackskb)
goto free_outskb;
 
skb_put(ackskb, length + ARC_HDR_SIZE);
diff --git a/drivers/net/arcnet/rfc1051.c b/drivers/net/arcnet/rfc1051.c
index 7e7eda5..b76e458 100644
--- a/drivers/net/arcnet/rfc1051.c
+++ b/drivers/net/arcnet/rfc1051.c
@@ -133,7 +133,7 @@ static void rx(struct net_device *dev, int bufnum,
ofs = 256 - length;
 
skb = alloc_skb(length + ARC_HDR_SIZE, GFP_ATOMIC);
-   if (skb == NULL) {
+   if (!skb) {
dev->stats.rx_dropped++;
return;
}
diff --git a/drivers/net/arcnet/rfc1201.c b/drivers/net/arcnet/rfc1201.c
index 9040a8b..1d777c1 100644
--- a/drivers/net/arcnet/rfc1201.c
+++ b/drivers/net/arcnet/rfc1201.c
@@ -178,7 +178,7 @@ static void rx(struct net_device *dev, int bufnum,
in->sequence = soft->sequence;
 
skb = alloc_skb(length + ARC_HDR_SIZE, GFP_ATOMIC);
-   if (skb == NULL) {
+   if (!skb) {
dev->stats.rx_dropped++;
return;
}
@@ -286,7 +286,7 @@ static void rx(struct net_device *dev, int bufnum,
}
in->skb = skb = alloc_skb(508 * in->numpackets + 
ARC_HDR_SIZE,
  GFP_ATOMIC);
-   if (skb == NULL) {
+   if (!skb) {
arc_printk(D_NORMAL, dev, "(split) memory 
squeeze, dropping packet.\n");
lp->rfc1201.aborted_seq = soft->sequence;
dev->stats.rx_dropped++;
-- 
2.5.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 16/33] arcnet: Convert arcnet_dump_skb macro to static inline

2015-09-22 Thread Michael Grzeschik
From: Joe Perches <j...@perches.com>

Make sure the arguments are tested appropriately when not using
this function.

Signed-off-by: Joe Perches <j...@perches.com>
Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 include/linux/arcdevice.h | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/include/linux/arcdevice.h b/include/linux/arcdevice.h
index a678027..1d8e36e 100644
--- a/include/linux/arcdevice.h
+++ b/include/linux/arcdevice.h
@@ -326,7 +326,10 @@ struct arcnet_local {
 #if ARCNET_DEBUG_MAX & D_SKB
 void arcnet_dump_skb(struct net_device *dev, struct sk_buff *skb, char *desc);
 #else
-#define arcnet_dump_skb(dev, skb, desc) ;
+static inline
+void arcnet_dump_skb(struct net_device *dev, struct sk_buff *skb, char *desc)
+{
+}
 #endif
 
 void arcnet_unregister_proto(struct ArcProto *proto);
-- 
2.5.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 17/33] arcnet: Wrap some long lines

2015-09-22 Thread Michael Grzeschik
From: Joe Perches <j...@perches.com>

Just neatening.

Signed-off-by: Joe Perches <j...@perches.com>
Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/arc-rawmode.c  |  3 ++-
 drivers/net/arcnet/arc-rimi.c | 11 ++-
 drivers/net/arcnet/arcnet.c   | 10 +++---
 drivers/net/arcnet/capmode.c  |  3 ++-
 drivers/net/arcnet/com20020-pci.c |  3 ++-
 drivers/net/arcnet/com20020.c | 14 --
 drivers/net/arcnet/com90io.c  | 31 +++
 drivers/net/arcnet/com90xx.c  | 28 +---
 drivers/net/arcnet/rfc1051.c  |  3 ++-
 drivers/net/arcnet/rfc1201.c  | 15 ++-
 include/linux/arcdevice.h | 12 ++--
 11 files changed, 81 insertions(+), 52 deletions(-)

diff --git a/drivers/net/arcnet/arc-rawmode.c b/drivers/net/arcnet/arc-rawmode.c
index 40035ee..59b3083 100644
--- a/drivers/net/arcnet/arc-rawmode.c
+++ b/drivers/net/arcnet/arc-rawmode.c
@@ -165,7 +165,8 @@ static int prepare_tx(struct net_device *dev, struct archdr 
*pkt, int length,
arc_printk(D_DURING, dev, "prepare_tx: txbufs=%d/%d/%d\n",
   lp->next_tx, lp->cur_tx, bufnum);
 
-   length -= ARC_HDR_SIZE; /* hard header is not included in packet length 
*/
+   /* hard header is not included in packet length */
+   length -= ARC_HDR_SIZE;
 
if (length > XMTU) {
/* should never happen! other people already check for this. */
diff --git a/drivers/net/arcnet/arc-rimi.c b/drivers/net/arcnet/arc-rimi.c
index 7360214..8fa5eb4 100644
--- a/drivers/net/arcnet/arc-rimi.c
+++ b/drivers/net/arcnet/arc-rimi.c
@@ -49,8 +49,8 @@ static void arcrimi_setmask(struct net_device *dev, int mask);
 static int arcrimi_reset(struct net_device *dev, int really_reset);
 static void arcrimi_copy_to_card(struct net_device *dev, int bufnum, int 
offset,
 void *buf, int count);
-static void arcrimi_copy_from_card(struct net_device *dev, int bufnum, int 
offset,
-  void *buf, int count);
+static void arcrimi_copy_from_card(struct net_device *dev, int bufnum,
+  int offset, void *buf, int count);
 
 /* Handy defines for ARCnet specific stuff */
 
@@ -215,7 +215,8 @@ static int __init arcrimi_found(struct net_device *dev)
goto err_free_irq;
}
 
-   lp->mem_start = ioremap(dev->mem_start, dev->mem_end - dev->mem_start + 
1);
+   lp->mem_start = ioremap(dev->mem_start,
+   dev->mem_end - dev->mem_start + 1);
if (!lp->mem_start) {
arc_printk(D_NORMAL, dev, "Can't remap device memory!\n");
goto err_release_mem;
@@ -307,8 +308,8 @@ static void arcrimi_copy_to_card(struct net_device *dev, 
int bufnum, int offset,
TIME(dev, "memcpy_toio", count, memcpy_toio(memaddr, buf, count));
 }
 
-static void arcrimi_copy_from_card(struct net_device *dev, int bufnum, int 
offset,
-  void *buf, int count)
+static void arcrimi_copy_from_card(struct net_device *dev, int bufnum,
+  int offset, void *buf, int count)
 {
struct arcnet_local *lp = netdev_priv(dev);
void __iomem *memaddr = lp->mem_start + 0x800 + bufnum * 512 + offset;
diff --git a/drivers/net/arcnet/arcnet.c b/drivers/net/arcnet/arcnet.c
index a9535ec..00074e7 100644
--- a/drivers/net/arcnet/arcnet.c
+++ b/drivers/net/arcnet/arcnet.c
@@ -759,7 +759,8 @@ irqreturn_t arcnet_interrupt(int irq, void *dev_id)
if ((status & lp->intmask & TXFREEflag) || lp->timed_out) {
lp->intmask &= ~(TXFREEflag | EXCNAKflag);
 
-   arc_printk(D_DURING, dev, "TX IRQ (stat=%Xh)\n", 
status);
+   arc_printk(D_DURING, dev, "TX IRQ (stat=%Xh)\n",
+  status);
 
if (lp->cur_tx != -1 && !lp->timed_out) {
if (!(status & TXACKflag)) {
@@ -804,7 +805,8 @@ irqreturn_t arcnet_interrupt(int irq, void *dev_id)
go_tx(dev);
 
/* continue a split packet, if any */
-   if (lp->outgoing.proto && 
lp->outgoing.proto->continue_tx) {
+   if (lp->outgoing.proto &&
+   lp->outgoing.proto->continue_tx) {
int txbuf = get_arcbuf(dev);
 
if (txbuf != -1) {
@@ -874,7 +876,9 @@ irqreturn_t arcnet_interrupt(int irq, void *dev_id)
arc_printk(D_NORMAL, dev, "many 
reconfigurations detected: cabling problem?\n");
} else if (!l

[PATCH 23/33] arcnet: com90xx: Use arcnet_ routines

2015-09-22 Thread Michael Grzeschik
From: Joe Perches <j...@perches.com>

Simplify and make consistent the current uses of inb/outb
by using the newly introduced arcnet_ equivalents.

o Add new #defines for register offsets
o Remove old #defines that included the ioaddr
o Remove obfuscating macros by expanding them in-place where appropriate

Signed-off-by: Joe Perches <j...@perches.com>
Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/com90xx.c | 67 ++--
 1 file changed, 33 insertions(+), 34 deletions(-)

diff --git a/drivers/net/arcnet/com90xx.c b/drivers/net/arcnet/com90xx.c
index b672795..f1cfeb0 100644
--- a/drivers/net/arcnet/com90xx.c
+++ b/drivers/net/arcnet/com90xx.c
@@ -79,22 +79,14 @@ static int numcards;
 #define MIRROR_SIZE (BUFFER_SIZE * 4)
 
 /* COM 9026 controller chip --> ARCnet register addresses */
-#define _INTMASK   (ioaddr + 0)/* writable */
-#define _STATUS(ioaddr + 0)/* readable */
-#define _COMMAND   (ioaddr + 1)/* writable, returns random vals on 
read (?) */
-#define _CONFIG(ioaddr + 2)/* Configuration register */
-#define _RESET (ioaddr + 8)/* software reset (on read) */
-#define _MEMDATA   (ioaddr + 12)   /* Data port for IO-mapped memory */
-#define _ADDR_HI   (ioaddr + 15)   /* Control registers for said */
-#define _ADDR_LO   (ioaddr + 14)
-
-#undef ASTATUS
-#undef ACOMMAND
-#undef AINTMASK
-
-#define ASTATUS()  inb(_STATUS)
-#define ACOMMAND(cmd)  outb((cmd), _COMMAND)
-#define AINTMASK(msk)  outb((msk), _INTMASK)
+#define COM9026_REG_W_INTMASK  0   /* writable */
+#define COM9026_REG_R_STATUS   0   /* readable */
+#define COM9026_REG_W_COMMAND  1   /* writable, returns random vals on 
read (?) */
+#define COM9026_REG_RW_CONFIG  2   /* Configuration register */
+#define COM9026_REG_R_RESET8   /* software reset (on read) */
+#define COM9026_REG_RW_MEMDATA 12  /* Data port for IO-mapped memory */
+#define COM9026_REG_W_ADDR_LO  14  /* Control registers for said */
+#define COM9026_REG_W_ADDR_HI  15
 
 static int com90xx_skip_probe __initdata = 0;
 
@@ -175,7 +167,7 @@ static void __init com90xx_probe(void)
*port-- = ports[--numports];
continue;
}
-   if (ASTATUS() == 0xFF) {
+   if (arcnet_inb(ioaddr, COM9026_REG_R_STATUS) == 0xFF) {
arc_cont(D_INIT_REASONS, "(empty)\n");
arc_cont(D_INIT_REASONS, "S1: ");
if (BUGLVL(D_INIT_REASONS))
@@ -184,7 +176,8 @@ static void __init com90xx_probe(void)
*port-- = ports[--numports];
continue;
}
-   inb(_RESET);/* begin resetting card */
+   /* begin resetting card */
+   arcnet_inb(ioaddr, COM9026_REG_R_RESET);
 
arc_cont(D_INIT_REASONS, "\n");
arc_cont(D_INIT_REASONS, "S1: ");
@@ -324,7 +317,7 @@ static void __init com90xx_probe(void)
arc_cont(D_INIT, "%Xh ", *port);
 
ioaddr = *port;
-   status = ASTATUS();
+   status = arcnet_inb(ioaddr, COM9026_REG_R_STATUS);
 
if ((status & 0x9D)
!= (NORXflag | RECONflag | TXFREEflag | RESETflag)) {
@@ -336,8 +329,9 @@ static void __init com90xx_probe(void)
*port-- = ports[--numports];
continue;
}
-   ACOMMAND(CFLAGScmd | RESETclear | CONFIGclear);
-   status = ASTATUS();
+   arcnet_outb(CFLAGScmd | RESETclear | CONFIGclear,
+   ioaddr, COM9026_REG_W_COMMAND);
+   status = arcnet_inb(ioaddr, COM9026_REG_R_STATUS);
if (status & RESETflag) {
arc_cont(D_INIT_REASONS, " (eternal reset, 
status=%Xh)\n",
 status);
@@ -357,9 +351,9 @@ static void __init com90xx_probe(void)
 * we tell it to start receiving.
 */
airqmask = probe_irq_on();
-   AINTMASK(NORXflag);
+   arcnet_outb(NORXflag, ioaddr, COM9026_REG_W_INTMASK);
udelay(1);
-   AINTMASK(0);
+   arcnet_outb(0, ioaddr, COM9026_REG_W_INTMASK);
airq = probe_irq_off(airqmask);
 
if (airq <= 0) {
@@ -386,14 +380,14 @@ static void __init com90xx_probe(void)
 */
 #ifdef FAST_PROBE
if (numports > 1 || numshmems > 1) {
-   inb(_RESET);
+   arcnet_inb(ioaddr, COM9026_REG_R_RESET);
mdelay(RESETtim

[PATCH 31/33] arcnet: com20020: replace magic numbers with readable macros

2015-09-22 Thread Michael Grzeschik
This patch replaces all magic numbers in the driver with
proper named macros. For the case of XTOcfg and STARTIOcmd
it introduces the new macros.

Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/arcdevice.h |  1 +
 drivers/net/arcnet/com20020.c  | 17 +
 drivers/net/arcnet/com20020.h  |  1 +
 3 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/net/arcnet/arcdevice.h b/drivers/net/arcnet/arcdevice.h
index 4c1c44c..d7fdea1 100644
--- a/drivers/net/arcnet/arcdevice.h
+++ b/drivers/net/arcnet/arcdevice.h
@@ -164,6 +164,7 @@ do {
\
 #define CONFIGcmd   0x05   /* define configuration */
 #define CFLAGScmd   0x06   /* clear flags */
 #define TESTcmd 0x07   /* load test flags */
+#define STARTIOcmd  0x18   /* start internal operation */
 
 /* flags for "clear flags" command */
 #define RESETclear  0x08   /* power-on-reset */
diff --git a/drivers/net/arcnet/com20020.c b/drivers/net/arcnet/com20020.c
index d416275..c82f323 100644
--- a/drivers/net/arcnet/com20020.c
+++ b/drivers/net/arcnet/com20020.c
@@ -94,9 +94,9 @@ int com20020_check(struct net_device *dev)
int ioaddr = dev->base_addr, status;
struct arcnet_local *lp = netdev_priv(dev);
 
-   arcnet_outb(0x18 | 0x80, ioaddr, COM20020_REG_W_CONFIG);
+   arcnet_outb(XTOcfg(3) | RESETcfg, ioaddr, COM20020_REG_W_CONFIG);
udelay(5);
-   arcnet_outb(0x18 , ioaddr, COM20020_REG_W_CONFIG);
+   arcnet_outb(XTOcfg(3), ioaddr, COM20020_REG_W_CONFIG);
mdelay(RESETtime);
 
lp->setup = lp->clockm ? 0 : (lp->clockp << 1);
@@ -115,10 +115,10 @@ int com20020_check(struct net_device *dev)
 
/* must now write the magic "restart operation" command */
mdelay(1);
-   arcnet_outb(0x18, ioaddr, COM20020_REG_W_COMMAND);
+   arcnet_outb(STARTIOcmd, ioaddr, COM20020_REG_W_COMMAND);
}
 
-   lp->config = 0x21 | (lp->timeout << 3) | (lp->backplane << 2);
+   lp->config = TXENcfg | (lp->timeout << 3) | (lp->backplane << 2) | 
SUB_NODE;
/* set node ID to 0x42 (but transmitter is disabled, so it's okay) */
arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
arcnet_outb(0x42, ioaddr, COM20020_REG_W_XREG);
@@ -132,7 +132,8 @@ int com20020_check(struct net_device *dev)
arc_printk(D_INIT_REASONS, dev, "status after reset: %X\n", status);
 
/* Enable TX */
-   arcnet_outb(0x39, ioaddr, COM20020_REG_W_CONFIG);
+   lp->config |= TXENcfg;
+   arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
arcnet_outb(arcnet_inb(ioaddr, 8), ioaddr, COM20020_REG_W_XREG);
 
arcnet_outb(CFLAGScmd | RESETclear | CONFIGclear,
@@ -211,10 +212,10 @@ int com20020_found(struct net_device *dev, int shared)
 
/* must now write the magic "restart operation" command */
mdelay(1);
-   arcnet_outb(0x18, ioaddr, COM20020_REG_W_COMMAND);
+   arcnet_outb(STARTIOcmd, ioaddr, COM20020_REG_W_COMMAND);
}
 
-   lp->config = 0x20 | (lp->timeout << 3) | (lp->backplane << 2) | 1;
+   lp->config = TXENcfg | (lp->timeout << 3) | (lp->backplane << 2) | 
SUB_NODE;
/* Default 0x38 + register: Node ID */
arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
arcnet_outb(dev->dev_addr[0], ioaddr, COM20020_REG_W_XREG);
@@ -280,7 +281,7 @@ static int com20020_reset(struct net_device *dev, int 
really_reset)
 
if (really_reset) {
/* reset the card */
-   arcnet_outb(lp->config | 0x80, ioaddr, COM20020_REG_W_CONFIG);
+   arcnet_outb(lp->config | RESETcfg, ioaddr, 
COM20020_REG_W_CONFIG);
udelay(5);
arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
mdelay(RESETtime * 2);
diff --git a/drivers/net/arcnet/com20020.h b/drivers/net/arcnet/com20020.h
index ffb1946..22a460f 100644
--- a/drivers/net/arcnet/com20020.h
+++ b/drivers/net/arcnet/com20020.h
@@ -86,6 +86,7 @@ struct com20020_dev {
 /* in the CONFIG register */
 #define RESETcfg   0x80/* put card in reset state */
 #define TXENcfg0x20/* enable TX */
+#define XTOcfg(x)  ((x) << 3)  /* extended timeout */
 
 /* in SETUP register */
 #define PROMISCset 0x10/* enable RCV_ALL */
-- 
2.5.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 22/33] arcnet: com90io: Use arcnet_ routines

2015-09-22 Thread Michael Grzeschik
From: Joe Perches <j...@perches.com>

Simplify and make consistent the current uses of inb/outb
by using the newly introduced arcnet_ equivalents.

o Add new #defines for register offsets
o Remove old #defines that included the ioaddr
o Remove obfuscating macros by expanding them in-place where appropriate

Signed-off-by: Joe Perches <j...@perches.com>
Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/com90io.c | 101 ---
 1 file changed, 48 insertions(+), 53 deletions(-)

diff --git a/drivers/net/arcnet/com90io.c b/drivers/net/arcnet/com90io.c
index ce15d191..7e084f1 100644
--- a/drivers/net/arcnet/com90io.c
+++ b/drivers/net/arcnet/com90io.c
@@ -59,23 +59,14 @@ static void com90io_copy_from_card(struct net_device *dev, 
int bufnum,
 #define ARCNET_TOTAL_SIZE 16
 
 /* COM 9026 controller chip --> ARCnet register addresses */
-#define _INTMASK   (ioaddr + 0)/* writable */
-#define _STATUS(ioaddr + 0)/* readable */
-#define _COMMAND   (ioaddr + 1)/* writable, returns random vals on 
read (?) */
-#define _RESET (ioaddr + 8)/* software reset (on read) */
-#define _MEMDATA   (ioaddr + 12)   /* Data port for IO-mapped memory */
-#define _ADDR_HI   (ioaddr + 15)   /* Control registers for said */
-#define _ADDR_LO   (ioaddr + 14)
-#define _CONFIG(ioaddr + 2)/* Configuration register */
-
-#undef ASTATUS
-#undef ACOMMAND
-#undef AINTMASK
-
-#define ASTATUS()  inb(_STATUS)
-#define ACOMMAND(cmd)  outb((cmd), _COMMAND)
-#define AINTMASK(msk)  outb((msk), _INTMASK)
-#define SETCONF()  outb((lp->config), _CONFIG)
+#define COM9026_REG_W_INTMASK  0   /* writable */
+#define COM9026_REG_R_STATUS   0   /* readable */
+#define COM9026_REG_W_COMMAND  1   /* writable, returns random vals on 
read (?) */
+#define COM9026_REG_RW_CONFIG  2   /* Configuration register */
+#define COM9026_REG_R_RESET8   /* software reset (on read) */
+#define COM9026_REG_RW_MEMDATA 12  /* Data port for IO-mapped memory */
+#define COM9026_REG_W_ADDR_LO  14  /* Control registers for said */
+#define COM9026_REG_W_ADDR_HI  15
 
 /
  *  *
@@ -90,10 +81,10 @@ static u_char get_buffer_byte(struct net_device *dev, 
unsigned offset)
 {
int ioaddr = dev->base_addr;
 
-   outb(offset >> 8, _ADDR_HI);
-   outb(offset & 0xff, _ADDR_LO);
+   arcnet_outb(offset >> 8, ioaddr, COM9026_REG_W_ADDR_HI);
+   arcnet_outb(offset & 0xff, ioaddr, COM9026_REG_W_ADDR_LO);
 
-   return inb(_MEMDATA);
+   return arcnet_inb(ioaddr, COM9026_REG_RW_MEMDATA);
 }
 
 #ifdef ONE_AT_A_TIME_TX
@@ -102,10 +93,10 @@ static void put_buffer_byte(struct net_device *dev, 
unsigned offset,
 {
int ioaddr = dev->base_addr;
 
-   outb(offset >> 8, _ADDR_HI);
-   outb(offset & 0xff, _ADDR_LO);
+   arcnet_outb(offset >> 8, ioaddr, COM9026_REG_W_ADDR_HI);
+   arcnet_outb(offset & 0xff, ioaddr, COM9026_REG_W_ADDR_LO);
 
-   outb(datum, _MEMDATA);
+   arcnet_outb(datum, ioaddr, COM9026_REG_RW_MEMDATA);
 }
 
 #endif
@@ -115,14 +106,14 @@ static void get_whole_buffer(struct net_device *dev, 
unsigned offset,
 {
int ioaddr = dev->base_addr;
 
-   outb((offset >> 8) | AUTOINCflag, _ADDR_HI);
-   outb(offset & 0xff, _ADDR_LO);
+   arcnet_outb((offset >> 8) | AUTOINCflag, ioaddr, COM9026_REG_W_ADDR_HI);
+   arcnet_outb(offset & 0xff, ioaddr, COM9026_REG_W_ADDR_LO);
 
while (length--)
 #ifdef ONE_AT_A_TIME_RX
*(dest++) = get_buffer_byte(dev, offset++);
 #else
-   *(dest++) = inb(_MEMDATA);
+   *(dest++) = arcnet_inb(ioaddr, COM9026_REG_RW_MEMDATA);
 #endif
 }
 
@@ -131,14 +122,14 @@ static void put_whole_buffer(struct net_device *dev, 
unsigned offset,
 {
int ioaddr = dev->base_addr;
 
-   outb((offset >> 8) | AUTOINCflag, _ADDR_HI);
-   outb(offset & 0xff, _ADDR_LO);
+   arcnet_outb((offset >> 8) | AUTOINCflag, ioaddr, COM9026_REG_W_ADDR_HI);
+   arcnet_outb(offset & 0xff, ioaddr,COM9026_REG_W_ADDR_LO);
 
while (length--)
 #ifdef ONE_AT_A_TIME_TX
put_buffer_byte(dev, offset++, *(dest++));
 #else
-   outb(*(dest++), _MEMDATA);
+   arcnet_outb(*(dest++), ioaddr, COM9026_REG_RW_MEMDATA);
 #endif
 }
 
@@ -164,15 +155,15 @@ static int __init com90io_probe(struct net_device *dev)
   ioaddr, ioaddr + ARCNET_TOTAL_SIZE - 1);
return -ENXIO;
}
-   if (ASTATUS() == 0xFF) {
+   if (arcnet_inb(ioaddr, COM9026_REG_R_STATUS) == 0xFF) {
arc_printk(D_INIT_REASONS, dev, &qu

[PATCH 07/33] arcnet: Use network block comment style

2015-09-22 Thread Michael Grzeschik
From: Joe Perches <j...@perches.com>

Conformity can be useful.

Signed-off-by: Joe Perches <j...@perches.com>
Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/arc-rawmode.c  | 15 
 drivers/net/arcnet/arc-rimi.c | 17 -
 drivers/net/arcnet/arcnet.c   | 76 ---
 drivers/net/arcnet/capmode.c  | 25 +++--
 drivers/net/arcnet/com20020-isa.c |  3 +-
 drivers/net/arcnet/com20020.c |  3 +-
 drivers/net/arcnet/com20020_cs.c  |  3 +-
 drivers/net/arcnet/com90io.c  |  9 ++---
 drivers/net/arcnet/com90xx.c  |  3 +-
 drivers/net/arcnet/rfc1051.c  | 19 --
 drivers/net/arcnet/rfc1201.c  | 54 ++--
 11 files changed, 95 insertions(+), 132 deletions(-)

diff --git a/drivers/net/arcnet/arc-rawmode.c b/drivers/net/arcnet/arc-rawmode.c
index 500b5bb..efdd8e9 100644
--- a/drivers/net/arcnet/arc-rawmode.c
+++ b/drivers/net/arcnet/arc-rawmode.c
@@ -123,8 +123,7 @@ static void rx(struct net_device *dev, int bufnum,
netif_rx(skb);
 }
 
-/*
- * Create the ARCnet hard/soft headers for raw mode.
+/* Create the ARCnet hard/soft headers for raw mode.
  * There aren't any soft headers in raw mode - not even the protocol id.
  */
 static int build_header(struct sk_buff *skb, struct net_device *dev,
@@ -133,21 +132,19 @@ static int build_header(struct sk_buff *skb, struct 
net_device *dev,
int hdr_size = ARC_HDR_SIZE;
struct archdr *pkt = (struct archdr *)skb_push(skb, hdr_size);
 
-   /*
-* Set the source hardware address.
+   /* Set the source hardware address.
 *
 * This is pretty pointless for most purposes, but it can help in
-* debugging.  ARCnet does not allow us to change the source address in
-* the actual packet sent)
+* debugging.  ARCnet does not allow us to change the source address
+* in the actual packet sent.
 */
pkt->hard.source = *dev->dev_addr;
 
/* see linux/net/ethernet/eth.c to see where I got the following */
 
if (dev->flags & (IFF_LOOPBACK | IFF_NOARP)) {
-   /*
-* FIXME: fill in the last byte of the dest ipaddr here to 
better
-* comply with RFC1051 in "noarp" mode.
+   /* FIXME: fill in the last byte of the dest ipaddr here
+* to better comply with RFC1051 in "noarp" mode.
 */
pkt->hard.dest = 0;
return hdr_size;
diff --git a/drivers/net/arcnet/arc-rimi.c b/drivers/net/arcnet/arc-rimi.c
index 88e6157..c7ab23e 100644
--- a/drivers/net/arcnet/arc-rimi.c
+++ b/drivers/net/arcnet/arc-rimi.c
@@ -76,8 +76,7 @@ static void arcrimi_copy_from_card(struct net_device *dev, 
int bufnum, int offse
 #define AINTMASK(msk)  writeb((msk), _INTMASK)
 #define SETCONF()  writeb(lp->config, _CONFIG)
 
-/*
- * We cannot probe for a RIM I card; one reason is I don't know how to reset
+/* We cannot probe for a RIM I card; one reason is I don't know how to reset
  * them.  In fact, we can't even get their node ID automatically.  So, we
  * need to be passed a specific shmem address, IRQ, and node ID.
  */
@@ -97,8 +96,7 @@ static int __init arcrimi_probe(struct net_device *dev)
BUGLVL(D_NORMAL) printk("You need to specify your card's 
station ID!\n");
return -ENODEV;
}
-   /*
-* Grab the memory region at mem_start for MIRROR_SIZE bytes.
+   /* Grab the memory region at mem_start for MIRROR_SIZE bytes.
 * Later in arcrimi_found() the real size will be determined
 * and this reserve will be released and the correct size
 * will be taken.
@@ -131,9 +129,8 @@ static int check_mirror(unsigned long addr, size_t size)
return res;
 }
 
-/*
- * Set up the struct net_device associated with this card.  Called after
- * probing succeeds.
+/* Set up the struct net_device associated with this card.
+ * Called after probing succeeds.
  */
 static int __init arcrimi_found(struct net_device *dev)
 {
@@ -199,8 +196,7 @@ static int __init arcrimi_found(struct net_device *dev)
lp->hw.copy_to_card = arcrimi_copy_to_card;
lp->hw.copy_from_card = arcrimi_copy_from_card;
 
-   /*
-* re-reserve the memory region - arcrimi_probe() alloced this reqion
+   /* re-reserve the memory region - arcrimi_probe() alloced this reqion
 * but didn't know the real size.  Free that region and then re-get
 * with the correct size.  There is a VERY slim chance this could
 * fail.
@@ -243,8 +239,7 @@ err_free_irq:
return -EIO;
 }
 
-/*
- * Do a hardware reset on the card, and set up necessary registers.
+/* Do a hardware reset on the card, and set up necessary registers.
  *
  * This should be called as little as possible, because it disrupts the
  * token on 

[PATCH 03/33] arcnet: Add and remove blank lines

2015-09-22 Thread Michael Grzeschik
From: Joe Perches <j...@perches.com>

Use a more current kernel line style.

Signed-off-by: Joe Perches <j...@perches.com>
Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/arc-rawmode.c  |  5 -
 drivers/net/arcnet/arc-rimi.c |  8 +++-
 drivers/net/arcnet/arcnet.c   | 23 +++
 drivers/net/arcnet/capmode.c  |  3 ---
 drivers/net/arcnet/com20020-isa.c |  1 -
 drivers/net/arcnet/com20020-pci.c |  2 --
 drivers/net/arcnet/com20020.c |  8 ++--
 drivers/net/arcnet/com20020_cs.c  |  4 +---
 drivers/net/arcnet/com90io.c  | 12 +---
 drivers/net/arcnet/com90xx.c  | 13 +++--
 drivers/net/arcnet/rfc1051.c  |  7 ---
 drivers/net/arcnet/rfc1201.c  |  8 
 include/linux/arcdevice.h | 12 
 13 files changed, 13 insertions(+), 93 deletions(-)

diff --git a/drivers/net/arcnet/arc-rawmode.c b/drivers/net/arcnet/arc-rawmode.c
index 49f5819..251a98b 100644
--- a/drivers/net/arcnet/arc-rawmode.c
+++ b/drivers/net/arcnet/arc-rawmode.c
@@ -35,7 +35,6 @@
 
 #define VERSION "arcnet: raw mode (`r') encapsulation support loaded.\n"
 
-
 static void rx(struct net_device *dev, int bufnum,
   struct archdr *pkthdr, int length);
 static int build_header(struct sk_buff *skb, struct net_device *dev,
@@ -54,7 +53,6 @@ static struct ArcProto rawmode_proto =
.ack_tx = NULL
 };
 
-
 static int __init arcnet_raw_init(void)
 {
int count;
@@ -83,7 +81,6 @@ module_exit(arcnet_raw_exit);
 
 MODULE_LICENSE("GPL");
 
-
 /* packet receiver */
 static void rx(struct net_device *dev, int bufnum,
   struct archdr *pkthdr, int length)
@@ -127,7 +124,6 @@ static void rx(struct net_device *dev, int bufnum,
netif_rx(skb);
 }
 
-
 /*
  * Create the ARCnet hard/soft headers for raw mode.
  * There aren't any soft headers in raw mode - not even the protocol id.
@@ -163,7 +159,6 @@ static int build_header(struct sk_buff *skb, struct 
net_device *dev,
return hdr_size;/* success */
 }
 
-
 static int prepare_tx(struct net_device *dev, struct archdr *pkt, int length,
  int bufnum)
 {
diff --git a/drivers/net/arcnet/arc-rimi.c b/drivers/net/arcnet/arc-rimi.c
index 4644d46..e8c1501 100644
--- a/drivers/net/arcnet/arc-rimi.c
+++ b/drivers/net/arcnet/arc-rimi.c
@@ -36,10 +36,8 @@
 #include 
 #include 
 
-
 #define VERSION "arcnet: RIM I (entirely mem-mapped) support\n"
 
-
 /* Internal function declarations */
 
 static int arcrimi_probe(struct net_device *dev);
@@ -78,7 +76,6 @@ static void arcrimi_copy_from_card(struct net_device *dev, 
int bufnum, int offse
 #define AINTMASK(msk)  writeb((msk), _INTMASK)
 #define SETCONF()  writeb(lp->config, _CONFIG)
 
-
 /*
  * We cannot probe for a RIM I card; one reason is I don't know how to reset
  * them.  In fact, we can't even get their node ID automatically.  So, we
@@ -249,7 +246,6 @@ err_free_irq:
return -EIO;
 }
 
-
 /*
  * Do a hardware reset on the card, and set up necessary registers.
  *
@@ -308,15 +304,16 @@ static void arcrimi_copy_to_card(struct net_device *dev, 
int bufnum, int offset,
 {
struct arcnet_local *lp = netdev_priv(dev);
void __iomem *memaddr = lp->mem_start + 0x800 + bufnum * 512 + offset;
+
TIME("memcpy_toio", count, memcpy_toio(memaddr, buf, count));
 }
 
-
 static void arcrimi_copy_from_card(struct net_device *dev, int bufnum, int 
offset,
   void *buf, int count)
 {
struct arcnet_local *lp = netdev_priv(dev);
void __iomem *memaddr = lp->mem_start + 0x800 + bufnum * 512 + offset;
+
TIME("memcpy_fromio", count, memcpy_fromio(buf, memaddr, count));
 }
 
@@ -374,6 +371,7 @@ static void __exit arc_rimi_exit(void)
 static int __init arcrimi_setup(char *s)
 {
int ints[8];
+
s = get_options(s, 8, ints);
if (!ints[0])
return 1;
diff --git a/drivers/net/arcnet/arcnet.c b/drivers/net/arcnet/arcnet.c
index 2a594d1..bb49753 100644
--- a/drivers/net/arcnet/arcnet.c
+++ b/drivers/net/arcnet/arcnet.c
@@ -168,7 +168,6 @@ void arcnet_dump_skb(struct net_device *dev,
 EXPORT_SYMBOL(arcnet_dump_skb);
 #endif
 
-
 /*
  * Dump the contents of an ARCnet buffer
  */
@@ -206,7 +205,6 @@ static void arcnet_dump_packet(struct net_device *dev, int 
bufnum,
 
 #endif
 
-
 /*
  * Unregister a protocol driver from the arc_proto_map.  Protocol drivers
  * are responsible for registering themselves, but the unregister routine
@@ -229,7 +227,6 @@ void arcnet_unregister_proto(struct ArcProto *proto)
}
 }
 
-
 /*
  * Add a buffer to the queue.  Only the interrupt handler is allowed to do
  * this, unless interrupts are disabled.
@@ -254,7 +251,6 @@ static void release_arcbuf(struct net_device *dev, int 
bufnum)
}
 }
 
-
 /*
  * Get a buffer from the queue.  If this returns -1, 

[PATCH 33/33] arcnet: capmode: remove extra function

2015-09-22 Thread Michael Grzeschik
This patch cleans the capmode protocol module. It removes the obsolete
function arcnet_cap_init and replaces printk with pr_info.

Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/capmode.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/net/arcnet/capmode.c b/drivers/net/arcnet/capmode.c
index 8297e00..37d842b 100644
--- a/drivers/net/arcnet/capmode.c
+++ b/drivers/net/arcnet/capmode.c
@@ -238,10 +238,12 @@ static struct ArcProto capmode_proto = {
.ack_tx = ack_tx
 };
 
-static void arcnet_cap_init(void)
+static int __init capmode_module_init(void)
 {
int count;
 
+   pr_info("%s\n", "cap mode (`c') encapsulation support loaded");
+
for (count = 1; count <= 8; count++)
if (arc_proto_map[count] == arc_proto_default)
arc_proto_map[count] = _proto;
@@ -252,12 +254,7 @@ static void arcnet_cap_init(void)
 
arc_proto_default = _proto;
arc_raw_proto = _proto;
-}
 
-static int __init capmode_module_init(void)
-{
-   pr_info("%s\n", "cap mode (`c') encapsulation support loaded");
-   arcnet_cap_init();
return 0;
 }
 
-- 
2.5.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 10/33] arcnet: Convert BUGMSG and BUGMSG2 to arc_prink and arc_cont

2015-09-22 Thread Michael Grzeschik
From: Joe Perches <j...@perches.com>

These macros don't actually represent BUG uses but are more commonly
used as logging macros, so use a more kernel style macro.

Convert the BUGMSG from a netdev_ like use to actually use netdev_.

Signed-off-by: Joe Perches <j...@perches.com>
Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/arc-rawmode.c  |  16 +--
 drivers/net/arcnet/arc-rimi.c |  24 +++--
 drivers/net/arcnet/arcnet.c   | 212 --
 drivers/net/arcnet/capmode.c  |  35 ---
 drivers/net/arcnet/com20020-isa.c |  15 +--
 drivers/net/arcnet/com20020-pci.c |   2 +-
 drivers/net/arcnet/com20020.c |  64 ++--
 drivers/net/arcnet/com90io.c  |  43 
 drivers/net/arcnet/com90xx.c  | 119 ++---
 drivers/net/arcnet/rfc1051.c  |  16 +--
 drivers/net/arcnet/rfc1201.c  | 104 ++-
 include/linux/arcdevice.h |  32 +++---
 12 files changed, 355 insertions(+), 327 deletions(-)

diff --git a/drivers/net/arcnet/arc-rawmode.c b/drivers/net/arcnet/arc-rawmode.c
index 998c835..034c898 100644
--- a/drivers/net/arcnet/arc-rawmode.c
+++ b/drivers/net/arcnet/arc-rawmode.c
@@ -89,7 +89,7 @@ static void rx(struct net_device *dev, int bufnum,
struct archdr *pkt = pkthdr;
int ofs;
 
-   BUGMSG(D_DURING, "it's a raw packet (length=%d)\n", length);
+   arc_printk(D_DURING, dev, "it's a raw packet (length=%d)\n", length);
 
if (length > MTU)
ofs = 512 - length;
@@ -98,7 +98,7 @@ static void rx(struct net_device *dev, int bufnum,
 
skb = alloc_skb(length + ARC_HDR_SIZE, GFP_ATOMIC);
if (skb == NULL) {
-   BUGMSG(D_NORMAL, "Memory squeeze, dropping packet.\n");
+   arc_printk(D_NORMAL, dev, "Memory squeeze, dropping packet\n");
dev->stats.rx_dropped++;
return;
}
@@ -163,15 +163,15 @@ static int prepare_tx(struct net_device *dev, struct 
archdr *pkt, int length,
struct arc_hardware *hard = >hard;
int ofs;
 
-   BUGMSG(D_DURING, "prepare_tx: txbufs=%d/%d/%d\n",
-  lp->next_tx, lp->cur_tx, bufnum);
+   arc_printk(D_DURING, dev, "prepare_tx: txbufs=%d/%d/%d\n",
+  lp->next_tx, lp->cur_tx, bufnum);
 
length -= ARC_HDR_SIZE; /* hard header is not included in packet length 
*/
 
if (length > XMTU) {
/* should never happen! other people already check for this. */
-   BUGMSG(D_NORMAL, "Bug!  prepare_tx with size %d (> %d)\n",
-  length, XMTU);
+   arc_printk(D_NORMAL, dev, "Bug!  prepare_tx with size %d (> 
%d)\n",
+  length, XMTU);
length = XMTU;
}
if (length >= MinTU) {
@@ -184,8 +184,8 @@ static int prepare_tx(struct net_device *dev, struct archdr 
*pkt, int length,
hard->offset[0] = ofs = 256 - length;
}
 
-   BUGMSG(D_DURING, "prepare_tx: length=%d ofs=%d\n",
-  length, ofs);
+   arc_printk(D_DURING, dev, "prepare_tx: length=%d ofs=%d\n",
+  length, ofs);
 
lp->hw.copy_to_card(dev, bufnum, 0, hard, ARC_HDR_SIZE);
lp->hw.copy_to_card(dev, bufnum, ofs, >soft, length);
diff --git a/drivers/net/arcnet/arc-rimi.c b/drivers/net/arcnet/arc-rimi.c
index cd47a1b..25f84b7 100644
--- a/drivers/net/arcnet/arc-rimi.c
+++ b/drivers/net/arcnet/arc-rimi.c
@@ -147,7 +147,7 @@ static int __init arcrimi_found(struct net_device *dev)
p = ioremap(dev->mem_start, MIRROR_SIZE);
if (!p) {
release_mem_region(dev->mem_start, MIRROR_SIZE);
-   BUGMSG(D_NORMAL, "Can't ioremap\n");
+   arc_printk(D_NORMAL, dev, "Can't ioremap\n");
return -ENODEV;
}
 
@@ -155,7 +155,7 @@ static int __init arcrimi_found(struct net_device *dev)
if (request_irq(dev->irq, arcnet_interrupt, 0, "arcnet (RIM I)", dev)) {
iounmap(p);
release_mem_region(dev->mem_start, MIRROR_SIZE);
-   BUGMSG(D_NORMAL, "Can't get IRQ %d!\n", dev->irq);
+   arc_printk(D_NORMAL, dev, "Can't get IRQ %d!\n", dev->irq);
return -ENODEV;
}
 
@@ -210,23 +210,24 @@ static int __init arcrimi_found(struct net_device *dev)
if (!request_mem_region(dev->mem_start,
dev->mem_end - dev->mem_start + 1,
"arcnet (90xx)")) {
-   BUGMSG(D_NORMAL, "Card memory already allocated\n");
+   arc_printk(D_NORMAL, dev, "Card memory already allocated\n");
goto err_f

[PATCH 04/33] arcnet: Use normal kernel brace style

2015-09-22 Thread Michael Grzeschik
From: Joe Perches <j...@perches.com>

Move braces normal kernel locations.
Add missing braces.

Signed-off-by: Joe Perches <j...@perches.com>
Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/arc-rawmode.c |  6 +++---
 drivers/net/arcnet/arcnet.c  | 38 +++---
 drivers/net/arcnet/capmode.c |  6 +++---
 drivers/net/arcnet/com20020.c| 15 +++
 drivers/net/arcnet/com20020_cs.c | 31 +++
 drivers/net/arcnet/com90xx.c |  3 +--
 drivers/net/arcnet/rfc1051.c | 10 +-
 drivers/net/arcnet/rfc1201.c | 14 +++---
 8 files changed, 52 insertions(+), 71 deletions(-)

diff --git a/drivers/net/arcnet/arc-rawmode.c b/drivers/net/arcnet/arc-rawmode.c
index 251a98b..500b5bb 100644
--- a/drivers/net/arcnet/arc-rawmode.c
+++ b/drivers/net/arcnet/arc-rawmode.c
@@ -42,8 +42,7 @@ static int build_header(struct sk_buff *skb, struct 
net_device *dev,
 static int prepare_tx(struct net_device *dev, struct archdr *pkt, int length,
  int bufnum);
 
-static struct ArcProto rawmode_proto =
-{
+static struct ArcProto rawmode_proto = {
.suffix = 'r',
.mtu= XMTU,
.rx = rx,
@@ -183,8 +182,9 @@ static int prepare_tx(struct net_device *dev, struct archdr 
*pkt, int length,
} else if (length > MTU) {
hard->offset[0] = 0;
hard->offset[1] = ofs = 512 - length - 3;
-   } else
+   } else {
hard->offset[0] = ofs = 256 - length;
+   }
 
BUGMSG(D_DURING, "prepare_tx: length=%d ofs=%d\n",
   length, ofs);
diff --git a/drivers/net/arcnet/arcnet.c b/drivers/net/arcnet/arcnet.c
index bb49753..24c0a64 100644
--- a/drivers/net/arcnet/arcnet.c
+++ b/drivers/net/arcnet/arcnet.c
@@ -72,8 +72,7 @@ static void arcnet_rx(struct net_device *dev, int bufnum);
 struct ArcProto *arc_proto_map[256], *arc_proto_default,
*arc_bcast_proto, *arc_raw_proto;
 
-static struct ArcProto arc_proto_null =
-{
+static struct ArcProto arc_proto_null = {
.suffix = '?',
.mtu= XMTU,
.is_ip  = 0,
@@ -264,14 +263,13 @@ static int get_arcbuf(struct net_device *dev)
/* already in this function */
BUGMSG(D_NORMAL, "get_arcbuf: overlap (%d)!\n",
   lp->buf_lock.counter);
-   }
-   else {  /* we can continue */
+   } else {/* we can continue */
if (lp->next_buf >= 5)
lp->next_buf -= 5;
 
-   if (lp->next_buf == lp->first_free_buf)
+   if (lp->next_buf == lp->first_free_buf) {
BUGMSG(D_NORMAL, "get_arcbuf: BUG: no buffers are 
available??\n");
-   else {
+   } else {
buf = lp->buf_queue[lp->next_buf++];
lp->next_buf %= 5;
}
@@ -330,7 +328,6 @@ static void arcdev_setup(struct net_device *dev)
 
/* New-style flags. */
dev->flags = IFF_BROADCAST;
-
 }
 
 struct net_device *alloc_arcdev(const char *name)
@@ -494,8 +491,7 @@ static int arcnet_header(struct sk_buff *skb, struct 
net_device *dev,
proto = arc_raw_proto;
BUGMSG(D_DEBUG, "arc_raw_proto used. proto='%c'\n", 
proto->suffix);
_daddr = daddr ? *(uint8_t *)daddr : 0;
-   }
-   else if (!daddr) {
+   } else if (!daddr) {
/*
 * if the dest addr isn't provided, we can't choose an 
encapsulation!
 * Store the packet type (eg. ETH_P_IP) for now, and we'll push 
on a
@@ -509,8 +505,7 @@ static int arcnet_header(struct sk_buff *skb, struct 
net_device *dev,
BUGMSG(D_NORMAL, "arcnet_header: Yikes!  diff (%d) is 
not 2!\n",
   (int)(skb->network_header - skb->mac_header));
return -2;  /* return error -- can't transmit yet! */
-   }
-   else {
+   } else {
/* otherwise, we can just add the header as usual. */
_daddr = *(uint8_t *)daddr;
proto_num = lp->default_proto[_daddr];
@@ -564,9 +559,9 @@ netdev_tx_t arcnet_send_packet(struct sk_buff *skb,
AINTMASK(0);
if (lp->next_tx == -1)
txbuf = get_arcbuf(dev);
-   else {
+   else
txbuf = -1;
-   }
+
if (txbuf != -1) {
if (proto->prepare_tx(dev, pkt, skb->len, txbuf) &&
!proto->ack_tx) {
@@ -606,9 +601,9 @@ netdev_tx_t arcnet_send_packet(struct sk_buff *skb,
BUGMSG(D_DEBUG, "%s: %d: %s, status: %x\n", __FILE__, __LINE__, 
__func__, ASTATUS());
 
 

[PATCH 30/33] arcnet: reformat structs to C99 format

2015-09-22 Thread Michael Grzeschik
This patch changes the macro definitions to match the C99
formating. This improves the readability.

Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/capmode.c  | 14 ++
 drivers/net/arcnet/com20020-pci.c | 35 +--
 2 files changed, 35 insertions(+), 14 deletions(-)

diff --git a/drivers/net/arcnet/capmode.c b/drivers/net/arcnet/capmode.c
index 2f2d0d9..8297e00 100644
--- a/drivers/net/arcnet/capmode.c
+++ b/drivers/net/arcnet/capmode.c
@@ -230,14 +230,12 @@ free_outskb:
 }
 
 static struct ArcProto capmode_proto = {
-   'r',
-   XMTU,
-   0,
-   rx,
-   build_header,
-   prepare_tx,
-   NULL,
-   ack_tx
+   .suffix = 'r',
+   .mtu= XMTU,
+   .rx = rx,
+   .build_header   = build_header,
+   .prepare_tx = prepare_tx,
+   .ack_tx = ack_tx
 };
 
 static void arcnet_cap_init(void)
diff --git a/drivers/net/arcnet/com20020-pci.c 
b/drivers/net/arcnet/com20020-pci.c
index 9b82126..a12bf83 100644
--- a/drivers/net/arcnet/com20020-pci.c
+++ b/drivers/net/arcnet/com20020-pci.c
@@ -188,7 +188,11 @@ static struct com20020_pci_card_info card_info_10mbit = {
.name = "ARC-PCI",
.devcount = 1,
.chan_map_tbl = {
-   { 2, 0x00, 0x08 },
+   {
+   .bar = 2,
+   .offset = 0x00,
+   .size = 0x08,
+   },
},
.flags = ARC_CAN_10MBIT,
 };
@@ -197,7 +201,11 @@ static struct com20020_pci_card_info card_info_5mbit = {
.name = "ARC-PCI",
.devcount = 1,
.chan_map_tbl = {
-   { 2, 0x00, 0x08 },
+   {
+   .bar = 2,
+   .offset = 0x00,
+   .size = 0x08,
+   },
},
.flags = ARC_IS_5MBIT,
 };
@@ -207,7 +215,11 @@ static struct com20020_pci_card_info card_info_sohard = {
.devcount = 1,
/* SOHARD needs PCI base addr 4 */
.chan_map_tbl = {
-   {4, 0x00, 0x08},
+   {
+   .bar = 4,
+   .offset = 0x00,
+   .size = 0x08
+   },
},
.flags = ARC_CAN_10MBIT,
 };
@@ -216,7 +228,11 @@ static struct com20020_pci_card_info card_info_eae_arc1 = {
.name = "EAE PLX-PCI ARC1",
.devcount = 1,
.chan_map_tbl = {
-   { 2, 0x00, 0x08 },
+   {
+   .bar = 2,
+   .offset = 0x00,
+   .size = 0x08,
+   },
},
.flags = ARC_CAN_10MBIT,
 };
@@ -225,8 +241,15 @@ static struct com20020_pci_card_info card_info_eae_ma1 = {
.name = "EAE PLX-PCI MA1",
.devcount = 2,
.chan_map_tbl = {
-   { 2, 0x00, 0x08 },
-   { 2, 0x08, 0x08 }
+   {
+   .bar = 2,
+   .offset = 0x00,
+   .size = 0x08,
+   }, {
+   .bar = 2,
+   .offset = 0x08,
+   .size = 0x08,
+   }
},
.flags = ARC_CAN_10MBIT,
 };
-- 
2.5.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 24/33] arcnet: arcdevice.h: Add arcnet_readb and arcnet_writeb

2015-09-22 Thread Michael Grzeschik
From: Joe Perches <j...@perches.com>

Use the same indirection as the other arcnet_ macros.
Neither of these new macros add the BUS_ALIGN use for 8 bit devices
on 16 bit busses.

Signed-off-by: Joe Perches <j...@perches.com>
Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/arcdevice.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/arcnet/arcdevice.h b/drivers/net/arcnet/arcdevice.h
index 4afa32b..a05a77d 100644
--- a/drivers/net/arcnet/arcdevice.h
+++ b/drivers/net/arcnet/arcdevice.h
@@ -373,5 +373,10 @@ void arcnet_timeout(struct net_device *dev);
 #define arcnet_outsw(addr, offset, buffer, count)  \
outsw((addr) + BUS_ALIGN * (offset), buffer, count)
 
+#define arcnet_readb(addr, offset) \
+   readb((addr) + (offset))
+#define arcnet_writeb(value, addr, offset) \
+   writeb(value, (addr) + (offset))
+
 #endif /* __KERNEL__ */
 #endif /* _LINUX_ARCDEVICE_H */
-- 
2.5.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 28/33] arcnet: Add com9026.h to standardize COM9026_REG_

2015-09-22 Thread Michael Grzeschik
From: Joe Perches <j...@perches.com>

Deduplicate the COM9026 registers.

Signed-off-by: Joe Perches <j...@perches.com>
Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/arc-rimi.c | 13 +
 drivers/net/arcnet/arcnet.c   |  1 +
 drivers/net/arcnet/com9026.h  | 17 +
 drivers/net/arcnet/com90io.c  | 11 +--
 drivers/net/arcnet/com90xx.c  | 13 +
 5 files changed, 21 insertions(+), 34 deletions(-)
 create mode 100644 drivers/net/arcnet/com9026.h

diff --git a/drivers/net/arcnet/arc-rimi.c b/drivers/net/arcnet/arc-rimi.c
index 4c35a7e..a07e249 100644
--- a/drivers/net/arcnet/arc-rimi.c
+++ b/drivers/net/arcnet/arc-rimi.c
@@ -39,6 +39,7 @@
 #include 
 
 #include "arcdevice.h"
+#include "com9026.h"
 
 /* Internal function declarations */
 
@@ -59,18 +60,6 @@ static void arcrimi_copy_from_card(struct net_device *dev, 
int bufnum,
 #define BUFFER_SIZE(512)
 #define MIRROR_SIZE(BUFFER_SIZE * 4)
 
-/* COM 9026 controller chip --> ARCnet register addresses */
-#define COM9026_REG_W_INTMASK  0   /* writable */
-#define COM9026_REG_R_STATUS   0   /* readable */
-#define COM9026_REG_W_COMMAND  1   /* writable, returns random vals on 
read (?) */
-#define COM9026_REG_RW_CONFIG  2   /* Configuration register */
-#define COM9026_REG_R_RESET8   /* software reset (on read) */
-#define COM9026_REG_RW_MEMDATA 12  /* Data port for IO-mapped memory */
-#define COM9026_REG_W_ADDR_LO  14  /* Control registers for said */
-#define COM9026_REG_W_ADDR_HI  15
-
-#define COM9026_REG_R_STATION  1   /* Station ID */
-
 /* We cannot probe for a RIM I card; one reason is I don't know how to reset
  * them.  In fact, we can't even get their node ID automatically.  So, we
  * need to be passed a specific shmem address, IRQ, and node ID.
diff --git a/drivers/net/arcnet/arcnet.c b/drivers/net/arcnet/arcnet.c
index bcfdd91..2158e98 100644
--- a/drivers/net/arcnet/arcnet.c
+++ b/drivers/net/arcnet/arcnet.c
@@ -53,6 +53,7 @@
 #include 
 
 #include "arcdevice.h"
+#include "com9026.h"
 
 /* "do nothing" functions for protocol drivers */
 static void null_rx(struct net_device *dev, int bufnum,
diff --git a/drivers/net/arcnet/com9026.h b/drivers/net/arcnet/com9026.h
new file mode 100644
index 000..efcaf67
--- /dev/null
+++ b/drivers/net/arcnet/com9026.h
@@ -0,0 +1,17 @@
+#ifndef __COM9026_H
+#define __COM9026_H
+
+/* COM 9026 controller chip --> ARCnet register addresses */
+
+#define COM9026_REG_W_INTMASK  0   /* writable */
+#define COM9026_REG_R_STATUS   0   /* readable */
+#define COM9026_REG_W_COMMAND  1   /* writable, returns random vals on 
read (?) */
+#define COM9026_REG_RW_CONFIG  2   /* Configuration register */
+#define COM9026_REG_R_RESET8   /* software reset (on read) */
+#define COM9026_REG_RW_MEMDATA 12  /* Data port for IO-mapped memory */
+#define COM9026_REG_W_ADDR_LO  14  /* Control registers for said */
+#define COM9026_REG_W_ADDR_HI  15
+
+#define COM9026_REG_R_STATION  1   /* Station ID */
+
+#endif
diff --git a/drivers/net/arcnet/com90io.c b/drivers/net/arcnet/com90io.c
index 7e084f1..b57863d 100644
--- a/drivers/net/arcnet/com90io.c
+++ b/drivers/net/arcnet/com90io.c
@@ -40,6 +40,7 @@
 #include 
 
 #include "arcdevice.h"
+#include "com9026.h"
 
 /* Internal function declarations */
 
@@ -58,16 +59,6 @@ static void com90io_copy_from_card(struct net_device *dev, 
int bufnum,
 /* The number of low I/O ports used by the card. */
 #define ARCNET_TOTAL_SIZE 16
 
-/* COM 9026 controller chip --> ARCnet register addresses */
-#define COM9026_REG_W_INTMASK  0   /* writable */
-#define COM9026_REG_R_STATUS   0   /* readable */
-#define COM9026_REG_W_COMMAND  1   /* writable, returns random vals on 
read (?) */
-#define COM9026_REG_RW_CONFIG  2   /* Configuration register */
-#define COM9026_REG_R_RESET8   /* software reset (on read) */
-#define COM9026_REG_RW_MEMDATA 12  /* Data port for IO-mapped memory */
-#define COM9026_REG_W_ADDR_LO  14  /* Control registers for said */
-#define COM9026_REG_W_ADDR_HI  15
-
 /
  *  *
  * IO-mapped operation routines *
diff --git a/drivers/net/arcnet/com90xx.c b/drivers/net/arcnet/com90xx.c
index a97d086..0d9b45f 100644
--- a/drivers/net/arcnet/com90xx.c
+++ b/drivers/net/arcnet/com90xx.c
@@ -38,6 +38,7 @@
 #include 
 
 #include "arcdevice.h"
+#include "com9026.h"
 
 /* Define this to speed up the autoprobe by assuming if only one io port and
  * shmem are left in the list at Stage 5, they must correspond to each
@@ -78,18 +79,6 @@ static int numcards;
 #define BUFFER_SIZE (512)
 #define MIRROR_SIZ

[PATCH 32/33] arcnet: arc-rawmode: reorder module functions

2015-09-22 Thread Michael Grzeschik
This patch moves the module_init and module_exit patches to
the end of the file. It also replaces the printk with pr_info.

Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/arc-rawmode.c | 84 ++--
 1 file changed, 38 insertions(+), 46 deletions(-)

diff --git a/drivers/net/arcnet/arc-rawmode.c b/drivers/net/arcnet/arc-rawmode.c
index 35a747a..0046ddb 100644
--- a/drivers/net/arcnet/arc-rawmode.c
+++ b/drivers/net/arcnet/arc-rawmode.c
@@ -33,54 +33,8 @@
 #include 
 #include 
 #include 
-
 #include "arcdevice.h"
 
-static void rx(struct net_device *dev, int bufnum,
-  struct archdr *pkthdr, int length);
-static int build_header(struct sk_buff *skb, struct net_device *dev,
-   unsigned short type, uint8_t daddr);
-static int prepare_tx(struct net_device *dev, struct archdr *pkt, int length,
- int bufnum);
-
-static struct ArcProto rawmode_proto = {
-   .suffix = 'r',
-   .mtu= XMTU,
-   .rx = rx,
-   .build_header   = build_header,
-   .prepare_tx = prepare_tx,
-   .continue_tx= NULL,
-   .ack_tx = NULL
-};
-
-static int __init arcnet_raw_init(void)
-{
-   int count;
-
-   pr_info("%s\n", "raw mode (`r') encapsulation support loaded");
-
-   for (count = 0; count < 256; count++)
-   if (arc_proto_map[count] == arc_proto_default)
-   arc_proto_map[count] = _proto;
-
-   /* for raw mode, we only set the bcast proto if there's no better one */
-   if (arc_bcast_proto == arc_proto_default)
-   arc_bcast_proto = _proto;
-
-   arc_proto_default = _proto;
-   return 0;
-}
-
-static void __exit arcnet_raw_exit(void)
-{
-   arcnet_unregister_proto(_proto);
-}
-
-module_init(arcnet_raw_init);
-module_exit(arcnet_raw_exit);
-
-MODULE_LICENSE("GPL");
-
 /* packet receiver */
 static void rx(struct net_device *dev, int bufnum,
   struct archdr *pkthdr, int length)
@@ -195,3 +149,41 @@ static int prepare_tx(struct net_device *dev, struct 
archdr *pkt, int length,
 
return 1;   /* done */
 }
+
+static struct ArcProto rawmode_proto = {
+   .suffix = 'r',
+   .mtu= XMTU,
+   .rx = rx,
+   .build_header   = build_header,
+   .prepare_tx = prepare_tx,
+   .continue_tx= NULL,
+   .ack_tx = NULL
+};
+
+static int __init arcnet_raw_init(void)
+{
+   int count;
+
+   pr_info("%s\n", "raw mode (`r') encapsulation support loaded");
+
+   for (count = 0; count < 256; count++)
+   if (arc_proto_map[count] == arc_proto_default)
+   arc_proto_map[count] = _proto;
+
+   /* for raw mode, we only set the bcast proto if there's no better one */
+   if (arc_bcast_proto == arc_proto_default)
+   arc_bcast_proto = _proto;
+
+   arc_proto_default = _proto;
+   return 0;
+}
+
+static void __exit arcnet_raw_exit(void)
+{
+   arcnet_unregister_proto(_proto);
+}
+
+module_init(arcnet_raw_init);
+module_exit(arcnet_raw_exit);
+
+MODULE_LICENSE("GPL");
-- 
2.5.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 29/33] arcnet: Remove unused arcnet_w macros

2015-09-22 Thread Michael Grzeschik
From: Joe Perches <j...@perches.com>

The word length macros are unused.  Remove them.

Signed-off-by: Joe Perches <j...@perches.com>
Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/arcdevice.h | 10 --
 1 file changed, 10 deletions(-)

diff --git a/drivers/net/arcnet/arcdevice.h b/drivers/net/arcnet/arcdevice.h
index 2577485..4c1c44c 100644
--- a/drivers/net/arcnet/arcdevice.h
+++ b/drivers/net/arcnet/arcdevice.h
@@ -358,16 +358,6 @@ void arcnet_timeout(struct net_device *dev);
 #define arcnet_outsb(addr, offset, buffer, count)  \
outsb((addr) + BUS_ALIGN * (offset), buffer, count)
 
-#define arcnet_inw(addr, offset)   \
-   inw((addr) + BUS_ALIGN * (offset))
-#define arcnet_outw(value, addr, offset)   \
-   outw(value, (addr) + BUS_ALIGN * (offset))
-
-#define arcnet_insw(addr, offset, buffer, count)   \
-   insw((addr) + BUS_ALIGN * (offset), buffer, count)
-#define arcnet_outsw(addr, offset, buffer, count)  \
-   outsw((addr) + BUS_ALIGN * (offset), buffer, count)
-
 #define arcnet_readb(addr, offset) \
readb((addr) + (offset))
 #define arcnet_writeb(value, addr, offset) \
-- 
2.5.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 21/33] arcnet: com20020: Use arcnet_ routines

2015-09-22 Thread Michael Grzeschik
From: Joe Perches <j...@perches.com>

Simplify and make consistent the current uses of inb/outb
by using the newly introduced arcnet_ equivalents.

o Add new #defines for register offsets
  There is an register offset, 8, that is unnamed and used as-is.
o Remove old #defines that included the ioaddr
o Remove obfuscating macros by expanding them in-place where appropriate
o Create static inline com20020_set_subaddress for the SET_SUBADR macro

There is an unused arcnet config entry CONFIGSA100_CT6001 which added a
special #define BUS_ALIGN which was introduced but never used in fullhist git
tree commit 22cfce4b82b0 ("[ARCNET]: Fixes.") in Nov 2004 for Linux v2.6.10.

This BUS_ALIGN #define tries to allow 8 bit devices to work on a 16 bit
bus by aligning addresses to 16 bit boundaries.

Move this currently unused CONFIG_SA1100_CT6001 BUS_ALIGN macro from
com20020.h to arcdevice.h.

Signed-off-by: Joe Perches <j...@perches.com>
Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/arcdevice.h|  22 +---
 drivers/net/arcnet/com20020-isa.c |  14 +++---
 drivers/net/arcnet/com20020-pci.c |   6 +--
 drivers/net/arcnet/com20020.c | 103 +-
 drivers/net/arcnet/com20020.h |  74 +--
 drivers/net/arcnet/com20020_cs.c  |  17 ---
 6 files changed, 114 insertions(+), 122 deletions(-)

diff --git a/drivers/net/arcnet/arcdevice.h b/drivers/net/arcnet/arcdevice.h
index 95e7ed6..4afa32b 100644
--- a/drivers/net/arcnet/arcdevice.h
+++ b/drivers/net/arcnet/arcdevice.h
@@ -344,28 +344,34 @@ void arcnet_timeout(struct net_device *dev);
 
 /* I/O equivalents */
 
+#ifdef CONFIG_SA1100_CT6001
+#define BUS_ALIGN  2  /* 8 bit device on a 16 bit bus - needs padding */
+#else
+#define BUS_ALIGN  1
+#endif
+
 /* addr and offset allow register like names to define the actual IO  address.
  * A configuration option multiplies the offset for alignment.
  */
 #define arcnet_inb(addr, offset)   \
-   inb((addr) + (offset))
+   inb((addr) + BUS_ALIGN * (offset))
 #define arcnet_outb(value, addr, offset)   \
-   outb(value, (addr) + (offset))
+   outb(value, (addr) + BUS_ALIGN * (offset))
 
 #define arcnet_insb(addr, offset, buffer, count)   \
-   insb((addr) + (offset), buffer, count)
+   insb((addr) + BUS_ALIGN * (offset), buffer, count)
 #define arcnet_outsb(addr, offset, buffer, count)  \
-   outsb((addr) + (offset), buffer, count)
+   outsb((addr) + BUS_ALIGN * (offset), buffer, count)
 
 #define arcnet_inw(addr, offset)   \
-   inw((addr) + (offset))
+   inw((addr) + BUS_ALIGN * (offset))
 #define arcnet_outw(value, addr, offset)   \
-   outw(value, (addr) + (offset))
+   outw(value, (addr) + BUS_ALIGN * (offset))
 
 #define arcnet_insw(addr, offset, buffer, count)   \
-   insw((addr) + (offset), buffer, count)
+   insw((addr) + BUS_ALIGN * (offset), buffer, count)
 #define arcnet_outsw(addr, offset, buffer, count)  \
-   outsw((addr) + (offset), buffer, count)
+   outsw((addr) + BUS_ALIGN * (offset), buffer, count)
 
 #endif /* __KERNEL__ */
 #endif /* _LINUX_ARCDEVICE_H */
diff --git a/drivers/net/arcnet/com20020-isa.c 
b/drivers/net/arcnet/com20020-isa.c
index ab5202b..b9e9931 100644
--- a/drivers/net/arcnet/com20020-isa.c
+++ b/drivers/net/arcnet/com20020-isa.c
@@ -67,7 +67,7 @@ static int __init com20020isa_probe(struct net_device *dev)
   ioaddr, ioaddr + ARCNET_TOTAL_SIZE - 1);
return -ENXIO;
}
-   if (ASTATUS() == 0xFF) {
+   if (arcnet_inb(ioaddr, COM20020_REG_R_STATUS) == 0xFF) {
arc_printk(D_NORMAL, dev, "IO address %x empty\n", ioaddr);
err = -ENODEV;
goto out;
@@ -83,20 +83,20 @@ static int __init com20020isa_probe(struct net_device *dev)
 * we tell it to start receiving.
 */
arc_printk(D_INIT_REASONS, dev, "intmask was %02Xh\n",
-  inb(_INTMASK));
-   outb(0, _INTMASK);
+  arcnet_inb(ioaddr, COM20020_REG_R_STATUS));
+   arcnet_outb(0, ioaddr, COM20020_REG_W_INTMASK);
airqmask = probe_irq_on();
-   outb(NORXflag, _INTMASK);
+   arcnet_outb(NORXflag, ioaddr, COM20020_REG_W_INTMASK);
udelay(1);
-   outb(0, _INTMASK);
+   arcnet_outb(0, ioaddr, COM20020_REG_W_INTMASK);
dev->irq = probe_irq_off(airqmask);
 
if ((int)dev->irq <= 0) {
arc_printk(D_INIT_REASONS, dev, "Autoprobe IRQ failed 
f

[GIT PULL] ARCNET: refactoring and cleanup

2015-09-21 Thread Michael Grzeschik
Hi David,

The following changes since commit 1f93e4a96c9109378204c147b3eec0d0e8100fde:

  Linux 4.3-rc2 (2015-09-20 14:32:34 -0700)

are available in the git repository at:

  git://git.pengutronix.de/git/mgr/linux.git tags/arcnet-cleanup-v4.3-rc2

for you to fetch changes up to 9ac23e159ab81450d7c644b13a271b514d2bcc23:

  arcnet: capmode: remove extra function (2015-09-21 16:36:30 +0200)


ARCNET: refactoring and cleanup

This series cleans up the code in drivers/net/arcnet
and include/uapi/linux/if_arcnet.h . It doesn't change
the runtime behaviour of the code. Its only purpose
is to improve the code maintenance and readability.


Joe Perches (29):
  ARCNET: fix indentation of if_arcnet.h
  arcnet: Use normal kernel spacing style
  arcnet: Add and remove blank lines
  arcnet: Use normal kernel brace style
  arcnet: Coalesce string fragments
  arcnet: Use include/linux path for asm
  arcnet: Use network block comment style
  arcnet: Neaten BUGMSG macro defines
  arcnet: Expand odd BUGLVL macro with if and uses
  arcnet: Convert BUGMSG and BUGMSG2 to arc_prink and arc_cont
  arcnet: Convert printk to pr_
  arcnet: Move EXPORT_SYMBOL after declarations
  arcnet: Remove unnecessary OOM messages
  arcnet: Remove assignments from ifs
  arcnet: Remove pointer comparisons to NULL
  arcnet: Convert arcnet_dump_skb macro to static inline
  arcnet: Wrap some long lines
  arcnet: Move files out of include/linux
  arcnet: Make a char * array const char * const
  arcnet: Add arcnet_ macros
  arcnet: com20020: Use arcnet_ routines
  arcnet: com90io: Use arcnet_ routines
  arcnet: com90xx: Use arcnet_ routines
  arcnet: arcdevice.h: Add arcnet_readb and arcnet_writeb
  arcnet: arc-rimi: Use arcnet_ routines
  arcnet: com90xx: Use arcnet_readb/writeb routines
  arcnet: Remove function pointer macro indirections
  arcnet: Add com9026.h to standardize COM9026_REG_
  arcnet: Remove unused arcnet_w macros

Michael Grzeschik (4):
  arcnet: reformat structs to C99 format
  arcnet: com20020: replace magic numbers with readable macros
  arcnet: arc-rawmode: reorder module functions
  arcnet: capmode: remove extra function

 MAINTAINERS   |   1 -
 drivers/net/arcnet/arc-rawmode.c  | 142 +++--
 drivers/net/arcnet/arc-rimi.c | 145 +++---
 {include/linux => drivers/net/arcnet}/arcdevice.h | 152 +++---
 drivers/net/arcnet/arcnet.c   | 601 ++
 drivers/net/arcnet/capmode.c  | 138 +++--
 drivers/net/arcnet/com20020-isa.c |  54 +-
 drivers/net/arcnet/com20020-pci.c |  70 ++-
 drivers/net/arcnet/com20020.c | 234 +
 {include/linux => drivers/net/arcnet}/com20020.h  |  75 +--
 drivers/net/arcnet/com20020_cs.c  | 325 ++--
 drivers/net/arcnet/com9026.h  |  17 +
 drivers/net/arcnet/com90io.c  | 209 
 drivers/net/arcnet/com90xx.c  | 323 ++--
 drivers/net/arcnet/rfc1051.c  |  77 ++-
 drivers/net/arcnet/rfc1201.c  | 238 -
 include/uapi/linux/if_arcnet.h|  55 +-
 17 files changed, 1410 insertions(+), 1446 deletions(-)
 rename {include/linux => drivers/net/arcnet}/arcdevice.h (79%)
 rename {include/linux => drivers/net/arcnet}/com20020.h (61%)
 create mode 100644 drivers/net/arcnet/com9026.h

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH][RESEND] ARCNET: fix hard_header_len limit

2015-09-17 Thread Michael Grzeschik
For arcnet the bare minimum header only contains the 4 bytes to
specify source, dest and offset (1, 1 and 2 bytes respectively).
The corresponding struct is struct arc_hardware.

The struct archdr contains additionally a union of possible soft
headers. When doing $insertusecasehere packets might well
include short (or even no?) soft headers.

For this reason only use arc_hardware instead of archdr to
determine the hard_header_len for an arcnet device.

Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/net/arcnet/arcnet.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/arcnet/arcnet.c b/drivers/net/arcnet/arcnet.c
index 10f71c73..816d0e9 100644
--- a/drivers/net/arcnet/arcnet.c
+++ b/drivers/net/arcnet/arcnet.c
@@ -326,7 +326,7 @@ static void arcdev_setup(struct net_device *dev)
dev->type = ARPHRD_ARCNET;
dev->netdev_ops = _netdev_ops;
dev->header_ops = _header_ops;
-   dev->hard_header_len = sizeof(struct archdr);
+   dev->hard_header_len = sizeof(struct arc_hardware);
dev->mtu = choose_mtu();
 
dev->addr_len = ARCNET_ALEN;
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH][RESEND] MAINTAINERS: add arcnet and take maintainership

2015-09-17 Thread Michael Grzeschik
Add entry for arcnet to MAINTAINERS file and add myself as the
maintainer of the subsystem.

Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
Cc: da...@davemloft.net
Cc: j...@perches.com
---
 MAINTAINERS | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 7ba7ab7..0a015f7 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -808,6 +808,13 @@ S: Maintained
 F: drivers/video/fbdev/arcfb.c
 F: drivers/video/fbdev/core/fb_defio.c
 
+ARCNET NETWORK LAYER
+M: Michael Grzeschik <m.grzesc...@pengutronix.de>
+L: netdev@vger.kernel.org
+S: Maintained
+F: drivers/net/arcnet/
+F: include/uapi/linux/if_arcnet.h
+
 ARM MFM AND FLOPPY DRIVERS
 M: Ian Molton <sp...@f2s.com>
 S: Maintained
-- 
2.5.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] ARCNET: fix hard_header_len limit

2015-09-16 Thread Michael Grzeschik
On Wed, Aug 05, 2015 at 05:34:51PM +0200, Michael Grzeschik wrote:
> On Thu, Jul 30, 2015 at 11:16:36AM -0700, David Miller wrote:
> > From: Michael Grzeschik <m.grzesc...@pengutronix.de>
> > Date: Thu, 30 Jul 2015 15:34:36 +0200
> > 
> > > The commit <9c7077622dd9> ("packet: make packet_snd fail on len smaller
> > > than l2 header") adds the check for minimum packet length of the used l2.
> > > For arcnet the hardware header length is not the complete archdr which
> > > includes hard + soft header. This patch changes the length to
> > > sizeof(arc_hardware).
> > > 
> > > Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
> > 
> > The hard header len is used for other purposes as well, are you sure
> > those don't get broken by this change?
> 
> Its meaning is to represent the amount of the hardware (link layer)
> data of one packet.
> 
> Which other purposes do you mean?
> Can you point to some code?
> 
> > Code assumes that if the data at the SKB mac pointer is taken, for
> > dev->hard_header_len bytes, that is exactly the link layer header.
> > And that this can be used to compare two MAC headers, copy the
> > MAC header from one packet to another, etc.
> 
> The link layer size of arcnet is 4 bytes long. 1 byte source, 1 byte
> dest and two offset bytes. As described by struct arc_hardware in
> if_arcnet.h . The above condition is fulfilled when the mac pointer
> is 0.
> 
> The following pending bytes of struct archdr have a variable meaning
> depending of the used protocol and are represented by an union.
> (network layer)
> 
> In the case of raw packets, the payload comes immediately after the
> hard_header.
> 

Ping!

I have the cleanup patches from Joe Perches and several ARCNET patches
on top, waiting to be posted on the list. What is your Opinion to my
Maintainer Request I send some weeks ago?

Michael

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] ARCNET: fix hard_header_len limit

2015-08-05 Thread Michael Grzeschik
On Thu, Jul 30, 2015 at 11:16:36AM -0700, David Miller wrote:
 From: Michael Grzeschik m.grzesc...@pengutronix.de
 Date: Thu, 30 Jul 2015 15:34:36 +0200
 
  The commit 9c7077622dd9 (packet: make packet_snd fail on len smaller
  than l2 header) adds the check for minimum packet length of the used l2.
  For arcnet the hardware header length is not the complete archdr which
  includes hard + soft header. This patch changes the length to
  sizeof(arc_hardware).
  
  Signed-off-by: Michael Grzeschik m.grzesc...@pengutronix.de
 
 The hard header len is used for other purposes as well, are you sure
 those don't get broken by this change?

Its meaning is to represent the amount of the hardware (link layer)
data of one packet.

Which other purposes do you mean?
Can you point to some code?

 Code assumes that if the data at the SKB mac pointer is taken, for
 dev-hard_header_len bytes, that is exactly the link layer header.
 And that this can be used to compare two MAC headers, copy the
 MAC header from one packet to another, etc.

The link layer size of arcnet is 4 bytes long. 1 byte source, 1 byte
dest and two offset bytes. As described by struct arc_hardware in
if_arcnet.h . The above condition is fulfilled when the mac pointer
is 0.

The following pending bytes of struct archdr have a variable meaning
depending of the used protocol and are represented by an union.
(network layer)

In the case of raw packets, the payload comes immediately after the
hard_header.

Thanks,
Michael

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |
--
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] MAINTAINERS: add arcnet and take maintainership

2015-07-30 Thread Michael Grzeschik
Add entry for arcnet to MAINTAINERS file and add myself as the
maintainer of the subsystem.

Signed-off-by: Michael Grzeschik m.grzesc...@pengutronix.de
Cc: da...@davemloft.net
Cc: j...@perches.com
---
As I have a test coverage of com20020 based arcnet systems
I would like to take the responsibility of maintaining the subsystem.

 MAINTAINERS | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 9289ecb..08f1a41 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -790,6 +790,12 @@ S: Maintained
 F: drivers/video/fbdev/arcfb.c
 F: drivers/video/fbdev/core/fb_defio.c
 
+ARCNET NETWORK LAYER
+M: Michael Grzeschik m.grzesc...@pengutronix.de
+L: netdev@vger.kernel.org
+S: Maintained
+F: drivers/net/arcnet/
+
 ARM MFM AND FLOPPY DRIVERS
 M: Ian Molton sp...@f2s.com
 S: Maintained
-- 
2.1.4

--
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


  1   2   >