[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YQJCC66c2v7Dv59j@kroah.com>
Date: Thu, 29 Jul 2021 07:52:11 +0200
From: Greg KH <greg@...ah.com>
To: Ian Pilcher <arequipeno@...il.com>
Cc: linux-block@...r.kernel.org, linux-leds@...r.kernel.org,
axboe@...nel.dk, linux-kernel@...r.kernel.org, pavel@....cz,
kernelnewbies@...nelnewbies.org
Subject: Re: [RFC PATCH 3/8] block: Add kernel APIs to create & delete block
device LED triggers
On Wed, Jul 28, 2021 at 08:53:39PM -0500, Ian Pilcher wrote:
> * New file - include/linux/blk-ledtrig.h
>
> Signed-off-by: Ian Pilcher <arequipeno@...il.com>
> ---
> 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
> @@ -6,9 +6,11 @@
> * Copyright 2021 Ian Pilcher <arequipeno@...il.com>
> */
>
> +#include <linux/blk-ledtrig.h>
> #include <linux/leds.h>
> #include <linux/list.h>
> #include <linux/mutex.h>
> +#include <linux/slab.h>
>
>
> /*
> @@ -49,3 +51,153 @@ static struct blk_ledtrig *blk_ledtrig_find(const char *const name,
>
> return NULL;
> }
> +
> +
> +/*
> + *
> + * Create a new trigger
> + *
> + */
> +
> +static int __blk_ledtrig_create(const char *const name, const size_t len)
> +{
> + struct blk_ledtrig *t;
> + int ret;
> +
> + if (len == 0) {
> + pr_warn("empty name specified for blockdev LED trigger\n");
> + ret = -EINVAL;
> + goto create_exit_return;
> + }
> +
> + ret = mutex_lock_interruptible(&blk_ledtrig_list_mutex);
> + if (unlikely(ret != 0))
Only ever use likely/unlikely if you can measure the difference without
it. Otherwise the CPU and compiler will almost always get it right and
you should not clutter up the code with them at all.
For something like this function, where there is no speed difference at
all, there is no need for these types of markings, so I would recommend
just removing them all from your patchset.
thanks,
greg k-h
Powered by blists - more mailing lists