devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Benjamin Tissoires <benjamin.tissoires@redhat.com>
To: Phil Reid <preid@electromag.com.au>
Cc: Wolfram Sang <wsa@the-dreams.de>,
	robh+dt@kernel.org, mark.rutland@arm.com, sre@kernel.org,
	jdelvare@suse.com, jglauber@cavium.com, david.daney@cavium.com,
	peda@axentia.se, linux-i2c@vger.kernel.org,
	devicetree@vger.kernel.org, linux-pm@vger.kernel.org
Subject: Re: [PATCH v7 05/10] i2c: core: call of_i2c_setup_smbus_alert in i2c_register_adapter
Date: Wed, 28 Jun 2017 14:45:49 +0200	[thread overview]
Message-ID: <20170628124549.GF26073@mail.corp.redhat.com> (raw)
In-Reply-To: <367a1a1d-afdb-8895-8216-ae3c18e16fc8@electromag.com.au>

On Jun 28 2017 or thereabouts, Phil Reid wrote:
> On 23/06/2017 20:19, Benjamin Tissoires wrote:
> > On Jun 19 2017 or thereabouts, Wolfram Sang wrote:
> > > On Thu, Jun 15, 2017 at 09:59:33PM +0800, Phil Reid wrote:
> > > > Add a call to of_i2c_setup_smbus_alert when a i2c adapter is registered
> > > > so the the smbalert driver can be registered.
> > > > 
> > > > Signed-off-by: Phil Reid <preid@electromag.com.au>
> > > 
> > > CCing Benjamin
> > > 
> > > > ---
> > > >   drivers/i2c/i2c-core.c | 4 ++++
> > > >   1 file changed, 4 insertions(+)
> > > > 
> > > > diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
> > > > index d2402bb..626471b 100644
> > > > --- a/drivers/i2c/i2c-core.c
> > > > +++ b/drivers/i2c/i2c-core.c
> > > > @@ -40,6 +40,7 @@
> > > >   #include <linux/gpio.h>
> > > >   #include <linux/hardirq.h>
> > > >   #include <linux/i2c.h>
> > > > +#include <linux/i2c-smbus.h>
> > > >   #include <linux/idr.h>
> > > >   #include <linux/init.h>
> > > >   #include <linux/irqflags.h>
> > > > @@ -2045,6 +2046,9 @@ static int i2c_register_adapter(struct i2c_adapter *adap)
> > > >   		dev_warn(&adap->dev,
> > > >   			 "Failed to create compatibility class link\n");
> > > >   #endif
> > > > +	res = of_i2c_setup_smbus_alert(adap);
> > > > +	if (res)
> > > > +		goto out_list;
> > 
> > See my concerns in patch 4/10.
> > 
> > In addition, shouldn't this be placed before device_register() for the
> > least? pm_runtime_enable() would require a matching pm_runtime_disable(),
> > and device_register() some unregistering behavior too.
> > 
> 
> G'day Ben,
> 
> Thanks for the review.
> Yes this makes sense. I tried having it before the device_register and I get an error
> about a kobject not being initialised in the a call from of_i2c_setup_smbus_alert.
> 
> Having a look at what I'm doing in of_i2c_setup_smbus_alert now I'm not sure there's
> a need to bail out on an error now. Originally I was registering the irq in the setup call.
> Which need to handle probe defer. Now this should be handled in the alert probe call.
> 
> WDYR?

Well, of_i2c_setup_smbus_alert() returns an error code, so it has to be
accounted for. If the error is not a reason to fail, you should at least
shout some error messages and act accordingly.

However, looking at of_i2c_setup_smbus_alert() again, I wonder if we
should not split it in 2: one part that checks for the OF flag presence
and bail out early if an error is encountered (before device
registration), and one part once the device is registered that calls
i2c_setup_smbus_alert(). In case of a failure here, we need to
unregister the adapter because we don't have all the elements at hands
(assuming we consider that smbus-alert should be mandatory).

Cheers,
Benjamin

  reply	other threads:[~2017-06-28 12:45 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-15 13:59 [PATCH v7 00/10] Add sbs-manager with smbalert support Phil Reid
2017-06-15 13:59 ` [PATCH v7 01/10] power: supply: sbs-battery: remove incorrect le16_to_cpu calls Phil Reid
     [not found]   ` <1497535178-12001-2-git-send-email-preid-qgqNFa1JUf/o2iN0hyhwsIdd74u8MsAO@public.gmane.org>
2017-06-15 14:49     ` Sebastian Reichel
2017-06-15 13:59 ` [PATCH v7 02/10] power: supply: bq24735: " Phil Reid
     [not found]   ` <1497535178-12001-3-git-send-email-preid-qgqNFa1JUf/o2iN0hyhwsIdd74u8MsAO@public.gmane.org>
2017-06-15 14:50     ` Sebastian Reichel
2017-06-15 13:59 ` [PATCH v7 03/10] i2c: i2c-smbus: Use threaded irq for smbalert Phil Reid
2017-06-19 15:27   ` Wolfram Sang
2017-06-20  2:30     ` Phil Reid
2017-06-23 12:11     ` Benjamin Tissoires
2017-06-15 13:59 ` [PATCH v7 04/10] i2c: i2c-smbus: add of_i2c_setup_smbus_alert Phil Reid
     [not found]   ` <1497535178-12001-5-git-send-email-preid-qgqNFa1JUf/o2iN0hyhwsIdd74u8MsAO@public.gmane.org>
2017-06-19 15:27     ` Wolfram Sang
2017-06-23 12:15       ` Benjamin Tissoires
2017-06-28  6:48         ` Phil Reid
2017-06-28 12:42           ` Benjamin Tissoires
2017-06-15 13:59 ` [PATCH v7 05/10] i2c: core: call of_i2c_setup_smbus_alert in i2c_register_adapter Phil Reid
2017-06-19 15:28   ` Wolfram Sang
2017-06-23 12:19     ` Benjamin Tissoires
2017-06-28  6:44       ` Phil Reid
2017-06-28 12:45         ` Benjamin Tissoires [this message]
2017-07-11  7:52           ` Phil Reid
2017-07-21  9:24             ` Benjamin Tissoires
     [not found]               ` <20170721092431.GA11387-/m+UfqrgI5QNLKR9yMNcA1aTQe2KTcn/@public.gmane.org>
2017-07-24  7:38                 ` Phil Reid
2017-06-15 13:59 ` [PATCH v7 06/10] i2c: mux: pca954x: Call request irq after adding mux segments Phil Reid
2017-06-15 13:59 ` [PATCH v7 07/10] Documentation: Add sbs-manager device tree node documentation Phil Reid
2017-07-03 13:57   ` Sebastian Reichel
2017-06-15 13:59 ` [PATCH v7 08/10] power: Adds support for Smart Battery System Manager Phil Reid
     [not found]   ` <1497535178-12001-9-git-send-email-preid-qgqNFa1JUf/o2iN0hyhwsIdd74u8MsAO@public.gmane.org>
2017-07-03 15:17     ` Sebastian Reichel
2017-06-15 13:59 ` [PATCH v7 09/10] power: supply: sbs-manager: Add alert callback and battery change notification Phil Reid
2017-06-15 13:59 ` [PATCH v7 10/10] power: supply: sbs-battery: move gpio present detect to sbs_get_property Phil Reid
2017-07-03 15:21   ` Sebastian Reichel

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=20170628124549.GF26073@mail.corp.redhat.com \
    --to=benjamin.tissoires@redhat.com \
    --cc=david.daney@cavium.com \
    --cc=devicetree@vger.kernel.org \
    --cc=jdelvare@suse.com \
    --cc=jglauber@cavium.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=peda@axentia.se \
    --cc=preid@electromag.com.au \
    --cc=robh+dt@kernel.org \
    --cc=sre@kernel.org \
    --cc=wsa@the-dreams.de \
    /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).