• David Fries's avatar
    w1: avoid recursive device_add · 18d7f891
    David Fries authored
    __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 47eba33a 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: default avatarBelisko Marek <marek.belisko@gmail.com>
    Signed-off-by: default avatarDavid Fries <David@Fries.net>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    18d7f891
w1.c 30.1 KB