linux_old1/drivers/iio
Michal Nazarewicz 8f57e4d930 include/linux/kernel.h: change abs() macro so it uses consistent return type
Rewrite abs() so that its return type does not depend on the
architecture and no unexpected type conversion happen inside of it.  The
only conversion is from unsigned to signed type.  char is left as a
return type but treated as a signed type regradless of it's actual
signedness.

With the old version, int arguments were promoted to long and depending
on architecture a long argument might result in s64 or long return type
(which may or may not be the same).

This came after some back and forth with Nicolas.  The current macro has
different return type (for the same input type) depending on
architecture which might be midly iritating.

An alternative version would promote to int like so:

	#define abs(x)	__abs_choose_expr(x, long long,			\
			__abs_choose_expr(x, long,			\
			__builtin_choose_expr(				\
				sizeof(x) <= sizeof(int),		\
				({ int __x = (x); __x<0?-__x:__x; }),	\
				((void)0))))

I have no preference but imagine Linus might.  :] Nicolas argument against
is that promoting to int causes iconsistent behaviour:

	int main(void) {
		unsigned short a = 0, b = 1, c = a - b;
		unsigned short d = abs(a - b);
		unsigned short e = abs(c);
		printf("%u %u\n", d, e);  // prints: 1 65535
	}

Then again, no sane person expects consistent behaviour from C integer
arithmetic.  ;)

Note:

  __builtin_types_compatible_p(unsigned char, char) is always false, and
  __builtin_types_compatible_p(signed char, char) is also always false.

Signed-off-by: Michal Nazarewicz <mina86@mina86.com>
Reviewed-by: Nicolas Pitre <nico@linaro.org>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2016-01-16 11:17:22 -08:00
..
accel iio: mma8452: use enum for channel index 2015-12-19 16:45:42 +00:00
adc Third set of new stuff for IIO in the 4.5 cycle. 2015-12-26 17:05:25 -08:00
amplifiers spi: Updates for v4.4 2015-11-05 13:15:12 -08:00
buffer iio: Add a DMAengine framework based buffer 2015-10-25 13:55:32 +00:00
chemical iio: chemical: add AMS iAQ-core support 2015-12-12 15:07:38 +00:00
common iio: st_accel_core: Remove unneeded define 2015-12-05 17:28:31 +00:00
dac First set of IIO fixes for the 4.4 cycle. 2015-11-18 13:15:50 -08:00
dummy Second set of IIO new drivers, functionality and cleanups for the 4.5 cycle. 2015-12-26 17:03:33 -08:00
frequency spi: Updates for v4.4 2015-11-05 13:15:12 -08:00
gyro First set of new device support, features and cleanups for IIO in the 4.5 cycle 2015-12-01 09:13:29 -08:00
health iio: light: add MAX30100 oximeter driver support 2015-12-12 12:14:37 +00:00
humidity First set of IIO fixes for the 4.4 cycle. 2015-11-18 13:15:50 -08:00
imu First set of new device support, features and cleanups for IIO in the 4.5 cycle 2015-12-01 09:13:29 -08:00
light Third set of new stuff for IIO in the 4.5 cycle. 2015-12-26 17:05:25 -08:00
magnetometer First set of new device support, features and cleanups for IIO in the 4.5 cycle 2015-12-01 09:13:29 -08:00
orientation iio: orientation: hid-sensor-rotation: Fix memory leak in probe() 2015-05-17 09:10:25 +01:00
potentiometer iio: mcp4531: Driver for Microchip digital potentiometers 2015-09-30 18:20:53 +01:00
pressure spi: Updates for v4.4 2015-11-05 13:15:12 -08:00
proximity Second set of IIO new drivers, functionality and cleanups for the 4.5 cycle. 2015-12-26 17:03:33 -08:00
temperature Add tsys02d meas-spec driver support 2015-10-11 10:21:19 +01:00
trigger iio: trigger: Introduce IIO hrtimer based trigger 2015-12-03 18:19:27 +00:00
Kconfig iio: light: add MAX30100 oximeter driver support 2015-12-12 12:14:37 +00:00
Makefile iio: light: add MAX30100 oximeter driver support 2015-12-12 12:14:37 +00:00
iio_core.h iio: Move buffer registration to the core 2014-12-12 12:28:31 +00:00
iio_core_trigger.h
industrialio-buffer.c Merge 4.4-rc5 into staging-next 2015-12-13 19:23:01 -08:00
industrialio-configfs.c iio:configfs: Introduce iio/configfs.h to provide a location for the configfs_subsystem 2015-12-05 16:25:30 +00:00
industrialio-core.c include/linux/kernel.h: change abs() macro so it uses consistent return type 2016-01-16 11:17:22 -08:00
industrialio-event.c iio: event: Remove negative error code from iio_event_poll 2015-08-12 19:26:39 +01:00
industrialio-sw-trigger.c iio:configfs: Introduce iio/configfs.h to provide a location for the configfs_subsystem 2015-12-05 16:25:30 +00:00
industrialio-trigger.c iio: Support triggered events 2015-08-27 20:47:09 +01:00
industrialio-triggered-event.c iio: Support triggered events 2015-08-27 20:47:09 +01:00
inkern.c iio/inkern.c Use list_for_each_entry_safe 2015-12-12 17:23:37 +00:00