OSDN Git Service

Winter cleanup: use typedef on our own types
authorPatrick Porlan <patrick.porlan@intel.com>
Thu, 18 Dec 2014 09:34:12 +0000 (10:34 +0100)
committerPatrick Porlan <patrick.porlan@intel.com>
Thu, 18 Dec 2014 10:50:02 +0000 (11:50 +0100)
All these explicit structs ended up being noisy for little benefit.

Change-Id: I0b7ace85ab8a7644d3895e3e45e97ff0e14c5cfc
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
calibration.h
common.h
compass-calibration.c
control.c
enumeration.c
filtering.c
filtering.h
gyro-calibration.c
transform.c

index 04c5686..cf66705 100644 (file)
@@ -9,7 +9,8 @@
 
 #define MAGN_DS_SIZE 32
 
-struct compass_cal_t {
+
+typedef struct {
     /* hard iron offsets */
     double offset[3][1];
 
@@ -23,22 +24,28 @@ struct compass_cal_t {
     float sample[MAGN_DS_SIZE][3];
     unsigned int sample_count;
     float average[3];
-};
+}
+compass_cal_t;
+
 
-struct gyro_cal_t {
+typedef struct {
     float bias_x, bias_y, bias_z;
     int count;
     float min_x, min_y, min_z;
     float max_x, max_y, max_z;
-};
+}
+gyro_cal_t;
+
 
 typedef double mat_input_t[MAGN_DS_SIZE][3];
 
-void calibrate_compass (struct sensors_event_t* event, struct sensor_info_t* info);
-void compass_read_data (struct sensor_info_t* info);
-void compass_store_data (struct sensor_info_t* info);
 
-void calibrate_gyro(struct sensors_event_t* event, struct sensor_info_t* info);
-void gyro_cal_init(struct sensor_info_t* info);
-void gyro_store_data (struct sensor_info_t* info);
+void calibrate_compass  (sensors_event_t* event, sensor_info_t* info);
+void compass_read_data  (sensor_info_t* info);
+void compass_store_data (sensor_info_t* info);
+
+void calibrate_gyro     (sensors_event_t* event, sensor_info_t* info);
+void gyro_cal_init      (sensor_info_t* info);
+void gyro_store_data    (sensor_info_t* info);
+
 #endif
index 53138c8..1d40842 100644 (file)
--- a/common.h
+++ b/common.h
@@ -46,7 +46,8 @@
        typedef int32_t max_delay_t;
 #endif
 
-struct channel_descriptor_t
+
+typedef struct
 {
        const char *name;       /* channel name ; ex: x */
 
@@ -59,48 +60,58 @@ struct channel_descriptor_t
        const char *raw_path;   /* _raw sysfs file name  */
        const char *input_path; /* _input sysfs file name */
        const char *scale_path; /* _scale sysfs file name */
-};
+}
+channel_descriptor_t;
+
 
-struct sensor_catalog_entry_t
+typedef struct
 {
        const char *tag; /* Prefix such as "accel", "gyro", "temp"... */
        const int type;  /* Sensor type ; ex: SENSOR_TYPE_ACCELEROMETER */
        const int num_channels; /* Expected iio channels for this sensor */
        const int is_virtual;  /* Is the sensor virtual or not */
-       struct channel_descriptor_t channel[MAX_CHANNELS];
-};
+       channel_descriptor_t channel[MAX_CHANNELS];
+}
+sensor_catalog_entry_t;
 
-struct datum_info_t
+
+typedef struct
 {
        char sign;
        char endianness;
        short realbits;
        short storagebits;
        short shift;
-};
+}
+datum_info_t;
+
 
-struct channel_info_t
+typedef struct
 {
        int offset; /* Offset in bytes within the iio character device report */
        int size;                       /* Field size in bytes */
        float scale;                    /* scale for each channel */
        char type_spec[MAX_TYPE_SPEC_LEN]; /* From driver; ex: le:u10/16>>0 */
-       struct datum_info_t type_info;     /* Decoded contents of type spec */
+       datum_info_t type_info;         /* Decoded contents of type spec */
        float opt_scale; /* Optional correction scale read from a property such
                          * as iio.accel.x.scale, allowing late compensation of
                          * problems such as misconfigured axes ; set to 1 by
                          * default. Applied at the end of the scaling process.
                          */
-};
+}
+channel_info_t;
 
-struct sample_ops_t
+
+typedef struct
 {
        /* Conversion function called once per channel */
-       float (*transform)(int s, int c, unsigned char* sample_data);
+       float (*transform) (int s, int c, unsigned char* sample_data);
 
        /* Function called once per sample */
-       int (*finalize)(int s, struct sensors_event_t* data);
-};
+       int (*finalize) (int s, sensors_event_t* data);
+}
+sample_ops_t;
+
 
 /*
  * Whenever we have sensor data recorded for a sensor in the associated
@@ -111,7 +122,8 @@ struct sample_ops_t
 #define DATA_SYSFS     2       /* Through polling                      */
 #define DATA_DUPLICATE 3       /* Duplicate of triggered motion sample */
 
-struct sensor_info_t
+
+typedef struct
 {
        char friendly_name[MAX_NAME_SIZE];      /* ex: Accelerometer         */
        char internal_name[MAX_NAME_SIZE];      /* ex: accel_3d              */
@@ -154,7 +166,7 @@ struct sensor_info_t
         * should be zero for disabled channels. The type field indicates how a
         * specific channel data item is structured.
         */
-       struct channel_info_t channel[MAX_CHANNELS];
+       channel_info_t channel[MAX_CHANNELS];
 
        /*
         * This flag is set if we acquired data from the sensor but did not
@@ -184,7 +196,7 @@ struct sensor_info_t
        int report_initialized;
 
        /* Channel and sample finalization callbacks for this sensor */
-       struct sample_ops_t ops;
+       sample_ops_t ops;
 
        int cal_level; /* 0 means not calibrated */
 
@@ -236,7 +248,7 @@ struct sensor_info_t
         * keep the data here until it's finally processed. Can be modified for
         * more than one at a later time.
         */
-       struct sensors_event_t sample;
+       sensors_event_t sample;
 
        /*
         * If the QUIRK_FIELD_ORDERING bit is set in quirks, the contents of
@@ -260,12 +272,14 @@ struct sensor_info_t
         * events before filtering kicks in. We can also use it for statistics.
         */
        uint64_t event_count;
-};
+}
+sensor_info_t;
+
 
 /* Reference a few commonly used variables... */
-extern int                             sensor_count;
-extern struct sensor_t      sensor_desc[MAX_SENSORS];
-extern struct sensor_info_t            sensor[MAX_SENSORS];
-extern struct sensor_catalog_entry_t   sensor_catalog[];
+extern int                     sensor_count;
+extern struct sensor_t         sensor_desc[MAX_SENSORS];
+extern sensor_info_t           sensor[MAX_SENSORS];
+extern sensor_catalog_entry_t  sensor_catalog[];
 
 #endif
index 85934be..2bbdce6 100644 (file)
@@ -37,8 +37,9 @@ static const float min_diffs[CAL_STEPS] =  {0.2,  0.25, 0.4, 0.6, 1.0 };
 static const float max_sqr_errs[CAL_STEPS] = {10.0, 10.0, 8.0, 5.0, 3.5 };
 static const unsigned int lookback_counts[CAL_STEPS] = {2, 3, 4, 5, 6 };
 
-/* reset calibration algorithm */
-static void reset_sample (struct compass_cal_t* data)
+
+/* Reset calibration algorithm */
+static void reset_sample (compass_cal_t* data)
 {
     int i,j;
     data->sample_count = 0;
@@ -49,7 +50,8 @@ static void reset_sample (struct compass_cal_t* data)
     data->average[0] = data->average[1] = data->average[2] = 0;
 }
 
-static double calc_square_err (struct compass_cal_t* data)
+
+static double calc_square_err (compass_cal_t* data)
 {
     double err = 0;
     double raw[3][1], result[3][1], mat_diff[3][1];
@@ -89,8 +91,9 @@ static double calc_square_err (struct compass_cal_t* data)
     return err;
 }
 
+
 /* Given an real symmetric 3x3 matrix A, compute the eigenvalues */
-static void compute_eigenvalues(double mat[3][3], double* eig1, double* eig2, double* eig3)
+static void compute_eigenvalues (double mat[3][3], double* eig1, double* eig2, double* eig3)
 {
     double p = mat[0][1] * mat[0][1] + mat[0][2] * mat[0][2] + mat[1][2] * mat[1][2];
 
@@ -133,7 +136,8 @@ static void compute_eigenvalues(double mat[3][3], double* eig1, double* eig2, do
     *eig2 = 3 * q - *eig1 - *eig3;
 }
 
-static void calc_evector(double mat[3][3], double eig, double vec[3][1])
+
+static void calc_evector (double mat[3][3], double eig, double vec[3][1])
 {
     double h[3][3];
     double x_tmp[2][2];
@@ -159,6 +163,7 @@ static void calc_evector(double mat[3][3], double eig, double vec[3][1])
     vec[2][0] = temp2 / norm;
 }
 
+
 static int ellipsoid_fit (mat_input_t m, double offset[3][1], double w_invert[3][3], double* bfield)
 {
     int i;
@@ -271,7 +276,8 @@ static int ellipsoid_fit (mat_input_t m, double offset[3][1], double w_invert[3]
     return 1;
 }
 
-static void compass_cal_init (FILE* data_file, struct sensor_info_t* info)
+
+static void compass_cal_init (FILE* data_file, sensor_info_t* info)
 {
 
 #ifdef DBG_RAW_DATA
@@ -294,7 +300,7 @@ static void compass_cal_init (FILE* data_file, struct sensor_info_t* info)
     raw_data_count = 0;
 #endif
 
-    struct compass_cal_t* cal_data = (struct compass_cal_t*) info->cal_data;
+    compass_cal_t* cal_data = (compass_cal_t*) info->cal_data;
     int cal_steps = (info->max_cal_level && info->max_cal_level <= CAL_STEPS) ?
         info->max_cal_level : CAL_STEPS;
     if (cal_data == NULL)
@@ -344,9 +350,10 @@ static void compass_cal_init (FILE* data_file, struct sensor_info_t* info)
 
 }
 
-static void compass_store_result(FILE* data_file, struct sensor_info_t* info)
+
+static void compass_store_result (FILE* data_file, sensor_info_t* info)
 {
-    struct compass_cal_t* cal_data = (struct compass_cal_t*) info->cal_data;
+    compass_cal_t* cal_data = (compass_cal_t*) info->cal_data;
 
     if (data_file == NULL || cal_data == NULL)
         return;
@@ -362,14 +369,15 @@ static void compass_store_result(FILE* data_file, struct sensor_info_t* info)
         ALOGE ("compass calibration - store data failed!");
 }
 
-static int compass_collect (struct sensors_event_t* event, struct sensor_info_t* info)
+
+static int compass_collect (sensors_event_t* event, sensor_info_t* info)
 {
     float data[3] = {event->magnetic.x, event->magnetic.y, event->magnetic.z};
     unsigned int index,j;
     unsigned int lookback_count;
     float min_diff;
 
-    struct compass_cal_t* cal_data = (struct compass_cal_t*) info->cal_data;
+    compass_cal_t* cal_data = (compass_cal_t*) info->cal_data;
 
     if (cal_data == NULL)
         return -1;
@@ -429,7 +437,8 @@ static int compass_collect (struct sensors_event_t* event, struct sensor_info_t*
     return 1;
 }
 
-static void scale_event (struct sensors_event_t* event)
+
+static void scale_event (sensors_event_t* event)
 {
     float sqr_norm = 0;
     float sanity_norm = 0;
@@ -448,13 +457,13 @@ static void scale_event (struct sensors_event_t* event)
         event->magnetic.x = event->magnetic.x * scale;
         event->magnetic.y = event->magnetic.y * scale;
         event->magnetic.z = event->magnetic.z * scale;
-
     }
 }
 
-static void compass_compute_cal (struct sensors_event_t* event, struct sensor_info_t* info)
+
+static void compass_compute_cal (sensors_event_t* event, sensor_info_t* info)
 {
-    struct compass_cal_t* cal_data = (struct compass_cal_t*) info->cal_data;
+    compass_cal_t* cal_data = (compass_cal_t*) info->cal_data;
     double result[3][1], raw[3][1], diff[3][1];
 
     if (!info->cal_level || cal_data == NULL)
@@ -475,14 +484,14 @@ static void compass_compute_cal (struct sensors_event_t* event, struct sensor_in
 }
 
 
-static int compass_ready (struct sensor_info_t* info)
+static int compass_ready (sensor_info_t* info)
 {
     mat_input_t mat;
     int i;
     float max_sqr_err;
 
-    struct compass_cal_t* cal_data = (struct compass_cal_t*) info->cal_data;
-    struct compass_cal_t new_cal_data;
+    compass_cal_t* cal_data = (compass_cal_t*) info->cal_data;
+    compass_cal_t new_cal_data;
 
     /*
      *  Some sensors take unrealistically long to calibrate at higher levels.
@@ -538,7 +547,7 @@ static int compass_ready (struct sensor_info_t* info)
 }
 
 
-void calibrate_compass (struct sensors_event_t* event, struct sensor_info_t* info)
+void calibrate_compass (sensors_event_t* event, sensor_info_t* info)
 {
     int cal_level;
 
@@ -571,7 +580,7 @@ void calibrate_compass (struct sensors_event_t* event, struct sensor_info_t* inf
     }
 }
 
-void compass_read_data (struct sensor_info_t* info)
+void compass_read_data (sensor_info_t* info)
 {
     FILE* data_file = fopen (COMPASS_CALIBRATION_PATH, "r");
 
@@ -580,7 +589,8 @@ void compass_read_data (struct sensor_info_t* info)
         fclose(data_file);
 }
 
-void compass_store_data (struct sensor_info_t* info)
+
+void compass_store_data (sensor_info_t* info)
 {
     FILE* data_file = fopen (COMPASS_CALIBRATION_PATH, "w");
 
index 482786d..769ba0d 100644 (file)
--- a/control.c
+++ b/control.c
@@ -196,7 +196,7 @@ static void enable_iio_timestamp (int dev_num, int known_channels)
 
 
 static int decode_type_spec (const char type_buf[MAX_TYPE_SPEC_LEN],
-                            struct datum_info_t *type_info)
+                            datum_info_t *type_info)
 {
        /* Return size in bytes for this type specification, or -1 in error */
        char sign;
@@ -251,7 +251,7 @@ void build_sensor_report_maps (int dev_num)
        int ch_index;
        char* ch_spec;
        char spec_buf[MAX_TYPE_SPEC_LEN];
-       struct datum_info_t* ch_info;
+       datum_info_t* ch_info;
        int size;
        char sysfs_path[PATH_MAX];
        int known_channels;
@@ -489,7 +489,7 @@ static void* acquisition_routine (void* param)
 
        int s = (int) (size_t) param;
        int num_fields, sample_size;
-       struct sensors_event_t data = {0};
+       sensors_event_t data = {0};
        int c;
        int ret;
        struct timespec target_time;
@@ -1316,11 +1316,11 @@ static int integrate_device_report (int dev_num)
 }
 
 
-static int propagate_vsensor_report (int s, struct sensors_event_t  *data)
+static int propagate_vsensor_report (int s, sensors_event_t *data)
 {
        /* There's a new report stored in sensor.sample for this sensor; transmit it */
 
-       memcpy(data, &sensor[s].sample, sizeof(struct sensors_event_t));
+       memcpy(data, &sensor[s].sample, sizeof(sensors_event_t));
 
        data->sensor    = s;
        data->type      = sensor[s].type;
@@ -1328,7 +1328,7 @@ static int propagate_vsensor_report (int s, struct sensors_event_t  *data)
 }
 
 
-static int propagate_sensor_report (int s, struct sensors_event_t  *data)
+static int propagate_sensor_report (int s, sensors_event_t *data)
 {
        /* There's a sensor report pending for this sensor ; transmit it */
 
@@ -1498,7 +1498,7 @@ static int get_poll_wait_timeout (void)
 }
 
 
-int sensor_poll (struct sensors_event_t* data, int count)
+int sensor_poll (sensors_event_t* data, int count)
 {
        int s;
        int i;
index 54467f2..66d6576 100644 (file)
@@ -28,7 +28,7 @@
   * from the same iio device as the base one.
   */
 
-struct sensor_catalog_entry_t sensor_catalog[] = {
+sensor_catalog_entry_t sensor_catalog[] = {
        DECLARE_SENSOR3("accel",      SENSOR_TYPE_ACCELEROMETER,  "x", "y", "z")
        DECLARE_SENSOR3("anglvel",    SENSOR_TYPE_GYROSCOPE,      "x", "y", "z")
        DECLARE_SENSOR3("magn",       SENSOR_TYPE_MAGNETIC_FIELD, "x", "y", "z")
@@ -51,9 +51,9 @@ struct sensor_catalog_entry_t sensor_catalog[] = {
 
 /* We equate sensor handles to indices in these tables */
 
-struct sensor_t      sensor_desc[MAX_SENSORS]; /* Android-level descriptors */
-struct sensor_info_t sensor[MAX_SENSORS];      /* Internal descriptors      */
-int sensor_count;                              /* Detected sensors          */
+struct sensor_t        sensor_desc[MAX_SENSORS];       /* Android-level descriptors */
+sensor_info_t  sensor[MAX_SENSORS];            /* Internal descriptors      */
+int            sensor_count;                   /* Detected sensors          */
 
 
 static void setup_properties_from_pld (int s, int panel, int rotation,
@@ -414,11 +414,11 @@ static void add_sensor (int dev_num, int catalog_index, int use_polling)
 
        switch (sensor_type) {
                case SENSOR_TYPE_GYROSCOPE:
-                       sensor[s].cal_data = malloc(sizeof(struct gyro_cal_t));
+                       sensor[s].cal_data = malloc(sizeof(gyro_cal_t));
                        break;
 
                case SENSOR_TYPE_MAGNETIC_FIELD:
-                       sensor[s].cal_data = malloc(sizeof(struct compass_cal_t));
+                       sensor[s].cal_data = malloc(sizeof(compass_cal_t));
                        break;
        }
 
index d310a7d..97dbd25 100644 (file)
@@ -7,13 +7,14 @@
 #include "filtering.h"
 
 
-struct filter_median_t
+typedef struct
 {
        float* buff;
        unsigned int idx;
        unsigned int count;
        unsigned int sample_size;
-};
+}
+filter_median_t;
 
 
 static unsigned int partition (        float* list, unsigned int left,
@@ -83,8 +84,8 @@ static float median (float* queue, unsigned int size)
 static void denoise_median_init(int s, unsigned int num_fields,
                                unsigned int max_samples)
 {
-       struct filter_median_t* f_data = (struct filter_median_t*)
-                                        malloc(sizeof(struct filter_median_t));
+       filter_median_t* f_data = (filter_median_t*)
+                                        malloc(sizeof(filter_median_t));
 
        f_data->buff = (float*) calloc(max_samples, sizeof(float) * num_fields);
        f_data->sample_size = max_samples;
@@ -94,9 +95,9 @@ static void denoise_median_init(int s, unsigned int num_fields,
 }
 
 
-static void denoise_median_reset (struct sensor_info_t* info)
+static void denoise_median_reset (sensor_info_t* info)
 {
-       struct filter_median_t* f_data = (struct filter_median_t*) info->filter;
+       filter_median_t* f_data = (filter_median_t*) info->filter;
 
        if (!f_data)
                return;
@@ -106,15 +107,15 @@ static void denoise_median_reset (struct sensor_info_t* info)
 }
 
 
-static void denoise_median (   struct sensor_info_t* info,
-                               struct sensors_event_t* data,
+static void denoise_median (   sensor_info_t* info,
+                               sensors_event_t* data,
                                unsigned int num_fields)
 {
        float x, y, z;
        float scale;
        unsigned int field, offset;
 
-       struct filter_median_t* f_data = (struct filter_median_t*) info->filter;
+       filter_median_t* f_data = (filter_median_t*) info->filter;
        if (!f_data)
                return;
 
@@ -136,8 +137,8 @@ static void denoise_median (        struct sensor_info_t* info,
 }
 
 
-static void denoise_average (  struct sensor_info_t* si,
-                               struct sensors_event_t* data,
+static void denoise_average (  sensor_info_t* si,
+                               sensors_event_t* data,
                                int num_fields, int max_samples)
 {
        /*
@@ -219,7 +220,7 @@ void setup_noise_filtering (int s)
 }
 
 
-void denoise (int s, struct sensors_event_t* data)
+void denoise (int s, sensors_event_t* data)
 {
        switch (sensor[s].type) {
                case SENSOR_TYPE_GYROSCOPE:
@@ -250,7 +251,7 @@ void release_noise_filtering_data (int s)
 
        /* Delete median filter structures */
        if (sensor[s].filter) {
-               buff = ((struct filter_median_t*)sensor[s].filter)->buff;
+               buff = ((filter_median_t*) sensor[s].filter)->buff;
 
                if (buff)
                        free(buff);
@@ -263,12 +264,13 @@ void release_noise_filtering_data (int s)
 
 #define GLOBAL_HISTORY_SIZE 100
 
-struct recorded_sample_t
+typedef struct
 {
        int sensor;
        int motion_trigger;
        sensors_event_t data;
-};
+}
+recorded_sample_t;
 
 /*
  * This is a circular buffer holding the last GLOBAL_HISTORY_SIZE events,
@@ -280,15 +282,15 @@ struct recorded_sample_t
  * be a delay between acquisition and insertion into this table.
  */
 
-static struct recorded_sample_t global_history[GLOBAL_HISTORY_SIZE];
+static recorded_sample_t global_history[GLOBAL_HISTORY_SIZE];
 
 static int initialized_entries;        /* How many of these are initialized          */
 static int insertion_index;    /* Index of sample to evict next time         */
 
 
-void record_sample (int s, const struct sensors_event_t* event)
+void record_sample (int s, const sensors_event_t* event)
 {
-       struct recorded_sample_t *cell;
+       recorded_sample_t *cell;
        int i;
 
        /* Don't record duplicate samples, as they are not useful for filters */
index e899202..b0393a3 100644 (file)
@@ -5,7 +5,7 @@
 
 void setup_noise_filtering             (int s);
 void release_noise_filtering_data      (int s);
-void denoise                           (int s, struct sensors_event_t* event);
+void denoise                           (int s, sensors_event_t* event);
 void record_sample                     (int s, const sensors_event_t* data);
 
 #endif
index 48518c3..84d6a31 100644 (file)
@@ -17,7 +17,7 @@
 #define GYRO_CALIBRATION_PATH "/data/gyro.conf"
 
 
-static void reset (struct gyro_cal_t* cal_data)
+static void reset (gyro_cal_t* cal_data)
 {
        cal_data->count = 0;
 
@@ -28,10 +28,10 @@ static void reset (struct gyro_cal_t* cal_data)
 }
 
 
-void gyro_cal_init (struct sensor_info_t* info)
+void gyro_cal_init (sensor_info_t* info)
 {
        int ret;
-       struct gyro_cal_t* cal_data = (struct gyro_cal_t*) info->cal_data;
+       gyro_cal_t* cal_data = (gyro_cal_t*) info->cal_data;
        FILE* data_file;
 
        info->cal_level = 0;
@@ -51,10 +51,10 @@ void gyro_cal_init (struct sensor_info_t* info)
 }
 
 
-void gyro_store_data (struct sensor_info_t* info)
+void gyro_store_data (sensor_info_t* info)
 {
        int ret;
-       struct gyro_cal_t* cal_data = (struct gyro_cal_t*) info->cal_data;
+       gyro_cal_t* cal_data = (gyro_cal_t*) info->cal_data;
        FILE* data_file;
 
        if (cal_data == NULL)
@@ -75,7 +75,7 @@ void gyro_store_data (struct sensor_info_t* info)
 }
 
 
-static int gyro_collect (float x, float y, float z, struct gyro_cal_t* cal_data)
+static int gyro_collect (float x, float y, float z, gyro_cal_t* cal_data)
 {
        /* Analyze gyroscope data */
 
@@ -126,9 +126,9 @@ static int gyro_collect (float x, float y, float z, struct gyro_cal_t* cal_data)
 }
 
 
-void calibrate_gyro (struct sensors_event_t* event, struct sensor_info_t* info)
+void calibrate_gyro (sensors_event_t* event, sensor_info_t* info)
 {
-       struct gyro_cal_t* cal_data = (struct gyro_cal_t*) info->cal_data;
+       gyro_cal_t* cal_data = (gyro_cal_t*) info->cal_data;
 
        if (cal_data == NULL)
                return;
index bc4e03c..ea9222f 100644 (file)
@@ -123,7 +123,8 @@ inline float convert_from_vtf_format(int size, int exponent, unsigned int value)
 
 /*----------------------------------------------------------------------------*/
 
-static int64_t sample_as_int64(unsigned char* sample, struct datum_info_t* type)
+
+static int64_t sample_as_int64 (unsigned char* sample, datum_info_t* type)
 {
        uint64_t u64;
        int i;
@@ -176,7 +177,7 @@ static int64_t sample_as_int64(unsigned char* sample, struct datum_info_t* type)
 }
 
 
-static void reorder_fields(float* data,        unsigned char map[MAX_CHANNELS])
+static void reorder_fields (float* data, unsigned char map[MAX_CHANNELS])
 {
        int i;
        float temp[MAX_CHANNELS];
@@ -189,7 +190,7 @@ static void reorder_fields(float* data,     unsigned char map[MAX_CHANNELS])
 }
 
 
-static void clamp_gyro_readings_to_zero (int s, struct sensors_event_t* data)
+static void clamp_gyro_readings_to_zero (int s, sensors_event_t* data)
 {
        float x, y, z;
        float near_zero;
@@ -220,14 +221,15 @@ static void clamp_gyro_readings_to_zero (int s, struct sensors_event_t* data)
        }
 }
 
-static void process_event_gyro_uncal(int s, int i, struct sensors_event_t* data)
+
+static void process_event_gyro_uncal (int s, int i, sensors_event_t* data)
 {
-       struct gyro_cal_t* gyro_data;
+       gyro_cal_t* gyro_data;
 
        if (sensor[s].type == SENSOR_TYPE_GYROSCOPE) {
-               gyro_data = (struct gyro_cal_t*) sensor[s].cal_data;
+               gyro_data = (gyro_cal_t*) sensor[s].cal_data;
 
-               memcpy(&sensor[i].sample, data, sizeof(struct sensors_event_t));
+               memcpy(&sensor[i].sample, data, sizeof(sensors_event_t));
 
                sensor[i].sample.type = SENSOR_TYPE_GYROSCOPE_UNCALIBRATED;
                sensor[i].sample.sensor = s;
@@ -244,7 +246,8 @@ static void process_event_gyro_uncal(int s, int i, struct sensors_event_t* data)
        }
 }
 
-static void process_event(int s, struct sensors_event_t* data)
+
+static void process_event (int s, sensors_event_t* data)
 {
        /*
         * This gets the real event (post process - calibration, filtering & co.)
@@ -268,7 +271,8 @@ static void process_event(int s, struct sensors_event_t* data)
        }
 }
 
-static int finalize_sample_default (int s, struct sensors_event_t* data)
+
+static int finalize_sample_default (int s, sensors_event_t* data)
 {
        /* Swap fields if we have a custom channel ordering on this sensor */
        if (sensor[s].quirks & QUIRK_FIELD_ORDERING)
@@ -358,8 +362,8 @@ static int finalize_sample_default (int s, struct sensors_event_t* data)
 
 static float transform_sample_default(int s, int c, unsigned char* sample_data)
 {
-       struct datum_info_t* sample_type = &sensor[s].channel[c].type_info;
-       int64_t              s64 = sample_as_int64(sample_data, sample_type);
+       datum_info_t* sample_type = &sensor[s].channel[c].type_info;
+       int64_t s64 = sample_as_int64(sample_data, sample_type);
        float scale = sensor[s].scale ?
                        sensor[s].scale : sensor[s].channel[c].scale;
 
@@ -371,7 +375,7 @@ static float transform_sample_default(int s, int c, unsigned char* sample_data)
 }
 
 
-static int finalize_sample_ISH (int s, struct sensors_event_t* data)
+static int finalize_sample_ISH (int s, sensors_event_t* data)
 {
        float pitch, roll, yaw;
 
@@ -399,7 +403,7 @@ static int finalize_sample_ISH (int s, struct sensors_event_t* data)
 
 static float transform_sample_ISH (int s, int c, unsigned char* sample_data)
 {
-       struct datum_info_t* sample_type = &sensor[s].channel[c].type_info;
+       datum_info_t* sample_type = &sensor[s].channel[c].type_info;
        int val         = (int) sample_as_int64(sample_data, sample_type);
        float correction;
        int data_bytes  = (sample_type->realbits)/8;