Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4689243imm; Mon, 11 Jun 2018 17:28:22 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL2BLaFLn6R1Hcl2P4FU5A3BZQnVF4lluspmZvvGJWJlm5tb2rtPTuHk+bcv5MPT7ttxmvY X-Received: by 2002:a62:ba13:: with SMTP id k19-v6mr1313938pff.245.1528763302133; Mon, 11 Jun 2018 17:28:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528763302; cv=none; d=google.com; s=arc-20160816; b=0xRCWYM3ooTjLSeXlBWQCzwZcaKxSqK0xvelFNmTBzk5Nzu2tNC9eupq2gW3n8Mp6P 4W+FCCmAPIbwjtQpH9HfgJJXcnObmyiRHz4p2V20j336tZTaM6ITdSeTXvXtO0sG/TRu Zx0hvNEJE2vIr3ea5xXQ8o9FwcP79uNL3vdv9sBpp+EzwDt0KqN3nOVv0qh0CWywaun3 af6NXTMewx3gkX3LjyNyfnZcmfQA8HjecWgrqqIYrrij0VRgVNPmg0hcMt3LceKuVJQb tZf4kzJN5T072Vd/df4T3QhTN0BidaW1QyyE40+Sc/L/UPRB4BXzNS/NAWBWAXuwppwF dLxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:organization:reply-to :user-agent:references:in-reply-to:subject:to:from:message-id:date :arc-authentication-results; bh=+OiY74nAKcPNFFzd5vVyJHcqNHmO05hXlWxuj2aizsc=; b=T5gMleWAUoq9yaA370yvrALfPvgI2SmjDeStHCJVF/6CadA1S6cCxSKY0e33ui9mlf ZWlv2i8aHi+n6NyLaPEWTRqdphpRKbYjLlghSE9s+v8avDPtaa03JzwpOjSL9CbzoZq8 BrMzf2Qju7Pkg1PJuWbLYcIYf17PWXwmrdsPh3hP9PSEOQPTAExh4zJIPZDUlBZp1Bid v0VZ41v/1htQP0xY5RtFK0fU4H13AmzcpCZs43KJP7/g2cbFCOXXUJlydSSVYmUFaktO A+63M29LezZXSRAW5Sl27IkFCVIpk7lrqpsWKAryX5DTPyH/jdRfb8rSiq/Il+6EP6mz acWg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a12-v6si65167361plp.225.2018.06.11.17.28.08; Mon, 11 Jun 2018 17:28:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934779AbeFLA1l (ORCPT + 99 others); Mon, 11 Jun 2018 20:27:41 -0400 Received: from dallas-out-001.smtp25.com ([63.71.12.128]:55890 "EHLO dallas-out-001.smtp25.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934716AbeFLA1j (ORCPT ); Mon, 11 Jun 2018 20:27:39 -0400 X-Greylist: delayed 1919 seconds by postgrey-1.27 at vger.kernel.org; Mon, 11 Jun 2018 20:27:39 EDT Received: from ccs.covici.com (localhost [127.0.0.1]) by ccs.covici.com (8.14.9/8.14.8) with ESMTP id w5BNtRwM017117 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 Jun 2018 19:55:27 -0400 Received: (from covici@localhost) by ccs.covici.com (8.14.9/8.13.7/Submit) id w5BNtRUq017116; Mon, 11 Jun 2018 19:55:27 -0400 Date: Mon, 11 Jun 2018 19:55:27 -0400 Message-ID: From: John Covici To: Samuel Thibault , "Speakup is a screen review system for Linux." , devel@driverdev.osuosl.org, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] staging: speakup: refactor synths array to use a list In-Reply-To: <20180611225703.csi47cdafhy6rxcf@var.youpi.perso.aquilenet.fr> References: <20180604095212.GA18381@tanglefoot> <20180606132628.fxykchbznrwzgwqt@var.youpi.perso.aquilenet.fr> <20180611225703.csi47cdafhy6rxcf@var.youpi.perso.aquilenet.fr> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL/10.8 EasyPG/1.0.0 Emacs/26 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) Reply-To: covici@ccs.covici.com Organization: Covici Computer Systems MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SpamH-Filter: dallas-out-001.smtp25.com-w5BNtSGA029445 X-SpamH-OriginatingIP: 70.109.53.110 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 ] > 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 ] > --- > 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 ] > _______________________________________________ > 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