From patchwork Mon Dec 10 21:41:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 153367 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp4045339ljp; Mon, 10 Dec 2018 13:42:44 -0800 (PST) X-Google-Smtp-Source: AFSGD/X5ULuxnV+sEry5cTXrP85eKfTOdcLaJH4UlSdZP8fcm5Gbyu5D6pLFnfChR4AVtnL4YrUX X-Received: by 2002:a17:902:c85:: with SMTP id 5mr13864967plt.339.1544478164724; Mon, 10 Dec 2018 13:42:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544478164; cv=none; d=google.com; s=arc-20160816; b=fUlVsvnAJEVTXcAkkOLn930xzK6Qp46rh3SFnNHmDNVnyTZRymotuHCW4UwXXs3Joo 5ehZ8decxWI3so/dbO6puT1LP2tka4W/sSpaQNANvHLp0s33leKen31QL7rIK3LWULeY gJMQxL/jIiqfgJwXGx2kvKb6lpv8vXvASFSKTjqvitLw+wqfokz/sUM3VTO0Gutodnuv pjtQDr7ODWsNXlRG0DUBm3ZicAhXqSMGX1qsDi2KRA/4c1hiK+5nz4p9vCkaIyPiyp9W vcs2JwP5pHXfF/ITzlVcol4BgcYv/a0QK7zAVy3Nih43yMeYNx7n1ord6DXUw4Mo5L7m Zpdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=xyayPJlZkdx5+IR+yX2TtHO7qC2eGzMHVOuCrgdJmxE=; b=ROinaIzvdq6hSsW8yprWJbhyclMMLGlzQAcLkYg0V7wj0cPe08Gp2JwALsSjw7slUS Y/jNs3d2jGzpof2jjfO+ykiYN7ltzTgExfE7sF6BqBPPe3NVdQ88ssDLz3C+f+9nceP5 +HbrdAKaNnbcGgyjyeHEiuVJ13P6QwCqhje8YMdhQ7yXxl/gqbrAvlkZIEYbX4fiChwh B5JM65onsalT6lYGT7VcPxQlzCep6bvSJhOVgjk7ltYQbOMRXNnSJPUQsEV9ROJi/j+e c5pE/D39mpM6pN1ywYPV5MTz/T1iSXDZO+zm1/qM6B03LAuUevPddTo2u72pYKchwQoZ 2nkA== 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 h5si10145681pgc.237.2018.12.10.13.42.44; Mon, 10 Dec 2018 13:42:44 -0800 (PST) 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 S1729763AbeLJVmn (ORCPT + 31 others); Mon, 10 Dec 2018 16:42:43 -0500 Received: from mout.kundenserver.de ([217.72.192.73]:54123 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726562AbeLJVmn (ORCPT ); Mon, 10 Dec 2018 16:42:43 -0500 Received: from wuerfel.lan ([109.192.41.194]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.145]) with ESMTPA (Nemesis) id 1MkHIV-1hCQmt2ewD-00kfvI; Mon, 10 Dec 2018 22:42:30 +0100 From: Arnd Bergmann To: William Hubbs , Chris Brannon , Kirk Reiser , Samuel Thibault , Greg Kroah-Hartman Cc: Arnd Bergmann , speakup@linux-speakup.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH] staging: speakup: change semaphore to completion Date: Mon, 10 Dec 2018 22:41:50 +0100 Message-Id: <20181210214225.1497552-1-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 MIME-Version: 1.0 X-Provags-ID: V03:K1:p0k/nIw7k0tY2MW1KRKA/Yj5hMBdiphv3HwUyonquexwTrPZArU JPzq84mGW44V/N+yU4EQjxaUqSTNC73WSH7VoB/unYHDi73ibNJltsGtxB0ElC0va3xGwZD CsjdlSEvmYpHg1ZhcnTecAjLw2WbtJUNZlncArMqTd5r8tBx/qVAH5bBDKHrQBlbAbPmAym UACJ5EBSGmaYydCbv5rwg== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:ii1a6NuNR0A=:n//Fa2Zy49zgNcCT7KbsoB uU+WjdB3O+kQMoBQXXfH8tYH16rqzSzvT59jpbfBROdsTdGvIV7ttx9KrF6Q+vhvfyxEEzt4A vnOrTgrHWkhGLQGHzO7vAvM+5RX9IRjBmTbNw8kyj66zpYJwDqfOhJpv0p4Iqqvp1pvdyJoDO f+4YeUXUFpWzZLVzaWKnjYFbml7ddw4+0NsF+CAocQLM6kqqxXlRgAFLOpfDodibSXSPv45Zb WVH0jvXSkJb+tyFZc3KjA/g5Qke7vaRI5vBDBsUtFJPM0gi9qvoF5/oMIM3mEA7GAB4U4iJBO NRVrdUO5W/VlXD9dKj9xhRa4w5l+aBe2yGeGUgIm0aWB1zZ66hldzSHGTWa0BQOd8ytG3PB9S G+0VcCLwKAxXtwg5aN7BX8u58Dg0po2t9nj0OWpcdhtMN8LpXsWD7NXwn8jrTwplGFjkTpVgm nz9bvXTpMsDa9WvryXS5QwXKfHwQs0pIsDyQ+SFdQ/JSx0hl4rkHFyVM9oT5H0iMWMNrHTINa wPi+JQuRX7/HjDERFnoiOeQX10l8flEjopnH0mpr2EuZmTIvUP0Cz0LPEsW5B5QZkpf9XXmbj 4Gcre3q8TPSz5pFmWndoxKzj8Zzo9pdJjpYCb/XBKFmYVopd0mCw9jXGTTwXmP63b4p9LvbLX ugImL2XX6eg+9+jq3GNHGOCYRtuP5AtoUur1oggH60DeySrHTDOMpFIS4muZd0GsWNKW9JYH3 eH+krsds4y/D4B+pg11rzBnpQaS8Sv3pPVG5XA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In this driver, both function the same way, but we want to eventually kill off semaphores, so a completion is the better choice here. Signed-off-by: Arnd Bergmann --- drivers/staging/speakup/spk_ttyio.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) -- 2.20.0 Reviewed-by: Samuel Thibault diff --git a/drivers/staging/speakup/spk_ttyio.c b/drivers/staging/speakup/spk_ttyio.c index 979e3ae249c1..c92bbd05516e 100644 --- a/drivers/staging/speakup/spk_ttyio.c +++ b/drivers/staging/speakup/spk_ttyio.c @@ -10,7 +10,7 @@ struct spk_ldisc_data { char buf; - struct semaphore sem; + struct completion completion; bool buf_free; }; @@ -55,7 +55,7 @@ static int spk_ttyio_ldisc_open(struct tty_struct *tty) if (!ldisc_data) return -ENOMEM; - sema_init(&ldisc_data->sem, 0); + init_completion(&ldisc_data->completion); ldisc_data->buf_free = true; speakup_tty->disc_data = ldisc_data; @@ -95,7 +95,7 @@ static int spk_ttyio_receive_buf2(struct tty_struct *tty, ldisc_data->buf = cp[0]; ldisc_data->buf_free = false; - up(&ldisc_data->sem); + complete(&ldisc_data->completion); return 1; } @@ -286,7 +286,8 @@ static unsigned char ttyio_in(int timeout) struct spk_ldisc_data *ldisc_data = speakup_tty->disc_data; char rv; - if (down_timeout(&ldisc_data->sem, usecs_to_jiffies(timeout)) == -ETIME) { + if (wait_for_completion_timeout(&ldisc_data->completion, + usecs_to_jiffies(timeout)) == 0) { if (timeout) pr_warn("spk_ttyio: timeout (%d) while waiting for input\n", timeout);