Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754636Ab2BSCLU (ORCPT ); Sat, 18 Feb 2012 21:11:20 -0500 Received: from cantor2.suse.de ([195.135.220.15]:34305 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754574Ab2BSCLO (ORCPT ); Sat, 18 Feb 2012 21:11:14 -0500 From: NeilBrown To: Evgeniy Polyakov Date: Sun, 19 Feb 2012 13:10:00 +1100 Subject: [PATCH 3/3] w1_bq27000: Only one thread can access the bq27000 at a time. Cc: GregKH , Thomas Weber , Dan Carpenter , linux-kernel@vger.kernel.org, NeilBrown Message-ID: <20120219021000.4958.21513.stgit@notabene.brown> In-Reply-To: <20120219020910.4958.46866.stgit@notabene.brown> References: <20120219020910.4958.46866.stgit@notabene.brown> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 961 Lines: 30 If multiple threads try, they trip over each other badly. Signed-off-by: NeilBrown --- drivers/w1/slaves/w1_bq27000.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/drivers/w1/slaves/w1_bq27000.c b/drivers/w1/slaves/w1_bq27000.c index 6ae60aa..52ad812 100644 --- a/drivers/w1/slaves/w1_bq27000.c +++ b/drivers/w1/slaves/w1_bq27000.c @@ -31,8 +31,10 @@ static int w1_bq27000_read(struct device *dev, unsigned int reg) u8 val; struct w1_slave *sl = container_of(dev->parent, struct w1_slave, dev); + mutex_lock(&sl->master->mutex); w1_write_8(sl->master, HDQ_CMD_READ | reg); val = w1_read_8(sl->master); + mutex_unlock(&sl->master->mutex); return val; } -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/