OSDN Git Service

w1: avoid recursive device_add
authorDavid Fries <david@fries.net>
Wed, 16 Apr 2014 06:21:21 +0000 (01:21 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 16 Apr 2014 21:07:51 +0000 (14:07 -0700)
commit18d7f891bcc7e49f2900215f17a861ccec34b138
treeb70c5385376b8463fc4d1850574d7c7d8be9e4b1
parent593ceb0c7046c640cf463022189428a45219f595
w1: avoid recursive device_add

__w1_attach_slave_device calls device_add which calls w1_bus_notify
which calls the w1_bq27000 slave driver, which calls
platform_device_add and device_add and deadlocks on getting
&(&priv->bus_notifier)->rwsem as it is still held in the previous
device_add.  This avoids the problem by processing the family
add/remove outside of the slave device_add call.

Commit 47eba33a0997fc7362a introduced this deadlock and added
a KOBJ_ADD, as the add was already reported in device_register two add
events were being sent.  This change suppresses the device_register
add so that any slave device sysfs entries are setup before the add
goes out.

Belisko Marek reported this change fixed the deadlock he was seeing on
ARM device tree, while testing on my x86-64 system never saw the
deadlock.

Reported-by: Belisko Marek <marek.belisko@gmail.com>
Signed-off-by: David Fries <David@Fries.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/w1/w1.c