]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
staging: lustre: Convert "return seq_printf(...)" uses
[mirror_ubuntu-bionic-kernel.git] / drivers / staging / lustre / lustre / obdclass / lprocfs_status.c
index 3b7dfc367722f2b569d7706bb4b73343cc8a5f51..25f01cb23f22416455d28ba08c535101f8e747ad 100644 (file)
@@ -45,6 +45,7 @@
 #include "../include/lprocfs_status.h"
 #include "../include/lustre/lustre_idl.h"
 #include <linux/seq_file.h>
+#include <linux/ctype.h>
 
 static const char * const obd_connect_names[] = {
        "read_only",
@@ -376,7 +377,8 @@ EXPORT_SYMBOL(lprocfs_register);
 /* Generic callbacks */
 int lprocfs_rd_uint(struct seq_file *m, void *data)
 {
-       return seq_printf(m, "%u\n", *(unsigned int *)data);
+       seq_printf(m, "%u\n", *(unsigned int *)data);
+       return 0;
 }
 EXPORT_SYMBOL(lprocfs_rd_uint);
 
@@ -402,7 +404,8 @@ EXPORT_SYMBOL(lprocfs_wr_uint);
 
 int lprocfs_rd_u64(struct seq_file *m, void *data)
 {
-       return seq_printf(m, "%llu\n", *(__u64 *)data);
+       seq_printf(m, "%llu\n", *(__u64 *)data);
+       return 0;
 }
 EXPORT_SYMBOL(lprocfs_rd_u64);
 
@@ -410,7 +413,8 @@ int lprocfs_rd_atomic(struct seq_file *m, void *data)
 {
        atomic_t *atom = data;
        LASSERT(atom != NULL);
-       return seq_printf(m, "%d\n", atomic_read(atom));
+       seq_printf(m, "%d\n", atomic_read(atom));
+       return 0;
 }
 EXPORT_SYMBOL(lprocfs_rd_atomic);
 
@@ -438,7 +442,8 @@ int lprocfs_rd_uuid(struct seq_file *m, void *data)
        struct obd_device *obd = data;
 
        LASSERT(obd != NULL);
-       return seq_printf(m, "%s\n", obd->obd_uuid.uuid);
+       seq_printf(m, "%s\n", obd->obd_uuid.uuid);
+       return 0;
 }
 EXPORT_SYMBOL(lprocfs_rd_uuid);
 
@@ -447,7 +452,8 @@ int lprocfs_rd_name(struct seq_file *m, void *data)
        struct obd_device *dev = data;
 
        LASSERT(dev != NULL);
-       return seq_printf(m, "%s\n", dev->obd_name);
+       seq_printf(m, "%s\n", dev->obd_name);
+       return 0;
 }
 EXPORT_SYMBOL(lprocfs_rd_name);
 
@@ -923,7 +929,8 @@ int lprocfs_rd_num_exports(struct seq_file *m, void *data)
        struct obd_device *obd = data;
 
        LASSERT(obd != NULL);
-       return seq_printf(m, "%u\n", obd->obd_num_exports);
+       seq_printf(m, "%u\n", obd->obd_num_exports);
+       return 0;
 }
 EXPORT_SYMBOL(lprocfs_rd_num_exports);
 
@@ -932,7 +939,8 @@ int lprocfs_rd_numrefs(struct seq_file *m, void *data)
        struct obd_type *class = (struct obd_type *) data;
 
        LASSERT(class != NULL);
-       return seq_printf(m, "%d\n", class->typ_refcnt);
+       seq_printf(m, "%d\n", class->typ_refcnt);
+       return 0;
 }
 EXPORT_SYMBOL(lprocfs_rd_numrefs);
 
@@ -1605,8 +1613,9 @@ LPROC_SEQ_FOPS_RO(lproc_exp_hash);
 
 int lprocfs_nid_stats_clear_read(struct seq_file *m, void *data)
 {
-       return seq_printf(m, "%s\n",
-                         "Write into this file to clear all nid stats and stale nid entries");
+       seq_printf(m, "%s\n",
+                  "Write into this file to clear all nid stats and stale nid entries");
+       return 0;
 }
 EXPORT_SYMBOL(lprocfs_nid_stats_clear_read);
 
@@ -1849,7 +1858,7 @@ int lprocfs_seq_read_frac_helper(struct seq_file *m, long val, int mult)
 }
 EXPORT_SYMBOL(lprocfs_seq_read_frac_helper);
 
-int lprocfs_write_u64_helper(const char *buffer, unsigned long count,
+int lprocfs_write_u64_helper(const char __user *buffer, unsigned long count,
                             __u64 *val)
 {
        return lprocfs_write_frac_u64_helper(buffer, count, val, 1);
@@ -1862,6 +1871,7 @@ int lprocfs_write_frac_u64_helper(const char *buffer, unsigned long count,
        char kernbuf[22], *end, *pbuf;
        __u64 whole, frac = 0, units;
        unsigned frac_d = 1;
+       int sign = 1;
 
        if (count > (sizeof(kernbuf) - 1))
                return -EINVAL;
@@ -1872,7 +1882,7 @@ int lprocfs_write_frac_u64_helper(const char *buffer, unsigned long count,
        kernbuf[count] = '\0';
        pbuf = kernbuf;
        if (*pbuf == '-') {
-               mult = -mult;
+               sign = -1;
                pbuf++;
        }
 
@@ -1880,7 +1890,7 @@ int lprocfs_write_frac_u64_helper(const char *buffer, unsigned long count,
        if (pbuf == end)
                return -EINVAL;
 
-       if (end != NULL && *end == '.') {
+       if (*end == '.') {
                int i;
                pbuf = end + 1;
 
@@ -1895,25 +1905,25 @@ int lprocfs_write_frac_u64_helper(const char *buffer, unsigned long count,
        }
 
        units = 1;
-       switch (*end) {
-       case 'p': case 'P':
+       switch (tolower(*end)) {
+       case 'p':
                units <<= 10;
-       case 't': case 'T':
+       case 't':
                units <<= 10;
-       case 'g': case 'G':
+       case 'g':
                units <<= 10;
-       case 'm': case 'M':
+       case 'm':
                units <<= 10;
-       case 'k': case 'K':
+       case 'k':
                units <<= 10;
        }
        /* Specified units override the multiplier */
-       if (units)
-               mult = mult < 0 ? -units : units;
+       if (units > 1)
+               mult = units;
 
        frac *= mult;
        do_div(frac, frac_d);
-       *val = whole * mult + frac;
+       *val = sign * (whole * mult + frac);
        return 0;
 }
 EXPORT_SYMBOL(lprocfs_write_frac_u64_helper);