devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Mack <daniel@zonque.org>
To: Matt Ranostay <mranostay@gmail.com>,
	galak@codeaurora.org, linux-input@vger.kernel.org,
	linux-kernel@vger.kernel.org, dmitry.torokhov@gmail.com,
	robh+dt@kernel.org
Cc: devicetree@vger.kernel.org
Subject: Re: [PATCH 1/3] cap1106: Add support for various cap11xx devices
Date: Sun, 21 Sep 2014 12:53:33 +0200	[thread overview]
Message-ID: <541EAE2D.2080700@zonque.org> (raw)
In-Reply-To: <1411268469-21283-2-git-send-email-mranostay@gmail.com>

Hi,

On 09/21/2014 05:01 AM, Matt Ranostay wrote:
>  	priv->regmap = devm_regmap_init_i2c(i2c_client, &cap1106_regmap_config);
>  	if (IS_ERR(priv->regmap))
>  		return PTR_ERR(priv->regmap);
>  
> -	error = regmap_read(priv->regmap, CAP1106_REG_PRODUCT_ID, &val);
> -	if (error)
> -		return error;
> -
> -	if (val != CAP1106_PRODUCT_ID) {
> -		dev_err(dev, "Product ID: Got 0x%02x, expected 0x%02x\n",
> -			val, CAP1106_PRODUCT_ID);
> -		return -ENODEV;
> -	}
> -

Btw - the purpose of this code was to detect board configuration
mismatch. After all, I2C lacks a way to properly identify peripherals,
so the more runtime checks we do at probe time, the more of a chance we
have to detect wrong setups. This device is actually well implemented
and tells us something about itself.

Hence, I'd propose to define a structure like this:

struct cap11xx_hw_model {
	uint8_t product_id;
	unsigned int num_channels;
};

... and attach instances of that to the members of cap1106_dt_ids[] and
cap1106_i2c_ids[]. In the probe function, check that the contents of
CAP1106_PRODUCT_ID match what is expected by the configured model.


Thanks,
Daniel

  parent reply	other threads:[~2014-09-21 10:53 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-21  3:01 [PATCH 0/3] cap1106: add support for cap11xx variants Matt Ranostay
2014-09-21  3:01 ` [PATCH 1/3] cap1106: Add support for various cap11xx devices Matt Ranostay
2014-09-21  9:58   ` Daniel Mack
     [not found]     ` <541EA149.5000408-cYrQPVfZoowdnm+yROfE0A@public.gmane.org>
2014-09-21 22:46       ` Matt Ranostay
2014-09-22  7:36         ` Daniel Mack
2014-09-22  0:28     ` Matt Ranostay
2014-09-22  5:59       ` Dmitry Torokhov
2014-09-21 10:53   ` Daniel Mack [this message]
2014-09-21  3:01 ` [PATCH 2/3] cap1106: support for active-high interrupt option Matt Ranostay
2014-09-21 10:06   ` Daniel Mack
2014-09-22  5:56     ` Dmitry Torokhov
2014-09-22  7:44       ` Daniel Mack
2014-09-21  3:01 ` [PATCH 3/3] dt: cap1106 active-high property addition Matt Ranostay

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=541EAE2D.2080700@zonque.org \
    --to=daniel@zonque.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=galak@codeaurora.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mranostay@gmail.com \
    --cc=robh+dt@kernel.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).