Re: [RFC PATCH 3/8] block: Add kernel APIs to create & delete block device LED triggers

From: Valdis Klētnieks
Date: Wed Jul 28 2021 - 23:45:50 EST


On Wed, 28 Jul 2021 20:53:39 -0500, Ian Pilcher said:
> * New file - include/linux/blk-ledtrig.h
>
> Signed-off-by: Ian Pilcher <arequipeno@xxxxxxxxx>
> ---
> block/blk-ledtrig.c | 152 ++++++++++++++++++++++++++++++++++++
> include/linux/blk-ledtrig.h | 19 +++++
> 2 files changed, 171 insertions(+)
> create mode 100644 include/linux/blk-ledtrig.h
>
> diff --git a/block/blk-ledtrig.c b/block/blk-ledtrig.c
> index 345a3b6bdbc6..c69ea1539336 100644
> --- a/block/blk-ledtrig.c
> +++ b/block/blk-ledtrig.c

> +
> +static int __blk_ledtrig_create(const char *const name, const size_t len)

(...)
+ if (blk_ledtrig_find(name, len) != NULL) {
+ pr_warn("blockdev LED trigger named %.*s already exists\n",
+ (int)len, name);

Is pr_warn() the right level for this stuff? I'd think this sort of pilot error should
be pr_info() or even pr_debug(), if mentioned at all. pr_warn() would be for
something like an unexpected situation like trying to blink an LED but failing.
Simple syntax errors should probably just toss a -EINVAL and return.

(Among other things, this allows a userspace script to spam the
log by simply repeatedly trying to create the same entry)

Attachment: pgpW6UanYc3vg.pgp
Description: PGP signature