lkml.org 
[lkml]   [2020]   [Sep]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 19/23] gpio: mockup: add a symlink for the per-chip debugfs directory
    Date
    From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

    We used to have a symlink named after the chip's label linking to the
    per-chip directory named after the chip's name. This was removed by
    commit d51ee07a8de7 ("gpio: mockup: don't create the debugfs link named
    after the label") because there were no users of it.

    This changeset proposes to reintroduce debugfs symlinks but inverted:
    the link named after the device name points to the directory named after
    the label. This way user-space can dynamically create a chip (once that
    functionality is available), detect its creation over uevent and match
    the device name to the label by resolving the link.

    Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
    ---
    drivers/gpio/gpio-mockup.c | 20 +++++++++++++++++++-
    1 file changed, 19 insertions(+), 1 deletion(-)

    diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c
    index 7df990662c17..bc4609e047ef 100644
    --- a/drivers/gpio/gpio-mockup.c
    +++ b/drivers/gpio/gpio-mockup.c
    @@ -52,6 +52,7 @@ struct gpio_mockup_chip {
    struct gpio_mockup_line_status *lines;
    struct irq_domain *irq_sim_domain;
    struct dentry *dbg_dir;
    + struct dentry *dbg_link;
    struct mutex lock;
    };

    @@ -355,6 +356,13 @@ static void gpio_mockup_remove_chip_debugfs_entry(void *data)
    debugfs_remove_recursive(entry);
    }

    +static void gpio_mockup_remove_chip_debugfs_link(void *data)
    +{
    + struct dentry *link = data;
    +
    + debugfs_remove(link);
    +}
    +
    static int gpio_mockup_debugfs_setup(struct device *dev,
    struct gpio_mockup_chip *chip)
    {
    @@ -368,7 +376,7 @@ static int gpio_mockup_debugfs_setup(struct device *dev,
    gc = &chip->gc;
    devname = dev_name(&gc->gpiodev->dev);

    - chip->dbg_dir = debugfs_create_dir(devname, gpio_mockup_dbg_dir);
    + chip->dbg_dir = debugfs_create_dir(gc->label, gpio_mockup_dbg_dir);
    if (IS_ERR(chip->dbg_dir))
    return PTR_ERR(chip->dbg_dir);

    @@ -377,6 +385,16 @@ static int gpio_mockup_debugfs_setup(struct device *dev,
    if (ret)
    return ret;

    + chip->dbg_link = debugfs_create_symlink(devname, gpio_mockup_dbg_dir,
    + gc->label);
    + if (IS_ERR(chip->dbg_link))
    + return PTR_ERR(chip->dbg_link);
    +
    + ret = devm_add_action_or_reset(dev,
    + gpio_mockup_remove_chip_debugfs_link, chip->dbg_link);
    + if (ret)
    + return ret;
    +
    for (i = 0; i < gc->ngpio; i++) {
    name = devm_kasprintf(dev, GFP_KERNEL, "%d", i);
    if (!name)
    --
    2.26.1
    \
     
     \ /
      Last update: 2020-09-04 17:48    [W:4.223 / U:0.544 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site