Hi simran, [auto build test ERROR on iio/togreg] [also build test ERROR on v4.11-rc4 next-20170331] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/simran-singhal/iio-health-Clean-up/20170402-095718 base: https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg config: xtensa-allmodconfig (attached as .config) compiler: xtensa-linux-gcc (GCC) 4.9.0 reproduce: wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=xtensa All error/warnings (new ones prefixed by >>): In file included from include/linux/kobject.h:21:0, from include/linux/device.h:17, from drivers/iio/health/afe4403.c:17: drivers/iio/health/afe440x.h:96:23: error: '_name_show' undeclared here (not in a function) static DEVICE_ATTR_RO(_name) ^ include/linux/sysfs.h:116:10: note: in definition of macro '__ATTR_RO' .show = _name##_show, \ ^ drivers/iio/health/afe440x.h:96:8: note: in expansion of macro 'DEVICE_ATTR_RO' static DEVICE_ATTR_RO(_name) ^ In file included from drivers/iio/health/afe4403.c:34:0: drivers/iio/health/afe440x.h:98:1: error: expected ',' or ';' before 'struct' struct afe440x_attr { ^ drivers/iio/health/afe4403.c:110:2: error: implicit declaration of function 'AFE440X_INTENSITY_CHAN' [-Werror=implicit-function-declaration] AFE440X_INTENSITY_CHAN(LED2, 0), ^ >> drivers/iio/health/afe4403.c:110:2: warning: missing braces around initializer [-Wmissing-braces] drivers/iio/health/afe4403.c:110:2: warning: (near initialization for 'afe4403_channels[0]') [-Wmissing-braces] drivers/iio/health/afe4403.c:110:2: error: initializer element is not constant drivers/iio/health/afe4403.c:110:2: error: (near initialization for 'afe4403_channels[0].type') drivers/iio/health/afe4403.c:111:2: error: initializer element is not constant AFE440X_INTENSITY_CHAN(ALED2, 0), ^ drivers/iio/health/afe4403.c:111:2: error: (near initialization for 'afe4403_channels[0].channel') drivers/iio/health/afe4403.c:112:2: error: initializer element is not constant AFE440X_INTENSITY_CHAN(LED1, 0), ^ drivers/iio/health/afe4403.c:112:2: error: (near initialization for 'afe4403_channels[0].channel2') drivers/iio/health/afe4403.c:113:2: error: initializer element is not constant AFE440X_INTENSITY_CHAN(ALED1, 0), ^ drivers/iio/health/afe4403.c:113:2: error: (near initialization for 'afe4403_channels[0].address') drivers/iio/health/afe4403.c:114:2: error: initializer element is not constant AFE440X_INTENSITY_CHAN(LED2_ALED2, 0), ^ drivers/iio/health/afe4403.c:114:2: error: (near initialization for 'afe4403_channels[0].scan_index') drivers/iio/health/afe4403.c:115:2: error: initializer element is not constant AFE440X_INTENSITY_CHAN(LED1_ALED1, 0), ^ drivers/iio/health/afe4403.c:115:2: error: (near initialization for 'afe4403_channels[0].scan_type.sign') drivers/iio/health/afe4403.c:117:2: error: implicit declaration of function 'AFE440X_CURRENT_CHAN' [-Werror=implicit-function-declaration] AFE440X_CURRENT_CHAN(LED2), ^ drivers/iio/health/afe4403.c:117:2: error: initializer element is not constant drivers/iio/health/afe4403.c:117:2: error: (near initialization for 'afe4403_channels[0].scan_type.realbits') drivers/iio/health/afe4403.c:118:2: error: initializer element is not constant AFE440X_CURRENT_CHAN(LED1), ^ drivers/iio/health/afe4403.c:118:2: error: (near initialization for 'afe4403_channels[0].scan_type.storagebits') drivers/iio/health/afe4403.c:125:1: warning: data definition has no type or storage class AFE440X_TABLE_ATTR(in_intensity_resistance_available, afe4403_res_table); ^ drivers/iio/health/afe4403.c:125:1: error: type defaults to 'int' in declaration of 'AFE440X_TABLE_ATTR' [-Werror=implicit-int] drivers/iio/health/afe4403.c:125:1: warning: parameter names (without types) in function declaration drivers/iio/health/afe4403.c:137:1: warning: data definition has no type or storage class AFE440X_TABLE_ATTR(in_intensity_capacitance_available, afe4403_cap_table); ^ drivers/iio/health/afe4403.c:137:1: error: type defaults to 'int' in declaration of 'AFE440X_TABLE_ATTR' [-Werror=implicit-int] drivers/iio/health/afe4403.c:137:1: warning: parameter names (without types) in function declaration drivers/iio/health/afe4403.c: In function 'afe440x_show_register': drivers/iio/health/afe4403.c:145:9: error: implicit declaration of function 'to_afe440x_attr' [-Werror=implicit-function-declaration] struct afe440x_attr *afe440x_attr = to_afe440x_attr(attr); ^ drivers/iio/health/afe4403.c:145:38: warning: initialization makes pointer from integer without a cast struct afe440x_attr *afe440x_attr = to_afe440x_attr(attr); ^ drivers/iio/health/afe4403.c:150:50: error: dereferencing pointer to incomplete type ret = regmap_field_read(afe->fields[afe440x_attr->field], ®_val); ^ drivers/iio/health/afe4403.c:150:50: error: request for member 'field' in something not a structure or union drivers/iio/health/afe4403.c:150:37: error: array subscript is not an integer ret = regmap_field_read(afe->fields[afe440x_attr->field], ®_val); ^ drivers/iio/health/afe4403.c:150:8: warning: passing argument 1 of 'regmap_field_read' from incompatible pointer type ret = regmap_field_read(afe->fields[afe440x_attr->field], ®_val); ^ In file included from drivers/iio/health/afe4403.c:22:0: include/linux/regmap.h:850:5: note: expected 'struct regmap_field *' but argument is of type 'const struct iio_chan_spec *' int regmap_field_read(struct regmap_field *field, unsigned int *val); ^ drivers/iio/health/afe4403.c:154:29: error: dereferencing pointer to incomplete type if (reg_val >= afe440x_attr->table_size) ^ drivers/iio/health/afe4403.c:154:29: error: request for member 'table_size' in something not a structure or union drivers/iio/health/afe4403.c:154:14: warning: comparison between pointer and integer if (reg_val >= afe440x_attr->table_size) ^ drivers/iio/health/afe4403.c:157:24: error: dereferencing pointer to incomplete type vals[0] = afe440x_attr->val_table[reg_val].integer; ^ drivers/iio/health/afe4403.c:157:24: error: request for member 'val_table' in something not a structure or union drivers/iio/health/afe4403.c:157:44: error: 'const struct iio_chan_spec' has no member named 'integer' vals[0] = afe440x_attr->val_table[reg_val].integer; ^ drivers/iio/health/afe4403.c:157:10: warning: assignment makes integer from pointer without a cast vals[0] = afe440x_attr->val_table[reg_val].integer; ^ drivers/iio/health/afe4403.c:158:24: error: dereferencing pointer to incomplete type vals[1] = afe440x_attr->val_table[reg_val].fract; ^ drivers/iio/health/afe4403.c:158:24: error: request for member 'val_table' in something not a structure or union drivers/iio/health/afe4403.c:158:44: error: 'const struct iio_chan_spec' has no member named 'fract' vals[1] = afe440x_attr->val_table[reg_val].fract; ^ drivers/iio/health/afe4403.c:158:10: warning: assignment makes integer from pointer without a cast vals[1] = afe440x_attr->val_table[reg_val].fract; ^ drivers/iio/health/afe4403.c: In function 'afe440x_store_register': drivers/iio/health/afe4403.c:169:38: warning: initialization makes pointer from integer without a cast struct afe440x_attr *afe440x_attr = to_afe440x_attr(attr); ^ drivers/iio/health/afe4403.c:176:34: error: dereferencing pointer to incomplete type for (val = 0; val < afe440x_attr->table_size; val++) ^ drivers/iio/health/afe4403.c:176:34: error: request for member 'table_size' in something not a structure or union drivers/iio/health/afe4403.c:176:20: warning: comparison between pointer and integer for (val = 0; val < afe440x_attr->table_size; val++) -- drivers/iio/health/afe4403.c:177:44: warning: comparison between pointer and integer if (afe440x_attr->val_table[val].integer == integer && ^ drivers/iio/health/afe4403.c:178:19: error: dereferencing pointer to incomplete type afe440x_attr->val_table[val].fract == fract) ^ drivers/iio/health/afe4403.c:178:19: error: request for member 'val_table' in something not a structure or union drivers/iio/health/afe4403.c:178:35: error: 'const struct iio_chan_spec' has no member named 'fract' afe440x_attr->val_table[val].fract == fract) ^ drivers/iio/health/afe4403.c:178:42: warning: comparison between pointer and integer afe440x_attr->val_table[val].fract == fract) ^ drivers/iio/health/afe4403.c:180:25: error: dereferencing pointer to incomplete type if (val == afe440x_attr->table_size) ^ drivers/iio/health/afe4403.c:180:25: error: request for member 'table_size' in something not a structure or union drivers/iio/health/afe4403.c:180:10: warning: comparison between pointer and integer if (val == afe440x_attr->table_size) ^ In file included from drivers/iio/health/afe4403.c:22:0: drivers/iio/health/afe4403.c:183:51: error: dereferencing pointer to incomplete type ret = regmap_field_write(afe->fields[afe440x_attr->field], val); ^ include/linux/regmap.h:85:32: note: in definition of macro 'regmap_field_write' regmap_field_update_bits_base(field, ~0, val, NULL, false, false) ^ drivers/iio/health/afe4403.c:183:51: error: request for member 'field' in something not a structure or union ret = regmap_field_write(afe->fields[afe440x_attr->field], val); ^ include/linux/regmap.h:85:32: note: in definition of macro 'regmap_field_write' regmap_field_update_bits_base(field, ~0, val, NULL, false, false) ^ drivers/iio/health/afe4403.c:183:38: error: array subscript is not an integer ret = regmap_field_write(afe->fields[afe440x_attr->field], val); ^ include/linux/regmap.h:85:32: note: in definition of macro 'regmap_field_write' regmap_field_update_bits_base(field, ~0, val, NULL, false, false) ^ include/linux/regmap.h:85:2: warning: passing argument 1 of 'regmap_field_update_bits_base' from incompatible pointer type regmap_field_update_bits_base(field, ~0, val, NULL, false, false) ^ drivers/iio/health/afe4403.c:183:8: note: in expansion of macro 'regmap_field_write' ret = regmap_field_write(afe->fields[afe440x_attr->field], val); ^ include/linux/regmap.h:851:5: note: expected 'struct regmap_field *' but argument is of type 'const struct iio_chan_spec *' int regmap_field_update_bits_base(struct regmap_field *field, ^ drivers/iio/health/afe4403.c: At top level: drivers/iio/health/afe4403.c:190:8: error: type defaults to 'int' in declaration of 'AFE440X_ATTR' [-Werror=implicit-int] static AFE440X_ATTR(in_intensity1_resistance, F_RF_LED, afe4403_res_table); ^ drivers/iio/health/afe4403.c:190:1: warning: parameter names (without types) in function declaration static AFE440X_ATTR(in_intensity1_resistance, F_RF_LED, afe4403_res_table); ^ drivers/iio/health/afe4403.c:191:8: error: type defaults to 'int' in declaration of 'AFE440X_ATTR' [-Werror=implicit-int] static AFE440X_ATTR(in_intensity1_capacitance, F_CF_LED, afe4403_cap_table); ^ drivers/iio/health/afe4403.c:191:1: warning: parameter names (without types) in function declaration static AFE440X_ATTR(in_intensity1_capacitance, F_CF_LED, afe4403_cap_table); ^ drivers/iio/health/afe4403.c:193:8: error: type defaults to 'int' in declaration of 'AFE440X_ATTR' [-Werror=implicit-int] static AFE440X_ATTR(in_intensity2_resistance, F_RF_LED, afe4403_res_table); ^ drivers/iio/health/afe4403.c:193:1: warning: parameter names (without types) in function declaration static AFE440X_ATTR(in_intensity2_resistance, F_RF_LED, afe4403_res_table); ^ drivers/iio/health/afe4403.c:194:8: error: type defaults to 'int' in declaration of 'AFE440X_ATTR' [-Werror=implicit-int] static AFE440X_ATTR(in_intensity2_capacitance, F_CF_LED, afe4403_cap_table); ^ drivers/iio/health/afe4403.c:194:1: warning: parameter names (without types) in function declaration static AFE440X_ATTR(in_intensity2_capacitance, F_CF_LED, afe4403_cap_table); ^ drivers/iio/health/afe4403.c:196:8: error: type defaults to 'int' in declaration of 'AFE440X_ATTR' [-Werror=implicit-int] static AFE440X_ATTR(in_intensity3_resistance, F_RF_LED1, afe4403_res_table); ^ drivers/iio/health/afe4403.c:196:1: warning: parameter names (without types) in function declaration static AFE440X_ATTR(in_intensity3_resistance, F_RF_LED1, afe4403_res_table); ^ drivers/iio/health/afe4403.c:197:8: error: type defaults to 'int' in declaration of 'AFE440X_ATTR' [-Werror=implicit-int] static AFE440X_ATTR(in_intensity3_capacitance, F_CF_LED1, afe4403_cap_table); ^ drivers/iio/health/afe4403.c:197:1: warning: parameter names (without types) in function declaration static AFE440X_ATTR(in_intensity3_capacitance, F_CF_LED1, afe4403_cap_table); ^ drivers/iio/health/afe4403.c:199:8: error: type defaults to 'int' in declaration of 'AFE440X_ATTR' [-Werror=implicit-int] static AFE440X_ATTR(in_intensity4_resistance, F_RF_LED1, afe4403_res_table); ^ drivers/iio/health/afe4403.c:199:1: warning: parameter names (without types) in function declaration static AFE440X_ATTR(in_intensity4_resistance, F_RF_LED1, afe4403_res_table); ^ drivers/iio/health/afe4403.c:200:8: error: type defaults to 'int' in declaration of 'AFE440X_ATTR' [-Werror=implicit-int] static AFE440X_ATTR(in_intensity4_capacitance, F_CF_LED1, afe4403_cap_table); ^ drivers/iio/health/afe4403.c:200:1: warning: parameter names (without types) in function declaration static AFE440X_ATTR(in_intensity4_capacitance, F_CF_LED1, afe4403_cap_table); ^ drivers/iio/health/afe4403.c:203:3: error: 'dev_attr_in_intensity_resistance_available' undeclared here (not in a function) &dev_attr_in_intensity_resistance_available.attr, ^ >> drivers/iio/health/afe4403.c:203:45: error: request for member 'attr' in something not a structure or union &dev_attr_in_intensity_resistance_available.attr, ^ drivers/iio/health/afe4403.c:203:2: error: initializer element is not constant &dev_attr_in_intensity_resistance_available.attr, ^ drivers/iio/health/afe4403.c:203:2: error: (near initialization for 'afe440x_attributes[0]') drivers/iio/health/afe4403.c:204:3: error: 'dev_attr_in_intensity_capacitance_available' undeclared here (not in a function) &dev_attr_in_intensity_capacitance_available.attr, ^ drivers/iio/health/afe4403.c:204:46: error: request for member 'attr' in something not a structure or union &dev_attr_in_intensity_capacitance_available.attr, ^ drivers/iio/health/afe4403.c:204:2: error: initializer element is not constant &dev_attr_in_intensity_capacitance_available.attr, ^ drivers/iio/health/afe4403.c:204:2: error: (near initialization for 'afe440x_attributes[1]') drivers/iio/health/afe4403.c:205:3: error: 'afe440x_attr_in_intensity1_resistance' undeclared here (not in a function) &afe440x_attr_in_intensity1_resistance.dev_attr.attr, ^ >> drivers/iio/health/afe4403.c:205:40: error: request for member 'dev_attr' in something not a structure or union &afe440x_attr_in_intensity1_resistance.dev_attr.attr, ^ drivers/iio/health/afe4403.c:205:49: error: request for member 'attr' in something not a structure or union &afe440x_attr_in_intensity1_resistance.dev_attr.attr, ^ drivers/iio/health/afe4403.c:205:2: error: initializer element is not constant &afe440x_attr_in_intensity1_resistance.dev_attr.attr, ^ drivers/iio/health/afe4403.c:205:2: error: (near initialization for 'afe440x_attributes[2]') drivers/iio/health/afe4403.c:206:3: error: 'afe440x_attr_in_intensity1_capacitance' undeclared here (not in a function) &afe440x_attr_in_intensity1_capacitance.dev_attr.attr, ^ drivers/iio/health/afe4403.c:206:41: error: request for member 'dev_attr' in something not a structure or union &afe440x_attr_in_intensity1_capacitance.dev_attr.attr, ^ drivers/iio/health/afe4403.c:206:50: error: request for member 'attr' in something not a structure or union &afe440x_attr_in_intensity1_capacitance.dev_attr.attr, ^ drivers/iio/health/afe4403.c:206:2: error: initializer element is not constant &afe440x_attr_in_intensity1_capacitance.dev_attr.attr, ^ drivers/iio/health/afe4403.c:206:2: error: (near initialization for 'afe440x_attributes[3]') drivers/iio/health/afe4403.c:207:3: error: 'afe440x_attr_in_intensity2_resistance' undeclared here (not in a function) &afe440x_attr_in_intensity2_resistance.dev_attr.attr, ^ drivers/iio/health/afe4403.c:207:40: error: request for member 'dev_attr' in something not a structure or union &afe440x_attr_in_intensity2_resistance.dev_attr.attr, ^ drivers/iio/health/afe4403.c:207:49: error: request for member 'attr' in something not a structure or union &afe440x_attr_in_intensity2_resistance.dev_attr.attr, ^ drivers/iio/health/afe4403.c:207:2: error: initializer element is not constant &afe440x_attr_in_intensity2_resistance.dev_attr.attr, ^ drivers/iio/health/afe4403.c:207:2: error: (near initialization for 'afe440x_attributes[4]') drivers/iio/health/afe4403.c:208:3: error: 'afe440x_attr_in_intensity2_capacitance' undeclared here (not in a function) &afe440x_attr_in_intensity2_capacitance.dev_attr.attr, ^ drivers/iio/health/afe4403.c:208:41: error: request for member 'dev_attr' in something not a structure or union &afe440x_attr_in_intensity2_capacitance.dev_attr.attr, ^ drivers/iio/health/afe4403.c:208:50: error: request for member 'attr' in something not a structure or union &afe440x_attr_in_intensity2_capacitance.dev_attr.attr, ^ drivers/iio/health/afe4403.c:208:2: error: initializer element is not constant &afe440x_attr_in_intensity2_capacitance.dev_attr.attr, ^ drivers/iio/health/afe4403.c:208:2: error: (near initialization for 'afe440x_attributes[5]') drivers/iio/health/afe4403.c:209:3: error: 'afe440x_attr_in_intensity3_resistance' undeclared here (not in a function) &afe440x_attr_in_intensity3_resistance.dev_attr.attr, ^ drivers/iio/health/afe4403.c:209:40: error: request for member 'dev_attr' in something not a structure or union &afe440x_attr_in_intensity3_resistance.dev_attr.attr, ^ drivers/iio/health/afe4403.c:209:49: error: request for member 'attr' in something not a structure or union &afe440x_attr_in_intensity3_resistance.dev_attr.attr, ^ drivers/iio/health/afe4403.c:209:2: error: initializer element is not constant &afe440x_attr_in_intensity3_resistance.dev_attr.attr, ^ drivers/iio/health/afe4403.c:209:2: error: (near initialization for 'afe440x_attributes[6]') drivers/iio/health/afe4403.c:210:3: error: 'afe440x_attr_in_intensity3_capacitance' undeclared here (not in a function) &afe440x_attr_in_intensity3_capacitance.dev_attr.attr, ^ drivers/iio/health/afe4403.c:210:41: error: request for member 'dev_attr' in something not a structure or union &afe440x_attr_in_intensity3_capacitance.dev_attr.attr, ^ drivers/iio/health/afe4403.c:210:50: error: request for member 'attr' in something not a structure or union &afe440x_attr_in_intensity3_capacitance.dev_attr.attr, ^ drivers/iio/health/afe4403.c:210:2: error: initializer element is not constant &afe440x_attr_in_intensity3_capacitance.dev_attr.attr, ^ drivers/iio/health/afe4403.c:210:2: error: (near initialization for 'afe440x_attributes[7]') drivers/iio/health/afe4403.c:211:3: error: 'afe440x_attr_in_intensity4_resistance' undeclared here (not in a function) &afe440x_attr_in_intensity4_resistance.dev_attr.attr, ^ drivers/iio/health/afe4403.c:211:40: error: request for member 'dev_attr' in something not a structure or union &afe440x_attr_in_intensity4_resistance.dev_attr.attr, ^ drivers/iio/health/afe4403.c:211:49: error: request for member 'attr' in something not a structure or union &afe440x_attr_in_intensity4_resistance.dev_attr.attr, ^ drivers/iio/health/afe4403.c:211:2: error: initializer element is not constant &afe440x_attr_in_intensity4_resistance.dev_attr.attr, ^ drivers/iio/health/afe4403.c:211:2: error: (near initialization for 'afe440x_attributes[8]') drivers/iio/health/afe4403.c:212:3: error: 'afe440x_attr_in_intensity4_capacitance' undeclared here (not in a function) &afe440x_attr_in_intensity4_capacitance.dev_attr.attr, ^ drivers/iio/health/afe4403.c:212:41: error: request for member 'dev_attr' in something not a structure or union &afe440x_attr_in_intensity4_capacitance.dev_attr.attr, ^ drivers/iio/health/afe4403.c:212:50: error: request for member 'attr' in something not a structure or union &afe440x_attr_in_intensity4_capacitance.dev_attr.attr, ^ drivers/iio/health/afe4403.c:212:2: error: initializer element is not constant &afe440x_attr_in_intensity4_capacitance.dev_attr.attr, ^ drivers/iio/health/afe4403.c:212:2: error: (near initialization for 'afe440x_attributes[9]') .. vim +/dev_attr +205 drivers/iio/health/afe4403.c eec96d1e2 Andrew F. Davis 2016-02-06 28 #include eec96d1e2 Andrew F. Davis 2016-02-06 29 #include eec96d1e2 Andrew F. Davis 2016-02-06 30 #include eec96d1e2 Andrew F. Davis 2016-02-06 31 #include eec96d1e2 Andrew F. Davis 2016-02-06 32 #include eec96d1e2 Andrew F. Davis 2016-02-06 33 eec96d1e2 Andrew F. Davis 2016-02-06 @34 #include "afe440x.h" eec96d1e2 Andrew F. Davis 2016-02-06 35 eec96d1e2 Andrew F. Davis 2016-02-06 36 #define AFE4403_DRIVER_NAME "afe4403" eec96d1e2 Andrew F. Davis 2016-02-06 37 eec96d1e2 Andrew F. Davis 2016-02-06 38 /* AFE4403 Registers */ eec96d1e2 Andrew F. Davis 2016-02-06 39 #define AFE4403_TIAGAIN 0x20 eec96d1e2 Andrew F. Davis 2016-02-06 40 #define AFE4403_TIA_AMB_GAIN 0x21 eec96d1e2 Andrew F. Davis 2016-02-06 41 b36e82576 Andrew F. Davis 2016-05-01 42 enum afe4403_fields { b36e82576 Andrew F. Davis 2016-05-01 43 /* Gains */ b36e82576 Andrew F. Davis 2016-05-01 44 F_RF_LED1, F_CF_LED1, b36e82576 Andrew F. Davis 2016-05-01 45 F_RF_LED, F_CF_LED, b36e82576 Andrew F. Davis 2016-05-01 46 b36e82576 Andrew F. Davis 2016-05-01 47 /* LED Current */ b36e82576 Andrew F. Davis 2016-05-01 48 F_ILED1, F_ILED2, b36e82576 Andrew F. Davis 2016-05-01 49 b36e82576 Andrew F. Davis 2016-05-01 50 /* sentinel */ b36e82576 Andrew F. Davis 2016-05-01 51 F_MAX_FIELDS b36e82576 Andrew F. Davis 2016-05-01 52 }; b36e82576 Andrew F. Davis 2016-05-01 53 b36e82576 Andrew F. Davis 2016-05-01 54 static const struct reg_field afe4403_reg_fields[] = { b36e82576 Andrew F. Davis 2016-05-01 55 /* Gains */ b36e82576 Andrew F. Davis 2016-05-01 56 [F_RF_LED1] = REG_FIELD(AFE4403_TIAGAIN, 0, 2), b36e82576 Andrew F. Davis 2016-05-01 57 [F_CF_LED1] = REG_FIELD(AFE4403_TIAGAIN, 3, 7), b36e82576 Andrew F. Davis 2016-05-01 58 [F_RF_LED] = REG_FIELD(AFE4403_TIA_AMB_GAIN, 0, 2), b36e82576 Andrew F. Davis 2016-05-01 59 [F_CF_LED] = REG_FIELD(AFE4403_TIA_AMB_GAIN, 3, 7), b36e82576 Andrew F. Davis 2016-05-01 60 /* LED Current */ b36e82576 Andrew F. Davis 2016-05-01 61 [F_ILED1] = REG_FIELD(AFE440X_LEDCNTRL, 0, 7), b36e82576 Andrew F. Davis 2016-05-01 62 [F_ILED2] = REG_FIELD(AFE440X_LEDCNTRL, 8, 15), b36e82576 Andrew F. Davis 2016-05-01 63 }; b36e82576 Andrew F. Davis 2016-05-01 64 eec96d1e2 Andrew F. Davis 2016-02-06 65 /** f59e6b5ae Andrew F. Davis 2016-05-01 66 * struct afe4403_data - AFE4403 device instance data f59e6b5ae Andrew F. Davis 2016-05-01 67 * @dev: Device structure f59e6b5ae Andrew F. Davis 2016-05-01 68 * @spi: SPI device handle f59e6b5ae Andrew F. Davis 2016-05-01 69 * @regmap: Register map of the device b36e82576 Andrew F. Davis 2016-05-01 70 * @fields: Register fields of the device f59e6b5ae Andrew F. Davis 2016-05-01 71 * @regulator: Pointer to the regulator for the IC f59e6b5ae Andrew F. Davis 2016-05-01 72 * @trig: IIO trigger for this device f59e6b5ae Andrew F. Davis 2016-05-01 73 * @irq: ADC_RDY line interrupt number eec96d1e2 Andrew F. Davis 2016-02-06 74 */ eec96d1e2 Andrew F. Davis 2016-02-06 75 struct afe4403_data { eec96d1e2 Andrew F. Davis 2016-02-06 76 struct device *dev; eec96d1e2 Andrew F. Davis 2016-02-06 77 struct spi_device *spi; eec96d1e2 Andrew F. Davis 2016-02-06 78 struct regmap *regmap; b36e82576 Andrew F. Davis 2016-05-01 79 struct regmap_field *fields[F_MAX_FIELDS]; eec96d1e2 Andrew F. Davis 2016-02-06 80 struct regulator *regulator; eec96d1e2 Andrew F. Davis 2016-02-06 81 struct iio_trigger *trig; eec96d1e2 Andrew F. Davis 2016-02-06 82 int irq; eec96d1e2 Andrew F. Davis 2016-02-06 83 }; eec96d1e2 Andrew F. Davis 2016-02-06 84 eec96d1e2 Andrew F. Davis 2016-02-06 85 enum afe4403_chan_id { 24b9dea76 Andrew F. Davis 2016-05-01 86 LED2 = 1, 24b9dea76 Andrew F. Davis 2016-05-01 87 ALED2, eec96d1e2 Andrew F. Davis 2016-02-06 88 LED1, eec96d1e2 Andrew F. Davis 2016-02-06 89 ALED1, eec96d1e2 Andrew F. Davis 2016-02-06 90 LED2_ALED2, 24b9dea76 Andrew F. Davis 2016-05-01 91 LED1_ALED1, eec96d1e2 Andrew F. Davis 2016-02-06 92 }; eec96d1e2 Andrew F. Davis 2016-02-06 93 b36e82576 Andrew F. Davis 2016-05-01 94 static const unsigned int afe4403_channel_values[] = { b36e82576 Andrew F. Davis 2016-05-01 95 [LED2] = AFE440X_LED2VAL, b36e82576 Andrew F. Davis 2016-05-01 96 [ALED2] = AFE440X_ALED2VAL, b36e82576 Andrew F. Davis 2016-05-01 97 [LED1] = AFE440X_LED1VAL, b36e82576 Andrew F. Davis 2016-05-01 98 [ALED1] = AFE440X_ALED1VAL, b36e82576 Andrew F. Davis 2016-05-01 99 [LED2_ALED2] = AFE440X_LED2_ALED2VAL, b36e82576 Andrew F. Davis 2016-05-01 100 [LED1_ALED1] = AFE440X_LED1_ALED1VAL, b36e82576 Andrew F. Davis 2016-05-01 101 }; b36e82576 Andrew F. Davis 2016-05-01 102 b36e82576 Andrew F. Davis 2016-05-01 103 static const unsigned int afe4403_channel_leds[] = { 3ff34ee2a Andrew F. Davis 2016-05-01 104 [LED2] = F_ILED2, 3ff34ee2a Andrew F. Davis 2016-05-01 105 [LED1] = F_ILED1, eec96d1e2 Andrew F. Davis 2016-02-06 106 }; eec96d1e2 Andrew F. Davis 2016-02-06 107 eec96d1e2 Andrew F. Davis 2016-02-06 108 static const struct iio_chan_spec afe4403_channels[] = { eec96d1e2 Andrew F. Davis 2016-02-06 109 /* ADC values */ 24b9dea76 Andrew F. Davis 2016-05-01 @110 AFE440X_INTENSITY_CHAN(LED2, 0), 24b9dea76 Andrew F. Davis 2016-05-01 111 AFE440X_INTENSITY_CHAN(ALED2, 0), 24b9dea76 Andrew F. Davis 2016-05-01 112 AFE440X_INTENSITY_CHAN(LED1, 0), 24b9dea76 Andrew F. Davis 2016-05-01 113 AFE440X_INTENSITY_CHAN(ALED1, 0), 24b9dea76 Andrew F. Davis 2016-05-01 114 AFE440X_INTENSITY_CHAN(LED2_ALED2, 0), 24b9dea76 Andrew F. Davis 2016-05-01 115 AFE440X_INTENSITY_CHAN(LED1_ALED1, 0), eec96d1e2 Andrew F. Davis 2016-02-06 116 /* LED current */ 3ff34ee2a Andrew F. Davis 2016-05-01 117 AFE440X_CURRENT_CHAN(LED2), 3ff34ee2a Andrew F. Davis 2016-05-01 118 AFE440X_CURRENT_CHAN(LED1), eec96d1e2 Andrew F. Davis 2016-02-06 119 }; eec96d1e2 Andrew F. Davis 2016-02-06 120 eec96d1e2 Andrew F. Davis 2016-02-06 121 static const struct afe440x_val_table afe4403_res_table[] = { eec96d1e2 Andrew F. Davis 2016-02-06 122 { 500000 }, { 250000 }, { 100000 }, { 50000 }, eec96d1e2 Andrew F. Davis 2016-02-06 123 { 25000 }, { 10000 }, { 1000000 }, { 0 }, eec96d1e2 Andrew F. Davis 2016-02-06 124 }; 1276187c5 Andrew F. Davis 2016-05-01 125 AFE440X_TABLE_ATTR(in_intensity_resistance_available, afe4403_res_table); eec96d1e2 Andrew F. Davis 2016-02-06 126 eec96d1e2 Andrew F. Davis 2016-02-06 127 static const struct afe440x_val_table afe4403_cap_table[] = { eec96d1e2 Andrew F. Davis 2016-02-06 128 { 0, 5000 }, { 0, 10000 }, { 0, 20000 }, { 0, 25000 }, eec96d1e2 Andrew F. Davis 2016-02-06 129 { 0, 30000 }, { 0, 35000 }, { 0, 45000 }, { 0, 50000 }, eec96d1e2 Andrew F. Davis 2016-02-06 130 { 0, 55000 }, { 0, 60000 }, { 0, 70000 }, { 0, 75000 }, eec96d1e2 Andrew F. Davis 2016-02-06 131 { 0, 80000 }, { 0, 85000 }, { 0, 95000 }, { 0, 100000 }, eec96d1e2 Andrew F. Davis 2016-02-06 132 { 0, 155000 }, { 0, 160000 }, { 0, 170000 }, { 0, 175000 }, eec96d1e2 Andrew F. Davis 2016-02-06 133 { 0, 180000 }, { 0, 185000 }, { 0, 195000 }, { 0, 200000 }, eec96d1e2 Andrew F. Davis 2016-02-06 134 { 0, 205000 }, { 0, 210000 }, { 0, 220000 }, { 0, 225000 }, eec96d1e2 Andrew F. Davis 2016-02-06 135 { 0, 230000 }, { 0, 235000 }, { 0, 245000 }, { 0, 250000 }, eec96d1e2 Andrew F. Davis 2016-02-06 136 }; 1276187c5 Andrew F. Davis 2016-05-01 137 AFE440X_TABLE_ATTR(in_intensity_capacitance_available, afe4403_cap_table); eec96d1e2 Andrew F. Davis 2016-02-06 138 eec96d1e2 Andrew F. Davis 2016-02-06 139 static ssize_t afe440x_show_register(struct device *dev, eec96d1e2 Andrew F. Davis 2016-02-06 140 struct device_attribute *attr, eec96d1e2 Andrew F. Davis 2016-02-06 141 char *buf) eec96d1e2 Andrew F. Davis 2016-02-06 142 { eec96d1e2 Andrew F. Davis 2016-02-06 143 struct iio_dev *indio_dev = dev_to_iio_dev(dev); eec96d1e2 Andrew F. Davis 2016-02-06 144 struct afe4403_data *afe = iio_priv(indio_dev); eec96d1e2 Andrew F. Davis 2016-02-06 145 struct afe440x_attr *afe440x_attr = to_afe440x_attr(attr); 81f517270 Andrew F. Davis 2016-05-01 146 unsigned int reg_val; eec96d1e2 Andrew F. Davis 2016-02-06 147 int vals[2]; 81f517270 Andrew F. Davis 2016-05-01 148 int ret; eec96d1e2 Andrew F. Davis 2016-02-06 149 b36e82576 Andrew F. Davis 2016-05-01 150 ret = regmap_field_read(afe->fields[afe440x_attr->field], ®_val); eec96d1e2 Andrew F. Davis 2016-02-06 151 if (ret) eec96d1e2 Andrew F. Davis 2016-02-06 152 return ret; eec96d1e2 Andrew F. Davis 2016-02-06 153 81f517270 Andrew F. Davis 2016-05-01 154 if (reg_val >= afe440x_attr->table_size) 81f517270 Andrew F. Davis 2016-05-01 155 return -EINVAL; 81f517270 Andrew F. Davis 2016-05-01 156 eec96d1e2 Andrew F. Davis 2016-02-06 157 vals[0] = afe440x_attr->val_table[reg_val].integer; eec96d1e2 Andrew F. Davis 2016-02-06 158 vals[1] = afe440x_attr->val_table[reg_val].fract; eec96d1e2 Andrew F. Davis 2016-02-06 159 81f517270 Andrew F. Davis 2016-05-01 160 return iio_format_value(buf, IIO_VAL_INT_PLUS_MICRO, 2, vals); eec96d1e2 Andrew F. Davis 2016-02-06 161 } eec96d1e2 Andrew F. Davis 2016-02-06 162 eec96d1e2 Andrew F. Davis 2016-02-06 163 static ssize_t afe440x_store_register(struct device *dev, eec96d1e2 Andrew F. Davis 2016-02-06 164 struct device_attribute *attr, eec96d1e2 Andrew F. Davis 2016-02-06 165 const char *buf, size_t count) eec96d1e2 Andrew F. Davis 2016-02-06 166 { eec96d1e2 Andrew F. Davis 2016-02-06 167 struct iio_dev *indio_dev = dev_to_iio_dev(dev); eec96d1e2 Andrew F. Davis 2016-02-06 168 struct afe4403_data *afe = iio_priv(indio_dev); eec96d1e2 Andrew F. Davis 2016-02-06 169 struct afe440x_attr *afe440x_attr = to_afe440x_attr(attr); eec96d1e2 Andrew F. Davis 2016-02-06 170 int val, integer, fract, ret; eec96d1e2 Andrew F. Davis 2016-02-06 171 eec96d1e2 Andrew F. Davis 2016-02-06 172 ret = iio_str_to_fixpoint(buf, 100000, &integer, &fract); eec96d1e2 Andrew F. Davis 2016-02-06 173 if (ret) eec96d1e2 Andrew F. Davis 2016-02-06 174 return ret; eec96d1e2 Andrew F. Davis 2016-02-06 175 eec96d1e2 Andrew F. Davis 2016-02-06 176 for (val = 0; val < afe440x_attr->table_size; val++) eec96d1e2 Andrew F. Davis 2016-02-06 177 if (afe440x_attr->val_table[val].integer == integer && eec96d1e2 Andrew F. Davis 2016-02-06 178 afe440x_attr->val_table[val].fract == fract) eec96d1e2 Andrew F. Davis 2016-02-06 179 break; eec96d1e2 Andrew F. Davis 2016-02-06 180 if (val == afe440x_attr->table_size) eec96d1e2 Andrew F. Davis 2016-02-06 181 return -EINVAL; eec96d1e2 Andrew F. Davis 2016-02-06 182 b36e82576 Andrew F. Davis 2016-05-01 183 ret = regmap_field_write(afe->fields[afe440x_attr->field], val); eec96d1e2 Andrew F. Davis 2016-02-06 184 if (ret) eec96d1e2 Andrew F. Davis 2016-02-06 185 return ret; eec96d1e2 Andrew F. Davis 2016-02-06 186 eec96d1e2 Andrew F. Davis 2016-02-06 187 return count; eec96d1e2 Andrew F. Davis 2016-02-06 188 } eec96d1e2 Andrew F. Davis 2016-02-06 189 1276187c5 Andrew F. Davis 2016-05-01 190 static AFE440X_ATTR(in_intensity1_resistance, F_RF_LED, afe4403_res_table); 1276187c5 Andrew F. Davis 2016-05-01 191 static AFE440X_ATTR(in_intensity1_capacitance, F_CF_LED, afe4403_cap_table); eec96d1e2 Andrew F. Davis 2016-02-06 192 1276187c5 Andrew F. Davis 2016-05-01 193 static AFE440X_ATTR(in_intensity2_resistance, F_RF_LED, afe4403_res_table); 1276187c5 Andrew F. Davis 2016-05-01 194 static AFE440X_ATTR(in_intensity2_capacitance, F_CF_LED, afe4403_cap_table); 1276187c5 Andrew F. Davis 2016-05-01 195 1276187c5 Andrew F. Davis 2016-05-01 196 static AFE440X_ATTR(in_intensity3_resistance, F_RF_LED1, afe4403_res_table); 1276187c5 Andrew F. Davis 2016-05-01 197 static AFE440X_ATTR(in_intensity3_capacitance, F_CF_LED1, afe4403_cap_table); 1276187c5 Andrew F. Davis 2016-05-01 198 1276187c5 Andrew F. Davis 2016-05-01 199 static AFE440X_ATTR(in_intensity4_resistance, F_RF_LED1, afe4403_res_table); 1276187c5 Andrew F. Davis 2016-05-01 @200 static AFE440X_ATTR(in_intensity4_capacitance, F_CF_LED1, afe4403_cap_table); eec96d1e2 Andrew F. Davis 2016-02-06 201 eec96d1e2 Andrew F. Davis 2016-02-06 202 static struct attribute *afe440x_attributes[] = { 1276187c5 Andrew F. Davis 2016-05-01 @203 &dev_attr_in_intensity_resistance_available.attr, 1276187c5 Andrew F. Davis 2016-05-01 @204 &dev_attr_in_intensity_capacitance_available.attr, 1276187c5 Andrew F. Davis 2016-05-01 @205 &afe440x_attr_in_intensity1_resistance.dev_attr.attr, 1276187c5 Andrew F. Davis 2016-05-01 206 &afe440x_attr_in_intensity1_capacitance.dev_attr.attr, 1276187c5 Andrew F. Davis 2016-05-01 207 &afe440x_attr_in_intensity2_resistance.dev_attr.attr, 1276187c5 Andrew F. Davis 2016-05-01 208 &afe440x_attr_in_intensity2_capacitance.dev_attr.attr, :::::: The code at line 205 was first introduced by commit :::::: 1276187c5261217aa9cc23ec153e0e903181c16b iio: health/afe440x: Make gain settings a modifier for the stages :::::: TO: Andrew F. Davis :::::: CC: Jonathan Cameron --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation