diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-07-06 23:01:20 (GMT) |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-07-06 23:01:20 (GMT) |
commit | b600c5b569c2f62eacf8d71dd9975d7a996073f3 (patch) | |
tree | 4b16b0ada1c7a732fc04518ecdd2d6c97512729f /drivers/staging/iio/Documentation | |
parent | c14d1769ba81ed084adb450d2fa1bacaee3cd2c7 (diff) | |
parent | 06d5199d4c53615338d0453b62458cd82fb88f33 (diff) | |
download | linux-fsl-qoriq-b600c5b569c2f62eacf8d71dd9975d7a996073f3.tar.xz |
Merge branch 'fixes-togreg' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next
Diffstat (limited to 'drivers/staging/iio/Documentation')
-rw-r--r-- | drivers/staging/iio/Documentation/iio_utils.h | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/drivers/staging/iio/Documentation/iio_utils.h b/drivers/staging/iio/Documentation/iio_utils.h index c0448b3..5244fa0 100644 --- a/drivers/staging/iio/Documentation/iio_utils.h +++ b/drivers/staging/iio/Documentation/iio_utils.h @@ -158,7 +158,8 @@ inline int iioutils_get_type(unsigned *is_signed, &padint, shift); if (ret < 0) { printf("failed to pass scan type description\n"); - return ret; + ret = -errno; + goto error_close_sysfsfp; } *be = (endianchar == 'b'); *bytes = padint / 8; @@ -174,7 +175,11 @@ inline int iioutils_get_type(unsigned *is_signed, free(filename); filename = 0; + sysfsfp = 0; } +error_close_sysfsfp: + if (sysfsfp) + fclose(sysfsfp); error_free_filename: if (filename) free(filename); @@ -468,23 +473,30 @@ inline int find_type_by_name(const char *name, const char *type) + strlen(type) + numstrlen + 6); - if (filename == NULL) + if (filename == NULL) { + closedir(dp); return -ENOMEM; + } sprintf(filename, "%s%s%d/name", iio_dir, type, number); nameFile = fopen(filename, "r"); - if (!nameFile) + if (!nameFile) { + free(filename); continue; + } free(filename); fscanf(nameFile, "%s", thisname); - if (strcmp(name, thisname) == 0) - return number; fclose(nameFile); + if (strcmp(name, thisname) == 0) { + closedir(dp); + return number; + } } } } + closedir(dp); return -ENODEV; } @@ -513,6 +525,7 @@ inline int _write_sysfs_int(char *filename, char *basedir, int val, int verify) goto error_free; } fscanf(sysfsfp, "%d", &test); + fclose(sysfsfp); if (test != val) { printf("Possible failure in int write %d to %s%s\n", val, @@ -562,6 +575,7 @@ int _write_sysfs_string(char *filename, char *basedir, char *val, int verify) goto error_free; } fscanf(sysfsfp, "%s", temp); + fclose(sysfsfp); if (strcmp(temp, val) != 0) { printf("Possible failure in string write of %s " "Should be %s " |