Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1509498 > unrolled thread
| Started by | Antoine Tenart <antoine.tenart@free-electrons.com> |
|---|---|
| First post | 2016-10-26 17:00 +0200 |
| Last post | 2016-10-26 19:40 +0200 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[RFC PATCH 4/5] w1: add a callback to call slave when a new device is connected Antoine Tenart <antoine.tenart@free-electrons.com> - 2016-10-26 17:00 +0200
Re: [RFC PATCH 4/5] w1: add a callback to call slave when a new device is connected Mathieu Poirier <mathieu.poirier@linaro.org> - 2016-10-26 18:50 +0200
Re: [RFC PATCH 4/5] w1: add a callback to call slave when a new device is connected Antoine Tenart <antoine.tenart@free-electrons.com> - 2016-10-26 19:40 +0200
| From | Antoine Tenart <antoine.tenart@free-electrons.com> |
|---|---|
| Date | 2016-10-26 17:00 +0200 |
| Subject | [RFC PATCH 4/5] w1: add a callback to call slave when a new device is connected |
| Message-ID | <swxQl-57S-3@gated-at.bofh.it> |
This patch adds the possibility for slave drivers to register a
callback, to be called whenever a new device matching the slave ID
is connected.
Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
---
drivers/w1/w1.c | 10 ++++++++++
drivers/w1/w1_family.h | 2 ++
2 files changed, 12 insertions(+)
diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index 80d0cc4e6e7f..7010ffd1ea93 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -659,6 +659,16 @@ static int w1_family_notify(unsigned long action, struct w1_slave *sl)
return err;
}
}
+ if (fops->callback) {
+ err = fops->callback(sl);
+ /*
+ * Do not return an error as the slave driver correctly
+ * probed.
+ */
+ if (err)
+ dev_err(&sl->dev,
+ "callback call failed. err=%d\n", err);
+ }
break;
case BUS_NOTIFY_DEL_DEVICE:
diff --git a/drivers/w1/w1_family.h b/drivers/w1/w1_family.h
index 10a7a0767187..5e165babc6f3 100644
--- a/drivers/w1/w1_family.h
+++ b/drivers/w1/w1_family.h
@@ -55,11 +55,13 @@ struct w1_slave;
* @add_slave: add_slave
* @remove_slave: remove_slave
* @groups: sysfs group
+ * @callback: called when a new device is discovered
*/
struct w1_family_ops
{
int (* add_slave)(struct w1_slave *);
void (* remove_slave)(struct w1_slave *);
+ int (* callback)(struct w1_slave *);
const struct attribute_group **groups;
};
--
2.10.1
[toc] | [next] | [standalone]
| From | Mathieu Poirier <mathieu.poirier@linaro.org> |
|---|---|
| Date | 2016-10-26 18:50 +0200 |
| Subject | Re: [RFC PATCH 4/5] w1: add a callback to call slave when a new device is connected |
| Message-ID | <swzyO-6qe-23@gated-at.bofh.it> |
| In reply to | #1509498 |
On 26 October 2016 at 08:57, Antoine Tenart
<antoine.tenart@free-electrons.com> wrote:
> This patch adds the possibility for slave drivers to register a
> callback, to be called whenever a new device matching the slave ID
> is connected.
>
> Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
> ---
> drivers/w1/w1.c | 10 ++++++++++
> drivers/w1/w1_family.h | 2 ++
> 2 files changed, 12 insertions(+)
>
> diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
> index 80d0cc4e6e7f..7010ffd1ea93 100644
> --- a/drivers/w1/w1.c
> +++ b/drivers/w1/w1.c
> @@ -659,6 +659,16 @@ static int w1_family_notify(unsigned long action, struct w1_slave *sl)
> return err;
> }
> }
> + if (fops->callback) {
> + err = fops->callback(sl);
> + /*
> + * Do not return an error as the slave driver correctly
> + * probed.
> + */
I don't get this part. What's the point of calling a callback if a
failure is not important - maybe I'm just missing something.
> + if (err)
> + dev_err(&sl->dev,
> + "callback call failed. err=%d\n", err);
> + }
>
> break;
> case BUS_NOTIFY_DEL_DEVICE:
> diff --git a/drivers/w1/w1_family.h b/drivers/w1/w1_family.h
> index 10a7a0767187..5e165babc6f3 100644
> --- a/drivers/w1/w1_family.h
> +++ b/drivers/w1/w1_family.h
> @@ -55,11 +55,13 @@ struct w1_slave;
> * @add_slave: add_slave
> * @remove_slave: remove_slave
> * @groups: sysfs group
> + * @callback: called when a new device is discovered
> */
> struct w1_family_ops
> {
> int (* add_slave)(struct w1_slave *);
> void (* remove_slave)(struct w1_slave *);
> + int (* callback)(struct w1_slave *);
> const struct attribute_group **groups;
> };
>
> --
> 2.10.1
>
[toc] | [prev] | [next] | [standalone]
| From | Antoine Tenart <antoine.tenart@free-electrons.com> |
|---|---|
| Date | 2016-10-26 19:40 +0200 |
| Subject | Re: [RFC PATCH 4/5] w1: add a callback to call slave when a new device is connected |
| Message-ID | <swAlc-6WH-25@gated-at.bofh.it> |
| In reply to | #1509597 |
[Multipart message — attachments visible in raw view] — view raw
Hello Mathieu,
On Wed, Oct 26, 2016 at 10:42:28AM -0600, Mathieu Poirier wrote:
> On 26 October 2016 at 08:57, Antoine Tenart
> <antoine.tenart@free-electrons.com> wrote:
> > }
> > + if (fops->callback) {
> > + err = fops->callback(sl);
> > + /*
> > + * Do not return an error as the slave driver correctly
> > + * probed.
> > + */
>
> I don't get this part. What's the point of calling a callback if a
> failure is not important - maybe I'm just missing something.
>
> > + if (err)
> > + dev_err(&sl->dev,
> > + "callback call failed. err=%d\n", err);
> > + }
In our case it can be not that important: if we fail to apply an
overlay, we can still use the w1 interfaces to access the eeprom.
Anyway, all those errors weren't taken into account by the w1 framework
before (see my other patch). Also, the w1 patches are given for the
example and could be improved. Part of the reason is the w1 framework
itself :-)
Antoine
--
Antoine Ténart, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web