From patchwork Sat Jan 6 17:45:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 10147975 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AA074601A1 for ; Sat, 6 Jan 2018 17:50:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9CC0728606 for ; Sat, 6 Jan 2018 17:50:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8E78D28617; Sat, 6 Jan 2018 17:50:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4145C28606 for ; Sat, 6 Jan 2018 17:50:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753183AbeAFRuN (ORCPT ); Sat, 6 Jan 2018 12:50:13 -0500 Received: from mail-pl0-f65.google.com ([209.85.160.65]:40184 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752821AbeAFRtm (ORCPT ); Sat, 6 Jan 2018 12:49:42 -0500 Received: by mail-pl0-f65.google.com with SMTP id 62so5060436pld.7; Sat, 06 Jan 2018 09:49:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=VqEhRZ9b+dwJY5PXZ9lynHZBPw0w/VfoFYEVfhUDiH8=; b=cxq54BBL4I6cniRksonMdad4kyUWo8OuwbMsPaFK61iJF/nj3nfM3/O8iux/dBex6I vIrux5JmpRVrlnIarxg0QO8Gb7RfcEQOajeHE6Rt+95mXGV3YSQp1+JAqk3ndfPWFhxl 4ox8odXPBCxjYj1JHT6twhvGm0XHgOevp+3KFMNNohA8hJVLY7eA2XW+GMYQOJCePW5x Sm8JCLAKq/kb9OH/tSqP0cstUxucpeFN7LFmF+UVClh9r1iZkeF6z1taGAp/pHTRiBnn R2lx2IFlZpXnA5V9ckax6v4kseo7QvKN7y85GQrgmOnwcxyeg0MWn3F0VFLC0fL/ni5l lhrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=VqEhRZ9b+dwJY5PXZ9lynHZBPw0w/VfoFYEVfhUDiH8=; b=EQ4jgAzAZQPApnXT8oREsW5zhnZKnJBmkAw29FY7/uC5XdJCd3RRrHlv+I/9ltUvbd /wnqleoTBnoQfgUUpZd9VbfsE+R/fwfmEp5Kk8Ch/g8lsx75ZmahjSQzytqqGD0larzb hR8bTTaztvItFEn1urk2bEVN6PsoQAp9wj8qi5lW6B9nEfPuCNaL79IO3wwEV1nm09pE +3V1XHgLhBxZuZkJOrZHYYDJqo8ISuFMalceKpSutLSem2FgNQ8WwSQ3dAkpolTzuL+b l7rPbqXgv5vly4ikXwPYnkgyPl3gz+RCCZChWspFvUTSoLo25zKGYhm+aKdOMLXtgpVp Ynow== X-Gm-Message-State: AKGB3mLzC/e65xgpyRHthq5I6FxzrNrrLz2R3gvKCvJLe1r/mzZ5TKl0 ukZa3BerjeE90PmLbh/mupaO+JHm X-Google-Smtp-Source: ACJfBovQNQPLgLiOvaCDg6U6Jx9j1MVd0PLR1igBfPAq1rk/ILqYkkx+TuSQhbYPG7lpYuDqZ1CJ4g== X-Received: by 10.159.197.75 with SMTP id d11mr7110707plo.240.1515260981298; Sat, 06 Jan 2018 09:49:41 -0800 (PST) Received: from zzz.localdomain (c-67-185-97-198.hsd1.wa.comcast.net. [67.185.97.198]) by smtp.gmail.com with ESMTPSA id p10sm19990234pfl.32.2018.01.06.09.49.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 06 Jan 2018 09:49:40 -0800 (PST) From: Eric Biggers To: linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Andrew Morton , Davide Libenzi , Eric Biggers Subject: [PATCH 3/3] eventfd: fold eventfd_ctx_get() into eventfd_ctx_fileget() Date: Sat, 6 Jan 2018 09:45:44 -0800 Message-Id: <20180106174544.5331-4-ebiggers3@gmail.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180106174544.5331-1-ebiggers3@gmail.com> References: <20180106174544.5331-1-ebiggers3@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Eric Biggers eventfd_ctx_get() is not used outside of eventfd.c, so unexport it and fold it into eventfd_ctx_fileget(). (eventfd_ctx_get() was apparently added years ago for KVM irqfd's, but was never used.) Signed-off-by: Eric Biggers --- fs/eventfd.c | 21 ++++++--------------- include/linux/eventfd.h | 2 +- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/fs/eventfd.c b/fs/eventfd.c index 6138d2b5cdeb..bc0105ae253f 100644 --- a/fs/eventfd.c +++ b/fs/eventfd.c @@ -79,25 +79,12 @@ static void eventfd_free(struct kref *kref) eventfd_free_ctx(ctx); } -/** - * eventfd_ctx_get - Acquires a reference to the internal eventfd context. - * @ctx: [in] Pointer to the eventfd context. - * - * Returns: In case of success, returns a pointer to the eventfd context. - */ -struct eventfd_ctx *eventfd_ctx_get(struct eventfd_ctx *ctx) -{ - kref_get(&ctx->kref); - return ctx; -} -EXPORT_SYMBOL_GPL(eventfd_ctx_get); - /** * eventfd_ctx_put - Releases a reference to the internal eventfd context. * @ctx: [in] Pointer to eventfd context. * * The eventfd context reference must have been previously acquired either - * with eventfd_ctx_get() or eventfd_ctx_fdget(). + * with eventfd_ctx_fdget() or eventfd_ctx_fileget(). */ void eventfd_ctx_put(struct eventfd_ctx *ctx) { @@ -382,10 +369,14 @@ EXPORT_SYMBOL_GPL(eventfd_ctx_fdget); */ struct eventfd_ctx *eventfd_ctx_fileget(struct file *file) { + struct eventfd_ctx *ctx; + if (file->f_op != &eventfd_fops) return ERR_PTR(-EINVAL); - return eventfd_ctx_get(file->private_data); + ctx = file->private_data; + kref_get(&ctx->kref); + return ctx; } EXPORT_SYMBOL_GPL(eventfd_ctx_fileget); diff --git a/include/linux/eventfd.h b/include/linux/eventfd.h index 566fef14d0a6..7094718b653b 100644 --- a/include/linux/eventfd.h +++ b/include/linux/eventfd.h @@ -26,11 +26,11 @@ #define EFD_SHARED_FCNTL_FLAGS (O_CLOEXEC | O_NONBLOCK) #define EFD_FLAGS_SET (EFD_SHARED_FCNTL_FLAGS | EFD_SEMAPHORE) +struct eventfd_ctx; struct file; #ifdef CONFIG_EVENTFD -struct eventfd_ctx *eventfd_ctx_get(struct eventfd_ctx *ctx); void eventfd_ctx_put(struct eventfd_ctx *ctx); struct file *eventfd_fget(int fd); struct eventfd_ctx *eventfd_ctx_fdget(int fd);