IB/srp: replace custom implementation of hex2bin()
authorAndy Shevchenko <andy.shevchenko@gmail.com>
Mon, 11 Dec 2017 13:05:05 +0000 (15:05 +0200)
committerJason Gunthorpe <jgg@mellanox.com>
Mon, 11 Dec 2017 23:19:45 +0000 (16:19 -0700)
There is no need to have a duplication of the generic library, i.e.
hex2bin().

Replace the open coded variant.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Bart Van Assche <bart.vanassche@wdc.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
drivers/infiniband/ulp/srp/ib_srp.c

index 972d4b3c5223c168aecf3512095e02166c984b6b..62d88212c1b0148c37101a1fe68a8e0d5dbd8c12 100644 (file)
@@ -3110,7 +3110,6 @@ static int srp_parse_options(const char *buf, struct srp_target_port *target)
 {
        char *options, *sep_opt;
        char *p;
-       char dgid[3];
        substring_t args[MAX_OPT_ARGS];
        int opt_mask = 0;
        int token;
@@ -3162,16 +3161,10 @@ static int srp_parse_options(const char *buf, struct srp_target_port *target)
                                goto out;
                        }
 
-                       for (i = 0; i < 16; ++i) {
-                               strlcpy(dgid, p + i * 2, sizeof(dgid));
-                               if (sscanf(dgid, "%hhx",
-                                          &target->orig_dgid.raw[i]) < 1) {
-                                       ret = -EINVAL;
-                                       kfree(p);
-                                       goto out;
-                               }
-                       }
+                       ret = hex2bin(target->orig_dgid.raw, p, 16);
                        kfree(p);
+                       if (ret < 0)
+                               goto out;
                        break;
 
                case SRP_OPT_PKEY: