From: Benjamin Tissoires <benjamin.tissoires@redhat.com>
To: Wolfram Sang <wsa@the-dreams.de>
Cc: Phil Reid <preid@electromag.com.au>,
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 04/10] i2c: i2c-smbus: add of_i2c_setup_smbus_alert
Date: Fri, 23 Jun 2017 14:15:52 +0200 [thread overview]
Message-ID: <20170623121552.GM26073@mail.corp.redhat.com> (raw)
In-Reply-To: <20170619152744.4gtlyrwdhjbhy562@ninjato>
On Jun 19 2017 or thereabouts, Wolfram Sang wrote:
> On Thu, Jun 15, 2017 at 09:59:32PM +0800, Phil Reid wrote:
> > This commit adds of_i2c_setup_smbus_alert which allows the smbalert
> > driver to be attached to an i2c adapter via the device tree.
> >
> > Signed-off-by: Phil Reid <preid@electromag.com.au>
> > Acked-by: Rob Herring <robh@kernel.org>
>
> CCing Benjamin
>
> > ---
> > Documentation/devicetree/bindings/i2c/i2c.txt | 4 ++--
> > drivers/i2c/i2c-smbus.c | 34 ++++++++++++++++++++++++---
> > include/linux/i2c-smbus.h | 9 +++++++
> > 3 files changed, 42 insertions(+), 5 deletions(-)
> >
> > diff --git a/Documentation/devicetree/bindings/i2c/i2c.txt b/Documentation/devicetree/bindings/i2c/i2c.txt
> > index cee9d50..1126398 100644
> > --- a/Documentation/devicetree/bindings/i2c/i2c.txt
> > +++ b/Documentation/devicetree/bindings/i2c/i2c.txt
> > @@ -59,8 +59,8 @@ wants to support one of the below features, it should adapt the bindings below.
> > interrupts used by the device.
> >
> > - interrupt-names
> > - "irq" and "wakeup" names are recognized by I2C core, other names are
> > - left to individual drivers.
> > + "irq", "wakeup" and "smbus_alert" names are recognized by I2C core,
> > + other names are left to individual drivers.
> >
> > - host-notify
> > device uses SMBus host notify protocol instead of interrupt line.
> > diff --git a/drivers/i2c/i2c-smbus.c b/drivers/i2c/i2c-smbus.c
> > index d4af270..0ad7f7f 100644
> > --- a/drivers/i2c/i2c-smbus.c
> > +++ b/drivers/i2c/i2c-smbus.c
> > @@ -21,6 +21,7 @@
> > #include <linux/interrupt.h>
> > #include <linux/kernel.h>
> > #include <linux/module.h>
> > +#include <linux/of_irq.h>
> > #include <linux/slab.h>
> > #include <linux/workqueue.h>
> >
> > @@ -131,7 +132,7 @@ static int smbalert_probe(struct i2c_client *ara,
> > {
> > struct i2c_smbus_alert_setup *setup = dev_get_platdata(&ara->dev);
> > struct i2c_smbus_alert *alert;
> > - struct i2c_adapter *adapter = ara->adapter;
> > + struct i2c_adapter *adap = ara->adapter;
I am not a big fan of this rename (even for consistency with the rest of
the file). It makes the patch bigger of 2 hunks for nothing :/
(Wolfram might have a different opinion)
> > int res, irq;
> >
> > alert = devm_kzalloc(&ara->dev, sizeof(struct i2c_smbus_alert),
> > @@ -139,7 +140,14 @@ static int smbalert_probe(struct i2c_client *ara,
> > if (!alert)
> > return -ENOMEM;
> >
> > - irq = setup->irq;
> > + if (setup) {
> > + irq = setup->irq;
> > + } else {
> > + irq = of_irq_get_byname(adap->dev.of_node, "smbus_alert");
> > + if (irq <= 0)
> > + return irq;
> > + }
> > +
> > INIT_WORK(&alert->alert, smbalert_work);
> > alert->ara = ara;
> >
> > @@ -153,7 +161,7 @@ static int smbalert_probe(struct i2c_client *ara,
> > }
> >
> > i2c_set_clientdata(ara, alert);
> > - dev_info(&adapter->dev, "supports SMBALERT#\n");
> > + dev_info(&adap->dev, "supports SMBALERT#\n");
> >
> > return 0;
> > }
> > @@ -214,6 +222,26 @@ struct i2c_client *i2c_setup_smbus_alert(struct i2c_adapter *adapter,
> > }
> > EXPORT_SYMBOL_GPL(i2c_setup_smbus_alert);
> >
> > +int of_i2c_setup_smbus_alert(struct i2c_adapter *adap)
> > +{
> > + struct i2c_client *client;
> > + int irq;
> > +
> > + irq = of_property_match_string(adap->dev.of_node, "interrupt-names",
> > + "smbus_alert");
> > + if (irq == -EINVAL || irq == -ENODATA)
> > + return 0;
> > + else if (irq < 0)
> > + return irq;
> > +
> > + client = i2c_setup_smbus_alert(adap, NULL);
> > + if (!client)
> > + return -ENODEV;
> > +
> > + return 0;
> > +}
> > +EXPORT_SYMBOL_GPL(of_i2c_setup_smbus_alert);
> > +
> > /**
> > * i2c_handle_smbus_alert - Handle an SMBus alert
> > * @ara: the ARA client on the relevant adapter
> > diff --git a/include/linux/i2c-smbus.h b/include/linux/i2c-smbus.h
> > index 19efbd1..b5261c1 100644
> > --- a/include/linux/i2c-smbus.h
> > +++ b/include/linux/i2c-smbus.h
> > @@ -49,4 +49,13 @@ struct i2c_client *i2c_setup_smbus_alert(struct i2c_adapter *adapter,
> > struct i2c_smbus_alert_setup *setup);
> > int i2c_handle_smbus_alert(struct i2c_client *ara);
> >
> > +#if IS_ENABLED(CONFIG_I2C_SMBUS)
Can't we have:
#if IS_ENABLED(CONFIG_I2C_SMBUS) && IS_ENABLED(*whatever OF config symbol is*)
Because otherwise, even if the code works from what I understand, we
will pull in i2c-smbus from i2c-core all the time.
Besides those nitpicks, the patch is OK IMO.
Cheers,
Benjamin
> > +int of_i2c_setup_smbus_alert(struct i2c_adapter *adap);
> > +#else
> > +static inline int of_i2c_setup_smbus_alert(struct i2c_adapter *adap)
> > +{
> > + return 0;
> > +}
> > +#endif
> > +
> > #endif /* _LINUX_I2C_SMBUS_H */
> > --
> > 1.8.3.1
> >
next prev parent reply other threads:[~2017-06-23 12:15 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 [this message]
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
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=20170623121552.GM26073@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).