Re: [PATCH 08/18] ledtrig-blkdev: Add miscellaneous helper functions

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

 



On Fri, Sep 03, 2021 at 03:45:38PM -0500, Ian Pilcher wrote:
> Add blkdev_skip_space() and blkdev_find_space() for parsing writes to
> sysfs attributes
> 
> Add blkdev_read_mode() and blkdev_write_mode() LED comparison helpers
> 
> Signed-off-by: Ian Pilcher <arequipeno@xxxxxxxxx>
> ---
>  drivers/leds/trigger/ledtrig-blkdev.c | 44 +++++++++++++++++++++++++++
>  1 file changed, 44 insertions(+)
> 
> diff --git a/drivers/leds/trigger/ledtrig-blkdev.c b/drivers/leds/trigger/ledtrig-blkdev.c
> index db8326874400..1f319529c3be 100644
> --- a/drivers/leds/trigger/ledtrig-blkdev.c
> +++ b/drivers/leds/trigger/ledtrig-blkdev.c
> @@ -6,6 +6,7 @@
>   *	Copyright 2021 Ian Pilcher <arequipeno@xxxxxxxxx>
>   */
>  
> +#include <linux/ctype.h>
>  #include <linux/module.h>
>  
>  #include "ledtrig-blkdev.h"
> @@ -66,3 +67,46 @@ static unsigned int ledtrig_blkdev_count;
>  
>  /* How often to check for drive activity - in jiffies */
>  static unsigned int ledtrig_blkdev_interval;
> +
> +
> +/*
> + *
> + *	Miscellaneous helper functions
> + *
> + */
> +
> +/*
> + * Returns a pointer to the first non-whitespace character in s
> + * (or a pointer to the terminating null).
> + */
> +static const char *blkdev_skip_space(const char *s)
> +{
> +	while (*s != 0 && isspace(*s))
> +		++s;
> +
> +	return s;
> +}
> +
> +/*
> + * Returns a pointer to the first whitespace character in s (or a pointer to the
> + * terminating null), which is effectively a pointer to the position *after* the
> + * last character in the non-whitespace token at the beginning of s.  (s is
> + * expected to be the result of a previous call to blkdev_skip_space()).
> + */
> +static const char *blkdev_find_space(const char *s)
> +{
> +	while (*s != 0 && !isspace(*s))
> +		++s;
> +
> +	return s;
> +}

Why are block devices odd and need to have spaces found in their names?

And are you sure we do not already have string functions that do this?

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