mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] w1: Fix slave count on 1-Wire bus (resend)
@ 2017-05-30 18:04 Alex A. Mihaylov
       [not found] ` <566761497080616@web49g.yandex.ru>
  0 siblings, 1 reply; 3+ messages in thread
From: Alex A. Mihaylov @ 2017-05-30 18:04 UTC (permalink / raw)
  To: Evgeniy Polyakov, linux-kernel; +Cc: Alex A. Mihaylov

1-Wire bus have very fast algorith for exchange with single slave
device. Fix incorrect count of slave devices on connect second slave
device. This case on slave device probe() step we need use generic
(multislave) functions for read/write device.

Signed-off-by: Alex A. Mihaylov <minimumlaw@rambler.ru>
---
 drivers/w1/w1.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index 90a3d93..5b8b976 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -731,6 +731,7 @@ int w1_attach_slave_device(struct w1_master *dev, struct w1_reg_num *rn)
 	memcpy(&sl->reg_num, rn, sizeof(sl->reg_num));
 	atomic_set(&sl->refcnt, 1);
 	atomic_inc(&sl->master->refcnt);
+	dev->slave_count++;
 
 	/* slave modules need to be loaded in a context with unlocked mutex */
 	mutex_unlock(&dev->mutex);
@@ -750,11 +751,11 @@ int w1_attach_slave_device(struct w1_master *dev, struct w1_reg_num *rn)
 
 	sl->family = f;
 
-
 	err = __w1_attach_slave_device(sl);
 	if (err < 0) {
 		dev_err(&dev->dev, "%s: Attaching %s failed.\n", __func__,
 			 sl->name);
+		dev->slave_count--;
 		w1_family_put(sl->family);
 		atomic_dec(&sl->master->refcnt);
 		kfree(sl);
@@ -762,7 +763,6 @@ int w1_attach_slave_device(struct w1_master *dev, struct w1_reg_num *rn)
 	}
 
 	sl->ttl = dev->slave_ttl;
-	dev->slave_count++;
 
 	memcpy(msg.id.id, rn, sizeof(msg.id));
 	msg.type = W1_SLAVE_ADD;
-- 
2.8.4 (Apple Git-73)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] w1: Fix slave count on 1-Wire bus (resend)
       [not found] ` <566761497080616@web49g.yandex.ru>
@ 2017-06-13  7:18   ` Greg Kroah-Hartman
  2017-06-13 15:57     ` Alex A. Mihaylov
  0 siblings, 1 reply; 3+ messages in thread
From: Greg Kroah-Hartman @ 2017-06-13  7:18 UTC (permalink / raw)
  To: Evgeniy Polyakov; +Cc: Alex A. Mihaylov, linux-kernel

On Sat, Jun 10, 2017 at 10:43:36AM +0300, Evgeniy Polyakov wrote:
> Hi
> 
> 30.05.2017, 21:04, "Alex A. Mihaylov" <minimumlaw@rambler.ru>:
> > 1-Wire bus have very fast algorith for exchange with single slave
> > device. Fix incorrect count of slave devices on connect second slave
> > device. This case on slave device probe() step we need use generic
> > (multislave) functions for read/write device.
> >
> > Signed-off-by: Alex A. Mihaylov <minimumlaw@rambler.ru>
> 
> Thank you.
> 
> Greg, please pull this into your tree, it is a bugfix and probably should go quicker path
> 
> Acked-by: Evgeniy Polyakov <zbr@ioremap.net>

I can't find the original version of this.  Alex, can you please resend
it to me, with Evgeniy's ack on it?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] w1: Fix slave count on 1-Wire bus (resend)
  2017-06-13  7:18   ` Greg Kroah-Hartman
@ 2017-06-13 15:57     ` Alex A. Mihaylov
  0 siblings, 0 replies; 3+ messages in thread
From: Alex A. Mihaylov @ 2017-06-13 15:57 UTC (permalink / raw)
  To: Evgeniy Polyakov, Greg Kroah-Hartman, linux-kernel; +Cc: Alex A. Mihaylov

1-Wire bus have very fast algorith for exchange with single slave
device. Fix incorrect count of slave devices on connect second slave
device. This case on slave device probe() step we need use generic
(multislave) functions for read/write device.

Signed-off-by: Alex A. Mihaylov <minimumlaw@rambler.ru>
---
 drivers/w1/w1.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index 90a3d93..5b8b976 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -731,6 +731,7 @@ int w1_attach_slave_device(struct w1_master *dev, struct w1_reg_num *rn)
 	memcpy(&sl->reg_num, rn, sizeof(sl->reg_num));
 	atomic_set(&sl->refcnt, 1);
 	atomic_inc(&sl->master->refcnt);
+	dev->slave_count++;
 
 	/* slave modules need to be loaded in a context with unlocked mutex */
 	mutex_unlock(&dev->mutex);
@@ -750,11 +751,11 @@ int w1_attach_slave_device(struct w1_master *dev, struct w1_reg_num *rn)
 
 	sl->family = f;
 
-
 	err = __w1_attach_slave_device(sl);
 	if (err < 0) {
 		dev_err(&dev->dev, "%s: Attaching %s failed.\n", __func__,
 			 sl->name);
+		dev->slave_count--;
 		w1_family_put(sl->family);
 		atomic_dec(&sl->master->refcnt);
 		kfree(sl);
@@ -762,7 +763,6 @@ int w1_attach_slave_device(struct w1_master *dev, struct w1_reg_num *rn)
 	}
 
 	sl->ttl = dev->slave_ttl;
-	dev->slave_count++;
 
 	memcpy(msg.id.id, rn, sizeof(msg.id));
 	msg.type = W1_SLAVE_ADD;
-- 
2.8.4 (Apple Git-73)

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-06-13 15:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-30 18:04 [PATCH] w1: Fix slave count on 1-Wire bus (resend) Alex A. Mihaylov
     [not found] ` <566761497080616@web49g.yandex.ru>
2017-06-13  7:18   ` Greg Kroah-Hartman
2017-06-13 15:57     ` Alex A. Mihaylov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®