* [PATCH] (2/25) sk98: handle device rename impact on /proc
[not found] <20041115150910.0f3b8498@zqx3.pdx.osdl.net>
@ 2004-11-15 23:21 ` Stephen Hemminger
2004-11-15 23:21 ` [PATCH] (3/25) sk98: remove #define of net_device Stephen Hemminger
` (4 subsequent siblings)
5 siblings, 0 replies; 12+ messages in thread
From: Stephen Hemminger @ 2004-11-15 23:21 UTC (permalink / raw)
To: Jeff Garzik; +Cc: Mirko Lindner, netdev, Christoph Hellwig
Move all /proc related functions into skproc.c and handle device
name changes.
Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
diff -Nru a/drivers/net/sk98lin/Makefile b/drivers/net/sk98lin/Makefile
--- a/drivers/net/sk98lin/Makefile 2004-11-15 11:21:41 -08:00
+++ b/drivers/net/sk98lin/Makefile 2004-11-15 11:21:41 -08:00
@@ -27,8 +27,12 @@
sktimer.o \
skvpd.o \
skxmac2.o \
- skproc.o \
skcsum.o
+
+ifdef CONFIG_PROC_FS
+sk98lin-objs += skproc.o
+endif
+
# DBGDEF = \
# -DDEBUG
diff -Nru a/drivers/net/sk98lin/h/skdrv2nd.h b/drivers/net/sk98lin/h/skdrv2nd.h
--- a/drivers/net/sk98lin/h/skdrv2nd.h 2004-11-15 11:21:41 -08:00
+++ b/drivers/net/sk98lin/h/skdrv2nd.h 2004-11-15 11:21:41 -08:00
@@ -70,6 +70,19 @@
extern int SkDrvLeaveDiagMode(SK_AC *pAc);
#endif
+extern int SkGeXmit(struct sk_buff *skb, struct SK_NET_DEVICE *dev);
+#ifdef CONFIG_PROC_FS
+extern struct proc_dir_entry *SkGeProcCreate(struct net_device *dev);
+extern void SkGeProcRemove(struct proc_dir_entry *pe);
+extern void SkGeProcInit(void);
+extern void SkGeProcExit(void);
+#else
+#define SkGeProcCreate(dev) (NULL)
+#define SkGeProcRemove(pe) do { } while(0)
+#define SkGeProcInit() do { } while(0)
+#define SkGeProcExit() do { } while(0)
+#endif
+
struct s_DrvRlmtMbuf {
SK_MBUF *pNext; /* Pointer to next RLMT Mbuf. */
SK_U8 *pData; /* Data buffer (virtually contig.). */
@@ -266,11 +279,12 @@
typedef struct s_DevNet DEV_NET;
struct s_DevNet {
+ SK_AC *pAC;
int PortNr;
int NetNr;
int Mtu;
int Up;
- SK_AC *pAC;
+ struct proc_dir_entry *proc;
};
typedef struct s_TxPort TX_PORT;
diff -Nru a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c
--- a/drivers/net/sk98lin/skge.c 2004-11-15 11:21:41 -08:00
+++ b/drivers/net/sk98lin/skge.c 2004-11-15 11:21:41 -08:00
@@ -199,7 +199,6 @@
static SkIsrRetVar SkGeIsrOnePort(int irq, void *dev_id, struct pt_regs *ptregs);
static int SkGeOpen(struct SK_NET_DEVICE *dev);
static int SkGeClose(struct SK_NET_DEVICE *dev);
-static int SkGeXmit(struct sk_buff *skb, struct SK_NET_DEVICE *dev);
static int SkGeSetMacAddr(struct SK_NET_DEVICE *dev, void *p);
static void SkGeSetRxMode(struct SK_NET_DEVICE *dev);
static struct net_device_stats *SkGeStats(struct SK_NET_DEVICE *dev);
@@ -234,27 +233,6 @@
* Extern Function Prototypes
*
******************************************************************************/
-static const char SKRootName[] = "sk98lin";
-static struct proc_dir_entry *pSkRootDir;
-extern struct file_operations sk_proc_fops;
-
-static inline void SkGeProcCreate(struct net_device *dev)
-{
- struct proc_dir_entry *pe;
-
- if (pSkRootDir &&
- (pe = create_proc_entry(dev->name, S_IRUGO, pSkRootDir))) {
- pe->proc_fops = &sk_proc_fops;
- pe->data = dev;
- pe->owner = THIS_MODULE;
- }
-}
-
-static inline void SkGeProcRemove(struct net_device *dev)
-{
- if (pSkRootDir)
- remove_proc_entry(dev->name, pSkRootDir);
-}
extern void SkDimEnableModerationIfNeeded(SK_AC *pAC);
extern void SkDimDisplayModerationSettings(SK_AC *pAC);
@@ -1420,7 +1398,7 @@
* WARNING: returning 1 in 'tbusy' case caused system crashes (double
* allocated skb's) !!!
*/
-static int SkGeXmit(struct sk_buff *skb, struct SK_NET_DEVICE *dev)
+int SkGeXmit(struct sk_buff *skb, struct SK_NET_DEVICE *dev)
{
DEV_NET *pNet;
SK_AC *pAC;
@@ -5004,7 +4982,7 @@
memcpy(&dev->dev_addr, &pAC->Addr.Net[0].CurrentMacAddress, 6);
- SkGeProcCreate(dev);
+ pNet->proc = SkGeProcCreate(dev);
pNet->PortNr = 0;
pNet->NetNr = 0;
@@ -5053,7 +5031,7 @@
free_netdev(dev);
pAC->dev[1] = pAC->dev[0];
} else {
- SkGeProcCreate(dev);
+ pNet->proc = SkGeProcCreate(dev);
memcpy(&dev->dev_addr,
&pAC->Addr.Net[1].CurrentMacAddress, 6);
@@ -5093,10 +5071,12 @@
SK_AC *pAC = pNet->pAC;
struct net_device *otherdev = pAC->dev[1];
- SkGeProcRemove(dev);
+ SkGeProcRemove(pNet->proc);
unregister_netdev(dev);
- if (otherdev != dev)
- SkGeProcRemove(otherdev);
+ if (otherdev != dev) {
+ DEV_NET *otherNet = netdev_priv(otherdev);
+ SkGeProcRemove(otherNet->proc);
+ }
SkGeYellowLED(pAC, pAC->IoBase, 0);
@@ -5163,21 +5143,18 @@
{
int error;
- pSkRootDir = proc_mkdir(SKRootName, proc_net);
- if (pSkRootDir)
- pSkRootDir->owner = THIS_MODULE;
+ SkGeProcInit();
error = pci_register_driver(&skge_driver);
if (error)
- proc_net_remove(SKRootName);
+ SkGeProcExit();
return error;
}
static void __exit skge_exit(void)
{
pci_unregister_driver(&skge_driver);
- proc_net_remove(SKRootName);
-
+ SkGeProcExit();
}
module_init(skge_init);
diff -Nru a/drivers/net/sk98lin/skproc.c b/drivers/net/sk98lin/skproc.c
--- a/drivers/net/sk98lin/skproc.c 2004-11-15 11:21:41 -08:00
+++ b/drivers/net/sk98lin/skproc.c 2004-11-15 11:21:41 -08:00
@@ -31,10 +31,13 @@
#include "h/skdrv2nd.h"
#include "h/skversion.h"
+static const char SKRootName[] = "sk98lin";
+static struct proc_dir_entry *pSkRootDir;
+
static int sk_seq_show(struct seq_file *seq, void *v);
static int sk_proc_open(struct inode *inode, struct file *file);
-struct file_operations sk_proc_fops = {
+static struct file_operations sk_proc_fops = {
.owner = THIS_MODULE,
.open = sk_proc_open,
.read = seq_read,
@@ -258,8 +261,66 @@
return single_open(file, sk_seq_show, PDE(inode)->data);
}
-/*******************************************************************************
- *
- * End of file
- *
- ******************************************************************************/
+
+struct proc_dir_entry *SkGeProcCreate(struct net_device *dev)
+{
+ struct proc_dir_entry *pe = NULL;
+
+ if (pSkRootDir &&
+ (pe = create_proc_entry(dev->name, S_IRUGO, pSkRootDir))) {
+ pe->proc_fops = &sk_proc_fops;
+ pe->data = dev;
+ pe->owner = THIS_MODULE;
+ }
+ return pe;
+}
+
+void SkGeProcRemove(struct proc_dir_entry *pe)
+{
+ char oldname[IFNAMSIZ];
+
+ if (pe) {
+ strlcpy(oldname, pe->name, IFNAMSIZ);
+ remove_proc_entry(oldname, pSkRootDir);
+ }
+}
+
+/* Callback about network device events.
+ * Only care if device is this driver and it is a name change
+ */
+static int skge_device_notifier(struct notifier_block *unused,
+ unsigned long event, void *ptr)
+{
+ struct net_device *dev = ptr;
+ DEV_NET *pNet = netdev_priv(dev);
+
+ if (event == NETDEV_CHANGENAME
+ && dev->hard_start_xmit == &SkGeXmit
+ && pNet->proc) {
+ SkGeProcRemove(pNet->proc);
+ pNet->proc = SkGeProcCreate(dev);
+ }
+ return NOTIFY_DONE;
+}
+
+static struct notifier_block skge_dev_notifier = {
+ .notifier_call = skge_device_notifier,
+};
+
+void SkGeProcInit(void)
+{
+ pSkRootDir = proc_mkdir(SKRootName, proc_net);
+ if (pSkRootDir) {
+ pSkRootDir->owner = THIS_MODULE;
+ register_netdevice_notifier(&skge_dev_notifier);
+ }
+}
+
+void SkGeProcExit(void)
+{
+ if (pSkRootDir) {
+ proc_net_remove(SKRootName);
+ unregister_netdevice_notifier(&skge_dev_notifier);
+ }
+}
+
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH] (3/25) sk98: remove #define of net_device
[not found] <20041115150910.0f3b8498@zqx3.pdx.osdl.net>
2004-11-15 23:21 ` [PATCH] (2/25) sk98: handle device rename impact on /proc Stephen Hemminger
@ 2004-11-15 23:21 ` Stephen Hemminger
2004-11-15 23:22 ` [PATCH] (4/25) sk98: change #define to typedef Stephen Hemminger
` (3 subsequent siblings)
5 siblings, 0 replies; 12+ messages in thread
From: Stephen Hemminger @ 2004-11-15 23:21 UTC (permalink / raw)
To: Jeff Garzik; +Cc: Mirko Lindner, netdev, Christoph Hellwig
Get rid of obfuscating #define of net_device.
Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
diff -Nru a/drivers/net/sk98lin/h/skdrv1st.h b/drivers/net/sk98lin/h/skdrv1st.h
--- a/drivers/net/sk98lin/h/skdrv1st.h 2004-11-15 11:22:11 -08:00
+++ b/drivers/net/sk98lin/h/skdrv1st.h 2004-11-15 11:22:11 -08:00
@@ -96,9 +96,6 @@
#define SK_BIG_ENDIAN
#endif
-#define SK_NET_DEVICE net_device
-
-
/* we use gethrtime(), return unit: nanoseconds */
#define SK_TICKS_PER_SEC 100
diff -Nru a/drivers/net/sk98lin/h/skdrv2nd.h b/drivers/net/sk98lin/h/skdrv2nd.h
--- a/drivers/net/sk98lin/h/skdrv2nd.h 2004-11-15 11:22:11 -08:00
+++ b/drivers/net/sk98lin/h/skdrv2nd.h 2004-11-15 11:22:11 -08:00
@@ -70,7 +70,7 @@
extern int SkDrvLeaveDiagMode(SK_AC *pAc);
#endif
-extern int SkGeXmit(struct sk_buff *skb, struct SK_NET_DEVICE *dev);
+extern int SkGeXmit(struct sk_buff *skb, struct net_device *dev);
#ifdef CONFIG_PROC_FS
extern struct proc_dir_entry *SkGeProcCreate(struct net_device *dev);
extern void SkGeProcRemove(struct proc_dir_entry *pe);
@@ -408,7 +408,7 @@
SK_U32 AllocFlag; /* flag allocation of resources */
struct pci_dev *PciDev; /* for access to pci config space */
SK_U32 PciDevId; /* pci device id */
- struct SK_NET_DEVICE *dev[2]; /* pointer to device struct */
+ struct net_device *dev[2]; /* pointer to device struct */
char Name[30]; /* driver name */
int RxBufSize; /* length of receive buffers */
diff -Nru a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c
--- a/drivers/net/sk98lin/skge.c 2004-11-15 11:22:11 -08:00
+++ b/drivers/net/sk98lin/skge.c 2004-11-15 11:22:11 -08:00
@@ -189,20 +189,20 @@
*
******************************************************************************/
-static void FreeResources(struct SK_NET_DEVICE *dev);
-static int SkGeBoardInit(struct SK_NET_DEVICE *dev, SK_AC *pAC);
+static void FreeResources(struct net_device *dev);
+static int SkGeBoardInit(struct net_device *dev, SK_AC *pAC);
static SK_BOOL BoardAllocMem(SK_AC *pAC);
static void BoardFreeMem(SK_AC *pAC);
static void BoardInitMem(SK_AC *pAC);
static void SetupRing(SK_AC*, void*, uintptr_t, RXD**, RXD**, RXD**, int*, SK_BOOL);
static SkIsrRetVar SkGeIsr(int irq, void *dev_id, struct pt_regs *ptregs);
static SkIsrRetVar SkGeIsrOnePort(int irq, void *dev_id, struct pt_regs *ptregs);
-static int SkGeOpen(struct SK_NET_DEVICE *dev);
-static int SkGeClose(struct SK_NET_DEVICE *dev);
-static int SkGeSetMacAddr(struct SK_NET_DEVICE *dev, void *p);
-static void SkGeSetRxMode(struct SK_NET_DEVICE *dev);
-static struct net_device_stats *SkGeStats(struct SK_NET_DEVICE *dev);
-static int SkGeIoctl(struct SK_NET_DEVICE *dev, struct ifreq *rq, int cmd);
+static int SkGeOpen(struct net_device *dev);
+static int SkGeClose(struct net_device *dev);
+static int SkGeSetMacAddr(struct net_device *dev, void *p);
+static void SkGeSetRxMode(struct net_device *dev);
+static struct net_device_stats *SkGeStats(struct net_device *dev);
+static int SkGeIoctl(struct net_device *dev, struct ifreq *rq, int cmd);
static void GetConfiguration(SK_AC*);
static void ProductStr(SK_AC*);
static int XmitFrame(SK_AC*, TX_PORT*, struct sk_buff*);
@@ -214,7 +214,7 @@
static void ClearTxIrq(SK_AC*, int, int);
static void ClearRxRing(SK_AC*, RX_PORT*);
static void ClearTxRing(SK_AC*, TX_PORT*);
-static int SkGeChangeMtu(struct SK_NET_DEVICE *dev, int new_mtu);
+static int SkGeChangeMtu(struct net_device *dev, int new_mtu);
static void PortReInitBmu(SK_AC*, int);
static int SkGeIocMib(DEV_NET*, unsigned int, int);
static int SkGeInitPCI(SK_AC *pAC);
@@ -266,7 +266,7 @@
*/
int SkGeInitPCI(SK_AC *pAC)
{
- struct SK_NET_DEVICE *dev = pAC->dev[0];
+ struct net_device *dev = pAC->dev[0];
struct pci_dev *pdev = pAC->PciDev;
int retval;
@@ -326,7 +326,7 @@
* Returns: N/A
*
*/
-static void FreeResources(struct SK_NET_DEVICE *dev)
+static void FreeResources(struct net_device *dev)
{
SK_U32 AllocFlag;
DEV_NET *pNet;
@@ -471,7 +471,7 @@
* 0, if everything is ok
* !=0, on error
*/
-static int __init SkGeBoardInit(struct SK_NET_DEVICE *dev, SK_AC *pAC)
+static int __init SkGeBoardInit(struct net_device *dev, SK_AC *pAC)
{
short i;
unsigned long Flags;
@@ -874,7 +874,7 @@
*/
static SkIsrRetVar SkGeIsr(int irq, void *dev_id, struct pt_regs *ptregs)
{
-struct SK_NET_DEVICE *dev = (struct SK_NET_DEVICE *)dev_id;
+struct net_device *dev = (struct net_device *)dev_id;
DEV_NET *pNet;
SK_AC *pAC;
SK_U32 IntSrc; /* interrupts source register contents */
@@ -1023,7 +1023,7 @@
*/
static SkIsrRetVar SkGeIsrOnePort(int irq, void *dev_id, struct pt_regs *ptregs)
{
-struct SK_NET_DEVICE *dev = (struct SK_NET_DEVICE *)dev_id;
+struct net_device *dev = (struct net_device *)dev_id;
DEV_NET *pNet;
SK_AC *pAC;
SK_U32 IntSrc; /* interrupts source register contents */
@@ -1154,7 +1154,7 @@
* != 0 on error
*/
static int SkGeOpen(
-struct SK_NET_DEVICE *dev)
+struct net_device *dev)
{
DEV_NET *pNet;
SK_AC *pAC;
@@ -1269,7 +1269,7 @@
* error code - on error
*/
static int SkGeClose(
-struct SK_NET_DEVICE *dev)
+struct net_device *dev)
{
DEV_NET *pNet;
DEV_NET *newPtrNet;
@@ -1398,7 +1398,7 @@
* WARNING: returning 1 in 'tbusy' case caused system crashes (double
* allocated skb's) !!!
*/
-int SkGeXmit(struct sk_buff *skb, struct SK_NET_DEVICE *dev)
+int SkGeXmit(struct sk_buff *skb, struct net_device *dev)
{
DEV_NET *pNet;
SK_AC *pAC;
@@ -2497,7 +2497,7 @@
* 0, if everything is ok
* !=0, on error
*/
-static int SkGeSetMacAddr(struct SK_NET_DEVICE *dev, void *p)
+static int SkGeSetMacAddr(struct net_device *dev, void *p)
{
DEV_NET *pNet = netdev_priv(dev);
@@ -2543,7 +2543,7 @@
* 0, if everything is ok
* !=0, on error
*/
-static void SkGeSetRxMode(struct SK_NET_DEVICE *dev)
+static void SkGeSetRxMode(struct net_device *dev)
{
DEV_NET *pNet;
@@ -2617,7 +2617,7 @@
* 0, if everything is ok
* !=0, on error
*/
-static int SkGeChangeMtu(struct SK_NET_DEVICE *dev, int NewMtu)
+static int SkGeChangeMtu(struct net_device *dev, int NewMtu)
{
DEV_NET *pNet;
DEV_NET *pOtherNet;
@@ -2855,7 +2855,7 @@
* Returns:
* pointer to the statistic structure.
*/
-static struct net_device_stats *SkGeStats(struct SK_NET_DEVICE *dev)
+static struct net_device_stats *SkGeStats(struct net_device *dev)
{
DEV_NET *pNet = netdev_priv(dev);
SK_AC *pAC = pNet->pAC;
@@ -2939,7 +2939,7 @@
* 0, if everything is ok
* !=0, on error
*/
-static int SkGeIoctl(struct SK_NET_DEVICE *dev, struct ifreq *rq, int cmd)
+static int SkGeIoctl(struct net_device *dev, struct ifreq *rq, int cmd)
{
DEV_NET *pNet;
SK_AC *pAC;
@@ -4676,7 +4676,7 @@
SK_AC *pAC, /* pointer to adapter context */
int devNbr) /* what device is to be handled */
{
- struct SK_NET_DEVICE *dev;
+ struct net_device *dev;
dev = pAC->dev[devNbr];
@@ -4707,7 +4707,7 @@
SK_AC *pAC, /* pointer to adapter context */
int devNbr) /* what device is to be handled */
{
- struct SK_NET_DEVICE *dev;
+ struct net_device *dev;
dev = pAC->dev[devNbr];
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH] (4/25) sk98: change #define to typedef
[not found] <20041115150910.0f3b8498@zqx3.pdx.osdl.net>
2004-11-15 23:21 ` [PATCH] (2/25) sk98: handle device rename impact on /proc Stephen Hemminger
2004-11-15 23:21 ` [PATCH] (3/25) sk98: remove #define of net_device Stephen Hemminger
@ 2004-11-15 23:22 ` Stephen Hemminger
2004-11-16 8:22 ` Christoph Hellwig
2004-11-15 23:22 ` [PATCH] (5/25) sk98: elimnate nested macro Stephen Hemminger
` (2 subsequent siblings)
5 siblings, 1 reply; 12+ messages in thread
From: Stephen Hemminger @ 2004-11-15 23:22 UTC (permalink / raw)
To: Jeff Garzik; +Cc: Mirko Lindner, netdev
Change #define of to a typedef.
Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
diff -Nru a/drivers/net/sk98lin/h/skdrv1st.h b/drivers/net/sk98lin/h/skdrv1st.h
--- a/drivers/net/sk98lin/h/skdrv1st.h 2004-11-15 11:22:28 -08:00
+++ b/drivers/net/sk98lin/h/skdrv1st.h 2004-11-15 11:22:28 -08:00
@@ -106,7 +106,7 @@
#define SK_MAX_MACS 2
#define SK_MAX_NETS 2
-#define SK_IOC char __iomem *
+typedef void __iomem *SK_IOC;
typedef struct s_DrvRlmtMbuf SK_MBUF;
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH] (5/25) sk98: elimnate nested macro.
[not found] <20041115150910.0f3b8498@zqx3.pdx.osdl.net>
` (2 preceding siblings ...)
2004-11-15 23:22 ` [PATCH] (4/25) sk98: change #define to typedef Stephen Hemminger
@ 2004-11-15 23:22 ` Stephen Hemminger
2004-11-16 8:23 ` Christoph Hellwig
2004-11-15 23:22 ` [PATCH] (6/25) sk98: get rid of #define's for C99 types Stephen Hemminger
2004-11-15 23:23 ` [PATCH] (7/25) sk98: remove unneeded include's Stephen Hemminger
5 siblings, 1 reply; 12+ messages in thread
From: Stephen Hemminger @ 2004-11-15 23:22 UTC (permalink / raw)
To: Jeff Garzik; +Cc: Mirko Lindner, netdev
Replace nested macros to handle defining 64bit constants with
simpler macro. Would prefer to just remove it but it gets used in multiple
OS common code.
Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
diff -Nru a/drivers/net/sk98lin/h/skdrv1st.h b/drivers/net/sk98lin/h/skdrv1st.h
--- a/drivers/net/sk98lin/h/skdrv1st.h 2004-11-15 11:22:48 -08:00
+++ b/drivers/net/sk98lin/h/skdrv1st.h 2004-11-15 11:22:48 -08:00
@@ -110,8 +110,8 @@
typedef struct s_DrvRlmtMbuf SK_MBUF;
-#define SK_CONST64 INT64_C
-#define SK_CONSTU64 UINT64_C
+#define SK_CONST64(x) (x##ll)
+#define SK_CONSTU64(x) (x##ull)
#define SK_MEMCPY(dest,src,size) memcpy(dest,src,size)
#define SK_MEMCMP(s1,s2,size) memcmp(s1,s2,size)
@@ -139,13 +139,6 @@
#define t_scalar_t int
#define t_uscalar_t unsigned int
#define uintptr_t unsigned long
-
-#define __CONCAT__(A,B) A##B
-
-#define INT32_C(a) __CONCAT__(a,L)
-#define INT64_C(a) __CONCAT__(a,LL)
-#define UINT32_C(a) __CONCAT__(a,UL)
-#define UINT64_C(a) __CONCAT__(a,ULL)
#ifdef DEBUG
#define SK_DBG_PRINTF printk
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH] (6/25) sk98: get rid of #define's for C99 types
[not found] <20041115150910.0f3b8498@zqx3.pdx.osdl.net>
` (3 preceding siblings ...)
2004-11-15 23:22 ` [PATCH] (5/25) sk98: elimnate nested macro Stephen Hemminger
@ 2004-11-15 23:22 ` Stephen Hemminger
2004-11-15 23:23 ` [PATCH] (7/25) sk98: remove unneeded include's Stephen Hemminger
5 siblings, 0 replies; 12+ messages in thread
From: Stephen Hemminger @ 2004-11-15 23:22 UTC (permalink / raw)
To: Jeff Garzik; +Cc: Mirko Lindner, netdev
Get rid of #define's for type's and use proper kernel types.
Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
diff -Nru a/drivers/net/sk98lin/h/skdrv1st.h b/drivers/net/sk98lin/h/skdrv1st.h
--- a/drivers/net/sk98lin/h/skdrv1st.h 2004-11-15 11:24:00 -08:00
+++ b/drivers/net/sk98lin/h/skdrv1st.h 2004-11-15 11:24:00 -08:00
@@ -123,18 +123,6 @@
#define SK_IN16(b,a,pv) (*(pv) = readw((b)+(a)))
#define SK_IN32(b,a,pv) (*(pv) = readl((b)+(a)))
-#define int8_t char
-#define int16_t short
-#define int32_t long
-#define int64_t long long
-#define uint8_t u_char
-#define uint16_t u_short
-#define uint32_t u_long
-#define uint64_t unsigned long long
-#define t_scalar_t int
-#define t_uscalar_t unsigned int
-#define uintptr_t unsigned long
-
#ifdef DEBUG
#define SK_DBG_PRINTF printk
#ifndef SK_DEBUG_CHKMOD
diff -Nru a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c
--- a/drivers/net/sk98lin/skge.c 2004-11-15 11:24:00 -08:00
+++ b/drivers/net/sk98lin/skge.c 2004-11-15 11:24:00 -08:00
@@ -194,7 +194,7 @@
static SK_BOOL BoardAllocMem(SK_AC *pAC);
static void BoardFreeMem(SK_AC *pAC);
static void BoardInitMem(SK_AC *pAC);
-static void SetupRing(SK_AC*, void*, uintptr_t, RXD**, RXD**, RXD**, int*, SK_BOOL);
+static void SetupRing(SK_AC*, void*, u64, RXD**, RXD**, RXD**, int*, SK_BOOL);
static SkIsrRetVar SkGeIsr(int irq, void *dev_id, struct pt_regs *ptregs);
static SkIsrRetVar SkGeIsrOnePort(int irq, void *dev_id, struct pt_regs *ptregs);
static int SkGeOpen(struct net_device *dev);
@@ -251,8 +251,8 @@
extern struct ethtool_ops SkGeEthtoolOps;
/* local variables **********************************************************/
-static uintptr_t TxQueueAddr[SK_MAX_MACS][2] = {{0x680, 0x600},{0x780, 0x700}};
-static uintptr_t RxQueueAddr[SK_MAX_MACS] = {0x400, 0x480};
+static u32 TxQueueAddr[SK_MAX_MACS][2] = {{0x680, 0x600},{0x780, 0x700}};
+static u32 RxQueueAddr[SK_MAX_MACS] = {0x400, 0x480};
/*****************************************************************************
*
@@ -763,7 +763,7 @@
static void SetupRing(
SK_AC *pAC,
void *pMemArea, /* a pointer to the memory area for the ring */
-uintptr_t VMemArea, /* the virtual bus address of the memory area */
+u64 VMemArea, /* the virtual bus address of the memory area */
RXD **ppRingHead, /* address where the head should be written */
RXD **ppRingTail, /* address where the tail should be written */
RXD **ppRingPrev, /* address where the tail should be written */
@@ -776,7 +776,7 @@
RXD *pDescr; /* pointer to a descriptor (receive or transmit) */
RXD *pNextDescr; /* pointer to the next descriptor */
RXD *pPrevDescr; /* pointer to the previous descriptor */
-uintptr_t VNextDescr; /* the virtual bus address of the next descriptor */
+u64 VNextDescr; /* the virtual bus address of the next descriptor */
if (IsTx == SK_TRUE) {
DescrSize = (((sizeof(TXD) - 1) / DESCR_ALIGN) + 1) *
@@ -839,22 +839,22 @@
/* set address of first descriptor of ring in BMU */
SK_OUT32(pAC->IoBase, TxQueueAddr[PortIndex][TX_PRIO_LOW]+ Q_DA_L,
- (uint32_t)(((caddr_t)
+ (u32)(((caddr_t)
(pAC->TxPort[PortIndex][TX_PRIO_LOW].pTxdRingHead) -
pAC->TxPort[PortIndex][TX_PRIO_LOW].pTxDescrRing +
pAC->TxPort[PortIndex][TX_PRIO_LOW].VTxDescrRing) &
0xFFFFFFFF));
SK_OUT32(pAC->IoBase, TxQueueAddr[PortIndex][TX_PRIO_LOW]+ Q_DA_H,
- (uint32_t)(((caddr_t)
+ (u32)(((caddr_t)
(pAC->TxPort[PortIndex][TX_PRIO_LOW].pTxdRingHead) -
pAC->TxPort[PortIndex][TX_PRIO_LOW].pTxDescrRing +
pAC->TxPort[PortIndex][TX_PRIO_LOW].VTxDescrRing) >> 32));
SK_OUT32(pAC->IoBase, RxQueueAddr[PortIndex]+Q_DA_L,
- (uint32_t)(((caddr_t)(pAC->RxPort[PortIndex].pRxdRingHead) -
+ (u32)(((caddr_t)(pAC->RxPort[PortIndex].pRxdRingHead) -
pAC->RxPort[PortIndex].pRxDescrRing +
pAC->RxPort[PortIndex].VRxDescrRing) & 0xFFFFFFFF));
SK_OUT32(pAC->IoBase, RxQueueAddr[PortIndex]+Q_DA_H,
- (uint32_t)(((caddr_t)(pAC->RxPort[PortIndex].pRxdRingHead) -
+ (u32)(((caddr_t)(pAC->RxPort[PortIndex].pRxdRingHead) -
pAC->RxPort[PortIndex].pRxDescrRing +
pAC->RxPort[PortIndex].VRxDescrRing) >> 32));
} /* PortReInitBmu */
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH] (7/25) sk98: remove unneeded include's
[not found] <20041115150910.0f3b8498@zqx3.pdx.osdl.net>
` (4 preceding siblings ...)
2004-11-15 23:22 ` [PATCH] (6/25) sk98: get rid of #define's for C99 types Stephen Hemminger
@ 2004-11-15 23:23 ` Stephen Hemminger
5 siblings, 0 replies; 12+ messages in thread
From: Stephen Hemminger @ 2004-11-15 23:23 UTC (permalink / raw)
To: Jeff Garzik; +Cc: Mirko Lindner, netdev
Remove extraneous header includes
Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
diff -Nru a/drivers/net/sk98lin/h/skdrv1st.h b/drivers/net/sk98lin/h/skdrv1st.h
--- a/drivers/net/sk98lin/h/skdrv1st.h 2004-11-15 11:23:03 -08:00
+++ b/drivers/net/sk98lin/h/skdrv1st.h 2004-11-15 11:23:03 -08:00
@@ -39,9 +39,6 @@
#ifndef __INC_SKDRV1ST_H
#define __INC_SKDRV1ST_H
-/* Check kernel version */
-#include <linux/version.h>
-
typedef struct s_AC SK_AC;
/* Set card versions */
@@ -62,8 +59,6 @@
#include <linux/kernel.h>
#include <linux/string.h>
#include <linux/errno.h>
-#include <linux/ioport.h>
-#include <linux/slab.h>
#include <linux/interrupt.h>
#include <linux/pci.h>
#include <linux/bitops.h>
@@ -75,7 +70,7 @@
#include <linux/init.h>
#include <asm/uaccess.h>
-#include <net/checksum.h>
+
#define SK_CS_CALCULATE_CHECKSUM
#ifndef CONFIG_X86_64
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] (4/25) sk98: change #define to typedef
2004-11-15 23:22 ` [PATCH] (4/25) sk98: change #define to typedef Stephen Hemminger
@ 2004-11-16 8:22 ` Christoph Hellwig
0 siblings, 0 replies; 12+ messages in thread
From: Christoph Hellwig @ 2004-11-16 8:22 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: Jeff Garzik, Mirko Lindner, netdev
On Mon, Nov 15, 2004 at 03:22:03PM -0800, Stephen Hemminger wrote:
> Change #define of to a typedef.
>
> Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
>
> diff -Nru a/drivers/net/sk98lin/h/skdrv1st.h b/drivers/net/sk98lin/h/skdrv1st.h
> --- a/drivers/net/sk98lin/h/skdrv1st.h 2004-11-15 11:22:28 -08:00
> +++ b/drivers/net/sk98lin/h/skdrv1st.h 2004-11-15 11:22:28 -08:00
> @@ -106,7 +106,7 @@
> #define SK_MAX_MACS 2
> #define SK_MAX_NETS 2
>
> -#define SK_IOC char __iomem *
> +typedef void __iomem *SK_IOC;
Why do you need the typedef at all? Just about every driver on the
planet is fine with a single void *__iomem iobase; in the per-device
structure
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] (5/25) sk98: elimnate nested macro.
2004-11-15 23:22 ` [PATCH] (5/25) sk98: elimnate nested macro Stephen Hemminger
@ 2004-11-16 8:23 ` Christoph Hellwig
0 siblings, 0 replies; 12+ messages in thread
From: Christoph Hellwig @ 2004-11-16 8:23 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: Jeff Garzik, Mirko Lindner, netdev
On Mon, Nov 15, 2004 at 03:22:08PM -0800, Stephen Hemminger wrote:
> Replace nested macros to handle defining 64bit constants with
> simpler macro. Would prefer to just remove it but it gets used in multiple
> OS common code.
I don't think the driver is complex enough for all that os-common mess.
If you look at the BSD sk driver it's about a third of the size of the
Linux driver because it doesn't have all this mess.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] (4/25) sk98: change #define to typedef
@ 2004-11-16 15:56 Mirko Lindner
2004-11-16 17:12 ` Stephen Hemminger
2004-11-17 15:01 ` Christoph Hellwig
0 siblings, 2 replies; 12+ messages in thread
From: Mirko Lindner @ 2004-11-16 15:56 UTC (permalink / raw)
To: Christoph Hellwig, Stephen Hemminger
Cc: Jeff Garzik, Mirko Lindner, netdev, Ralph Roesler
> I don't think the driver is complex enough for all that os-common mess.
> If you look at the BSD sk driver it's about a third of the size of the
> Linux driver because it doesn't have all this mess.
Note that the kernel BSD sk driver was _not_ written by SysKonnect and
only supports Genesis and Yukon1; linux supports Genesis (single and
dual), Yukon1, Yukon Plus, Yukon EC, Yukon FE and Yukon2 (single and
dual). The BSD sk driver supports substantially less functionality than
the Linux driver. For example, there is no link failover capability in
the sk driver; it has no power management; numerous chip changes and
minor tweaks have not been added, since many problems have become
apparent through our other supported platforms (some 15 operating
systems) and have since been fixed in our common modules; sk has no
wake-on-LAN and so on. The official SysKonnect BSD driver (yk) also uses
the common modules and is not open source.
However, the real point is that the Linux driver (as indeed _all_ of our
drivers) shares common code with all our supported platforms and this
necessarily introduces some overhead. But it isn't excessive, and the
benefits _far_ outweigh the drawbacks, namely, that we have a very wide
range of systems sharing common code and thus the probability of finding
and fixing bugs is very substantially higher than if we wrote a
dedicated driver for each platform.
For instance the symbol SK_IOC mentioned in your mail:
> -#define SK_IOC char __iomem *
> +typedef void __iomem *SK_IOC;
is used in a large number of OS independent driver files (e.g. skvpd.c).
The -for instance- file skvpd.c used by our Linux driver is used
at the same time without any changes by all our other drivers running
on other operating systems (e.g. Solaris, Windows).
This is the reason why we need to redefine this symbol to the Linux
specific implementation (void __iomem).
Mirko
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] (4/25) sk98: change #define to typedef
2004-11-16 15:56 [PATCH] (4/25) sk98: change #define to typedef Mirko Lindner
@ 2004-11-16 17:12 ` Stephen Hemminger
2004-11-17 15:01 ` Christoph Hellwig
1 sibling, 0 replies; 12+ messages in thread
From: Stephen Hemminger @ 2004-11-16 17:12 UTC (permalink / raw)
To: Mirko Lindner
Cc: Christoph Hellwig, Jeff Garzik, Mirko Lindner, netdev,
Ralph Roesler
On Tue, 16 Nov 2004 15:56:15 +0000
Mirko Lindner <mlindner@syskonnect.de> wrote:
> > I don't think the driver is complex enough for all that os-common mess.
> > If you look at the BSD sk driver it's about a third of the size of the
> > Linux driver because it doesn't have all this mess.
>
> Note that the kernel BSD sk driver was _not_ written by SysKonnect and
> only supports Genesis and Yukon1; linux supports Genesis (single and
> dual), Yukon1, Yukon Plus, Yukon EC, Yukon FE and Yukon2 (single and
> dual). The BSD sk driver supports substantially less functionality than
> the Linux driver. For example, there is no link failover capability in
> the sk driver; it has no power management; numerous chip changes and
> minor tweaks have not been added, since many problems have become
> apparent through our other supported platforms (some 15 operating
> systems) and have since been fixed in our common modules; sk has no
> wake-on-LAN and so on. The official SysKonnect BSD driver (yk) also uses
> the common modules and is not open source.
>
> However, the real point is that the Linux driver (as indeed _all_ of our
> drivers) shares common code with all our supported platforms and this
> necessarily introduces some overhead. But it isn't excessive, and the
> benefits _far_ outweigh the drawbacks, namely, that we have a very wide
> range of systems sharing common code and thus the probability of finding
> and fixing bugs is very substantially higher than if we wrote a
> dedicated driver for each platform.
>
> For instance the symbol SK_IOC mentioned in your mail:
>
> > -#define SK_IOC char __iomem *
> > +typedef void __iomem *SK_IOC;
>
> is used in a large number of OS independent driver files (e.g. skvpd.c).
> The -for instance- file skvpd.c used by our Linux driver is used
> at the same time without any changes by all our other drivers running
> on other operating systems (e.g. Solaris, Windows).
>
> This is the reason why we need to redefine this symbol to the Linux
> specific implementation (void __iomem).
I understand the benefits of a common driver, but there are costs too.
First, it means the community can't really support or fix the common code
only SysKonnect can. Also, there is functionality in the common part that
really isn't necessary:
* Vendor specific MIB support -- what tool could/does use that?
* Board specific bridging support
If the regular Linux infrastructure was used for these, then the
driver would get additional kernel bridge filtering, common management and security fixes.
My wish is that the common hardware layer could be used without dragging
in all the MIB and bridging stuff.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] (4/25) sk98: change #define to typedef
2004-11-16 15:56 [PATCH] (4/25) sk98: change #define to typedef Mirko Lindner
2004-11-16 17:12 ` Stephen Hemminger
@ 2004-11-17 15:01 ` Christoph Hellwig
2004-11-19 0:23 ` Stephen Hemminger
1 sibling, 1 reply; 12+ messages in thread
From: Christoph Hellwig @ 2004-11-17 15:01 UTC (permalink / raw)
To: Mirko Lindner
Cc: Stephen Hemminger, Jeff Garzik, Mirko Lindner, netdev,
Ralph Roesler
> Note that the kernel BSD sk driver was _not_ written by SysKonnect and
> only supports Genesis and Yukon1; linux supports Genesis (single and
> dual), Yukon1, Yukon Plus, Yukon EC, Yukon FE and Yukon2 (single and
> dual).
They have Yukon2 support for while - unlike Linux.
> The BSD sk driver supports substantially less functionality than
> the Linux driver. For example, there is no link failover capability in
> the sk driver;
Which isn't something that belongs into a driver anyway. It also
means you common code is obsfucated enough that no one noticed :)
> For instance the symbol SK_IOC mentioned in your mail:
>
> > -#define SK_IOC char __iomem *
> > +typedef void __iomem *SK_IOC;
>
> is used in a large number of OS independent driver files (e.g. skvpd.c).
> The -for instance- file skvpd.c used by our Linux driver is used
> at the same time without any changes by all our other drivers running
> on other operating systems (e.g. Solaris, Windows).
>
> This is the reason why we need to redefine this symbol to the Linux
> specific implementation (void __iomem).
And you still haven't explained why your common code uses such
a broken structure instead of having some semi-opaque private data
passed around everywhere.
Also note that we don't new drivers using such horrible "common code"
anymore, you can be happy you sneaked it in at all a few years ago.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] (4/25) sk98: change #define to typedef
2004-11-17 15:01 ` Christoph Hellwig
@ 2004-11-19 0:23 ` Stephen Hemminger
0 siblings, 0 replies; 12+ messages in thread
From: Stephen Hemminger @ 2004-11-19 0:23 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Mirko Lindner, Jeff Garzik, Mirko Lindner, netdev, Ralph Roesler
On Wed, 17 Nov 2004 15:01:34 +0000
Christoph Hellwig <hch@infradead.org> wrote:
> > Note that the kernel BSD sk driver was _not_ written by SysKonnect and
> > only supports Genesis and Yukon1; linux supports Genesis (single and
> > dual), Yukon1, Yukon Plus, Yukon EC, Yukon FE and Yukon2 (single and
> > dual).
>
> They have Yukon2 support for while - unlike Linux.
>
> > The BSD sk driver supports substantially less functionality than
> > the Linux driver. For example, there is no link failover capability in
> > the sk driver;
Is it even possible to do link failover with existing Open Source tools?
Also the whole Remote Link Mangement (RLMT) stuff has no security so
if it is used over a hostile network look out.
I intrigued by the idea of of porting FreeBSD driver to Linux. But this card
is already taking more time than I want to spend.
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2004-11-19 0:23 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20041115150910.0f3b8498@zqx3.pdx.osdl.net>
2004-11-15 23:21 ` [PATCH] (2/25) sk98: handle device rename impact on /proc Stephen Hemminger
2004-11-15 23:21 ` [PATCH] (3/25) sk98: remove #define of net_device Stephen Hemminger
2004-11-15 23:22 ` [PATCH] (4/25) sk98: change #define to typedef Stephen Hemminger
2004-11-16 8:22 ` Christoph Hellwig
2004-11-15 23:22 ` [PATCH] (5/25) sk98: elimnate nested macro Stephen Hemminger
2004-11-16 8:23 ` Christoph Hellwig
2004-11-15 23:22 ` [PATCH] (6/25) sk98: get rid of #define's for C99 types Stephen Hemminger
2004-11-15 23:23 ` [PATCH] (7/25) sk98: remove unneeded include's Stephen Hemminger
2004-11-16 15:56 [PATCH] (4/25) sk98: change #define to typedef Mirko Lindner
2004-11-16 17:12 ` Stephen Hemminger
2004-11-17 15:01 ` Christoph Hellwig
2004-11-19 0:23 ` Stephen Hemminger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).