Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp9332970imu; Wed, 5 Dec 2018 03:07:20 -0800 (PST) X-Google-Smtp-Source: AFSGD/UkIUZzLvPb9UJo+DFyGzIaEQccLLQhwOS3KFM28LVgM32YAEXAzKDAULCgku9+o8xRC95w X-Received: by 2002:a63:4926:: with SMTP id w38mr19254840pga.353.1544008040421; Wed, 05 Dec 2018 03:07:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544008040; cv=none; d=google.com; s=arc-20160816; b=xMQRkGTNzknmNlQAXU1O5RQEYh6PmbH6YNIvJN9/iSt4i75ar4zPDoJxsIgy3j4AvF VlnFXmqjkwsX7o854CqzYA6CRY9Zutc+GTQDdqdM3hrMOVAsARRCtCoQODw0/hXpNGh7 MTh7s/cx2Xt6JSWPQqQXuznXaOKv5qAHEoIsCnmOUOQMWTqbXRJuiP/JbtcOFWlaXgDZ oiq28fUvL0LjvIT8BZ29voF5oRi4bVi5ZQF5CCOJ/qU7xfkmxpRbUWTRK2l/fq5Zd0ri BcRH0nVZwItuDZQj2RVUM8BvR7mmECRBfux9rapr0SQxTf0no3nnnJ0FMC3PHSwoo8/Z ZwrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:dkim-filter; bh=+yODvpKS+IjtP5C3l9bjxJQaM/H7qM675yl9hgAMjGM=; b=ocHZyawIHXeD0bNmsWbXAr03th9w+RDT+sSIDSS4T+5nO0okxvgdQnRsjZ0X6lHnJl TIKRlbQaQfXfYhCk6/7AV4pV1ngxbmtr/ccVWUY7HQCSyDh9EMsA3QmqldxXtS7ejmUm 8vTxk24U6NeO0S4LPmW9/PQMiqWz4aSfl8NFqi2coaroRmGqkOwnnhKc6jsZ5nYDkV3b pUGoYFaUZj8BEBbEJgxMNV2/QdvfZxW1QErasO45mBZRwEQ921Cx7Yytzryc7a1md0XD UJX1Hd3jQpIfaCsDBJ7B4f4z6LJ3YHQeh0805LfSUF5FxMkpAK/tT3TsJMc+MKPiuVhK rK5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b="a8+ffV/p"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b21si21262104pfb.89.2018.12.05.03.07.05; Wed, 05 Dec 2018 03:07:20 -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=@samsung.com header.s=mail20170921 header.b="a8+ffV/p"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727510AbeLELGZ (ORCPT + 99 others); Wed, 5 Dec 2018 06:06:25 -0500 Received: from mailout1.w1.samsung.com ([210.118.77.11]:43907 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727419AbeLELGW (ORCPT ); Wed, 5 Dec 2018 06:06:22 -0500 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20181205110621euoutp0147c1a50347cf1f3d70a4d941d0e63adf~taxQrWYJR1413014130euoutp01q for ; Wed, 5 Dec 2018 11:06:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20181205110621euoutp0147c1a50347cf1f3d70a4d941d0e63adf~taxQrWYJR1413014130euoutp01q DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1544007981; bh=+yODvpKS+IjtP5C3l9bjxJQaM/H7qM675yl9hgAMjGM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a8+ffV/ppHjO6/43rWyQAN1cKT/V5V7w28BDRs9OaR1yBHWH+E5en+jLGDbZ03Ho7 wDdWJ6+ejI/8Jo00yrP15ghRQ3kZFVXu76AGIzAHsxTI2H3a0vWaPexunbt7V/eqJX FqjnNvZnEp8fv7TxJRoy9whaSotuvLKUzCf1G3rM= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20181205110620eucas1p15fc4603044966460775702120d240470~taxPMuQFG0437604376eucas1p1L; Wed, 5 Dec 2018 11:06:20 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 6F.F0.04441.B21B70C5; Wed, 5 Dec 2018 11:06:19 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20181205110619eucas1p2eb8553c60b4e23b07c76f02b3867827c~taxOa8Dbz1224412244eucas1p2S; Wed, 5 Dec 2018 11:06:19 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20181205110618eusmtrp2eda2fccddfe42703bc47625d361813ff~taxOK-vWc2724527245eusmtrp2D; Wed, 5 Dec 2018 11:06:18 +0000 (GMT) X-AuditID: cbfec7f2-a1ae89c000001159-7b-5c07b12b1336 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id B1.72.04128.A21B70C5; Wed, 5 Dec 2018 11:06:18 +0000 (GMT) Received: from AMDC3778.DIGITAL.local (unknown [106.120.51.20]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20181205110617eusmtip1b23623fc41618750d47a1122514b8060~taxNS0R-D2482424824eusmtip1B; Wed, 5 Dec 2018 11:06:17 +0000 (GMT) From: Lukasz Luba To: linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org Cc: tjakobi@math.uni-bielefeld.de, myungjoo.ham@samsung.com, kyungmin.park@samsung.com, cw00.choi@samsung.com, rjw@rjwysocki.net, len.brown@intel.com, pavel@ucw.cz, gregkh@linuxfoundation.org, keescook@chromium.org, anton@enomsg.org, ccross@android.com, tony.luck@intel.com, robh+dt@kernel.org, mark.rutland@arm.com, kgene@kernel.org, krzk@kernel.org, m.szyprowski@samsung.com, b.zolnierkie@samsung.com, Lukasz Luba Subject: [PATCH v3 1/5] devfreq: refactor set_target frequency function Date: Wed, 5 Dec 2018 12:05:52 +0100 Message-Id: <1544007956-28889-2-git-send-email-l.luba@partner.samsung.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1544007956-28889-1-git-send-email-l.luba@partner.samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA0WSe2xLYRjGfef0XNboctTYm1lImhC12BCLL4hLIhxEiPDPzKXsmMU69OiY CTWms9m6zKZsbKJk1ZVZzVSVpbOtZmY3lyFucYu6hM2ISTY7TvHf73ve532f9/vysaT6BxXB JqVsFwwpumQNrVTUNP5snRhVxcRPulgRg32XtbjqWCWFr1R9p/DDb+8oXFZ/l8L7bZU0vpOj x5ZXH0jc2nqRwS0ZHxn82BSJiwuvE9j16gGFOz0naNyTW4/wsdYbBD5f/5TBZx+2E/jJPjuN n95uGJzR3EHhzOv1DD5Y8YXCH9ueKeYAX3OthuKdpU7El5jaFXy+pRvxNu97gnc5DtF87Ukn w186s5fvb2R432cvwVffNyv4vGoH4u0VPxi+xzV6WWiccmaCkJyUKhhiZq1Tbvpa1EdsLYOd md0NjAk5w7JRC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+Tv3FVDBfoqL101H2BsY1Il2MHBwSAiYSN3d5djFy cQgJLGWU2Dr7CHMXIydQXExi0r7t7BC2sMSfa11sEEWfGCXu9xxnBWlmE9CT2LGqECQuIrAc KP5zNjuIwyzwgFmi4/kmVpBuYQF3iVfPvjKC2CwCqhJPfy8Am8or4CVxcNIrVogNchI3z3WC beYU8Jbo/r+ODcQWAqqZ2r+caQIj3wJGhlWMIqmlxbnpucVGesWJucWleel6yfm5mxiB8brt 2M8tOxi73gUfYhTgYFTi4ZWYwhYjxJpYVlyZe4hRgoNZSYR3hQ17jBBvSmJlVWpRfnxRaU5q 8SFGU6CjJjJLiSbnA1NJXkm8oamhuYWlobmxubGZhZI473mDyighgfTEktTs1NSC1CKYPiYO TqkGxuMeb9M/FaznkjCX63XX8uqx+3H/15Ea58O6WW3+WfKZ9/nqq7+GXflhn+j5+Yatd+TP Qr33ipmeK9adWXHpotOVA+v5eIu4WkpfrPw7uXnhkVLZjKz/C68cczni4VfxZDOX3q+jmxIE cn/JnAh/8XnjVW39dRxRtcWxxhN17Z8ee9Ba3/+hQYmlOCPRUIu5qDgRAOEdxZbtAgAA X-CMS-MailID: 20181205110619eucas1p2eb8553c60b4e23b07c76f02b3867827c X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20181205110619eucas1p2eb8553c60b4e23b07c76f02b3867827c X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20181205110619eucas1p2eb8553c60b4e23b07c76f02b3867827c References: <1544007956-28889-1-git-send-email-l.luba@partner.samsung.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The refactoring is needed for the new client in devfreq: suspend. To avoid code duplication, move it to the new local function devfreq_set_target. Suggested-by: Tobias Jakobi Suggested-by: Chanwoo Choi Reviewed-by: Chanwoo Choi Signed-off-by: Lukasz Luba --- drivers/devfreq/devfreq.c | 62 +++++++++++++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 26 deletions(-) diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index 1414130..a9fd61b 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -285,6 +285,40 @@ static int devfreq_notify_transition(struct devfreq *devfreq, return 0; } +static int devfreq_set_target(struct devfreq *devfreq, unsigned long new_freq, + u32 flags) +{ + struct devfreq_freqs freqs; + unsigned long cur_freq; + int err = 0; + + if (devfreq->profile->get_cur_freq) + devfreq->profile->get_cur_freq(devfreq->dev.parent, &cur_freq); + else + cur_freq = devfreq->previous_freq; + + freqs.old = cur_freq; + freqs.new = new_freq; + devfreq_notify_transition(devfreq, &freqs, DEVFREQ_PRECHANGE); + + err = devfreq->profile->target(devfreq->dev.parent, &new_freq, flags); + if (err) { + freqs.new = cur_freq; + devfreq_notify_transition(devfreq, &freqs, DEVFREQ_POSTCHANGE); + return err; + } + + freqs.new = new_freq; + devfreq_notify_transition(devfreq, &freqs, DEVFREQ_POSTCHANGE); + + if (devfreq_update_status(devfreq, new_freq)) + dev_err(&devfreq->dev, + "Couldn't update frequency transition information.\n"); + + devfreq->previous_freq = new_freq; + return err; +} + /* Load monitoring helper functions for governors use */ /** @@ -296,8 +330,7 @@ static int devfreq_notify_transition(struct devfreq *devfreq, */ int update_devfreq(struct devfreq *devfreq) { - struct devfreq_freqs freqs; - unsigned long freq, cur_freq, min_freq, max_freq; + unsigned long freq, min_freq, max_freq; int err = 0; u32 flags = 0; @@ -333,31 +366,8 @@ int update_devfreq(struct devfreq *devfreq) flags |= DEVFREQ_FLAG_LEAST_UPPER_BOUND; /* Use LUB */ } - if (devfreq->profile->get_cur_freq) - devfreq->profile->get_cur_freq(devfreq->dev.parent, &cur_freq); - else - cur_freq = devfreq->previous_freq; - - freqs.old = cur_freq; - freqs.new = freq; - devfreq_notify_transition(devfreq, &freqs, DEVFREQ_PRECHANGE); + return devfreq_set_target(devfreq, freq, flags); - err = devfreq->profile->target(devfreq->dev.parent, &freq, flags); - if (err) { - freqs.new = cur_freq; - devfreq_notify_transition(devfreq, &freqs, DEVFREQ_POSTCHANGE); - return err; - } - - freqs.new = freq; - devfreq_notify_transition(devfreq, &freqs, DEVFREQ_POSTCHANGE); - - if (devfreq_update_status(devfreq, freq)) - dev_err(&devfreq->dev, - "Couldn't update frequency transition information.\n"); - - devfreq->previous_freq = freq; - return err; } EXPORT_SYMBOL(update_devfreq); -- 2.7.4