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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@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
> @@ -6,9 +6,11 @@
>   *	Copyright 2021 Ian Pilcher <arequipeno@xxxxxxxxx>
>   */
>  
> +#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



[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux