public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: John Covici <covici@ccs.covici.com>
To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	"Speakup is a screen review system for Linux." 
	<speakup@linux-speakup.org>,
	devel@driverdev.osuosl.org, gregkh@linuxfoundation.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: speakup: refactor synths array to use a list
Date: Mon, 11 Jun 2018 19:55:27 -0400	[thread overview]
Message-ID: <m3bmcgho9c.wl-covici@ccs.covici.com> (raw)
In-Reply-To: <20180611225703.csi47cdafhy6rxcf@var.youpi.perso.aquilenet.fr>

Maybe I can do it, I have a kernel with speakup, using 4.9.43.  Will
the patch fit there?

On Mon, 11 Jun 2018 18:57:03 -0400,
Samuel Thibault wrote:
> 
> [1  <text/plain; us-ascii (7bit)>]
> Hello,
> 
> Samuel Thibault, le mer. 06 juin 2018 15:26:28 +0200, a ecrit:
> > I'd also rather see it tested in the real wild before committing. Could
> > somebody on the speakup mailing list test the patch? (which I have
> > re-attached as a file for conveniency).
> 
> Anybody up for testing please?
> 
> If people want to see speakup get mainlined instead of staging, please
> help.
> 
> Samuel
> [2 patch <text/plain; us-ascii (7bit)>]
> ---
>  drivers/staging/speakup/spk_types.h |  2 ++
>  drivers/staging/speakup/synth.c     | 40 ++++++++++-------------------
>  2 files changed, 15 insertions(+), 27 deletions(-)
> 
> diff --git a/drivers/staging/speakup/spk_types.h b/drivers/staging/speakup/spk_types.h
> index 3e082dc3d45c..a2fc72c29894 100644
> --- a/drivers/staging/speakup/spk_types.h
> +++ b/drivers/staging/speakup/spk_types.h
> @@ -160,6 +160,8 @@ struct spk_io_ops {
>  };
>  
>  struct spk_synth {
> +	struct list_head node;
> +
>  	const char *name;
>  	const char *version;
>  	const char *long_name;
> diff --git a/drivers/staging/speakup/synth.c b/drivers/staging/speakup/synth.c
> index 7deeb7061018..25f259ee4ffc 100644
> --- a/drivers/staging/speakup/synth.c
> +++ b/drivers/staging/speakup/synth.c
> @@ -18,8 +18,7 @@
>  #include "speakup.h"
>  #include "serialio.h"
>  
> -#define MAXSYNTHS       16      /* Max number of synths in array. */
> -static struct spk_synth *synths[MAXSYNTHS + 1];
> +static LIST_HEAD(synths);
>  struct spk_synth *synth;
>  char spk_pitch_buff[32] = "";
>  static int module_status;
> @@ -355,9 +354,8 @@ struct var_t synth_time_vars[] = {
>  /* called by: speakup_init() */
>  int synth_init(char *synth_name)
>  {
> -	int i;
>  	int ret = 0;
> -	struct spk_synth *synth = NULL;
> +	struct spk_synth *tmp, *synth = NULL;
>  
>  	if (!synth_name)
>  		return 0;
> @@ -371,9 +369,10 @@ int synth_init(char *synth_name)
>  
>  	mutex_lock(&spk_mutex);
>  	/* First, check if we already have it loaded. */
> -	for (i = 0; i < MAXSYNTHS && synths[i]; i++)
> -		if (strcmp(synths[i]->name, synth_name) == 0)
> -			synth = synths[i];
> +	list_for_each_entry(tmp, &synths, node) {
> +		if (strcmp(tmp->name, synth_name) == 0)
> +			synth = tmp;
> +	}
>  
>  	/* If we got one, initialize it now. */
>  	if (synth)
> @@ -448,29 +447,23 @@ void synth_release(void)
>  /* called by: all_driver_init() */
>  int synth_add(struct spk_synth *in_synth)
>  {
> -	int i;
>  	int status = 0;
> +	struct spk_synth *tmp;
>  
>  	mutex_lock(&spk_mutex);
> -	for (i = 0; i < MAXSYNTHS && synths[i]; i++)
> -		/* synth_remove() is responsible for rotating the array down */
> -		if (in_synth == synths[i]) {
> +
> +	list_for_each_entry(tmp, &synths, node) {
> +		if (tmp == in_synth) {
>  			mutex_unlock(&spk_mutex);
>  			return 0;
>  		}
> -	if (i == MAXSYNTHS) {
> -		pr_warn("Error: attempting to add a synth past end of array\n");
> -		mutex_unlock(&spk_mutex);
> -		return -1;
>  	}
>  
>  	if (in_synth->startup)
>  		status = do_synth_init(in_synth);
>  
> -	if (!status) {
> -		synths[i++] = in_synth;
> -		synths[i] = NULL;
> -	}
> +	if (!status)
> +		list_add_tail(&in_synth->node, &synths);
>  
>  	mutex_unlock(&spk_mutex);
>  	return status;
> @@ -479,17 +472,10 @@ EXPORT_SYMBOL_GPL(synth_add);
>  
>  void synth_remove(struct spk_synth *in_synth)
>  {
> -	int i;
> -
>  	mutex_lock(&spk_mutex);
>  	if (synth == in_synth)
>  		synth_release();
> -	for (i = 0; synths[i]; i++) {
> -		if (in_synth == synths[i])
> -			break;
> -	}
> -	for ( ; synths[i]; i++) /* compress table */
> -		synths[i] = synths[i + 1];
> +	list_del(&in_synth->node);
>  	module_status = 0;
>  	mutex_unlock(&spk_mutex);
>  }
> -- 
> 2.17.1
> [3  <text/plain; utf-8 (base64)>]
> _______________________________________________
> Speakup mailing list
> Speakup@linux-speakup.org
> http://linux-speakup.org/cgi-bin/mailman/listinfo/speakup

-- 
Your life is like a penny.  You're going to lose it.  The question is:
How do
you spend it?

         John Covici wb2una
         covici@ccs.covici.com

      parent reply	other threads:[~2018-06-12  0:27 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-04  9:52 [PATCH] staging: speakup: refactor synths array to use a list Justin Skists
2018-06-04  9:57 ` Samuel Thibault
2018-06-06 13:26 ` Samuel Thibault
2018-06-06 20:28   ` Justin Skists
2018-06-11 22:57   ` Samuel Thibault
2018-06-11 23:51     ` Gregory Nowak
2018-06-12  6:31       ` Samuel Thibault
2018-06-18  5:34         ` Gregory Nowak
2018-06-18  6:22           ` Samuel Thibault
2018-06-18  8:41           ` Justin Skists
2018-06-18  8:46             ` Samuel Thibault
2018-06-18  8:55               ` Justin Skists
2018-06-18  8:58                 ` Samuel Thibault
2018-06-11 23:55     ` John Covici [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3bmcgho9c.wl-covici@ccs.covici.com \
    --to=covici@ccs.covici.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=samuel.thibault@ens-lyon.org \
    --cc=speakup@linux-speakup.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox