From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753446AbcAGQHh (ORCPT ); Thu, 7 Jan 2016 11:07:37 -0500 Received: from mail-qk0-f177.google.com ([209.85.220.177]:34165 "EHLO mail-qk0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751534AbcAGQHg (ORCPT ); Thu, 7 Jan 2016 11:07:36 -0500 Date: Thu, 7 Jan 2016 11:07:32 -0500 From: Tejun Heo To: wanghaibin Cc: linux-kernel@vger.kernel.org, jiangshanlai@gmail.com, peter.huangpeng@huawei.com Subject: [RFC PATCH 4/4] workqueue: simplify the apply_workqueue_attrs_locked function. Message-ID: <20160107160732.GD1898@mtj.duckdns.org> References: <1452170339-26748-1-git-send-email-wanghaibin.wang@huawei.com> <1452170339-26748-5-git-send-email-wanghaibin.wang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1452170339-26748-5-git-send-email-wanghaibin.wang@huawei.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, Applied to wq/for-4.5 with some adjustments to patch title description. Thanks. ------ 8< ------ >>From 6201171e3b2c02992e62448636631a0dfe4e9d20 Mon Sep 17 00:00:00 2001 From: wanghaibin Date: Thu, 7 Jan 2016 20:38:59 +0800 Subject: [PATCH] workqueue: simplify the apply_workqueue_attrs_locked() If the apply_wqattrs_prepare() returns NULL, it has already cleaned up the related resources, so it can return directly and avoid calling the clean up function again. This doesn't introduce any functional changes. Signed-off-by: wanghaibin Signed-off-by: Tejun Heo --- kernel/workqueue.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 1ecb588..61a0264 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -3651,7 +3651,6 @@ static int apply_workqueue_attrs_locked(struct workqueue_struct *wq, const struct workqueue_attrs *attrs) { struct apply_wqattrs_ctx *ctx; - int ret = -ENOMEM; /* only unbound workqueues can change attributes */ if (WARN_ON(!(wq->flags & WQ_UNBOUND))) @@ -3662,16 +3661,14 @@ static int apply_workqueue_attrs_locked(struct workqueue_struct *wq, return -EINVAL; ctx = apply_wqattrs_prepare(wq, attrs); + if (!ctx) + return -ENOMEM; /* the ctx has been prepared successfully, let's commit it */ - if (ctx) { - apply_wqattrs_commit(ctx); - ret = 0; - } - + apply_wqattrs_commit(ctx); apply_wqattrs_cleanup(ctx); - return ret; + return 0; } /** -- 2.5.0