Fixes, cleanup and modernization for mac89x0 driver
Subsystems (4)
cover Fixes, cleanup and modernization for mac89x0 driver
Changes since v4 of combined patch series:
- Removed redundant and non-portable MACH_IS_MAC tests.
- Added acked-by tags from Geert Uytterhoeven.
- Omitted patches unrelated to mac89x0 driver.
Finn Thain (4):
net/mac89x0: Remove redundant code
net/mac89x0: Convert to platform_driver net/mac89x0: Fix and modernize log messages net/mac89x0: Replace custom debug logging with netif_* calls
arch/m68k/mac/config.c | 4 + drivers/net/Space.c | 3 - drivers/net/ethernet/cirrus/mac89x0.c | 158 +++++++++++----------------------- include/net/Space.h | 1 - 4 files changed, 53 insertions(+), 113 deletions(-)
Signature · 1 line
2.16.1
PATCH 1/4 net/mac89x0: Remove redundant code
--- drivers/net/ethernet/cirrus/mac89x0.c | 32 -------------------------------- 1 file changed, 32 deletions(-)
drivers/net/ethernet/cirrus/mac89x0.c +0 -32
@@ -115,14 +115,9 @@ struct net_local {int rx_mode;int curr_rx_cfg;int send_underrun;/* keep track of how many underruns in a row we get */ -struct sk_buff *skb; };/* Index to functions, as function prototypes. */ - -#if 0 -extern void reset_chip (struct net_device *dev); -#endif static int net_open (struct net_device *dev);static int net_send_packet (struct sk_buff *skb,struct net_device *dev);static irqreturn_t net_interrupt (int irq,void *dev_id);
@@ -132,10 +127,6 @@ static int net_close(struct net_device *dev);static struct net_device_stats *net_get_stats (struct net_device *dev);static int set_mac_address (struct net_device *dev,void *addr); - -/* Example routines you must write ;->. */ -#define tx_done (dev) 1 -/* For reading/writing registers ISA-style */ static inline int readreg_io (struct net_device *dev,int portno)
@@ -297,24 +288,6 @@ struct net_device * __init mac89x0_probe(int unit)return ERR_PTR (err); } -#if 0 -/* This is useful for something, but I don't know what yet. */ -void __init reset_chip (struct net_device *dev) -{ -int reset_start_time; - -writereg (dev, PP_SelfCTL,readreg (dev, PP_SelfCTL) |POWER_ON_RESET ); - -/* wait 30 ms */ -msleep_interruptible (30 ); - -/* Wait until the chip is reset */ - reset_start_time = jiffies; -while ( (readreg (dev, PP_SelfST) &INIT_DONE ) ==0 && jiffies - reset_start_time <2 ) - ; -} -#endif -/* Open/initialize the board. This is called (in the current kernel) sometime after booting when the 'ifconfig' program is run.
@@ -416,11 +389,6 @@ static irqreturn_t net_interrupt(int irq, void *dev_id)struct net_local *lp;int ioaddr, status; -if (dev ==NULL ) { -printk ("net_interrupt(): irq %d for unknown device.\n" , irq); -return IRQ_NONE ; - } - ioaddr = dev->base_addr; lp =netdev_priv (dev);
Signature · 1 line
2.16.1
PATCH 2/4 net/mac89x0: Convert to platform_driver
In reply to Finn ThainApparently these Dayna cards don't have a pseudoslot declaration ROM which means they can't be probed like NuBus cards.
--- arch/m68k/mac/config.c | 4 +++ drivers/net/Space.c | 3 -- drivers/net/ethernet/cirrus/mac89x0.c | 68 +++++++++++++++-------------------- include/net/Space.h | 1 - 4 files changed, 33 insertions(+), 43 deletions(-)
arch/m68k/mac/config.c +4 -0
@@ -1088,6 +1088,10 @@ int __init mac_platform_init(void) macintosh_config->expansion_type == MAC_EXP_PDS_COMM)platform_device_register_simple ("macsonic" ,-1 ,NULL ,0 ); +if (macintosh_config->expansion_type ==MAC_EXP_PDS || + macintosh_config->expansion_type ==MAC_EXP_PDS_COMM ) +platform_device_register_simple ("mac89x0" ,-1 ,NULL ,0 ); +if (macintosh_config->ether_type ==MAC_ETHER_MACE )platform_device_register_simple ("macmace" ,-1 ,NULL ,0 );
drivers/net/Space.c +0 -3
@@ -113,9 +113,6 @@ static struct devprobe2 m68k_probes[] __initdata = {#endif #ifdef CONFIG_MVME147_NET /* MVME147 internal Ethernet */ {mvme147lance_probe, 0}, -#endif -#ifdef CONFIG_MAC89x0 - {mac89x0_probe, 0}, #endif {NULL, 0}, };
drivers/net/ethernet/cirrus/mac89x0.c +29 -39
122 lines not on this page · raw message
include/net/Space.h +0 -1
@@ -20,7 +20,6 @@ struct net_device *cs89x0_probe(int unit);struct net_device *mvme147lance_probe (int unit);struct net_device *tc515_probe (int unit);struct net_device *lance_probe (int unit); -struct net_device *mac89x0_probe (int unit);struct net_device *cops_probe (int unit);struct net_device *ltpc_probe (void );
Signature · 1 line
2.16.1
PATCH 3/4 net/mac89x0: Fix and modernize log messages
In reply to Finn ThainFix log message fragments that no longer produce the desired output since the behaviour of printk() was changed.
Add missing printk severity levels.
Drop deprecated "out of memory" message as per checkpatch advice.
--- drivers/net/ethernet/cirrus/mac89x0.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
drivers/net/ethernet/cirrus/mac89x0.c +9 -10
@@ -56,6 +56,8 @@local_irq_{dis,en}able() */ +#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt +static const char version[] ="cs89x0.c:v1.02 11/26/96 Russell Nelson <[email protected]>\n" ;
@@ -245,16 +247,14 @@ static int mac89x0_device_probe(struct platform_device *pdev)if (net_debug && version_printed++ ==0 )printk (version); -printk (KERN_INFO "%s: cs89%c0%s rev %c found at %#8lx" , - dev->name, - lp->chip_type==CS8900 ?'0' :'2' , - lp->chip_type==CS8920M ?"M" :"" , - lp->chip_revision, - dev->base_addr); +pr_info ("cs89%c0%s rev %c found at %#8lx\n" , + lp->chip_type ==CS8900 ?'0' :'2' , + lp->chip_type ==CS8920M ?"M" :"" , + lp->chip_revision, dev->base_addr);/* Try to read the MAC address */ if ((readreg (dev, PP_SelfST) & (EEPROM_PRESENT |EEPROM_OK )) ==0 ) { -printk ("\nmac89x0: No EEPROM, giving up now.\n" ); +pr_info ("No EEPROM, giving up now.\n" ); goto out1; }else {for (i =0 ; i <ETH_ALEN ; i +=2 ) {
@@ -269,7 +269,7 @@ static int mac89x0_device_probe(struct platform_device *pdev)/* print the IRQ and ethernet address. */ -printk (" IRQ %d ADDR %pM\n" , dev->irq, dev->dev_addr); +pr_info ("MAC %pM, IRQ %d\n" , dev->dev_addr, dev->irq); dev->netdev_ops = &mac89x0_netdev_ops;
@@ -472,7 +472,6 @@ net_rx(struct net_device *dev)/* Malloc up new buffer. */ skb =alloc_skb (length,GFP_ATOMIC );if (skb ==NULL ) { -printk ("%s: Memory squeeze, dropping packet.\n" , dev->name); dev->stats.rx_dropped++;return ; }
@@ -560,7 +559,7 @@ static int set_mac_address(struct net_device *dev, void *addr)return -EADDRNOTAVAIL ;memcpy (dev->dev_addr, saddr->sa_data,ETH_ALEN ); -printk ("%s: Setting MAC address to %pM\n" , dev->name, dev->dev_addr); +netdev_info (dev,"Setting MAC address to %pM\n" , dev->dev_addr);/* set the Ethernet address */ for (i=0 ; i <ETH_ALEN /2 ; i++)
Signature · 1 line
2.16.1
PATCH 4/4 net/mac89x0: Replace custom debug logging with netif_* calls
In reply to Finn ThainAdopt the conventional style of debug logging because it is both shorter and more flexible.
Remove the 'version_printed' flag as the version will be printed only once anyway (when the module loads).
--- drivers/net/ethernet/cirrus/mac89x0.c | 47 +++++++++++------------------------ 1 file changed, 15 insertions(+), 32 deletions(-)
drivers/net/ethernet/cirrus/mac89x0.c +15 -32
@@ -61,18 +61,6 @@static const char version[] ="cs89x0.c:v1.02 11/26/96 Russell Nelson <[email protected]>\n" ; -/* ======================= configure the driver here ======================= */ - -/* use 0 for production, 1 for verification, >2 for debug */ -#ifndef NET_DEBUG -#define NET_DEBUG 0 -#endif - -/* ======================= end of configuration ======================= */ - - -/* Always include 'config.h' first in case the user wants to turn on -or override something. */ #include <linux/module.h> /*
@@ -108,14 +96,13 @@ static const char version[] =#include "cs89x0.h" -static int debug; +static int debug =-1 ;module_param (debug, int,0 ); -MODULE_PARM_DESC (debug,"CS89[02]0 debug level (0-5)" ); - -static unsigned int net_debug =NET_DEBUG ; +MODULE_PARM_DESC (debug,"debug message level" );/* Information that need to be kept for each board. */ struct net_local { +int msg_enable;int chip_type;/* one of: CS8900, CS8920, CS8920M */ char chip_revision;/* revision letter of the chip ('A'...) */ int send_cmd;/* the propercommand used to send a packet. */
@@ -178,7 +165,6 @@ static int mac89x0_device_probe(struct platform_device *pdev) {struct net_device *dev;struct net_local *lp; -static unsigned version_printed;int i, slot;unsigned rev_type =0 ;unsigned long ioaddr;
@@ -186,8 +172,6 @@ static int mac89x0_device_probe(struct platform_device *pdev)int err = -ENODEV ;struct nubus_rsrc *fres; - net_debug = debug; - dev =alloc_etherdev (sizeof (struct net_local ));if (!dev)return -ENOMEM ;
@@ -222,6 +206,8 @@ static int mac89x0_device_probe(struct platform_device *pdev)/* Initialize the net_device structure. */ lp =netdev_priv (dev); + lp->msg_enable =netif_msg_init (debug,0 ); +/* Fill in the 'dev' fields. */ dev->base_addr = ioaddr; dev->mem_start = (unsigned long)
@@ -244,8 +230,7 @@ static int mac89x0_device_probe(struct platform_device *pdev)if (lp->chip_type !=CS8900 && lp->chip_revision >='C' ) lp->send_cmd =TX_NOW ; -if (net_debug && version_printed++ ==0 ) -printk (version); +netif_dbg (lp, drv, dev,"%s" , version); pr_info("cs89%c0%s rev %c found at %#8lx\n", lp->chip_type == CS8900 ? '0' : '2',
@@ -345,11 +330,9 @@ net_send_packet(struct sk_buff *skb, struct net_device *dev)struct net_local *lp =netdev_priv (dev);unsigned long flags; -if (net_debug >3 ) -printk ("%s: sent %d byte packet of type %x\n" , - dev->name, skb->len, - (skb->data[ETH_ALEN +ETH_ALEN ] <<8 ) - | skb->data[ETH_ALEN +ETH_ALEN +1 ]); +netif_dbg (lp, tx_queued, dev,"sent %d byte packet of type %x\n" , + skb->len, skb->data[ETH_ALEN +ETH_ALEN ] <<8 | + skb->data[ETH_ALEN +ETH_ALEN +1 ]);/* keep the upload from being interrupted, since we ask the chip to start transmitting before the
@@ -398,7 +381,7 @@ static irqreturn_t net_interrupt(int irq, void *dev_id)faster than you can read them off, you're screwed. Hasta la vista, baby! */ while ((status =swab16 (nubus_readw (dev->base_addr +ISQ_PORT )))) { -if (net_debug >4 )printk ("%s: event=%04x\n" , dev->name, status); +netif_dbg (lp, intr, dev,"status=%04x\n" , status);switch (status &ISQ_EVENT_MASK ) {case ISQ_RECEIVER_EVENT :/* Got a packet(s). */
@@ -428,7 +411,7 @@ static irqreturn_t net_interrupt(int irq, void *dev_id)netif_wake_queue (dev); }if (status &TX_UNDERRUN ) { -if (net_debug >0 )printk ("%s: transmit underrun\n" , dev->name); +netif_dbg (lp, tx_err, dev,"transmit underrun\n" ); lp->send_underrun++;if (lp->send_underrun ==3 ) lp->send_cmd =TX_AFTER_381 ;else if (lp->send_underrun ==6 ) lp->send_cmd =TX_AFTER_ALL ;
@@ -449,6 +432,7 @@ static irqreturn_t net_interrupt(int irq, void *dev_id)static void net_rx (struct net_device *dev) { +struct net_local *lp =netdev_priv (dev);struct sk_buff *skb;int status, length;
@@ -480,10 +464,9 @@ net_rx(struct net_device *dev)skb_copy_to_linear_data (skb, (void *)(dev->mem_start + PP_RxFrame), length); -if (net_debug >3 )printk ("%s: received %d byte packet of type %x\n" , - dev->name, length, - (skb->data[ETH_ALEN +ETH_ALEN ] <<8 ) - | skb->data[ETH_ALEN +ETH_ALEN +1 ]); +netif_dbg (lp, rx_status, dev,"received %d byte packet of type %x\n" , + length, skb->data[ETH_ALEN +ETH_ALEN ] <<8 | + skb->data[ETH_ALEN +ETH_ALEN +1 ]); skb->protocol=eth_type_trans (skb,dev);netif_rx (skb);
Signature · 1 line
2.16.1
David Miller
maintainerFrom: Finn Thain <[email protected]>
Date: Thu, 1 Mar 2018 18:29:28 -0500 (EST)
Quoted 4 lines
Changes since v4 of combined patch series:
- Removed redundant and non-portableMACH_IS_MACtests.
- Added acked-by tags from Geert Uytterhoeven.
- Omitted patches unrelated to mac89x0 driver.
Series applied, thank you.