]> Git Repo - linux.git/commitdiff
Merge branch 'fixes-togreg' into togreg
authorJonathan Cameron <[email protected]>
Sat, 30 Jun 2012 09:14:29 +0000 (10:14 +0100)
committerJonathan Cameron <[email protected]>
Sat, 30 Jun 2012 09:14:29 +0000 (10:14 +0100)
1  2 
drivers/staging/iio/Documentation/iio_utils.h
drivers/staging/iio/accel/adis16240_core.c
drivers/staging/iio/adc/ad7793.c

index c0448b3e20dea67a803b613c12ffc7fc41490816,b38e81f4fa64f5f2148ce4bc6467a82a09b47c6d..5244fa0dfd2f6419a9138e5a9f2842bb00fa4abd
@@@ -7,15 -7,14 +7,15 @@@
   * the Free Software Foundation.
   */
  
 -/* Made up value to limit allocation sizes */
  #include <string.h>
  #include <stdlib.h>
  #include <ctype.h>
  #include <stdio.h>
  #include <stdint.h>
  #include <dirent.h>
 +#include <errno.h>
  
 +/* Made up value to limit allocation sizes */
  #define IIO_MAX_NAME_LENGTH 30
  
  #define FORMAT_SCAN_ELEMENTS_DIR "%s/scan_elements"
@@@ -28,7 -27,7 +28,7 @@@ const char *iio_dir = "/sys/bus/iio/dev
   * @full_name: the full channel name
   * @generic_name: the output generic channel name
   **/
 -static int iioutils_break_up_name(const char *full_name,
 +inline int iioutils_break_up_name(const char *full_name,
                                  char **generic_name)
  {
        char *current;
@@@ -158,7 -157,8 +158,8 @@@ inline int iioutils_get_type(unsigned *
                                     &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;
                        free(filename);
  
                        filename = 0;
+                       sysfsfp = 0;
                }
+ error_close_sysfsfp:
+       if (sysfsfp)
+               fclose(sysfsfp);
  error_free_filename:
        if (filename)
                free(filename);
@@@ -281,7 -285,7 +286,7 @@@ inline int build_channel_array(const ch
  {
        DIR *dp;
        FILE *sysfsfp;
 -      int count, temp, i;
 +      int count, i;
        struct iio_channel_info *current;
        int ret;
        const struct dirent *ent;
@@@ -468,23 -472,30 +473,30 @@@ inline int find_type_by_name(const cha
                                                + 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 -524,7 +525,7 @@@ inline int _write_sysfs_int(char *filen
                        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 -574,7 +575,7 @@@ int _write_sysfs_string(char *filename
                        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 "
index 2f59f83d002de7f79e168b1a969e0ad39d2117c8,4ba9b1c3bb5accfdbfe2cd775daa7d009fda0c7b..1a51f03d3d766da52bb20f91550a379fbe808b9c
@@@ -500,7 -500,8 +500,8 @@@ static struct iio_chan_spec adis16240_c
                .channel2 = IIO_MOD_X,
                .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
                IIO_CHAN_INFO_SCALE_SHARED_BIT |
-               IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT,
+               IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
+               IIO_CHAN_INFO_PEAK_SEPARATE_BIT,
                .address = accel_x,
                .scan_index = ADIS16240_SCAN_ACC_X,
                .scan_type = {
                .channel2 = IIO_MOD_Y,
                .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
                IIO_CHAN_INFO_SCALE_SHARED_BIT |
-               IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT,
+               IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
+               IIO_CHAN_INFO_PEAK_SEPARATE_BIT,
                .address = accel_y,
                .scan_index = ADIS16240_SCAN_ACC_Y,
                .scan_type = {
                .channel2 = IIO_MOD_Z,
                .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
                IIO_CHAN_INFO_SCALE_SHARED_BIT |
-               IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT,
+               IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
+               IIO_CHAN_INFO_PEAK_SEPARATE_BIT,
                .address = accel_z,
                .scan_index = ADIS16240_SCAN_ACC_Z,
                .scan_type = {
@@@ -641,6 -644,8 +644,6 @@@ static int adis16240_remove(struct spi_
  
        struct iio_dev *indio_dev = spi_get_drvdata(spi);
  
 -      flush_scheduled_work();
 -
        iio_device_unregister(indio_dev);
        adis16240_remove_trigger(indio_dev);
        iio_buffer_unregister(indio_dev);
index 2bb9f68d66a45a9ab6142c367f8ac0510196e2a0,92d8c255d4707649995b510963d4bc306a9257d5..eaa0cc93916563f28b5cff764a39e754a561bbe2
@@@ -21,9 -21,9 +21,9 @@@
  #include <linux/iio/iio.h>
  #include <linux/iio/sysfs.h>
  #include <linux/iio/buffer.h>
 -#include <linux/iio/kfifo_buf.h>
  #include <linux/iio/trigger.h>
  #include <linux/iio/trigger_consumer.h>
 +#include <linux/iio/triggered_buffer.h>
  
  #include "ad7793.h"
  
@@@ -407,13 -407,41 +407,13 @@@ static const struct iio_buffer_setup_op
  
  static int ad7793_register_ring_funcs_and_init(struct iio_dev *indio_dev)
  {
 -      int ret;
 -
 -      indio_dev->buffer = iio_kfifo_allocate(indio_dev);
 -      if (!indio_dev->buffer) {
 -              ret = -ENOMEM;
 -              goto error_ret;
 -      }
 -      indio_dev->pollfunc = iio_alloc_pollfunc(&iio_pollfunc_store_time,
 -                                               &ad7793_trigger_handler,
 -                                               IRQF_ONESHOT,
 -                                               indio_dev,
 -                                               "ad7793_consumer%d",
 -                                               indio_dev->id);
 -      if (indio_dev->pollfunc == NULL) {
 -              ret = -ENOMEM;
 -              goto error_deallocate_kfifo;
 -      }
 -
 -      /* Ring buffer functions - here trigger setup related */
 -      indio_dev->setup_ops = &ad7793_ring_setup_ops;
 -
 -      /* Flag that polled ring buffering is possible */
 -      indio_dev->modes |= INDIO_BUFFER_TRIGGERED;
 -      return 0;
 -
 -error_deallocate_kfifo:
 -      iio_kfifo_free(indio_dev->buffer);
 -error_ret:
 -      return ret;
 +      return iio_triggered_buffer_setup(indio_dev, &iio_pollfunc_store_time,
 +                      &ad7793_trigger_handler, &ad7793_ring_setup_ops);
  }
  
  static void ad7793_ring_cleanup(struct iio_dev *indio_dev)
  {
 -      iio_dealloc_pollfunc(indio_dev->pollfunc);
 -      iio_kfifo_free(indio_dev->buffer);
 +      iio_triggered_buffer_cleanup(indio_dev);
  }
  
  /**
@@@ -758,7 -786,7 +758,7 @@@ static const struct ad7793_chip_info ad
                        .address = AD7793_CH_AIN1M_AIN1M,
                        .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
                        IIO_CHAN_INFO_SCALE_SHARED_BIT,
-                       .scan_index = 2,
+                       .scan_index = 3,
                        .scan_type = IIO_ST('s', 24, 32, 0)
                },
                .channel[4] = {
                        .address = AD7793_CH_AIN1M_AIN1M,
                        .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
                        IIO_CHAN_INFO_SCALE_SHARED_BIT,
-                       .scan_index = 2,
+                       .scan_index = 3,
                        .scan_type = IIO_ST('s', 16, 32, 0)
                },
                .channel[4] = {
@@@ -931,16 -959,24 +931,16 @@@ static int __devinit ad7793_probe(struc
        if (ret)
                goto error_unreg_ring;
  
 -      ret = iio_buffer_register(indio_dev,
 -                                indio_dev->channels,
 -                                indio_dev->num_channels);
 -      if (ret)
 -              goto error_remove_trigger;
 -
        ret = ad7793_setup(st);
        if (ret)
 -              goto error_uninitialize_ring;
 +              goto error_remove_trigger;
  
        ret = iio_device_register(indio_dev);
        if (ret)
 -              goto error_uninitialize_ring;
 +              goto error_remove_trigger;
  
        return 0;
  
 -error_uninitialize_ring:
 -      iio_buffer_unregister(indio_dev);
  error_remove_trigger:
        ad7793_remove_trigger(indio_dev);
  error_unreg_ring:
@@@ -963,6 -999,7 +963,6 @@@ static int ad7793_remove(struct spi_dev
        struct ad7793_state *st = iio_priv(indio_dev);
  
        iio_device_unregister(indio_dev);
 -      iio_buffer_unregister(indio_dev);
        ad7793_remove_trigger(indio_dev);
        ad7793_ring_cleanup(indio_dev);
  
This page took 0.07036 seconds and 4 git commands to generate.