Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp60219imu; Mon, 10 Dec 2018 16:07:07 -0800 (PST) X-Google-Smtp-Source: AFSGD/VmKYp93ZyX7qwg2DhQKjmFSmsLm17lFQh0OENHmAE52YKHO5G7oq9Z43CBjXof6LdKbeJ5 X-Received: by 2002:a17:902:b090:: with SMTP id p16mr14000333plr.190.1544486827688; Mon, 10 Dec 2018 16:07:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544486827; cv=none; d=google.com; s=arc-20160816; b=caWMWQbDUgfJZX5HVQ1YjNTKQIViuC2e6ygJJkiBXQpKgKXpZPPTDmJ8y4x2cXdItd OurkuQTNtj+vuhFUf/8yZ6Pub2NatKQwwiPTgcAMtDSpaz4qcGWlYeyJfPk5R082f/rx izbdnhNlSC9abyxtK39C69qyZMCjyAR4pyHPg8XcGA4ZpML+QGFVBuuKBvy8L9YKrFWR qAyXAt0A4Pdbq43ActiNFQ/tdm8OsuVesglkmq9xCMUYZoA+nIOQd1Q6AyDLdFcVFjVZ CYUB1uWh52wsFbqvu9FL8H5EfzIHJ82WmwV77gnHeELRKEn72v3OPX208pI3V2Me97M4 odRw== 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 t186si11845142pfd.68.2018.12.10.16.06.52; Mon, 10 Dec 2018 16:07:07 -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 S1729183AbeLJVmn (ORCPT + 99 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 Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K1:p0k/nIw7k0t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ner@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(-) 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); -- 2.20.0