staging:iio:Documentation: cleanup properly in buffer handling code
authorJonathan Cameron <jic23@cam.ac.uk>
Sun, 4 Dec 2011 19:10:58 +0000 (19:10 +0000)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 8 Dec 2011 19:32:34 +0000 (11:32 -0800)
Eating the endian description for now.

Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/staging/iio/Documentation/iio_utils.h

index dbbad8a16382fe82766b6eeafa63c0c7992e2735..986889b6a1f6089e45ff762f21bb7ee6e1facbdb 100644 (file)
@@ -145,9 +145,17 @@ inline int iioutils_get_type(unsigned *is_signed,
                                ret = -errno;
                                goto error_free_filename;
                        }
-                       fscanf(sysfsfp,
-                              "%c%u/%u>>%u", &signchar, bits_used,
-                              &padint, shift);
+
+                       ret = fscanf(sysfsfp,
+                                    "%ce:%c%u/%u>>%u",
+                                    &endianchar,
+                                    &signchar,
+                                    bits_used,
+                                    &padint, shift);
+                       if (ret < 0) {
+                               printf("failed to pass scan type description\n");
+                               return ret;
+                       }
                        *bytes = padint / 8;
                        if (*bits_used == 64)
                                *mask = ~0;
@@ -157,6 +165,10 @@ inline int iioutils_get_type(unsigned *is_signed,
                                *is_signed = 1;
                        else
                                *is_signed = 0;
+                       fclose(sysfsfp);
+                       free(filename);
+
+                       filename = 0;
                }
 error_free_filename:
        if (filename)