Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp111291imu; Mon, 10 Dec 2018 17:18:09 -0800 (PST) X-Google-Smtp-Source: AFSGD/UBWZHu/LG8ZwG8Oi4NF3av2w2O6hWaifUlZAvMsqOAj9u2fupAf+4x8ZJwFZU2ogxAkv/e X-Received: by 2002:a17:902:32c3:: with SMTP id z61mr14132243plb.114.1544491089032; Mon, 10 Dec 2018 17:18:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544491089; cv=none; d=google.com; s=arc-20160816; b=du2tLz5asVW/WcOc4wE7XQsZQogFlbN006Q/qWTc5TWDDT3qj/uaIzyi01uKMgDwMm 0ydGxJx6XmppsRLlnQxMwCfkRirt+8gfJ9XjYXgnX/ZHu6TANxZ6WrVAc/Jq4V980Inu KWkKoFpNUpUSzG8/SaUIi83FAZDfcaCKiTYlwtGQ14spBYanFUa9gAYrHm1qBOo6TcpO VPKYsXT0jtADxydzn8SvozpJQ7kGfyBc4OOQ+4ObfFy6KT7JIGblb24izs5461Ch3Fkp iLWo44h9DGAhiy+SuzLyttaF8xmSvNmTXiOxf1LdyMuLbSo1U42imsu2Hv3IVx/zbBbg NTww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:organization:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:mail-followup-to:message-id:subject:cc:to:from:date; bh=PDudrLVHBVZFbsSgo02OTk+acMqHU0HzdAnOFbpdtFg=; b=jraFtPmIC6EiqAAZ0Sqpey3kEe2R0SiVkxMMOIw8JXLQeHeKepHfUiXO63sG6j4KwQ vNW0gKDlvhzT/Ct8eq9pt21Xq2qRnvXw8i4n1iit7CSJ0XN7SzlyFzjklvR/HGmU98Ae kBGrAqRLrHjC2qtjoWz8S5kx7mXp8Qn2oqRZQFiao1L4qyR6UxqudiYYhe1KsS03D4EY VooIM8OPlvs4pIHtUg7eWzst/RAhIdpt1oMse1s2WRYdkhYB81WJJ11XzLXznVTSqj6Z rcPvI8wLXIno7Tk+hpp628+l8b8Qc/La3FxxP5CfeNdKBpgwtWr6GgNel2jjZ0U2tJPq UnpA== 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 44si11370950plb.57.2018.12.10.17.17.54; Mon, 10 Dec 2018 17:18:08 -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 S1729355AbeLJWIy (ORCPT + 99 others); Mon, 10 Dec 2018 17:08:54 -0500 Received: from hera.aquilenet.fr ([185.233.100.1]:33942 "EHLO hera.aquilenet.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728786AbeLJWIy (ORCPT ); Mon, 10 Dec 2018 17:08:54 -0500 Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id DB5E42D7E; Mon, 10 Dec 2018 23:08:52 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at aquilenet.fr Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gSunzxIAEstH; Mon, 10 Dec 2018 23:08:52 +0100 (CET) Received: from function.home (unknown [IPv6:2a01:cb19:181:c200:9eb6:d0ff:fe88:c3c7]) by hera.aquilenet.fr (Postfix) with ESMTPSA id 346AF2D7D; Mon, 10 Dec 2018 23:08:52 +0100 (CET) Received: from samy by function.home with local (Exim 4.91) (envelope-from ) id 1gWTjO-0004w5-W9; Mon, 10 Dec 2018 23:08:51 +0100 Date: Mon, 10 Dec 2018 23:08:50 +0100 From: Samuel Thibault To: Arnd Bergmann Cc: William Hubbs , Chris Brannon , Kirk Reiser , Greg Kroah-Hartman , speakup@linux-speakup.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] staging: speakup: change semaphore to completion Message-ID: <20181210220850.wq7rbcc77v2ckw3f@function> Mail-Followup-To: Samuel Thibault , Arnd Bergmann , William Hubbs , Chris Brannon , Kirk Reiser , Greg Kroah-Hartman , speakup@linux-speakup.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org References: <20181210214225.1497552-1-arnd@arndb.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20181210214225.1497552-1-arnd@arndb.de> Organization: I am not organized User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Arnd Bergmann, le lun. 10 déc. 2018 22:41:50 +0100, a ecrit: > 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 Reviewed-by: Samuel Thibault > --- > 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 > -- Samuel Progress (n.): The process through which the Internet has evolved from smart people in front of dumb terminals to dumb people in front of smart terminals.