From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by befuddled.reisers.ca (Postfix, from userid 65534) id DE79B1EFFE2; Mon, 3 Apr 2017 16:26:08 -0400 (EDT) Received: from mail-wr0-x243.google.com (mail-wr0-x243.google.com [IPv6:2a00:1450:400c:c0c::243]) by befuddled.reisers.ca (Postfix) with ESMTPS id 595C91EFFCC for ; Mon, 3 Apr 2017 16:26:06 -0400 (EDT) Received: by mail-wr0-x243.google.com with SMTP id u18so36652511wrc.0 for ; Mon, 03 Apr 2017 13:26:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:user-agent:date:from:to:cc:subject:references :mime-version:content-disposition; bh=2dXpx6NgkYP7jh6p1J2dKK6we4p9/fDXZ/xv7+0PF4I=; b=bHxFW3bp20QnN+gVGXo+z4+xc4kM9z5WFjwWACXaEA4Bj3Ejv07IK4cR58VK4rbrqL 22mLAv98ozHwIp87pm9UYK/Q3V+eSPy6WtdD/25n/g8w3+Wd4rFQtgbnZThkbIn8Ri9R PjsDBS0EfW7MeCsofg4lFoEXZYbwbFUAcDvchZkwZjfBiR5JD+XsJYbMjqdpV+thC9q6 KmwF8T0RAFHR6RYyosS+SMBVLlktzaLeg8W8NpKCpwAWnrRnIIP9Zd1bt16o8dBOQXfk AA2hkOxgbPwO1AXIfIDp5JTXXubSqWaJfFz+aT8ao1BT2puI5F/NrAdP8BtYFq2PbQes ByPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:user-agent:date:from:to:cc:subject :references:mime-version:content-disposition; bh=2dXpx6NgkYP7jh6p1J2dKK6we4p9/fDXZ/xv7+0PF4I=; b=twHYSPL/hDx9yoeUDkMk8r7LDlNNbM+48sdY6HusvWjB3Iukm1s2SGge9A0ix+7qCK AZ2zWhl1USvzCGgTjVIDYlXrhV7slQq2EHynghKBAUQSdgRw/NhuN1eS31QTvmqrWMFQ STQnsdkUx2a7tJo+SsX11GeO4uaNpmLVmv/1BMGlNrP8C8eO7o5sAk3dAZhTCU6Yz9OG JkndrfLTM0D4XOfCaZBBrQLWkoGjOMM71fR6hbdNTIG88lJDIyu+1Cg+5e6JoyBdNVbe lVvHa2eg8OV+mfpxwy/B3SReNuVWOY/iCWK4Asl2BY95IA0Vlw1LMsv34GOINPMFSVSO 75GA== X-Gm-Message-State: AFeK/H1vgrFLBN7bOAiGBqp8HX4YvyfrYJnOSSpkk0+jPsrWrzVTl/Xhy5qxvpGue9ekCQ== X-Received: by 10.28.0.78 with SMTP id 75mr10917936wma.138.1491251161638; Mon, 03 Apr 2017 13:26:01 -0700 (PDT) Received: from sanghar ([2a00:23c4:7320:5e00:224:d6ff:fe76:7136]) by smtp.gmail.com with ESMTPSA id a10sm19589423wra.17.2017.04.03.13.26.00 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 03 Apr 2017 13:26:00 -0700 (PDT) Message-Id: <20170403202600.043084190@gmail.com> User-Agent: quilt/0.63-1 Date: Mon, 03 Apr 2017 21:21:27 +0100 From: Okash Khawaja To: speakup@linux-speakup.org Subject: [patch 4/7] staging: speakup: add send_xchar and tiocmset methods References: <20170403202123.194386356@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Disposition: inline; filename=04_add_send_xchar_and_tiocmset_methods X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 X-BeenThere: speakup@linux-speakup.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Speakup is a screen review system for Linux." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Apr 2017 20:26:09 -0000 This adds two methods to spk_synth struct: send_xchar and tiocmset, and creates serial and tty implementations for each of them. For serial implementation it takes existing code in apollo, audptr and spkout which already fits the behaviour of send_xchar and tiocmset. For tty implementation, it simply delegates to corresponding methods in tty->ops. Rest of the changes simply make use of serial implementation of these two functions. Signed-off-by: Okash Khawaja Index: linux-staging/drivers/staging/speakup/serialio.c =================================================================== --- linux-staging.orig/drivers/staging/speakup/serialio.c +++ linux-staging/drivers/staging/speakup/serialio.c @@ -26,8 +26,13 @@ static const struct old_serial_port *ser static int timeouts; static int spk_serial_out(struct spk_synth *in_synth, const char ch); +static void spk_serial_send_xchar(char ch); +static void spk_serial_tiocmset(unsigned int set, unsigned int clear); + struct spk_io_ops spk_serial_io_ops = { .synth_out = spk_serial_out, + .send_xchar = spk_serial_send_xchar, + .tiocmset = spk_serial_tiocmset, }; EXPORT_SYMBOL_GPL(spk_serial_io_ops); @@ -136,6 +141,24 @@ static void start_serial_interrupt(int i outb(1, speakup_info.port_tts + UART_FCR); /* Turn FIFO On */ } +static void spk_serial_send_xchar(char ch) +{ + int timeout = SPK_XMITR_TIMEOUT; + + while (spk_serial_tx_busy()) { + if (!--timeout) + break; + udelay(1); + } + outb(ch, speakup_info.port_tts); +} + +static void spk_serial_tiocmset(unsigned int set, unsigned int clear) +{ + int old = inb(speakup_info.port_tts + UART_MCR); + outb((old & ~clear) | set, speakup_info.port_tts + UART_MCR); +} + int spk_serial_synth_probe(struct spk_synth *synth) { const struct old_serial_port *ser; Index: linux-staging/drivers/staging/speakup/speakup_apollo.c =================================================================== --- linux-staging.orig/drivers/staging/speakup/speakup_apollo.c +++ linux-staging/drivers/staging/speakup/speakup_apollo.c @@ -171,9 +171,8 @@ static void do_catch_up(struct spk_synth full_time_val = full_time->u.n.value; spin_unlock_irqrestore(&speakup_info.spinlock, flags); if (!synth->io_ops->synth_out(synth, ch)) { - outb(UART_MCR_DTR, speakup_info.port_tts + UART_MCR); - outb(UART_MCR_DTR | UART_MCR_RTS, - speakup_info.port_tts + UART_MCR); + synth->io_ops->tiocmset(0, UART_MCR_RTS); + synth->io_ops->tiocmset(UART_MCR_RTS, 0); schedule_timeout(msecs_to_jiffies(full_time_val)); continue; } Index: linux-staging/drivers/staging/speakup/speakup_audptr.c =================================================================== --- linux-staging.orig/drivers/staging/speakup/speakup_audptr.c +++ linux-staging/drivers/staging/speakup/speakup_audptr.c @@ -128,14 +128,7 @@ static struct spk_synth synth_audptr = { static void synth_flush(struct spk_synth *synth) { - int timeout = SPK_XMITR_TIMEOUT; - - while (spk_serial_tx_busy()) { - if (!--timeout) - break; - udelay(1); - } - outb(SYNTH_CLEAR, speakup_info.port_tts); + synth->io_ops->send_xchar(SYNTH_CLEAR); synth->io_ops->synth_out(synth, PROCSPEECH); } Index: linux-staging/drivers/staging/speakup/speakup_spkout.c =================================================================== --- linux-staging.orig/drivers/staging/speakup/speakup_spkout.c +++ linux-staging/drivers/staging/speakup/speakup_spkout.c @@ -126,14 +126,7 @@ static struct spk_synth synth_spkout = { static void synth_flush(struct spk_synth *synth) { - int timeout = SPK_XMITR_TIMEOUT; - - while (spk_serial_tx_busy()) { - if (!--timeout) - break; - udelay(1); - } - outb(SYNTH_CLEAR, speakup_info.port_tts); + synth->io_ops->send_xchar(SYNTH_CLEAR); } module_param_named(ser, synth_spkout.ser, int, 0444); Index: linux-staging/drivers/staging/speakup/spk_ttyio.c =================================================================== --- linux-staging.orig/drivers/staging/speakup/spk_ttyio.c +++ linux-staging/drivers/staging/speakup/spk_ttyio.c @@ -29,8 +29,13 @@ static struct tty_ldisc_ops spk_ttyio_ld }; static int spk_ttyio_out(struct spk_synth *in_synth, const char ch); +static void spk_ttyio_send_xchar(char ch); +static void spk_ttyio_tiocmset(unsigned int set, unsigned int clear); + struct spk_io_ops spk_ttyio_ops = { .synth_out = spk_ttyio_out, + .send_xchar = spk_ttyio_send_xchar, + .tiocmset = spk_ttyio_tiocmset, }; EXPORT_SYMBOL_GPL(spk_ttyio_ops); @@ -95,6 +100,16 @@ static int spk_ttyio_out(struct spk_synt return 0; } +static void spk_ttyio_send_xchar(char ch) +{ + speakup_tty->ops->send_xchar(speakup_tty, ch); +} + +static void spk_ttyio_tiocmset(unsigned int set, unsigned int clear) +{ + speakup_tty->ops->tiocmset(speakup_tty, set, clear); +} + int spk_ttyio_synth_probe(struct spk_synth *synth) { int rv = spk_ttyio_initialise_ldisc(synth->ser); Index: linux-staging/drivers/staging/speakup/spk_types.h =================================================================== --- linux-staging.orig/drivers/staging/speakup/spk_types.h +++ linux-staging/drivers/staging/speakup/spk_types.h @@ -150,6 +150,8 @@ struct spk_synth; struct spk_io_ops { int (*synth_out)(struct spk_synth *synth, const char ch); + void (*send_xchar)(char ch); + void (*tiocmset)(unsigned int set, unsigned int clear); }; struct spk_synth {