From patchwork Mon Dec 16 10:47:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?QXJ0dXIgxZp3aWdvxYQ=?= X-Patchwork-Id: 11293765 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 17D1B139A for ; Mon, 16 Dec 2019 10:48:26 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E0907207FF for ; Mon, 16 Dec 2019 10:48:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="bbnY/HRa"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="g5VB92M6" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E0907207FF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=samsung.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:References:MIME-Version:Message-Id:Date :Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: List-Owner; bh=njfcS9GPGYUf9K53hifZ1uUOS6WAz5WSaCIZe8StMUE=; b=bbnY/HRa2Xvj2y LBkam0eBPXFvJy49tb7Csj8dFDZzognzN67W3hLvm8TTpfzKxen/KojpPJNm2EcVJDlFWhQeq4gZ8 WctQ8SHx22r8nD+upz3MrvHxBd5dVAN4+QQ34nCRGzTrcZgc1/JRRKFJkjVU4yWTahKUWkvwQzDPl GFTBymlioyI9HG7Wjty4PgokL86PUmWkY8rOfDoyjtxiknB4xCm2t1yO0pJmE2lc/jHQTFNeFmYmS sMgYVzW8fIUmbbEqEzx7Kl+9a7J2SYncevprdpRQ2PMdmnzE9hdt5ItadzzGHEWRjXhzDmA52coPz KEQHC3QV/U8f+NGxoH3g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ignvK-00064T-Mx; Mon, 16 Dec 2019 10:48:22 +0000 Received: from mailout1.w1.samsung.com ([210.118.77.11]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ignvH-00063E-7u for linux-arm-kernel@lists.infradead.org; Mon, 16 Dec 2019 10:48:21 +0000 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20191216104817euoutp01f6f6887c8159af0fc991ce0f26459587~g1E0f71kU1684116841euoutp01c for ; Mon, 16 Dec 2019 10:48:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20191216104817euoutp01f6f6887c8159af0fc991ce0f26459587~g1E0f71kU1684116841euoutp01c DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1576493297; bh=O6pcI0nl3cOacuyyeqkh+QDKkG1plk0wyzWw1uJR2cE=; h=From:To:Cc:Subject:Date:References:From; b=g5VB92M6Z/Gb0NzDoxraG1SidA2yRFf6Z13SC4rK9w/JX8I/lJkw+1R9n7dGDNrjt pZkek2PjXcTrpwA56TCD9tKGMggwkHKZQ43RqO+CdMY+EJRi0o8car0nfgJMgOKwaB UlFJ9mb35RFQvSheB4N81/i0JDToq35rtR+9lCbg= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20191216104817eucas1p13ae3217a6d97b3a7d1cab1c2fe4cb125~g1E0Qi9FP2735027350eucas1p1S; Mon, 16 Dec 2019 10:48:17 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 51.A3.60679.0F067FD5; Mon, 16 Dec 2019 10:48:16 +0000 (GMT) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20191216104816eucas1p1775a0dac98f507e10ee2fa15dccdc216~g1Ez4YgmL1561015610eucas1p19; Mon, 16 Dec 2019 10:48:16 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20191216104816eusmtrp11c9a18d77c49ef7645a8040290858ebc~g1Ez3laSb1051110511eusmtrp1f; Mon, 16 Dec 2019 10:48:16 +0000 (GMT) X-AuditID: cbfec7f4-0e5ff7000001ed07-86-5df760f096b7 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 79.EF.08375.0F067FD5; Mon, 16 Dec 2019 10:48:16 +0000 (GMT) Received: from AMDC3555.digital.local (unknown [106.120.51.67]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20191216104815eusmtip167d0578b820b91814462f43866d8600d~g1EzJV3692559025590eusmtip1H; Mon, 16 Dec 2019 10:48:15 +0000 (GMT) From: =?utf-8?b?QXJ0dXIgxZp3aWdvxYQ=?= To: linux-pm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] PM / devfreq: exynos-bus: Reduce the numer of goto statements and remove unused headers Date: Mon, 16 Dec 2019 11:47:48 +0100 Message-Id: <20191216104748.18877-1-a.swigon@samsung.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrJKsWRmVeSWpSXmKPExsWy7djP87ofEr7HGixaZGNxf14ro8XGGetZ La5/ec5qMen+BBaL/sevmS3On9/AbnG26Q27xabH11gtLu+aw2bxufcIo8WM8/uYLNYeuctu cbtxBZvFjMkv2Rz4PDat6mTz2Lyk3qNvyypGj8+b5AJYorhsUlJzMstSi/TtErgyvrXnFJxU rti48QhjA+MmmS5GTg4JAROJAzf2s4LYQgIrGCUuPFPuYuQCsr8wSnz/95QRwvnMKLHgzDZ2 mI7l35pYIRLLGSW6W1qY4Vp6H99jBKliE3CUmDT1AViHiEAro8TMJnUQm1lgGpPExt0OILaw QK7Eg57FTCA2i4CqxIHbc1lAbF4BS4lZM6ayQWyTl1i94QAzRFxQ4uTMJywQc+QlmrfOBlss IbCNXeJnazsLRIOLxKRlL6CahSVeHd8CdbaMxOnJPVA1xRJPd95nhWhuYJTYtOwIM0TCWuLw 8YtACQ6gDZoS63fpQ4QdJbb1dICFJQT4JG68FYS4gU9i0rbpzBBhXomONiEIU0li10w+iEYJ iabV16Bme0jc3zcPGtKxEme2vGeewKgwC8ljs5A8NgvhhAWMzKsYxVNLi3PTU4uN8lLL9YoT c4tL89L1kvNzNzECE9Tpf8e/7GDc9SfpEKMAB6MSD69D9rdYIdbEsuLK3EOMEhzMSiK8OxS+ xwrxpiRWVqUW5ccXleakFh9ilOZgURLnNV70MlZIID2xJDU7NbUgtQgmy8TBKdXAGG5tIFFh f0RSJOK/x/U4C7fYTXy71sgH9i87N1cl/vr6pf4Tj/wO1tnxaZPBm4IFXyeqsxn93d3zamvr 9raV8583Jp5wX6WeeVgt12W5EWd+wbqJfcvttMPFU1i9dq7SiF39PHQnx8/nd5122fKz1dwx n9/0UPecWbeIu7N1W6dv0bfmpt97lViKMxINtZiLihMBYDVeFkwDAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrJIsWRmVeSWpSXmKPExsVy+t/xu7ofEr7HGqw9rWhxf14ro8XGGetZ La5/ec5qMen+BBaL/sevmS3On9/AbnG26Q27xabH11gtLu+aw2bxufcIo8WM8/uYLNYeuctu cbtxBZvFjMkv2Rz4PDat6mTz2Lyk3qNvyypGj8+b5AJYovRsivJLS1IVMvKLS2yVog0tjPQM LS30jEws9QyNzWOtjEyV9O1sUlJzMstSi/TtEvQyvrXnFJxUrti48QhjA+MmmS5GTg4JAROJ 5d+aWLsYuTiEBJYySsz/fY8RIiEh8XH9DVYIW1jiz7UuNoiiT4wSn44fACtiE3CUmDT1ATtI QkSgk1Gia/M5JhCHWWARk0TDxydMIFXCAtkSh74dYgGxWQRUJQ7cngtm8wpYSsyaMZUNYoW8 xOoNB5gh4oISJ2c+AarhABqkLrF+nhBImBmopHnrbOYJjPyzkFTNQqiahaRqASPzKkaR1NLi 3PTcYkO94sTc4tK8dL3k/NxNjMBo2nbs5+YdjJc2Bh9iFOBgVOLhdcj+FivEmlhWXJl7iFGC g1lJhHeHwvdYId6UxMqq1KL8+KLSnNTiQ4ymQC9MZJYSTc4HRnpeSbyhqaG5haWhubG5sZmF kjhvh8DBGCGB9MSS1OzU1ILUIpg+Jg5OqQbGllyW4if8za/PhBYvMzMLOSy1Lk9pL0tCh+mm D8/+26qrn+T5fDUp4KQmW7F0/J4JjXNnaOa2LZvEcfvTu187lI0CtQ9YGZfFz7wYcsAlXKn8 ggTL3oIeGUGj/OS5HB95dWddndkmdaA871vx1K+nQ4/MrFo6VcHvmbC+qhePlfMf9y6RY3eU WIozEg21mIuKEwGyNPL6vAIAAA== X-CMS-MailID: 20191216104816eucas1p1775a0dac98f507e10ee2fa15dccdc216 X-Msg-Generator: CA X-RootMTR: 20191216104816eucas1p1775a0dac98f507e10ee2fa15dccdc216 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20191216104816eucas1p1775a0dac98f507e10ee2fa15dccdc216 References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191216_024819_490621_13E9C519 X-CRM114-Status: GOOD ( 16.56 ) X-Spam-Score: -5.2 (-----) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-5.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at https://www.dnswl.org/, high trust [210.118.77.11 listed in list.dnswl.org] 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [210.118.77.11 listed in wl.mailspike.net] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: b.zolnierkie@samsung.com, sw0312.kim@samsung.com, =?utf-8?b?QXJ0dXIgxZp3?= =?utf-8?b?aWdvxYQ=?= , krzk@kernel.org, inki.dae@samsung.com, cw00.choi@samsung.com, kyungmin.park@samsung.com, kgene@kernel.org, myungjoo.ham@samsung.com, m.szyprowski@samsung.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org This patch improves code readability by changing the following construct: if (cond) goto passive; foo(); goto out; passive: bar(); out: into this: if (cond) bar(); else foo(); as well as eliminating a few more goto statements (related to return paths). Moreover, this patch removes unused header file includes and adds a missing include . Signed-off-by: Artur Świgoń --- drivers/devfreq/exynos-bus.c | 54 +++++++++++++----------------------- 1 file changed, 19 insertions(+), 35 deletions(-) diff --git a/drivers/devfreq/exynos-bus.c b/drivers/devfreq/exynos-bus.c index 19d9f9f8ced2..7f5917d59072 100644 --- a/drivers/devfreq/exynos-bus.c +++ b/drivers/devfreq/exynos-bus.c @@ -15,11 +15,10 @@ #include #include #include -#include +#include #include #include #include -#include #define DEFAULT_SATURATION_RATIO 40 @@ -301,10 +300,9 @@ static int exynos_bus_profile_init(struct exynos_bus *bus, profile->exit = exynos_bus_exit; ondemand_data = devm_kzalloc(dev, sizeof(*ondemand_data), GFP_KERNEL); - if (!ondemand_data) { - ret = -ENOMEM; - goto err; - } + if (!ondemand_data) + return -ENOMEM; + ondemand_data->upthreshold = 40; ondemand_data->downdifferential = 5; @@ -314,15 +312,14 @@ static int exynos_bus_profile_init(struct exynos_bus *bus, ondemand_data); if (IS_ERR(bus->devfreq)) { dev_err(dev, "failed to add devfreq device\n"); - ret = PTR_ERR(bus->devfreq); - goto err; + return PTR_ERR(bus->devfreq); } /* Register opp_notifier to catch the change of OPP */ ret = devm_devfreq_register_opp_notifier(dev, bus->devfreq); if (ret < 0) { dev_err(dev, "failed to register opp notifier\n"); - goto err; + return ret; } /* @@ -332,17 +329,16 @@ static int exynos_bus_profile_init(struct exynos_bus *bus, ret = exynos_bus_enable_edev(bus); if (ret < 0) { dev_err(dev, "failed to enable devfreq-event devices\n"); - goto err; + return ret; } ret = exynos_bus_set_event(bus); if (ret < 0) { dev_err(dev, "failed to set event to devfreq-event devices\n"); - goto err; + return ret; } -err: - return ret; + return 0; } static int exynos_bus_profile_init_passive(struct exynos_bus *bus, @@ -351,7 +347,6 @@ static int exynos_bus_profile_init_passive(struct exynos_bus *bus, struct device *dev = bus->dev; struct devfreq_passive_data *passive_data; struct devfreq *parent_devfreq; - int ret = 0; /* Initialize the struct profile and governor data for passive device */ profile->target = exynos_bus_target; @@ -359,16 +354,13 @@ static int exynos_bus_profile_init_passive(struct exynos_bus *bus, /* Get the instance of parent devfreq device */ parent_devfreq = devfreq_get_devfreq_by_phandle(dev, 0); - if (IS_ERR(parent_devfreq)) { - ret = -EPROBE_DEFER; - goto err; - } + if (IS_ERR(parent_devfreq)) + return -EPROBE_DEFER; passive_data = devm_kzalloc(dev, sizeof(*passive_data), GFP_KERNEL); - if (!passive_data) { - ret = -ENOMEM; - goto err; - } + if (!passive_data) + return -ENOMEM; + passive_data->parent = parent_devfreq; /* Add devfreq device for exynos bus with passive governor */ @@ -377,12 +369,10 @@ static int exynos_bus_profile_init_passive(struct exynos_bus *bus, if (IS_ERR(bus->devfreq)) { dev_err(dev, "failed to add devfreq dev with passive governor\n"); - ret = PTR_ERR(bus->devfreq); - goto err; + return PTR_ERR(bus->devfreq); } -err: - return ret; + return 0; } static int exynos_bus_probe(struct platform_device *pdev) @@ -427,19 +417,13 @@ static int exynos_bus_probe(struct platform_device *pdev) goto err_reg; if (passive) - goto passive; - - ret = exynos_bus_profile_init(bus, profile); - if (ret < 0) - goto err; + ret = exynos_bus_profile_init_passive(bus, profile); + else + ret = exynos_bus_profile_init(bus, profile); - goto out; -passive: - ret = exynos_bus_profile_init_passive(bus, profile); if (ret < 0) goto err; -out: max_state = bus->devfreq->profile->max_state; min_freq = (bus->devfreq->profile->freq_table[0] / 1000); max_freq = (bus->devfreq->profile->freq_table[max_state - 1] / 1000);