advice on checkpatch error

jim.cromie at gmail.com jim.cromie at gmail.com
Tue Oct 5 16:55:11 EDT 2021


On Tue, Oct 5, 2021 at 1:14 PM <jim.cromie at gmail.com> wrote:
>
> so I have this macro, with some helpers,
> the helper gets a checkpatch error.
>
>     DEFINE_DYNAMIC_DEBUG_CATEGORIES(debug_gvt, __gvt_debug,
>             "i915/gvt bitmap desc",
>             /* map each bit to a category */
>             _DD_cat_(0, "gvt:cmd:"),
>             _DD_cat_(1, "gvt:core:"),
>             _DD_cat_(2, "gvt:dpy:"),
>             _DD_cat_(3, "gvt:el:"),
>             _DD_cat_(4, "gvt:irq:"),
>             _DD_cat_(5, "gvt:mm:"),
>             _DD_cat_(6, "gvt:mmio:"),
>
>
> +#if defined(CONFIG_DYNAMIC_DEBUG) || \
> +       (defined(CONFIG_DYNAMIC_DEBUG_CORE) && defined(DYNAMIC_DEBUG_MODULE))
> +/**
> + * DEFINE_DYNAMIC_DEBUG_CATEGORIES() - bitmap control of categorized prdbgs
> + * @fsname: parameter basename under /sys
> + * @_var:    C-identifier holding bitmap
> + * @desc:  string summarizing the controls provided
> + * @...:    list of struct dyndbg_bitdesc initializations
> + *
> + * Intended for modules with substantial use of "categorized" prdbgs
> + * (those with some systematic prefix in the format string), this lets
> + * modules using pr_debug to control them in groups according to their
> + * format prefixes, and map them to bits 0-N of a sysfs control point.
> + * Each @... gives the index and prefix map.
> + */
> +#define DEFINE_DYNAMIC_DEBUG_CATEGORIES(fsname, _var, desc, ...)       \
> +       MODULE_PARM_DESC(fsname, desc);                                 \
> +       static struct dyndbg_bitmap_param ddcats_##_var =               \
> +       { .bits = &(_var), .map = { __VA_ARGS__, { .match = NULL }}};   \
> +       module_param_cb(fsname, &param_ops_dyndbg, &ddcats_##_var, 0644)
> +
> +/* helper macros provide combos of '^' anchor and ' ' postfix */
> +#define _DD_cat_(N, str)       [N] = { .match = str " " }
> +#define _DD_cats_(N, str)      [N] = { .match = str }
> +#define _DD_pfx_(N, str)       [N] = { .match = "^" str " " }
> +#define _DD_pfxs_(N, str)      [N] = { .match = "^" str }
> +
>
> ERROR: space prohibited before open square bracket '['
> #250: FILE: include/linux/dynamic_debug.h:273:
> +#define _DD_cat_(N, str) [N] = { .match = str " " }
>
> Ive tried various (encapsulations) to no avail.
>
> what am I missing ?

I'll just do it more like this ...

static const struct intel_step_info kbl_revids[] = {
        [1] = { .gt_step = STEP_B0, .display_step = STEP_B0 },
        [2] = { .gt_step = STEP_C0, .display_step = STEP_B0 },
        [3] = { .gt_step = STEP_D0, .display_step = STEP_B0 },
        [4] = { .gt_step = STEP_F0, .display_step = STEP_C0 },
        [5] = { .gt_step = STEP_C0, .display_step = STEP_B1 },
        [6] = { .gt_step = STEP_D1, .display_step = STEP_B1 },
        [7] = { .gt_step = STEP_G0, .display_step = STEP_C0 },
};



More information about the Kernelnewbies mailing list