• Hans de Goede's avatar
    regulator: core: Avoid debugfs: Directory ... already present! error · dbe954d8
    Hans de Goede authored
    Sometimes regulator_get() gets called twice for the same supply on the
    same device. This may happen e.g. when a framework / library is used
    which uses the regulator; and the driver itself also needs to enable
    the regulator in some cases where the framework will not enable it.
    
    Commit ff268b56 ("regulator: core: Don't spew backtraces on
    duplicate sysfs") already takes care of the backtrace which would
    trigger when creating a duplicate consumer symlink under
    /sys/class/regulator/regulator.%d in this scenario.
    
    Commit c33d4423 ("debugfs: make error message a bit more verbose")
    causes a new error to get logged in this scenario:
    
    [   26.938425] debugfs: Directory 'wm5102-codec-MICVDD' with parent 'spi-WM510204:00-MICVDD' already present!
    
    There is no _nowarn variant of debugfs_create_dir(), but we can detect
    and avoid this problem by checking the return value of the earlier
    sysfs_create_link_nowarn() call.
    
    Add a check for the earlier sysfs_create_link_nowarn() failing with
    -EEXIST and skip the debugfs_create_dir() call in that case, avoiding
    this error getting logged.
    
    Fixes: c33d4423 ("debugfs: make error message a bit more verbose")
    Cc: Charles Keepax <ckeepax@opensource.cirrus.com>
    Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
    Reviewed-by: default avatarCharles Keepax <ckeepax@opensource.cirrus.com>
    Link: https://lore.kernel.org/r/20210122183250.370571-1-hdegoede@redhat.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
    dbe954d8
core.c 152 KB