From patchwork Mon Dec 10 21:52:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 153371 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp4053789ljp; Mon, 10 Dec 2018 13:53:30 -0800 (PST) X-Google-Smtp-Source: AFSGD/UalhvvNmIRe3jNNTYBL+Z0dl5g/9Kh7voqxrZAR05Umud6nIv1UKR4O5wIlsVLojJCqEzO X-Received: by 2002:a62:dbc2:: with SMTP id f185mr13799382pfg.235.1544478810330; Mon, 10 Dec 2018 13:53:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544478810; cv=none; d=google.com; s=arc-20160816; b=U63CSFTFhTsoAyjrqGJ5WvWTtFIFPIVBLyxuBXRRljkLjKBkbqIYB9Ag2TMeIml4ol yaGiXz3DnFIexjnhrbaX77TlZYvhwUVgSZjxSYlXe+Y266kcMhBWzUq8FstHO9DqXtvO Vhk3w5V8VXBL3mpQXPUMQ0H7YKAGbntsUPg3Z3fXOMz6fW0oCoaWH5OzEIvMXo2GAhcJ c2Y8y8K5T1a6kr262vR4uL59JKeXiSUd0rClv8+D2GsKWK75y+ozGCTy5URlB49lncpd yKopmx67WV9/qwDEiTuzIl0XNplwPwUdEKYRXsiuOzrCq0Ixc9GQvLO6m75OrWljTnMd aHMA== 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=vTkvuJeaF2i7bTQncZeze1y8LVBmTYu+T5oStBCmlpk=; b=R0tAPHCNZnVZl9D/jr1ye5+dxBc84+5l6Uf/KbABoLDJZzQKRF79BjFSt8PVGWbXv/ TeYORuCxoiONfvoyIaA0yhW4rTrq+D1jR373KJUFAjXkRkaGK1ti8Qxw+ric8505AjUA 0r5W30gn8lhpTWhBRdqTsMt3rNS8mCi3e5whozAtP6w4BU6DkrCGDLc6KwJHCQG8EVLB DdiRfJ8covlaS3c0Hp961iDxYZE2VAEIbBzgl5Ddk7X+nQ/U6bmH3VlT1kuqo3maUMjr MlsxnRxbp7fNr54sMmGE+3xV8wTGHbzvRKc/NaiXxTWozpv24rNo5lDMG3NQJRXM2Qbp Trig== 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 g7si10618307plq.336.2018.12.10.13.53.30; Mon, 10 Dec 2018 13:53:30 -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 S1729681AbeLJVx2 (ORCPT + 31 others); Mon, 10 Dec 2018 16:53:28 -0500 Received: from mout.kundenserver.de ([212.227.126.187]:46109 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726392AbeLJVx1 (ORCPT ); Mon, 10 Dec 2018 16:53:27 -0500 Received: from wuerfel.lan ([109.192.41.194]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.129]) with ESMTPA (Nemesis) id 1MkEdF-1hCNxZ236v-00kgK7; Mon, 10 Dec 2018 22:53:20 +0100 From: Arnd Bergmann To: Andreas Koensgen , "David S. Miller" , Paul Mackerras Cc: Arnd Bergmann , Al Viro , Colin Ian King , linux-hams@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-ppp@vger.kernel.org Subject: [PATCH] hamradio, ppp: change semaphore to completion Date: Mon, 10 Dec 2018 22:52:56 +0100 Message-Id: <20181210215318.1982562-1-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 MIME-Version: 1.0 X-Provags-ID: V03:K1:d3v9JfKe1nH/BTMqoL4T45oaXvu8btJPVtquML8pEwYf1/kiony 8nd6/qm7IRQE5hmDAslkqZ6G8yP9cTO1Ke3HyBUx7VpYyTWhX8i4UN5zxfyXNWEl0N4Tx+v ZF7DwHdo+5SbNbHsnoOQ/hGTceRZ4hWctODjRQG2arh7IM70idaW+MRR0WgFo7atWBcoDo6 82NSNGsH7Stygrp6O9zDw== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:RNGezJgd3R4=:jYfsVW5pJF6PsTrOpTTQXQ lt/wB6Ob/dbmD5+38YgVhlhLasOehILOIaZLrxLVUlNNkMUZracr1kJUnN3jx1nH69G3U9tnk WRGT152ZkZSxlhoyJ/HiISHlFvi7GaShY2tP141dJ7foKsiv4NsJpoRr2Xg10zBUxUu/+aDss n51SwceQRDLc8ZsIA2av/SeeKaFJLkstz/gJgDhEHaCQipglBOFQKvKCFAQFpTQV9LV2h1QFV aNhjcpXBCBAwF5QqfiNvcu6kDa8N6VkDAjYUsIAJDT9OuYZIfVK8iMWDs1idt4RqgBuEyaT74 3cEnraTtRfZfqNDcYBSvvsvijza/y4YP/KttXd8iALQ17sVO1biG40lMLFdbAZe2et9gONONV qD2kwAQIoCeRQ2vkFkbyEhJHS4PetOnUw8WBbR417mrXUCzwRLm1IZ1TzKpeKA/8ylxLeqeGH timQYN/ml37PWf39d9EL5SvkHcPtsPFny4reaM9SEafBLrqG407fZ2/y3B1aA0V6BCW5IDGYF n0Vtp/e63+WRnH40QDRzdzMBd45Z1GOd08fvBjICPKZtAoZgKYkiAb2AKnS1A1uI/uvSbdAUy 9z9lyN8KgIKeB1YxzGINzAOV9RXM5gv8DBkyBAVi0Jc8efZcPHhRt381oyWWNr9R/4uYEzxBX cMVF9er2a3zCvz44vGIJ3wpXfzdM5miBlVnWWcO6M/w0qmZBxCyOlZb4D5A3Y/RkrB58XK5V6 28YYac4h8dhXpILVMdSabn7PqzRrjIriR2z6zg== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ppp and hamradio have copies of the same code that uses a semaphore in place of a completion for historic reasons. Make it use the proper interface instead in all copies. Signed-off-by: Arnd Bergmann --- drivers/net/hamradio/6pack.c | 10 +++++----- drivers/net/hamradio/mkiss.c | 8 ++++---- drivers/net/ppp/ppp_async.c | 8 ++++---- 3 files changed, 13 insertions(+), 13 deletions(-) -- 2.20.0 diff --git a/drivers/net/hamradio/6pack.c b/drivers/net/hamradio/6pack.c index 17e6dcd2eb42..28c749980359 100644 --- a/drivers/net/hamradio/6pack.c +++ b/drivers/net/hamradio/6pack.c @@ -120,7 +120,7 @@ struct sixpack { struct timer_list tx_t; struct timer_list resync_t; refcount_t refcnt; - struct semaphore dead_sem; + struct completion dead; spinlock_t lock; }; @@ -389,7 +389,7 @@ static struct sixpack *sp_get(struct tty_struct *tty) static void sp_put(struct sixpack *sp) { if (refcount_dec_and_test(&sp->refcnt)) - up(&sp->dead_sem); + complete(&sp->dead); } /* @@ -576,7 +576,7 @@ static int sixpack_open(struct tty_struct *tty) spin_lock_init(&sp->lock); refcount_set(&sp->refcnt, 1); - sema_init(&sp->dead_sem, 0); + init_completion(&sp->dead); /* !!! length of the buffers. MTU is IP MTU, not PACLEN! */ @@ -670,10 +670,10 @@ static void sixpack_close(struct tty_struct *tty) * we have to wait for all existing users to finish. */ if (!refcount_dec_and_test(&sp->refcnt)) - down(&sp->dead_sem); + wait_for_completion(&sp->dead); /* We must stop the queue to avoid potentially scribbling - * on the free buffers. The sp->dead_sem is not sufficient + * on the free buffers. The sp->dead completion is not sufficient * to protect us from sp->xbuff access. */ netif_stop_queue(sp->dev); diff --git a/drivers/net/hamradio/mkiss.c b/drivers/net/hamradio/mkiss.c index 802233d41b25..4938cf4c184c 100644 --- a/drivers/net/hamradio/mkiss.c +++ b/drivers/net/hamradio/mkiss.c @@ -81,7 +81,7 @@ struct mkiss { #define CRC_MODE_SMACK_TEST 4 atomic_t refcnt; - struct semaphore dead_sem; + struct completion dead; }; /*---------------------------------------------------------------------------*/ @@ -687,7 +687,7 @@ static struct mkiss *mkiss_get(struct tty_struct *tty) static void mkiss_put(struct mkiss *ax) { if (atomic_dec_and_test(&ax->refcnt)) - up(&ax->dead_sem); + complete(&ax->dead); } static int crc_force = 0; /* Can be overridden with insmod */ @@ -715,7 +715,7 @@ static int mkiss_open(struct tty_struct *tty) spin_lock_init(&ax->buflock); atomic_set(&ax->refcnt, 1); - sema_init(&ax->dead_sem, 0); + init_completion(&ax->dead); ax->tty = tty; tty->disc_data = ax; @@ -795,7 +795,7 @@ static void mkiss_close(struct tty_struct *tty) * we have to wait for all existing users to finish. */ if (!atomic_dec_and_test(&ax->refcnt)) - down(&ax->dead_sem); + wait_for_completion(&ax->dead); /* * Halt the transmit queue so that a new transmit cannot scribble * on our buffers diff --git a/drivers/net/ppp/ppp_async.c b/drivers/net/ppp/ppp_async.c index bdc4d23627c5..288cf099876b 100644 --- a/drivers/net/ppp/ppp_async.c +++ b/drivers/net/ppp/ppp_async.c @@ -70,7 +70,7 @@ struct asyncppp { struct tasklet_struct tsk; refcount_t refcnt; - struct semaphore dead_sem; + struct completion dead; struct ppp_channel chan; /* interface to generic ppp layer */ unsigned char obuf[OBUFSIZE]; }; @@ -148,7 +148,7 @@ static struct asyncppp *ap_get(struct tty_struct *tty) static void ap_put(struct asyncppp *ap) { if (refcount_dec_and_test(&ap->refcnt)) - up(&ap->dead_sem); + complete(&ap->dead); } /* @@ -186,7 +186,7 @@ ppp_asynctty_open(struct tty_struct *tty) tasklet_init(&ap->tsk, ppp_async_process, (unsigned long) ap); refcount_set(&ap->refcnt, 1); - sema_init(&ap->dead_sem, 0); + init_completion(&ap->dead); ap->chan.private = ap; ap->chan.ops = &async_ops; @@ -235,7 +235,7 @@ ppp_asynctty_close(struct tty_struct *tty) * by the time it returns. */ if (!refcount_dec_and_test(&ap->refcnt)) - down(&ap->dead_sem); + wait_for_completion(&ap->dead); tasklet_kill(&ap->tsk); ppp_unregister_channel(&ap->chan);