Linux-RTC Archive on lore.kernel.org
 help / color / Atom feed
From: Trent Piepho <tpiepho@impinj.com>
To: "alexandre.belloni@bootlin.com" <alexandre.belloni@bootlin.com>
Cc: "linux-rtc@vger.kernel.org" <linux-rtc@vger.kernel.org>,
	"a.zummo@towertech.it" <a.zummo@towertech.it>
Subject: Re: [PATCH 2/3] rtc: isl1208: Support more chip variations
Date: Tue, 12 Feb 2019 01:30:50 +0000
Message-ID: <1549935049.3075.118.camel@impinj.com> (raw)
In-Reply-To: <20190210211239.GH23062@piout.net>

On Sun, 2019-02-10 at 22:12 +0100, Alexandre Belloni wrote:
> +};
> > +MODULE_DEVICE_TABLE(i2c, isl1208_id);
> > +
> > +static const struct of_device_id isl1208_of_match[] = {
> > +	{ .compatible = "isil,isl1208", .data = &isl1208_configs[TYPE_ISL1208] },
> > +	{ .compatible = "isil,isl1209", .data = &isl1208_configs[TYPE_ISL1209] },
> 
> This compatible needs to be documented.

I see isil,isl1219 escaped documentation when it was added too.  I'll
add both to rtc.txt.

> >  
> >  	return handled ? IRQ_HANDLED : IRQ_NONE;
> > @@ -743,6 +778,19 @@ isl1208_probe(struct i2c_client *client, const struct i2c_device_id *id)
> >  		return -ENOMEM;
> >  	i2c_set_clientdata(client, isl1208);
> >  
> > +	/* Determine which chip we have */
> > +	if (client->dev.of_node) {
> > +		const struct of_device_id *match =
> > +			of_match_node(isl1208_of_match, client->dev.of_node);
> > +		if (!match)
> 
> This will never happen, else the driver would not be probed.

If there was a driver_override ability with i2c, like PCI and SPI, then
it would be possible.

> 
> > +			return -EINVAL;
> > +		isl1208->config = match->data;
> 
> Maybe you should use of_device_get_match_data anyway.

Yes, of_device_get_match_data() would be better.  Not sure why I didn't
find that.

Interestingly, I see could have just depended on id->driver_data being
set even in the OF case, as the i2c-core code always sets it.  But it
look to be deprecated and i2c clients should provide a probe_new method
that does not provide an i2c_device_id.  I'm not sure if that's
entirely better, as every i2c client that cares will need to re-
implement the code to look up by device name and/or OF node and/or
ACPI.

> 
> > +	} else {
> > +		if (id->driver_data >= ISL_LAST_ID)
> > +			return -EINVAL;
> 
> This should be -ENODEV.

There's quite a few drivers that return EINVAL when the driver_data
appears to be incorrect.  But some also return ENODEV.

  reply index

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-01 19:42 [PATCH 1/3] rtc: isl1208: Introduce driver state struct Trent Piepho
2019-02-01 19:42 ` [PATCH 2/3] rtc: isl1208: Support more chip variations Trent Piepho
2019-02-10 21:12   ` Alexandre Belloni
2019-02-12  1:30     ` Trent Piepho [this message]
2019-02-01 19:42 ` [PATCH 3/3] rtc: isl1208: Add new style nvmem support to driver Trent Piepho

Reply instructions:

You may reply publically 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=1549935049.3075.118.camel@impinj.com \
    --to=tpiepho@impinj.com \
    --cc=a.zummo@towertech.it \
    --cc=alexandre.belloni@bootlin.com \
    --cc=linux-rtc@vger.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

Linux-RTC Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-rtc/0 linux-rtc/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-rtc linux-rtc/ https://lore.kernel.org/linux-rtc \
		linux-rtc@vger.kernel.org linux-rtc@archiver.kernel.org
	public-inbox-index linux-rtc


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-rtc


AGPL code for this site: git clone https://public-inbox.org/ public-inbox