devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Lothar Waßmann" <LW@KARO-electronics.de>
To: Denis Carikli <denis@eukrea.com>
Cc: "Sascha Hauer" <kernel@pengutronix.de>,
	"Mark Rutland" <mark.rutland@arm.com>,
	devicetree@vger.kernel.org,
	"Dmitry Torokhov" <dmitry.torokhov@gmail.com>,
	"Pawel Moll" <pawel.moll@arm.com>,
	"Stephen Warren" <swarren@wwwdotorg.org>,
	"Ian Campbell" <ijc+devicetree@hellion.org.uk>,
	"Rob Herring" <rob.herring@calxeda.com>,
	"Eric Bénard" <eric@eukrea.com>,
	linux-input@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [Patch v2][ 15/37] Input: tsc2007: Add device tree support.
Date: Fri, 18 Oct 2013 10:36:11 +0200	[thread overview]
Message-ID: <20131018103611.4c6baabb@ipc1.ka-ro> (raw)
In-Reply-To: <1382022155-21954-16-git-send-email-denis@eukrea.com>

Hi,

Denis Carikli <denis@eukrea.com> wrote:
> diff --git a/Documentation/devicetree/bindings/input/touchscreen/tsc2007.txt b/Documentation/devicetree/bindings/input/touchscreen/tsc2007.txt
> new file mode 100644
> index 0000000..d67b33f
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/input/touchscreen/tsc2007.txt
> @@ -0,0 +1,44 @@
> +* Texas Instruments tsc2007 touchscreen controller
> +
> +Required properties:
> +- compatible: must be "ti,tsc2007".
> +- reg: I2C address of the chip.
> +- pinctrl-0: Should specify pin control groups used for this controller
> +  (see pinctrl bindings[0]).
> +- pinctrl-names: Should contain only one value - "default"
> +  (see pinctrl bindings[0]).
> +- interrupt-parent: the phandle for the interrupt controller
> +  (see interrupt binding[1]).
> +- interrupts: interrupt to which the chip is connected
> +  (see interrupt binding[1]).
> +- x-plate-ohms: X-plate resistance in ohms.
> +
There is already a property 'ti,x-plate-ohms' (used for ads7846).
Should this be used here too instead of inventing a new one?

[...]
> @@ -175,10 +192,10 @@ static irqreturn_t tsc2007_soft_irq(int irq, void *handle)
>  
>  		/* pen is down, continue with the measurement */
>  		tsc2007_read_values(ts, &tc);
> -
>  		rt = tsc2007_calculate_pressure(ts, &tc);
>  
> -		if (rt == 0 && !ts->get_pendown_state) {
> +		if ((ts->of && rt == 0 && ts->gpio < 0) ||
... && !gpio_is_valid(ts->gpio)) ||
for consistency?

> @@ -273,34 +294,64 @@ static void tsc2007_close(struct input_dev *input_dev)
>  	tsc2007_stop(ts);
>  }
>  
> -static int tsc2007_probe(struct i2c_client *client,
> -				   const struct i2c_device_id *id)
> +#ifdef CONFIG_OF
> +static int tsc2007_probe_dt(struct i2c_client *client, struct tsc2007 *ts,
> +			    struct device_node *np)
>  {
> -	struct tsc2007 *ts;
> -	struct tsc2007_platform_data *pdata = client->dev.platform_data;
> -	struct input_dev *input_dev;
> -	int err;
> -
> -	if (!pdata) {
> -		dev_err(&client->dev, "platform data is required!\n");
> +	int err = 0;
> +	u32 val32;
> +	u64 val64;
> +
> +	if (!of_property_read_u32(np, "max-rt", &val32))
> +		ts->max_rt = val32;
> +	else
> +		ts->max_rt = MAX_12BIT;
> +
> +	if (!of_property_read_u32(np, "fuzzy", &val32))
> +		ts->fuzzy = val32;
> +
> +	if (!of_property_read_u64(np, "poll-period", &val64))
> +		ts->poll_period = val64;
> +	else
> +		ts->poll_period = 1;
> +
> +	if (!of_property_read_u32(np, "x-plate-ohms", &val32)) {
> +		ts->x_plate_ohms = val32;
> +	} else {
> +		dev_err(&client->dev,
> +			"x-plate-ohms is not set up in the devicetree."
> +			" (err %d).", err);
>
It's a bad habit to split messages like this, since it makes it harder
to grep the kernel source for a message in a logfile.

>  		return -EINVAL;
>  	}
>  
> -	if (!i2c_check_functionality(client->adapter,
> -				     I2C_FUNC_SMBUS_READ_WORD_DATA))
> -		return -EIO;
> +	ts->gpio = of_get_gpio(np, 0);
> +	if (!gpio_is_valid(ts->gpio))
> +		dev_err(&client->dev, "GPIO not found "
> +			"(of_get_gpio returned %d)\n", ts->gpio);
>  
dito (at least you should be consistent putting the space either in the
end of the first line or in the beginning of the next line!)

[...]
> @@ -309,13 +360,59 @@ static int tsc2007_probe(struct i2c_client *client,
>  	ts->poll_period       = pdata->poll_period ? : 1;
>  	ts->get_pendown_state = pdata->get_pendown_state;
>  	ts->clear_penirq      = pdata->clear_penirq;
> +	ts->fuzzy             = pdata->fuzzy;
>  
>  	if (pdata->x_plate_ohms == 0) {
>  		dev_err(&client->dev, "x_plate_ohms is not set up in platform data");
> -		err = -EINVAL;
> +		return -EINVAL;
> +	}
> +
> +	/* Used to detect if it is probed trough the device tree,
> +	 * in order to be able to use that information in the IRQ handler.
> +	 */
> +	ts->of = 0;
> +
> +	return 0;
> +}
> +
> +static int tsc2007_probe(struct i2c_client *client,
> +			 const struct i2c_device_id *id)
> +{
> +	struct device_node *np = client->dev.of_node;
> +	struct tsc2007_platform_data *pdata = client->dev.platform_data;
> +	struct tsc2007 *ts;
> +	struct input_dev *input_dev;
> +	int err = 0;
> +
> +	ts = kzalloc(sizeof(struct tsc2007), GFP_KERNEL);
>
devm_kzalloc()?

> @@ -389,10 +494,19 @@ static const struct i2c_device_id tsc2007_idtable[] = {
>  
>  MODULE_DEVICE_TABLE(i2c, tsc2007_idtable);
>  
> +#ifdef CONFIG_OF
> +static const struct of_device_id tsc2007_of_match[] = {
> +	{ .compatible = "ti,tsc2007" },
> +	{ /* sentinel */ },
>
the redundant comma after the last entry in a struct initializer is
useful to ease adding more entries lateron. Since the empty entry
always has to be the last one, the comma doesn't make any sense here.


Lothar Waßmann
-- 
___________________________________________________________

Ka-Ro electronics GmbH | Pascalstraße 22 | D - 52076 Aachen
Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10
Geschäftsführer: Matthias Kaussen
Handelsregistereintrag: Amtsgericht Aachen, HRB 4996

www.karo-electronics.de | info@karo-electronics.de
___________________________________________________________
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2013-10-18  8:36 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1382022155-21954-1-git-send-email-denis@eukrea.com>
2013-10-17 15:02 ` [Patch v2][ 04/37] [media] v4l2: add new V4L2_PIX_FMT_RGB666 pixel format Denis Carikli
2013-10-31 13:18   ` Mauro Carvalho Chehab
2013-10-31 14:06     ` Laurent Pinchart
2013-10-17 15:02 ` [Patch v2][ 05/37] fbdev: Add the lacking FB_SYNC_* for matching the DISPLAY_FLAGS_* Denis Carikli
2013-10-19 11:08   ` Jean-Christophe PLAGNIOL-VILLARD
2013-10-17 15:02 ` [Patch v2][ 13/37] staging: imx-drm: Add RGB666 support for parallel display Denis Carikli
2013-10-31 13:18   ` Mauro Carvalho Chehab
2013-10-17 15:02 ` [Patch v2][ 14/37] staging: imx-drm: parallel display: add regulator support Denis Carikli
2013-10-17 16:47   ` Dan Carpenter
2013-10-17 15:02 ` [Patch v2][ 15/37] Input: tsc2007: Add device tree support Denis Carikli
2013-10-18  8:36   ` Lothar Waßmann [this message]
     [not found] ` <1382022155-21954-1-git-send-email-denis-fO0SIAKYzcbQT0dZR+AlfA@public.gmane.org>
2013-10-17 15:01   ` [Patch v2][ 01/37] of: add vendor prefix for Eukréa Electromatique Denis Carikli
2013-10-17 15:02   ` [Patch v2][ 02/37] dma: ipu: Add devicetree support Denis Carikli
     [not found]     ` <1382022155-21954-3-git-send-email-denis-fO0SIAKYzcbQT0dZR+AlfA@public.gmane.org>
2013-10-18  6:42       ` Sascha Hauer
2013-10-17 15:02   ` [Patch v2][ 06/37] video: backlight: gpio-backlight: Add DT support Denis Carikli
2013-10-17 15:02   ` [Patch v2][ 08/37] video: mx3fb: Add device tree suport Denis Carikli
2013-10-19 11:04     ` Jean-Christophe PLAGNIOL-VILLARD
     [not found]       ` <20131019110459.GM18477-HVbc7XotTAhnXn40ka+A6Q@public.gmane.org>
2013-10-21  8:03         ` Sascha Hauer
2013-10-17 15:02   ` [Patch v2][ 10/37] video: imxfb: Also add pwmr for the device tree Denis Carikli
     [not found]     ` <1382022155-21954-11-git-send-email-denis-fO0SIAKYzcbQT0dZR+AlfA@public.gmane.org>
2013-10-19 10:57       ` Jean-Christophe PLAGNIOL-VILLARD
2013-10-17 15:02   ` [Patch v2][ 16/37] ASoC: eukrea-tlv320: Add DT support Denis Carikli
     [not found]     ` <1382022155-21954-17-git-send-email-denis-fO0SIAKYzcbQT0dZR+AlfA@public.gmane.org>
2013-10-18  9:19       ` Lothar Waßmann
2013-10-17 15:02   ` [Patch v2][ 17/37] DT: Add basic support for imx35-based devices Denis Carikli
     [not found]     ` <1382022155-21954-18-git-send-email-denis-fO0SIAKYzcbQT0dZR+AlfA@public.gmane.org>
2013-10-18  6:58       ` Sascha Hauer
2013-10-17 15:02   ` [Patch v2][ 18/37] ARM: imx{25,27} DT: Permit the selection of the imxfb framebuffer driver Denis Carikli
2013-10-17 15:02   ` [Patch v2][ 19/37] pinctrl: pinctrl-imx: add imx25 pinctrl driver Denis Carikli
2013-10-17 15:02   ` [Patch v2][ 20/37] arm/dts: imx25.dtsi: Add some pinmux pins Denis Carikli
     [not found]     ` <1382022155-21954-21-git-send-email-denis-fO0SIAKYzcbQT0dZR+AlfA@public.gmane.org>
2013-10-18  7:02       ` Sascha Hauer
2013-10-17 15:02   ` [Patch v2][ 21/37] arm/dts: i.MX25: Add ssi clocks and DMA events Denis Carikli
2013-10-17 15:02   ` [Patch v2][ 22/37] arm/dts: i.MX25: Add sdma script path Denis Carikli
2013-10-17 15:02   ` [Patch v2][ 23/37] arm/dts: imx25.dtsi: Add an alias for the Audio Multiplexer Denis Carikli
2013-10-17 15:02   ` [Patch v2][ 24/37] arm/dts: Add support for the cpuimx25 board from Eukrea and its baseboard Denis Carikli
2013-10-17 15:02   ` [Patch v2][ 25/37] arm/dts: imx51.dtsi: Add some pinmux pins Denis Carikli
2013-10-17 15:02   ` [Patch v2][ 26/37] arm/dts: Add support for the cpuimx51 board from Eukrea and its baseboard Denis Carikli
2013-10-17 15:02   ` [Patch v2][ 27/37] arm/dts: Add support for the cpuimx35 " Denis Carikli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20131018103611.4c6baabb@ipc1.ka-ro \
    --to=lw@karo-electronics.de \
    --cc=denis@eukrea.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=eric@eukrea.com \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-input@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=pawel.moll@arm.com \
    --cc=rob.herring@calxeda.com \
    --cc=swarren@wwwdotorg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).