Re: [PATCH net-next 02/11] net: dsa: add debugfs interface

From: Florian Fainelli
Date: Tue Aug 15 2017 - 13:29:12 EST




On 08/14/2017 03:22 PM, Vivien Didelot wrote:
> This commit adds a DEBUG_FS dependent DSA core file creating a generic
> debug filesystem interface for the DSA switch devices.
>
> The interface can be mounted with:
>
> # mount -t debugfs none /sys/kernel/debug
>
> The dsa directory contains one directory per switch chip:
>
> # cd /sys/kernel/debug/dsa/
> # ls
> switch0 switch1 switch2
>
> Each chip directory contains one directory per port:
>
> # ls -l switch0/
> drwxr-xr-x 2 root root 0 Jan 1 00:00 port0
> drwxr-xr-x 2 root root 0 Jan 1 00:00 port1
> drwxr-xr-x 2 root root 0 Jan 1 00:00 port2
> drwxr-xr-x 2 root root 0 Jan 1 00:00 port5
> drwxr-xr-x 2 root root 0 Jan 1 00:00 port6
>
> Future patches will add entry files to these directories.
>
> Signed-off-by: Vivien Didelot <vivien.didelot@xxxxxxxxxxxxxxxxxxxx>
> ---

> +static int dsa_debugfs_create_switch(struct dsa_switch *ds)
> +{
> + char name[32];
> + int i;
> +
> + /* skip if there is no debugfs support */
> + if (!dsa_debugfs_dir)
> + return 0;
> +
> + snprintf(name, sizeof(name), DSA_SWITCH_FMT, ds->index);
> +
> + ds->debugfs_dir = debugfs_create_dir(name, dsa_debugfs_dir);
> + if (IS_ERR_OR_NULL(ds->debugfs_dir))
> + return -EFAULT;
> +
> + for (i = 0; i < ds->num_ports; i++) {
> + if (!ds->ports[i].dn)
> + continue;

This won't create port directories when using platform data, can you
check for BIT(i) & ds->enabled_port_mask instead?
--
Florian