summaryrefslogtreecommitdiff
path: root/drivers/w1
diff options
context:
space:
mode:
authorAlex A. Mihaylov <minimumlaw@rambler.ru>2017-06-13 18:57:56 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-07-17 16:45:16 +0200
commit2c927c0c73fd9f6de9ff576e08cd59f13b9d0ef7 (patch)
treef1d4b396bca148063cd5cbd4e2bc28293b5b07c5 /drivers/w1
parent998849967c57705b2cb013d4aea439e7e76e2d8a (diff)
w1: Fix slave count on 1-Wire bus (resend)
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> Acked-by: Evgeniy Polyakov <zbr@ioremap.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/w1')
-rw-r--r--drivers/w1/w1.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index 95ea7e6b1d99..74471e7aa5cc 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -728,6 +728,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);
@@ -747,11 +748,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);
@@ -759,7 +760,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;