include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit...
[safe/jmp/linux-2.6] / net / atm / mpoa_proc.c
index 43315af..53e5002 100644 (file)
@@ -1,3 +1,4 @@
+#define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__
 
 #ifdef CONFIG_PROC_FS
 #include <linux/errno.h>
@@ -8,9 +9,10 @@
 #include <linux/proc_fs.h>
 #include <linux/time.h>
 #include <linux/seq_file.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 #include <linux/atmmpc.h>
 #include <linux/atm.h>
+#include <linux/gfp.h>
 #include "mpc.h"
 #include "mpoa_caches.h"
 
  */
 
 #if 1
-#define dprintk printk   /* debug */
+#define dprintk(format, args...)                                       \
+       printk(KERN_DEBUG "mpoa:%s: " format, __FILE__, ##args)  /* debug */
 #else
-#define dprintk(format,args...)
+#define dprintk(format, args...)                                       \
+       do { if (0)                                                     \
+               printk(KERN_DEBUG "mpoa:%s: " format, __FILE__, ##args);\
+       } while (0)
+#endif
+
+#if 0
+#define ddprintk(format, args...)                                      \
+       printk(KERN_DEBUG "mpoa:%s: " format, __FILE__, ##args)  /* debug */
+#else
+#define ddprintk(format, args...)                                      \
+       do { if (0)                                                     \
+               printk(KERN_DEBUG "mpoa:%s: " format, __FILE__, ##args);\
+       } while (0)
 #endif
 
 #define STAT_FILE_NAME "mpc"     /* Our statistic file's name */
@@ -39,7 +55,7 @@ static int parse_qos(const char *buff);
 /*
  *   Define allowed FILE OPERATIONS
  */
-static struct file_operations mpc_file_operations = {
+static const struct file_operations mpc_file_operations = {
        .owner =        THIS_MODULE,
        .open =         proc_mpc_open,
        .read =         seq_read,
@@ -51,42 +67,37 @@ static struct file_operations mpc_file_operations = {
 /*
  * Returns the state of an ingress cache entry as a string
  */
-static const char *ingress_state_string(int state){
-       switch(state) {
+static const char *ingress_state_string(int state)
+{
+       switch (state) {
        case INGRESS_RESOLVING:
                return "resolving  ";
-               break;
        case INGRESS_RESOLVED:
                return "resolved   ";
-               break;
        case INGRESS_INVALID:
                return "invalid    ";
-               break;
        case INGRESS_REFRESHING:
                return "refreshing ";
-               break;
-       default:
-              return "";
        }
+
+       return "";
 }
 
 /*
  * Returns the state of an egress cache entry as a string
  */
-static const char *egress_state_string(int state){
-       switch(state) {
+static const char *egress_state_string(int state)
+{
+       switch (state) {
        case EGRESS_RESOLVED:
                return "resolved   ";
-               break;
        case EGRESS_PURGE:
                return "purge      ";
-               break;
        case EGRESS_INVALID:
                return "invalid    ";
-               break;
-       default:
-              return "";
        }
+
+       return "";
 }
 
 /*
@@ -123,7 +134,6 @@ static void mpc_stop(struct seq_file *m, void *v)
 static int mpc_show(struct seq_file *m, void *v)
 {
        struct mpoa_client *mpc = v;
-       unsigned char *temp;
        int i;
        in_cache_entry *in_entry;
        eg_cache_entry *eg_entry;
@@ -140,15 +150,17 @@ static int mpc_show(struct seq_file *m, void *v)
        do_gettimeofday(&now);
 
        for (in_entry = mpc->in_cache; in_entry; in_entry = in_entry->next) {
-               temp = (unsigned char *)&in_entry->ctrl_info.in_dst_ip;
-               sprintf(ip_string,"%d.%d.%d.%d", temp[0], temp[1], temp[2], temp[3]);
+               sprintf(ip_string, "%pI4", &in_entry->ctrl_info.in_dst_ip);
                seq_printf(m, "%-16s%s%-14lu%-12u",
-                             ip_string,
-                             ingress_state_string(in_entry->entry_state),
-                             in_entry->ctrl_info.holding_time-(now.tv_sec-in_entry->tv.tv_sec),
-                             in_entry->packets_fwded);
+                          ip_string,
+                          ingress_state_string(in_entry->entry_state),
+                          in_entry->ctrl_info.holding_time -
+                          (now.tv_sec-in_entry->tv.tv_sec),
+                          in_entry->packets_fwded);
                if (in_entry->shortcut)
-                       seq_printf(m, "   %-3d  %-3d",in_entry->shortcut->vpi,in_entry->shortcut->vci);
+                       seq_printf(m, "   %-3d  %-3d",
+                                  in_entry->shortcut->vpi,
+                                  in_entry->shortcut->vci);
                seq_printf(m, "\n");
        }
 
@@ -156,28 +168,30 @@ static int mpc_show(struct seq_file *m, void *v)
        seq_printf(m, "Egress Entries:\nIngress MPC ATM addr\nCache-id        State      Holding time  Packets recvd  Latest IP addr   VPI VCI\n");
        for (eg_entry = mpc->eg_cache; eg_entry; eg_entry = eg_entry->next) {
                unsigned char *p = eg_entry->ctrl_info.in_MPC_data_ATM_addr;
-               for(i = 0; i < ATM_ESA_LEN; i++)
+               for (i = 0; i < ATM_ESA_LEN; i++)
                        seq_printf(m, "%02x", p[i]);
                seq_printf(m, "\n%-16lu%s%-14lu%-15u",
                           (unsigned long)ntohl(eg_entry->ctrl_info.cache_id),
                           egress_state_string(eg_entry->entry_state),
-                          (eg_entry->ctrl_info.holding_time-(now.tv_sec-eg_entry->tv.tv_sec)),
+                          (eg_entry->ctrl_info.holding_time -
+                           (now.tv_sec-eg_entry->tv.tv_sec)),
                           eg_entry->packets_rcvd);
 
                /* latest IP address */
-               temp = (unsigned char *)&eg_entry->latest_ip_addr;
-               sprintf(ip_string, "%d.%d.%d.%d", temp[0], temp[1], temp[2], temp[3]);
+               sprintf(ip_string, "%pI4", &eg_entry->latest_ip_addr);
                seq_printf(m, "%-16s", ip_string);
 
                if (eg_entry->shortcut)
-                       seq_printf(m, " %-3d %-3d",eg_entry->shortcut->vpi,eg_entry->shortcut->vci);
+                       seq_printf(m, " %-3d %-3d",
+                                  eg_entry->shortcut->vpi,
+                                  eg_entry->shortcut->vci);
                seq_printf(m, "\n");
        }
        seq_printf(m, "\n");
        return 0;
 }
 
-static struct seq_operations mpc_op = {
+static const struct seq_operations mpc_op = {
        .start =        mpc_start,
        .next =         mpc_next,
        .stop =         mpc_stop,
@@ -258,12 +272,9 @@ static int parse_qos(const char *buff)
        qos.rxtp.max_pcr = rx_pcr;
        qos.rxtp.max_sdu = rx_sdu;
        qos.aal = ATM_AAL5;
-       dprintk("mpoa: mpoa_proc.c: parse_qos(): setting qos paramameters to tx=%d,%d rx=%d,%d\n",
-               qos.txtp.max_pcr,
-               qos.txtp.max_sdu,
-               qos.rxtp.max_pcr,
-               qos.rxtp.max_sdu
-               );
+       dprintk("parse_qos(): setting qos paramameters to tx=%d,%d rx=%d,%d\n",
+               qos.txtp.max_pcr, qos.txtp.max_sdu,
+               qos.rxtp.max_pcr, qos.rxtp.max_sdu);
 
        atm_mpoa_add_qos(ipaddr, &qos);
        return 1;
@@ -276,13 +287,11 @@ int mpc_proc_init(void)
 {
        struct proc_dir_entry *p;
 
-       p = create_proc_entry(STAT_FILE_NAME, 0, atm_proc_root);
+       p = proc_create(STAT_FILE_NAME, 0, atm_proc_root, &mpc_file_operations);
        if (!p) {
-               printk(KERN_ERR "Unable to initialize /proc/atm/%s\n", STAT_FILE_NAME);
+               pr_err("Unable to initialize /proc/atm/%s\n", STAT_FILE_NAME);
                return -ENOMEM;
        }
-       p->proc_fops = &mpc_file_operations;
-       p->owner = THIS_MODULE;
        return 0;
 }
 
@@ -291,10 +300,9 @@ int mpc_proc_init(void)
  */
 void mpc_proc_clean(void)
 {
-       remove_proc_entry(STAT_FILE_NAME,atm_proc_root);
+       remove_proc_entry(STAT_FILE_NAME, atm_proc_root);
 }
 
-
 #endif /* CONFIG_PROC_FS */