Minor fixes:
authorTom Knot <tomasknot@gmail.com>
Mon, 16 Apr 2018 10:41:30 +0000 (12:41 +0200)
committerTom Knot <tomasknot@gmail.com>
Mon, 16 Apr 2018 10:41:30 +0000 (12:41 +0200)
- Added version string to SYSFS
- Error code for direct SPI reads
- Model names should now correspond to DB names

modules/unipi/src/unipi_common.h
modules/unipi/src/unipi_platform.c
modules/unipi/src/unipi_spi.c
modules/unipi/src/unipi_spi.h
modules/unipi/src/unipi_sysfs.c

index c530417f4917fd3279fdc73a48e2ce6b20bfabee..4ea3748a84e6b3a881bba48396610393deedf1e6 100644 (file)
@@ -51,7 +51,7 @@
 #ifdef NEURONSPI_SCHED_REQUIRED
 #include <uapi/linux/sched/types.h>
 #endif
-#define NEURONSPI_MAJOR_VERSIONSTRING "Development Beta Version 0.04:05:04:2018"
+#define NEURONSPI_MAJOR_VERSIONSTRING "Development Beta Version 0.05:16:04:2018"
 
 #define NEURONSPI_MAX_DEVS                             3
 #define NEURONSPI_MAX_UART                             128
index f6ddf3057e0e53d4aba037e98fd53c44f723e204..afd107a16ad908e7ed73f03b4c4d58214f988950 100644 (file)
@@ -1446,35 +1446,35 @@ struct neuronspi_board_entry NEURONSPI_BOARDTABLE[NEURONSPI_BOARDTABLE_LEN] = {
 
 // Module table
 struct neuronspi_model_definition NEURONSPI_MODELTABLE[NEURONSPI_MODELTABLE_LEN] = {
-               {.eeprom_length = 4, .eeprom_name = "S103", .name_length = 4, .model_name = "S103",
+               {.eeprom_length = 4, .eeprom_name = "S103", .name_length = 4, .model_name = "Neuron S103",
                                .combination_count = 1, .combinations = NEURONSPI_MODEL_S103_HW_DEFINITION_BOARD},
-               {.eeprom_length = 4, .eeprom_name = "S103", .name_length = 6, .model_name = "S103-G",
+               {.eeprom_length = 4, .eeprom_name = "S103", .name_length = 6, .model_name = "Neuron S103-G",
                                .combination_count = 1, .combinations = NEURONSPI_MODEL_S103G_HW_DEFINITION_BOARD},
-               {.eeprom_length = 6, .eeprom_name = "S103IQ", .name_length = 7, .model_name = "S103-IQ",
+               {.eeprom_length = 6, .eeprom_name = "S103IQ", .name_length = 7, .model_name = "Neuron S103-IQRF",
                                .combination_count = 1, .combinations = NEURONSPI_MODEL_S103IQ_HW_DEFINITION_BOARD},
-               {.eeprom_length = 6, .eeprom_name = "S103EO", .name_length = 7, .model_name = "S103-EO",
+               {.eeprom_length = 6, .eeprom_name = "S103EO", .name_length = 7, .model_name = "Neuron HOUM Enocean S103",
                                .combination_count = 1, .combinations = NEURONSPI_MODEL_S103EO_HW_DEFINITION_BOARD},
-               {.eeprom_length = 4, .eeprom_name = "M103", .name_length = 4, .model_name = "M103",
+               {.eeprom_length = 4, .eeprom_name = "M103", .name_length = 4, .model_name = "Neuron M103",
                                .combination_count = 2, .combinations = NEURONSPI_MODEL_M103_HW_DEFINITION_BOARD},
-               {.eeprom_length = 4, .eeprom_name = "M203", .name_length = 4, .model_name = "M203",
+               {.eeprom_length = 4, .eeprom_name = "M203", .name_length = 4, .model_name = "Neuron M203",
                                .combination_count = 2, .combinations = NEURONSPI_MODEL_M203_HW_DEFINITION_BOARD},
-               {.eeprom_length = 4, .eeprom_name = "M303", .name_length = 4, .model_name = "M303",
+               {.eeprom_length = 4, .eeprom_name = "M303", .name_length = 4, .model_name = "Neuron M303",
                                .combination_count = 2, .combinations = NEURONSPI_MODEL_M303_HW_DEFINITION_BOARD},
-               {.eeprom_length = 4, .eeprom_name = "M403", .name_length = 4, .model_name = "M403",
+               {.eeprom_length = 4, .eeprom_name = "M403", .name_length = 4, .model_name = "Neuron M403",
                                .combination_count = 2, .combinations = NEURONSPI_MODEL_M403_HW_DEFINITION_BOARD},
-               {.eeprom_length = 4, .eeprom_name = "M503", .name_length = 4, .model_name = "M503",
+               {.eeprom_length = 4, .eeprom_name = "M503", .name_length = 4, .model_name = "Neuron M503",
                                .combination_count = 2, .combinations = NEURONSPI_MODEL_M503_HW_DEFINITION_BOARD},
-               {.eeprom_length = 4, .eeprom_name = "M603", .name_length = 4, .model_name = "M603",
+               {.eeprom_length = 4, .eeprom_name = "M603", .name_length = 4, .model_name = "Neuron M603",
                                .combination_count = 2, .combinations = NEURONSPI_MODEL_M603_HW_DEFINITION_BOARD},
-               {.eeprom_length = 4, .eeprom_name = "L203", .name_length = 4, .model_name = "L203",
+               {.eeprom_length = 4, .eeprom_name = "L203", .name_length = 4, .model_name = "Neuron L203",
                                .combination_count = 3, .combinations = NEURONSPI_MODEL_L203_HW_DEFINITION_BOARD},
-               {.eeprom_length = 4, .eeprom_name = "L303", .name_length = 4, .model_name = "L303",
+               {.eeprom_length = 4, .eeprom_name = "L303", .name_length = 4, .model_name = "Neuron L303",
                                .combination_count = 3, .combinations = NEURONSPI_MODEL_L303_HW_DEFINITION_BOARD},
-               {.eeprom_length = 4, .eeprom_name = "L403", .name_length = 4, .model_name = "L403",
+               {.eeprom_length = 4, .eeprom_name = "L403", .name_length = 4, .model_name = "Neuron L403",
                                .combination_count = 3, .combinations = NEURONSPI_MODEL_L403_HW_DEFINITION_BOARD},
-               {.eeprom_length = 4, .eeprom_name = "L503", .name_length = 4, .model_name = "L503",
+               {.eeprom_length = 4, .eeprom_name = "L503", .name_length = 4, .model_name = "Neuron L503",
                                .combination_count = 3, .combinations = NEURONSPI_MODEL_L503_HW_DEFINITION_BOARD},
-               {.eeprom_length = 4, .eeprom_name = "L513", .name_length = 4, .model_name = "L513",
+               {.eeprom_length = 4, .eeprom_name = "L513", .name_length = 4, .model_name = "Neuron L513",
                                .combination_count = 3, .combinations = NEURONSPI_MODEL_L513_HW_DEFINITION_BOARD}
 };
 
@@ -1579,9 +1579,13 @@ int neuronspi_regmap_hw_reg_read(void *context, unsigned int reg, unsigned int *
        struct neuronspi_driver_data *n_spi = spi_get_drvdata(spi);
        u8 *inp_buf;
        u8 *outp_buf;
-       int write_length;
+       int write_length, i;
        write_length = neuronspi_spi_compose_single_register_read(reg, &inp_buf, &outp_buf);
-       neuronspi_spi_send_message(spi, inp_buf, outp_buf, write_length, n_spi->ideal_frequency, 25, 1);
+       if (neuronspi_spi_send_message(spi, inp_buf, outp_buf, write_length, n_spi->ideal_frequency, 25, 1)) {
+               for (i = 0; i < write_length; i++) {
+                       outp_buf[i] = 0;
+               }
+       }
        memcpy(val, &outp_buf[NEURONSPI_HEADER_LENGTH], sizeof(u16));
        kfree(inp_buf);
        kfree(outp_buf);
@@ -1600,9 +1604,13 @@ int neuronspi_regmap_hw_reg_write(void *context, unsigned int reg, unsigned int
        struct neuronspi_driver_data *n_spi = spi_get_drvdata(spi);
        u8 *inp_buf;
        u8 *outp_buf;
-       int write_length;
+       int write_length, i;
        write_length = neuronspi_spi_compose_single_register_write(reg, &inp_buf, &outp_buf, (val >> 8));
-       neuronspi_spi_send_message(spi, inp_buf, outp_buf, write_length, n_spi->ideal_frequency, 25, 1);
+       if (neuronspi_spi_send_message(spi, inp_buf, outp_buf, write_length, n_spi->ideal_frequency, 25, 1)) {
+               for (i = 0; i < write_length; i++) {
+                       outp_buf[i] = 0;
+               }
+       }
        memcpy(&val, &outp_buf[NEURONSPI_HEADER_LENGTH], sizeof(u16));
        kfree(inp_buf);
        kfree(outp_buf);
@@ -1735,7 +1743,7 @@ int neuronspi_regmap_hw_read(void *context, const void *reg_buf, size_t reg_size
        struct neuronspi_driver_data *n_spi;
        u8 *inp_buf;
        u8 *outp_buf;
-       int i, write_length;
+       int i, j, write_length;
        int block_counter = 0;
        if (context == NULL) {
                return 0;
@@ -1749,7 +1757,11 @@ int neuronspi_regmap_hw_read(void *context, const void *reg_buf, size_t reg_size
                // Check for continuity and read the largest possible continuous block
                if (block_counter == ((reg_size / 2) - 1) || ((mb_reg_buf[i] + 1) != mb_reg_buf[i + 1])) {
                        write_length = neuronspi_spi_compose_multiple_register_read(block_counter + 1, mb_reg_buf[i - block_counter], &inp_buf, &outp_buf);
-                       neuronspi_spi_send_message(spi, inp_buf, outp_buf, write_length, n_spi->ideal_frequency, 125, 1);
+                       if (neuronspi_spi_send_message(spi, inp_buf, outp_buf, write_length, n_spi->ideal_frequency, 125, 1)) {
+                               for (j = 0; j < write_length; j++) {
+                                       outp_buf[j] = 0;
+                               }
+                       }
                        memcpy(&mb_val_buf[i - block_counter], &outp_buf[NEURONSPI_HEADER_LENGTH], (block_counter + 1) * 2);
                        kfree(inp_buf);
                        kfree(outp_buf);
index c4e6abfde8751e48edece92042bcc42d1acee863..6fc873ff82b34009f754e74cf1dc27e17205a4ad 100644 (file)
@@ -667,7 +667,7 @@ static s32 neuronspi_spi_watchdog(void *data)
 
 
 
-void neuronspi_spi_send_message(struct spi_device* spi_dev, u8 *send_buf, u8 *recv_buf, s32 len, s32 freq, s32 delay, s32 send_header)
+int neuronspi_spi_send_message(struct spi_device* spi_dev, u8 *send_buf, u8 *recv_buf, s32 len, s32 freq, s32 delay, s32 send_header)
 {
        s32 i = 0;
        u16 recv_crc1 = 0;
index 9edb27dc2d3537553381fa5cbedbd769571227d6..18fef469a3f005a214824cb34250e73f8d83a9e8 100644 (file)
@@ -168,7 +168,7 @@ s32 char_unregister_driver(void);
 irqreturn_t neuronspi_spi_irq(s32 irq, void *dev_id);
 s32 neuronspi_spi_probe(struct spi_device *spi);
 s32 neuronspi_spi_remove(struct spi_device *spi);
-void neuronspi_spi_send_message(struct spi_device *spi_dev, u8 *send_buf, u8 *recv_buf, s32 len, s32 freq, s32 delay, s32 send_header);
+int neuronspi_spi_send_message(struct spi_device *spi_dev, u8 *send_buf, u8 *recv_buf, s32 len, s32 freq, s32 delay, s32 send_header);
 s32 neuronspi_spi_uart_write(struct spi_device *spi, u8 *send_buf, u8 length, u8 uart_index);
 void neuronspi_spi_uart_read(struct spi_device* spi_dev, u8 *send_buf, u8 *recv_buf, s32 len, u8 uart_index);
 void neuronspi_spi_set_irqs(struct spi_device* spi_dev, u16 to);
index 56f422adb0929e517efa99112c5134276505530f..3bc08ba99948e58f9392830ae53471b2ab9d1469 100644 (file)
@@ -31,6 +31,17 @@ static ssize_t neuronspi_show_model(struct device *dev, struct device_attribute
        return ret;
 }
 
+static ssize_t neuronspi_show_driver_version(struct device *dev, struct device_attribute *attr, char *buf)
+{
+       ssize_t ret = 0;
+#ifdef NEURONSPI_MAJOR_VERSIONSTRING
+       ret = scnprintf(buf, 255, "%s\n", NEURONSPI_MAJOR_VERSIONSTRING);
+#else
+       ret = scnprintf(buf, 255, "%s\n", "Unspecified Driver Version");
+#endif
+       return ret;
+}
+
 static ssize_t neuronspi_show_eeprom(struct device *dev, struct device_attribute *attr, char *buf)
 {
        ssize_t ret = 0;
@@ -925,6 +936,7 @@ err_end:
 
 static DEVICE_ATTR(model_name, 0440, neuronspi_show_model, NULL);
 static DEVICE_ATTR(sys_eeprom_name, 0440, neuronspi_show_eeprom, NULL);
+static DEVICE_ATTR(driver_version, 0440, neuronspi_show_driver_version, NULL);
 static DEVICE_ATTR(register_read, 0660, neuronspi_show_regmap, neuronspi_store_regmap);
 static DEVICE_ATTR(sys_board_serial, 0440, neuronspi_spi_show_serial, NULL);
 static DEVICE_ATTR(sys_board_name, 0440, neuronspi_spi_show_board, NULL);
@@ -965,6 +977,7 @@ static DEVICE_ATTR(mode_ao_type_b, 0660, neuronspi_iio_show_secondary_ao_mode, n
 static struct attribute *neuron_plc_attrs[] = {
                &dev_attr_model_name.attr,
                &dev_attr_sys_eeprom_name.attr,
+               &dev_attr_driver_version.attr,
                NULL,
 };