Hi Dmitry and Jonathan,
Am 19.11.2016 um 21:09 schrieb Jonathan Cameron jic23@jic23.retrosnub.co.uk:
The IS_ENABLED macro takes care of both cases.
No it doesn't. Have you tried building the driver into the kernel with IIO as a module?
I have tried and it indeed fails to compile.
Fair point. Is there a clean way of handling this?
This seems to basically work and I have included it in [PATCH v8]:
obj-$(CONFIG_TOUCHSCREEN_TSC2004) += tsc2004.o obj-$(CONFIG_TOUCHSCREEN_TSC2005) += tsc2005.o tsc2007-y := tsc2007_core.o ifeq ($(CONFIG_IIO),y) tsc2007-y += tsc2007_iio.o endif ifeq ($(CONFIG_IIO),m) tsc2007-y += tsc2007_iio.o endif obj-$(CONFIG_TOUCHSCREEN_TSC2007) += tsc2007.o obj-$(CONFIG_TOUCHSCREEN_UCB1400) += ucb1400_ts.o obj-$(CONFIG_TOUCHSCREEN_WACOM_W8001) += wacom_w8001.o
but still has a problem because it is not possible to reference functions from the iio core with CONFIG_IIO=m from a driver built into the kernel:
drivers/built-in.o: In function `tsc2007_iio_unconfigure': /Users/hns/Sources/System/Kernel/Linux/src/master/drivers/input/touchscreen/tsc2007_iio.c:148: undefined reference to `iio_device_unregister' drivers/built-in.o: In function `tsc2007_iio_configure': /Users/hns/Sources/System/Kernel/Linux/src/master/drivers/input/touchscreen/tsc2007_iio.c:115: undefined reference to `devm_iio_device_alloc' /Users/hns/Sources/System/Kernel/Linux/src/master/drivers/input/touchscreen/tsc2007_iio.c:133: undefined reference to `iio_device_register'
So it would mean that we have to dynamically locate and bind iio_device_(un)register and devm_iio_device_alloc.
BR and thanks, Nikolaus