Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp6823089ybl; Wed, 15 Jan 2020 10:44:28 -0800 (PST) X-Google-Smtp-Source: APXvYqyI8jDqpkjjGEuSKLLa6X+RQqBpyXlYxOy2JyOPnQL4aP05JLqTFoZJquHVnVOLk4a88CvP X-Received: by 2002:a05:6830:2053:: with SMTP id f19mr3570748otp.193.1579113868448; Wed, 15 Jan 2020 10:44:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579113868; cv=none; d=google.com; s=arc-20160816; b=A5RFED7cSFhbEdrcO1K2UuPnW37LXhjKLQuQ0MD/pcmrs/oYbHR5HR/6Wf4+/TeNUp 1hulyzFEtFT42p5lHp7GsdQbMcM6/rGsInafvzd7Z84q4aeLO900WDg4ZWOzgohwwiPE GkpsipfQ1rOrGDcXTYAQyFDkPcTmcrZviAZN+CpvVxoshMX3lZ0GssM+21k/uKxQnrlD oYdEpr0p563sVB0zeQKQYQjVu25HePozfXG62+kg1uofE/MSaH2ZbMQJJ/+WTIzkzhVE exBYlKRFY5IgQzU40A1UCI3Gq3SWp/9epsvnSDwD1bQakVrZMIaD0yDZLAewaGHmN3vA EAsQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=F4f5SVpmjg4tV96vcY1wie1/tFbT5oyVSQBGC1Kpcs0=; b=EASpZaFiXzSC/fys9/EB9+RZCDX+nNjql12Zqtpq0RuhbtmXuBlvMemk9p7L5nY4P5 z3Knm2zqAxvPpxMUrk3SX699X7oZjKUltvwp83q6j/K4Ap19/OdlIN0nBshdpXVTjcRp QseJFaavQbnly0KDRXQISPJf2S4fiBKFYhtxfD5yzAkv5A/xnb6rBNI85NkKL73czBZo l8AL61PAztwt2VkGCS6hLOBjOT2evpIEThh4IMyrJ3IQbis+fRcxk5WN780QSxV5Mg1S Yl+K4wDUzkynmtiv+SbGf++QdZjtG2i/07/Isqy1ZPzrJ0EQBkZtGU5+xrQi08+nLPum ONpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=AITztlS2; 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 i10si11260089otr.272.2020.01.15.10.44.16; Wed, 15 Jan 2020 10:44:28 -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; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=AITztlS2; 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 S1729367AbgAOSmO (ORCPT + 99 others); Wed, 15 Jan 2020 13:42:14 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:41921 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729261AbgAOSmF (ORCPT ); Wed, 15 Jan 2020 13:42:05 -0500 Received: by mail-lj1-f194.google.com with SMTP id h23so19696829ljc.8 for ; Wed, 15 Jan 2020 10:42:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=F4f5SVpmjg4tV96vcY1wie1/tFbT5oyVSQBGC1Kpcs0=; b=AITztlS20IZgEJ8NQ5qreg8X15jfK/sjgiCboVCFiQDQZFRlubR3FYarEPw00acZpe o8V3XVR1YqCYdXcW8ZGUylPe84A4xWRJp2CjUQfJrfWjBTtkZ5fNrLCrHtYaC53IaJeW 0fIYFSZq0E+BcwB0WZG5+bntxw7n1YgL3FAPc= 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:mime-version:content-transfer-encoding; bh=F4f5SVpmjg4tV96vcY1wie1/tFbT5oyVSQBGC1Kpcs0=; b=A6ZNnClc36wpzNd4fAzeXvjIix1yX4cuoVfpIMu759CtAqykUFikd9H7U0pm6vQXkx t/Ynaew0Bl+Ml+tI1aTm7tMVk5EmoAAVmrzyNuZxmWQmgzazxyiOKjV4gG6PsXwZ3cNf tjQw/FtYXssaB5SHeWzBBz6V2x0C+oiW7TrUkVajCCbQVJ08aFtkZm0DSPEdQyJxWcko M5uhDydwNYszYZM8YR49+eZlsZ2ANCwZ0knnSPZIgr6mvZWYn9crDv9Cdr5M7VdcKrB5 hQBNIzo8Njk8Ilu5knwG8fGj2HPLUZCrNkcQavwNSejb/VtgL+UR60hDnurjzmr/xPqY 8S0w== X-Gm-Message-State: APjAAAWCxOc/ZoNOt6Zpi/bD66MFPldd/K35xx6FjJspckQziDmS8FIc h4BzXJtKh6wVOkA3Uu9uMfZ7zw== X-Received: by 2002:a2e:818e:: with SMTP id e14mr2688900ljg.2.1579113723348; Wed, 15 Jan 2020 10:42:03 -0800 (PST) Received: from prevas-ravi.prevas.se ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id 21sm9598631ljv.19.2020.01.15.10.42.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jan 2020 10:42:02 -0800 (PST) From: Rasmus Villemoes To: Greg Kroah-Hartman , "Rafael J. Wysocki" Cc: Rasmus Villemoes , linux-kernel@vger.kernel.org Subject: [PATCH 5/5] devtmpfs: factor out common tail of devtmpfs_{create,delete}_node Date: Wed, 15 Jan 2020 19:41:53 +0100 Message-Id: <20200115184154.3492-6-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200115184154.3492-1-linux@rasmusvillemoes.dk> References: <20200115184154.3492-1-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There's some common boilerplate in devtmpfs_{create,delete}_node, put that in a little helper. Signed-off-by: Rasmus Villemoes --- drivers/base/devtmpfs.c | 44 ++++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c index 56632fb22fc0..5995c437cbdf 100644 --- a/drivers/base/devtmpfs.c +++ b/drivers/base/devtmpfs.c @@ -89,6 +89,23 @@ static inline int is_blockdev(struct device *dev) static inline int is_blockdev(struct device *dev) { return 0; } #endif +static int devtmpfs_submit_req(struct req *req, const char *tmp) +{ + init_completion(&req->done); + + spin_lock(&req_lock); + req->next = requests; + requests = req; + spin_unlock(&req_lock); + + wake_up_process(thread); + wait_for_completion(&req->done); + + kfree(tmp); + + return req->err; +} + int devtmpfs_create_node(struct device *dev) { const char *tmp = NULL; @@ -113,19 +130,7 @@ int devtmpfs_create_node(struct device *dev) req.dev = dev; - init_completion(&req.done); - - spin_lock(&req_lock); - req.next = requests; - requests = &req; - spin_unlock(&req_lock); - - wake_up_process(thread); - wait_for_completion(&req.done); - - kfree(tmp); - - return req.err; + return devtmpfs_submit_req(&req, tmp); } int devtmpfs_delete_node(struct device *dev) @@ -143,18 +148,7 @@ int devtmpfs_delete_node(struct device *dev) req.mode = 0; req.dev = dev; - init_completion(&req.done); - - spin_lock(&req_lock); - req.next = requests; - requests = &req; - spin_unlock(&req_lock); - - wake_up_process(thread); - wait_for_completion(&req.done); - - kfree(tmp); - return req.err; + return devtmpfs_submit_req(&req, tmp); } static int dev_mkdir(const char *name, umode_t mode) -- 2.23.0