From: Luis Oliveira <Luis.Oliveira@synopsys.com>
To: Rob Herring <robh+dt@kernel.org>,
Luis Oliveira <Luis.Oliveira@synopsys.com>
Cc: "wsa@the-dreams.de" <wsa@the-dreams.de>,
Mark Rutland <mark.rutland@arm.com>,
"jarkko.nikula@linux.intel.com" <jarkko.nikula@linux.intel.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
"mika.westerberg@linux.intel.com"
<mika.westerberg@linux.intel.com>,
"linux-i2c@vger.kernel.org" <linux-i2c@vger.kernel.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
roliveir <Ramiro.Oliveira@synopsys.com>,
Joao Pinto <Joao.Pinto@synopsys.com>,
<CARLOS.PALMINHA@synopsys.com>
Subject: Re: [PATCH] i2c: core: helper function to detect slave mode
Date: Fri, 6 Jan 2017 17:12:58 +0000 [thread overview]
Message-ID: <1d8b201c-142b-cf88-6965-55aeaaff4dfa@synopsys.com> (raw)
In-Reply-To: <CAL_JsqK1=R6M=vrW5aqmQtMHUGGws_Hb=VHb9RNcvesjfkCjRA@mail.gmail.com>
On 06-Jan-17 16:35, Rob Herring wrote:
> On Thu, Jan 5, 2017 at 11:24 AM, Luis Oliveira
> <Luis.Oliveira@synopsys.com> wrote:
>> This function has the purpose of mode detection by checking the
>> device nodes for a reg matching with the I2C_OWN_SLAVE_ADDREESS flag.
>> Currently only checks using OF functions (ACPI slave not supported yet).
>>
>> Signed-off-by: Luis Oliveira <lolivei@synopsys.com>
>> ---
>> Due to the need of checking if the I2C slave address is our own (in
>> other words: if we are the I2C slave) I created a helper function
>> (proposed to me by @Andy) to enable that check.
>> Currently (because I am not able to test it using ACPI) it only
>> supports devicetree declarations.
>>
>> drivers/i2c/i2c-core.c | 19 +++++++++++++++++++
>> include/linux/i2c.h | 1 +
>> 2 files changed, 20 insertions(+)
>>
>> diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
>> index 3de95a29024c..48e705b23c59 100644
>> --- a/drivers/i2c/i2c-core.c
>> +++ b/drivers/i2c/i2c-core.c
>> @@ -3691,6 +3691,25 @@ int i2c_slave_unregister(struct i2c_client *client)
>> return ret;
>> }
>> EXPORT_SYMBOL_GPL(i2c_slave_unregister);
>> +
>> +int i2c_slave_mode_detect(struct device *dev)
>
> This can be bool instead. Otherwise, looks good to me.
>
Ok great, thank you.
>> +{
>> + struct device_node *child;
>> + u32 reg;
>> +
>> + if (IS_BUILTIN(CONFIG_OF) && dev->of_node) {
>> + for_each_child_of_node(dev->of_node, child) {
>> + of_property_read_u32(child, "reg", ®);
>> + if (reg & I2C_OWN_SLAVE_ADDRESS)
>> + return 1;
>> + }
>> + } else if (IS_BUILTIN(CONFIG_ACPI) && ACPI_HANDLE(dev)) {
>> + dev_dbg(dev, "ACPI slave is not supported yet\n");
>> + }
>> + return 0;
>> +}
>> +EXPORT_SYMBOL_GPL(i2c_slave_mode_detect);
>> +
>> #endif
>>
>> MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>");
>> diff --git a/include/linux/i2c.h b/include/linux/i2c.h
>> index b2109c522dec..53cf99569af5 100644
>> --- a/include/linux/i2c.h
>> +++ b/include/linux/i2c.h
>> @@ -282,6 +282,7 @@ enum i2c_slave_event {
>>
>> extern int i2c_slave_register(struct i2c_client *client, i2c_slave_cb_t slave_cb);
>> extern int i2c_slave_unregister(struct i2c_client *client);
>> +extern int i2c_slave_mode_detect(struct device *dev);
>>
>> static inline int i2c_slave_event(struct i2c_client *client,
>> enum i2c_slave_event event, u8 *val)
>> --
>> 2.11.0
>>
>>
next prev parent reply other threads:[~2017-01-06 17:13 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-05 17:24 Luis Oliveira
2017-01-06 16:29 ` Andy Shevchenko
2017-01-06 17:15 ` Luis Oliveira
2017-01-06 17:17 ` Andy Shevchenko
2017-01-06 17:46 ` Luis Oliveira
2017-01-06 21:32 ` Andy Shevchenko
2017-01-06 16:35 ` Rob Herring
2017-01-06 17:12 ` Luis Oliveira [this message]
2017-01-06 21:46 ` Vladimir Zapolskiy
2017-01-06 22:45 ` Andy Shevchenko
2017-01-06 23:43 ` Vladimir Zapolskiy
2017-01-07 0:19 ` Andy Shevchenko
2017-01-07 1:24 ` Vladimir Zapolskiy
2017-01-12 17:01 ` Andy Shevchenko
2017-01-16 10:32 ` Luis Oliveira
2017-01-16 23:14 ` Vladimir Zapolskiy
2017-01-18 10:59 ` Andy Shevchenko
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=1d8b201c-142b-cf88-6965-55aeaaff4dfa@synopsys.com \
--to=luis.oliveira@synopsys.com \
--cc=CARLOS.PALMINHA@synopsys.com \
--cc=Joao.Pinto@synopsys.com \
--cc=Ramiro.Oliveira@synopsys.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=devicetree@vger.kernel.org \
--cc=jarkko.nikula@linux.intel.com \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mika.westerberg@linux.intel.com \
--cc=robh+dt@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
Powered by JetHome