Skip to contentSkip to conversation

add analog devices AD714X captouch input driver

PATCH Superseded Barry Song 6 participants 12 messages Sep 8, 2009 – Sep 9, 2009 2 messages not in the archive

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Barry Song

author
#0 lore raw

PATCH v2 1/1 add analog devices AD714X captouch input driver

AD7142 and AD7147 are integrated capacitance-to-digital converters (CDCs) with on-chip environmental calibration for use in systems requiring a novel user input method. The AD7142 and AD7147 can interface to external capacitance sensors implementing functions such as buttons, scrollwheels, sliders, touchpads and so on.

The chips don't restrict the specific usage. Depending on the hardware connection, one special target board can include one or several these components. The platform_data for the device's "struct device" holds these information. The data-struct defined in head file descript the hardware feature of button/scrollwheel/slider/touchpad components on target boards, which need be filled in the arch/mach-/.

As the result, the driver is independent of boards. It gets the components layout from the platform_data, registers related devices, fullfills the algorithms and state machines for these components and report related input events to up level.

---
 drivers/input/misc/Kconfig   |   23 +
 drivers/input/misc/Makefile  |    1 +
 drivers/input/misc/ad714x.c  | 1642 ++++++++++++++++++++++++++++++++++++++++++
 include/linux/input.h        |    1 +
 include/linux/input/ad714x.h |   62 ++
 5 files changed, 1729 insertions(+), 0 deletions(-)
 create mode 100644 drivers/input/misc/ad714x.c
 create mode 100644 include/linux/input/ad714x.h
drivers/input/misc/Kconfig +23 -0
index cbe21bc..829af34 100644
@@ -260,6 +260,29 @@ config INPUT_RB532_BUTTON
 	  To compile this driver as a module, choose M here: the
 	  module will be called rb532_button.
 
+config INPUT_AD714X
+	tristate "Analog Devices AD714X Capacitance Touch Sensor"
+	depends on SPI || I2C
+	help
+	  Say Y here if you want to support an AD714X touch sensor.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called ad714X.
+
+config INPUT_EVAL_AD7147EBZ
+	bool "ADI EVAL-AD7147EBZ board"
+	depends on INPUT_AD714X && SPI
+	help
+	  Select this if you are using ADI EVAL-AD7147EBZ board, there are
+	  five buttons and one slider on this board.
+
+config INPUT_EVAL_AD7142EB
+	bool "ADI EVAL-AD7142EB board"
+	depends on INPUT_AD714X && I2C
+	help
+	  Select this if you are using ADI EVAL-AD7142EB board, there are
+	  four buttons and two sliders on this board.
+
 config INPUT_DM355EVM
 	tristate "TI DaVinci DM355 EVM Keypad and IR Remote"
 	depends on MFD_DM355EVM_MSP
drivers/input/misc/Makefile +1 -0
index 79c1e9a..39e0ae9 100644
@@ -4,6 +4,7 @@
 
 # Each configuration option enables a list of files.
 
+obj-$(CONFIG_INPUT_AD714X)		+= ad714x.o
 obj-$(CONFIG_INPUT_APANEL)		+= apanel.o
 obj-$(CONFIG_INPUT_ATI_REMOTE)		+= ati_remote.o
 obj-$(CONFIG_INPUT_ATI_REMOTE2)		+= ati_remote2.o
drivers/input/misc/ad714x.c new file +1642 -0

1,642 lines not on this page · raw message

include/linux/input.h +1 -0
index 8b3bc3e..3836e7c 100644
@@ -756,6 +756,7 @@ struct input_absinfo {
 #define BUS_HOST		0x19
 #define BUS_GSC			0x1A
 #define BUS_ATARI		0x1B
+#define BUS_SPI			0x1C
 
 /*
  * MT_TOOL types
include/linux/input/ad714x.h new file +62 -0

62 lines not on this page · raw message

Signature · 1 line
1.5.6.3

A message that is not in the archive (sent off-list or not yet received): 1252401564-5291-1-git-send-email-21cnbao-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#2 lore raw
Quoted 15 lines · Barry Song
drivers/input/misc/ad714x.c new file +15 -0
+static int __init ad714x_init(void)
+{
+#if (defined(CONFIG_SPI) || defined(CONFIG_SPI_MODULE)) && \
+       !(defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE))
+       return spi_register_driver(&ad714x_spi_driver);
+#endif
+
+#if (defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE))  && \
+       !(defined(CONFIG_SPI) || defined(CONFIG_SPI_MODULE))
+       return i2c_add_driver(&ad714x_i2c_driver);
+#endif
+
+#if (defined(CONFIG_SPI) || defined(CONFIG_SPI_MODULE)) && \
+       (defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE))
+       int ret = 0;

drivers/input/misc/ad714x.c line 1624

Quoted 10 lines
drivers/input/misc/ad714x.c new file +10 -0
+       ret = spi_register_driver(&ad714x_spi_driver);
+       if (ret)
+               goto err;
+       ret = i2c_add_driver(&ad714x_i2c_driver);
+       if (ret)
+               spi_unregister_driver(&ad714x_spi_driver);
+err:
+       return ret;
+#endif
+}

Ugly and error prone.
You should have only one block of code not four ...

Absolutely the cleanest solution adds inlined NOP stubs for I2C and SPI driver register/unregister calls, and gets rid of all that #ifdeffery; there are other solutions.

#3 lore raw

RE: [Uclinux-dist-devel] [PATCH v2]add analog devices AD714Xcaptouch input driver

Quoted 43 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of David Brownell
Sent: Wednesday, September 09, 2009 2:49 AM
To: Barry Song
Cc: [email protected]; [email protected]
Subject: Re: [Uclinux-dist-devel] [PATCH v2]add analog devices AD714Xcaptouch input driver

Quoted 15 lines · Barry Song
drivers/input/misc/ad714x.c new file +15 -0
+static int __init ad714x_init(void)
+{
+#if (defined(CONFIG_SPI) || defined(CONFIG_SPI_MODULE)) && \
+       !(defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE))
+       return spi_register_driver(&ad714x_spi_driver);
+#endif
+
+#if (defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE))  && \
+       !(defined(CONFIG_SPI) || defined(CONFIG_SPI_MODULE))
+       return i2c_add_driver(&ad714x_i2c_driver);
+#endif
+
+#if (defined(CONFIG_SPI) || defined(CONFIG_SPI_MODULE)) && \
+       (defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE))
+       int ret = 0;

drivers/input/misc/ad714x.c line 1624

Quoted 10 lines
drivers/input/misc/ad714x.c new file +10 -0
+       ret = spi_register_driver(&ad714x_spi_driver);
+       if (ret)
+               goto err;
+       ret = i2c_add_driver(&ad714x_i2c_driver);
+       if (ret)
+               spi_unregister_driver(&ad714x_spi_driver);
+err:
+       return ret;
+#endif
+}

Ugly and error prone.
You should have only one block of code not four ...

Quoted 4 lines

Absolutely the cleanest solution adds inlined NOP stubs for I2C and SPI driver register/unregister calls, and gets rid of all that #ifdeffery; there are other solutions.

The aim is that the module can work at:
1. only spi bus enabled (probe spi devices)
2. only i2c bus enabled (probe i2c devices)
3. both spi and i2c bus enabled. (probe both i2c/spi devices)
So the module depends on SPI || I2C not SPI && I2C. I used the #ifdeffery to avoid compiling error due to symbols losing of I2C or SPI while kernel configuration doesn't enable both SPI and I2C. If kernel only enables one of the two buses, the driver only probes the enabled bus.

I don't know what the exact meaning of "inlined NOP stubs", do you mean things like the following? #if (defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE))
...

static struct i2c_driver ad714x_i2c_driver = {
        .driver = {
                .name = "ad714x_captouch",
        },   
        .probe    = ad714x_i2c_probe,
        .remove   = __devexit_p(ad714x_i2c_remove),
        .suspend  = ad714x_i2c_suspend,
        .resume   = ad714x_i2c_resume,
        .id_table = ad714x_id,
};

static inline int ad714x_i2c_add_driver(struct i2c_driver *i2c_drv)

{
        return i2c_add_driver(i2c_drv);
}
#else
static inline int ad714x_i2c_add_driver(struct i2c_driver *i2c_drv)
{
        return 0;
}

#define ad714x_i2c_driver NULL
#endif

static int __init ad714x_init(void)

{
	...
	ad714x_i2c_add_driver(&ad714x_i2c_driver);
	...
}

Then ad714x_init can use a unified ad714x_i2c_add_driver, ad714x_spi_register_driver to avoid #ifdeffery used? It seems that doesn't make the codes more pretty?

Quoted 7 lines

_______________________________________________
Uclinux-dist-devel mailing list
[email protected]
https://blackfin.uclinux.org/mailman/listinfo/uclinux-dist-devel

--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw

Re: [Uclinux-dist-devel] [PATCH v2]add analog devices AD714Xcaptouch input driver

Quoted 6 lines · Barry

I don't know what the exact meaning of "inlined NOP stubs", do you mean things like the following? #if (defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE))
...
static struct i2c_driver ad714x_i2c_driver = {
        ..
};

You _should_ be able to always declare that and let GCC optimize it away ...

Quoted 9 lines

static inline int ad714x_i2c_add_driver(struct i2c_driver *i2c_drv) {
        return i2c_add_driver(i2c_drv);
}
#else
static inline int ad714x_i2c_add_driver(struct i2c_driver *i2c_drv) {
        return 0;
}

That'd be OK as a quick fix; ideally i2c_add_driver() itself would be what the #ifdef covers (in <linux/i2c.h> and likewise in <linux/spi/spi.h>). And you'd need to cover driver remove paths too.

Quoted 1 line

#define ad714x_i2c_driver NULL

Ditto: shouldn't need to #define that

Quoted 6 lines

#endif

static int __init ad714x_init(void)
{
        ...
        ad714x_i2c_add_driver(&ad714x_i2c_driver);

Yes; but do check the value!

Quoted 6 lines

        ...
}

Then ad714x_init can use a unified ad714x_i2c_add_driver, ad714x_spi_register_driver to avoid #ifdeffery used? It seems that doesn't make the codes more pretty?

Way less #ifdeffery and *ONE* non-#ifdeffed chunk of code in driver init/exit code.

- Dave

--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#5 lore raw

RE: [Uclinux-dist-devel] [PATCH v2]add analog devices AD714Xcaptouch input driver

Quoted 57 lines

-----Original Message-----
From: David Brownell [mailto:[email protected]]
Sent: Wednesday, September 09, 2009 10:30 AM
To: Song, Barry
Cc: Barry Song; [email protected]; [email protected]
Subject: Re: [Uclinux-dist-devel] [PATCH v2]add analog devices AD714Xcaptouch input driver

Quoted 1 line · Barry

I don't know what the exact meaning of "inlined NOP stubs",

do you mean things like the following?

Quoted 5 lines

#if (defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE))
...
static struct i2c_driver ad714x_i2c_driver = { ..
};

You _should_ be able to always declare that and let GCC optimize it away ...

Quoted 9 lines

static inline int ad714x_i2c_add_driver(struct i2c_driver *i2c_drv) {
        return i2c_add_driver(i2c_drv);
}
#else
static inline int ad714x_i2c_add_driver(struct i2c_driver *i2c_drv) {
        return 0;
}

That'd be OK as a quick fix; ideally i2c_add_driver() itself would be what the #ifdef covers (in <linux/i2c.h> and likewise in <linux/spi/spi.h>). And you'd need to cover driver remove paths too.

Quoted 1 line

#define ad714x_i2c_driver NULL

Ditto: shouldn't need to #define that

Quoted 6 lines

#endif

static int __init ad714x_init(void)
{
        ...
        ad714x_i2c_add_driver(&ad714x_i2c_driver);

Yes; but do check the value!

Quoted 3 lines

        ...
}

Quoted 6 lines
Quoted 3 lines

Then ad714x_init can use a unified ad714x_i2c_add_driver, ad714x_spi_register_driver to avoid #ifdeffery used? It seems that doesn't make the codes more pretty?

Way less #ifdeffery and *ONE* non-#ifdeffed chunk of code in driver init/exit code.

Fixed

Quoted 5 lines

- Dave

--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#6 lore raw

RE: [Uclinux-dist-devel] [PATCH v2]add analog devices AD714Xcaptouch input driver

In reply to David Brownell
Quoted 33 lines

-----Original Message-----
From: Song, Barry
Sent: Wednesday, September 09, 2009 11:00 AM
To: 'David Brownell'; '[email protected]'
Cc: Barry Song; [email protected]; [email protected]
Subject: RE: [Uclinux-dist-devel] [PATCH v2]add analog devices AD714Xcaptouch input driver

Quoted 20 lines

-----Original Message-----
From: David Brownell [mailto:[email protected]]
Sent: Wednesday, September 09, 2009 10:30 AM
To: Song, Barry
Cc: Barry Song; [email protected]; [email protected]
Subject: Re: [Uclinux-dist-devel] [PATCH v2]add analog devices AD714Xcaptouch input driver

Quoted 1 line · Barry

I don't know what the exact meaning of "inlined NOP stubs",

do you mean things like the following?

Quoted 5 lines

#if (defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE))
...
static struct i2c_driver ad714x_i2c_driver = { ..
};

You _should_ be able to always declare that and let GCC optimize it away ...

Even though I can always declare it, the functions in ad714x_i2c_driver still access i2c symbols. For that, I still need to use #ifdef to make the compiling pass.

Quoted 18 lines
Quoted 18 lines
Quoted 11 lines

static inline int ad714x_i2c_add_driver(struct i2c_driver *i2c_drv) {
        return i2c_add_driver(i2c_drv);
}
#else
static inline int ad714x_i2c_add_driver(struct i2c_driver *i2c_drv) {
        return 0;
}

That'd be OK as a quick fix; ideally i2c_add_driver() itself would be what the #ifdef covers (in <linux/i2c.h> and likewise in <linux/spi/spi.h>). And you'd need to cover driver remove paths too.

Quoted 3 lines
Quoted 3 lines
Quoted 1 line

#define ad714x_i2c_driver NULL

Ditto: shouldn't need to #define that

Even though GCC can optimize unused variants/functions, there are still compiling error since field functions of ad714x_i2c_driver/ad714x_spi_driver and other functions will access other spi/i2c symbols. So maybe the best fix is:

ad714x.c (working copy) renamed from ad714x.c (revision 7274) +33 -23
Index: ad714x.c
===================================================================
@@ -1478,9 +1478,22 @@
        .suspend        = ad714x_spi_suspend,
        .resume         = ad714x_spi_resume,
 };
+
+static inline int ad714x_spi_register_driver(struct spi_driver *spi_drv)
+{
+       return spi_register_driver(spi_drv);
+}
+
+static inline void ad714x_spi_unregister_driver(struct spi_driver *spi_drv)
+{
+       spi_unregister_driver(spi_drv);
+}
+
+#else
+#define ad714x_spi_register_driver(p) 0
+#define ad714x_spi_unregister_driver(p)
 #endif
 
-
 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
 static int ad714x_i2c_write(struct device *dev, unsigned short reg,
                unsigned short data)
@@ -1595,43 +1608,40 @@
        .resume   = ad714x_i2c_resume,
        .id_table = ad714x_id,
 };
+
+static inline int ad714x_i2c_add_driver(struct i2c_driver *i2c_drv)
+{
+       return i2c_add_driver(i2c_drv);
+}
+
+static inline void ad714x_i2c_del_driver(struct i2c_driver *i2c_drv)
+{
+       i2c_del_driver(i2c_drv);
+}
+
+#else
+#define ad714x_i2c_add_driver(p) 0
+#define ad714x_i2c_del_driver(p)
 #endif
 
 static int __init ad714x_init(void)
 {
-#if (defined(CONFIG_SPI) || defined(CONFIG_SPI_MODULE)) && \
-       !(defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE))
-       return spi_register_driver(&ad714x_spi_driver);
-#endif
 
-#if (defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE))  && \
-       !(defined(CONFIG_SPI) || defined(CONFIG_SPI_MODULE))
-       return i2c_add_driver(&ad714x_i2c_driver);
-#endif
-
-#if (defined(CONFIG_SPI) || defined(CONFIG_SPI_MODULE)) && \
-       (defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE))
        int ret = 0;
-       ret = spi_register_driver(&ad714x_spi_driver);
+       ret = ad714x_spi_register_driver(&ad714x_spi_driver);
        if (ret)
                goto err;
-       ret = i2c_add_driver(&ad714x_i2c_driver);
+       ret = ad714x_i2c_add_driver(&ad714x_i2c_driver);
        if (ret)
-               spi_unregister_driver(&ad714x_spi_driver);
+               ad714x_spi_unregister_driver(&ad714x_spi_driver);
 err:
        return ret;
-#endif
 }
 
 static void __exit ad714x_exit(void)
 {
-#if defined(CONFIG_SPI) || defined(CONFIG_SPI_MODULE)
-       spi_unregister_driver(&ad714x_spi_driver);
-#endif
-
-#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
-       i2c_del_driver(&ad714x_i2c_driver);
-#endif
+       ad714x_spi_unregister_driver(&ad714x_spi_driver);
+       ad714x_i2c_del_driver(&ad714x_i2c_driver);
 }
 
 module_init(ad714x_init);
Quoted 14 lines
Quoted 14 lines
Quoted 8 lines

#endif

static int __init ad714x_init(void)
{
        ...
        ad714x_i2c_add_driver(&ad714x_i2c_driver);

Yes; but do check the value!

Quoted 3 lines

        ...
}

Quoted 13 lines
Quoted 6 lines
Quoted 3 lines

Then ad714x_init can use a unified ad714x_i2c_add_driver, ad714x_spi_register_driver to avoid #ifdeffery used? It seems that doesn't make the codes more pretty?

Way less #ifdeffery and *ONE* non-#ifdeffed chunk of code in driver init/exit code.

Fixed

Quoted 5 lines

- Dave

--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 0F1B54C89D5F954D8535DB252AF412FA04B118A5-SGdA1W8gREmuVPpjEGsWsTcYPEmu4y7e@public.gmane.org

#8 lore raw

Re: [PATCH v2]add analog devices AD714Xcaptouch input driver

Quoted 13 lines · Barry
ad714x.c (working copy) renamed from ad714x.c (revision 7274) +13 -0
+static inline int ad714x_spi_register_driver(struct spi_driver *spi_drv)
+{
+       return spi_register_driver(spi_drv);
+}
+
+static inline void ad714x_spi_unregister_driver(struct spi_driver *spi_drv)
+{
+       spi_unregister_driver(spi_drv);
+}
+
+#else
+#define ad714x_spi_register_driver(p) 0
+#define ad714x_spi_unregister_driver(p)
Quoted 1 line

 #endif

i dont think you need the ifdef protection that far up. what about using the ifdef in this one place:
static inline int ad714x_spi_register_driver(struct spi_driver *spi_drv) {

#if defined(CONFIG_SPI) || defined(CONFIG_SPI_MODULE)
    return spi_register_driver(spi_drv);
#else
    return 0;

#endif
}

then i imagine you can have all the other pieces always enabled. gcc will see that everything is marked static and not used, so it'll cull things.
-mike
_______________________________________________
Uclinux-dist-devel mailing list [email protected]
https://blackfin.uclinux.org/mailman/listinfo/uclinux-dist-devel

#9 lore raw

RE: [Uclinux-dist-devel] [PATCH v2]add analog devices AD714Xcaptouch input driver

Quoted 38 lines

-----Original Message-----
From: Mike Frysinger [mailto:[email protected]]
Sent: Wednesday, September 09, 2009 2:06 PM
To: Song, Barry
Cc: David Brownell; [email protected]; [email protected]; [email protected]
Subject: Re: [Uclinux-dist-devel] [PATCH v2]add analog devices AD714Xcaptouch input driver

Quoted 1 line · Barry

+static inline int ad714x_spi_register_driver(struct

spi_driver *spi_drv)

ad714x.c (working copy)

Quoted 5 lines
ad714x.c (working copy) renamed from ad714x.c (revision 7274) +5 -0
+{
+       return spi_register_driver(spi_drv);
+}
+
+static inline void ad714x_spi_unregister_driver(struct 

spi_driver *spi_drv)

Quoted 8 lines
ad714x.c (working copy) renamed from ad714x.c (revision 7274) +7 -0
+{
+       spi_unregister_driver(spi_drv);
+}
+
+#else
+#define ad714x_spi_register_driver(p) 0
+#define ad714x_spi_unregister_driver(p)

 #endif

i dont think you need the ifdef protection that far up. what about using the ifdef in this one place:
static inline int ad714x_spi_register_driver(struct spi_driver *spi_drv)
{

#if defined(CONFIG_SPI) || defined(CONFIG_SPI_MODULE)
   return spi_register_driver(spi_drv);
#else
   return 0;
Quoted 6 lines

#endif
}

then i imagine you can have all the other pieces always enabled. gcc will see that everything is marked static and not used, so it'll cull things.

In fact, I have tried to do like this before changing like I sent in the last mail. In fact, it will get compiling error if I always enable all spi and i2c functions without a #ifdef protection. So since there are far #ifdef, I think it shoud be better to place related codes to existed #ifdef.

Quoted 2 lines

-mike

--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#10 lore raw

Re: [Uclinux-dist-devel] [PATCH v2]add analog devices AD714Xcaptouch input driver

Quoted 31 lines · Barry

From: Mike Frysinger [mailto:[email protected]]

Quoted 30 lines · Barry

ad714x.c (working copy)

Quoted 7 lines

+static inline int ad714x_spi_register_driver(struct spi_driver *spi_drv)

ad714x.c (working copy) renamed from ad714x.c (revision 7274) +5 -0
+{
+       return spi_register_driver(spi_drv);
+}
+
+static inline void ad714x_spi_unregister_driver(struct

spi_driver *spi_drv)

Quoted 8 lines
ad714x.c (working copy) renamed from ad714x.c (revision 7274) +7 -0
+{
+       spi_unregister_driver(spi_drv);
+}
+
+#else
+#define ad714x_spi_register_driver(p) 0
+#define ad714x_spi_unregister_driver(p)

 #endif

i dont think you need the ifdef protection that far up.  what about using the ifdef in this one place:
static inline int ad714x_spi_register_driver(struct spi_driver *spi_drv)
{
#if defined(CONFIG_SPI) || defined(CONFIG_SPI_MODULE) return spi_register_driver(spi_drv);
#else
   return 0;
#endif
}

Quoted 6 lines
Quoted 3 lines

then i imagine you can have all the other pieces always enabled.  gcc will see that everything is marked static and not used, so it'll cull things.

In fact, I have tried to do like this before changing like I sent in the last mail. In fact, it will get compiling error if I always enable all spi and i2c functions without a #ifdef protection. So since there are far #ifdef, I think it shoud be better to place related codes to existed #ifdef.

i really have no idea what you're trying to say or why it didnt work for you -mike
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#11 lore raw

RE: [Uclinux-dist-devel] [PATCH v2]add analog devices AD714Xcaptouch input driver

Quoted 47 lines

-----Original Message-----
From: Mike Frysinger [mailto:[email protected]]
Sent: Wednesday, September 09, 2009 3:48 PM
To: Song, Barry
Cc: David Brownell; [email protected]; [email protected]; [email protected]
Subject: Re: [Uclinux-dist-devel] [PATCH v2]add analog devices AD714Xcaptouch input driver

Quoted 35 lines · Barry

From: Mike Frysinger [mailto:[email protected]]

Quoted 33 lines · Barry

ad714x.c (working copy)

Quoted 7 lines

+static inline int ad714x_spi_register_driver(struct spi_driver *spi_drv)

ad714x.c (working copy) renamed from ad714x.c (revision 7274) +5 -0
+{
+       return spi_register_driver(spi_drv);
+}
+
+static inline void ad714x_spi_unregister_driver(struct

spi_driver *spi_drv)

Quoted 8 lines
ad714x.c (working copy) renamed from ad714x.c (revision 7274) +7 -0
+{
+       spi_unregister_driver(spi_drv);
+}
+
+#else
+#define ad714x_spi_register_driver(p) 0
+#define ad714x_spi_unregister_driver(p)

 #endif

i dont think you need the ifdef protection that far up.  what about using the ifdef in this one place:
static inline int ad714x_spi_register_driver(struct spi_driver *spi_drv)
{
#if defined(CONFIG_SPI) || defined(CONFIG_SPI_MODULE) return spi_register_driver(spi_drv);
#else
   return 0;
#endif
}

then i imagine you can have all the other pieces always enabled.  gcc will see that everything is marked static and not used, so it'll cull things.

Quoted 8 lines
Quoted 1 line

In fact, I have tried to do like this before changing like I

sent in the last mail. In fact, it will get compiling error if I always enable all spi and i2c functions without a #ifdef protection.

Quoted 1 line

So since there are far #ifdef, I think it shoud be better to

place related codes to existed #ifdef.

i really have no idea what you're trying to say or why it didnt work for you

I guess you want to change like this:
- #if (defined(CONFIG_SPI) || defined(CONFIG_SPI_MODULE)) static int ad714x_spi_read(struct device *dev, unsigned short reg, unsigned short *data)
{
...

static struct spi_driver ad714x_spi_driver = {
...

static inline int ad714x_spi_register_driver(struct spi_driver *spi_drv) {

#if defined(CONFIG_SPI) || defined(CONFIG_SPI_MODULE)
        return spi_register_driver(spi_drv);
#else
        return 0;

#endif
}

static inline void ad714x_spi_unregister_driver(struct spi_driver *spi_drv) {

#if defined(CONFIG_SPI) || defined(CONFIG_SPI_MODULE)
        spi_unregister_driver(spi_drv);

#endif
}

- #endif

- #if (defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)) static int ad714x_i2c_write(struct device *dev, unsigned short reg, unsigned short data)
{
...

static struct i2c_driver ad714x_i2c_driver = {
...

static inline int ad714x_i2c_add_driver(struct i2c_driver *i2c_drv) {

#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
        return i2c_add_driver(i2c_drv);
#else
        return 0;

#endif
}

static inline void ad714x_i2c_del_driver(struct i2c_driver *i2c_drv) {

#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
        i2c_del_driver(i2c_drv);

#endif
}
- #endif

static int __init ad714x_init(void)
{

        int ret = 0;
        ret = ad714x_spi_register_driver(&ad714x_spi_driver);
        if (ret)
                goto err;
        ret = ad714x_i2c_add_driver(&ad714x_i2c_driver);
        if (ret)
                ad714x_spi_unregister_driver(&ad714x_spi_driver);
err:
        return ret;
}

static void __exit ad714x_exit(void)

{
        ad714x_spi_unregister_driver(&ad714x_spi_driver);
        ad714x_i2c_del_driver(&ad714x_i2c_driver);
}

In fact, it can still cause link errors due to lost i2c/spi symbols if only spi/i2c enabled. It makes simple things too complex. So I think keeping the

#if (defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE))
#if (defined(CONFIG_SPI) || defined(CONFIG_SPI_MODULE))

is better.
Since I don't delete the two far #ifdefs, I'd like to split spi/i2c register/unregister definition to those #ifdef to cover them.
If you consider ad714x_spi_driver and ad714x_i2c_driver, field functions in them include internal i2c/spi symbols, which can cause link errors too if the two variants are not protected by far #ifdef.

Quoted 2 lines

-mike

--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#12 lore raw
In reply to a message not in the archive

drivers/input/misc/Kconfig config INPUT_RB532_BUTTON · line 270

Quoted 8 lines · Barry Song
drivers/input/misc/Kconfig +8 -0
+config INPUT_AD714X
+       tristate "Analog Devices AD714X Capacitance Touch Sensor"
+       depends on SPI || I2C
+       help
+         Say Y here if you want to support an AD714X touch sensor.
+
+         To compile this driver as a module, choose M here: the
+         module will be called ad714X.

capital X in define/config is OK, but the desc and user output should really be lower case. plus the module wont be named "ad714X", it'll be "ad714x".
-mike
_______________________________________________
Uclinux-dist-devel mailing list [email protected]
https://blackfin.uclinux.org/mailman/listinfo/uclinux-dist-devel

#13 lore raw

RE: [Uclinux-dist-devel] [PATCH v2]add analog devices AD714Xcaptouch input driver

Quoted 14 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Mike Frysinger
Sent: Wednesday, September 09, 2009 2:09 PM
To: Barry Song
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [Uclinux-dist-devel] [PATCH v2]add analog devices AD714Xcaptouch input driver

On Tue, Sep 8, 2009 at 05:19, Barry Song wrote:

Quoted 12 lines

drivers/input/misc/Kconfig config INPUT_RB532_BUTTON · line 270

Quoted 8 lines
drivers/input/misc/Kconfig +8 -0
+config INPUT_AD714X
+       tristate "Analog Devices AD714X Capacitance Touch Sensor"
+       depends on SPI || I2C
+       help
+         Say Y here if you want to support an AD714X touch sensor.
+
+         To compile this driver as a module, choose M here: the
+         module will be called ad714X.

capital X in define/config is OK, but the desc and user output should really be lower case. plus the module wont be named "ad714X", it'll be "ad714x".

Fixed

Quoted 6 lines

-mike
_______________________________________________
Uclinux-dist-devel mailing list
[email protected]
https://blackfin.uclinux.org/mailman/listinfo/uclinux-dist-devel

--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html