From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.4 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51956C432C1 for ; Wed, 25 Sep 2019 05:44:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 13DEF21D7C for ; Wed, 25 Sep 2019 05:44:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="HwblHVWg" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2411779AbfIYFom (ORCPT ); Wed, 25 Sep 2019 01:44:42 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:49276 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404508AbfIYFom (ORCPT ); Wed, 25 Sep 2019 01:44:42 -0400 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20190925054438euoutp0150827e99ef6880724deda8e42d75116d~HmCTHqMpD0515305153euoutp01r for ; Wed, 25 Sep 2019 05:44:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20190925054438euoutp0150827e99ef6880724deda8e42d75116d~HmCTHqMpD0515305153euoutp01r DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1569390278; bh=kYIVoeIsDZViEyQtoAUGXK4fxaz0KwTD7EylbtIhnqY=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=HwblHVWgUg45oQOao8CkgXOzQ0d3qfnEH2faJeR9CDcI4CjKwA/dttL96cTe6Rm4A j1o2vCrh7CPq7ItV/XPN5BZbfLceIi6icRdzMCBKRMYIwyrsBsJlqSkC3a3XnpPHH7 3ACNyBLlUD6I7UhJ4s5uydXnPDXtrNJdFxVm2FH0= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20190925054437eucas1p108c8908cb95482cff91297ba3fa5a2e2~HmCRwrvU62405424054eucas1p15; Wed, 25 Sep 2019 05:44:37 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id A8.80.04469.5CEFA8D5; Wed, 25 Sep 2019 06:44:37 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20190925054437eucas1p1faa58a48a75c43fd5b5c7424e3d658e7~HmCRdetQF1488914889eucas1p1b; Wed, 25 Sep 2019 05:44:37 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20190925054437eusmtrp12dae90d5d9dd472b8fbea5f7cbab0880~HmCRcM_cn1789117891eusmtrp1F; Wed, 25 Sep 2019 05:44:37 +0000 (GMT) X-AuditID: cbfec7f2-54fff70000001175-b2-5d8afec5d574 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id A6.64.04117.4CEFA8D5; Wed, 25 Sep 2019 06:44:36 +0100 (BST) Received: from AMDC3555 (unknown [106.120.51.67]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20190925054436eusmtip11d852d14d1080b152186c05430a580ba~HmCQp4U1h2516225162eusmtip1Z; Wed, 25 Sep 2019 05:44:36 +0000 (GMT) Message-ID: Subject: Re: [RFC PATCH v2 01/11] devfreq: exynos-bus: Extract exynos_bus_profile_init() From: Artur =?UTF-8?Q?=C5=9Awigo=C5=84?= To: Chanwoo Choi , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, dri-devel@lists.freedesktop.org Cc: Artur =?UTF-8?Q?=C5=9Awigo=C5=84?= , myungjoo.ham@samsung.com, inki.dae@samsung.com, sw0312.kim@samsung.com, georgi.djakov@linaro.org, leonard.crestez@nxp.com, m.szyprowski@samsung.com, b.zolnierkie@samsung.com, krzk@kernel.org Date: Wed, 25 Sep 2019 07:44:35 +0200 In-Reply-To: <2e49bd2c-e074-038b-f8a2-7dd8dea4a9af@samsung.com> X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.1 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA01Sa0hTYRju29k5O0qzr2n4UlI4qCgqEypOVFYUcaB+SPmrqytPOtym7aip QS27UCuXTUubXU1KDSnnLJUuNJdLJVdpVl5QnCZaaWtqRddtZ2L/nvc5z+V74NCE7CU5k1Zq UjitRqGSU4Hi+/U/HIuf/dHvWvpJD0z31ROIqSi4SzJvRwdI5pqtmWRax0YoJv+RmWKM3Tli xuG4J2FKulwkY3a2kUxL7WWKcWfbEFPgeCxiym1dEqbjaAnFFOQOUusway47TbGdbQ8ptvuM XcRWFh9hK4arRazBUoZYt3l2tGR74Oo4TqVM47QRUbGBCeO9ODmfTa/vKiF1qGilHgXQgJdB 7vBtkR4F0jJcguDh+Y+kcIwisOQ1IK9Kht0IdEWSCUejxeEX3UZQ1P9LIhwfEPS4q3wOKWah uFZHeHEw3g7NXS4fpvBaeNEx7usLwcMI+p58IbwHgY+LYMA0JPaqxHgumJ898PUFeBxljlZK 6F4EnxsNH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ch6ZiFUDULSdUCRuZVjCKppcW56bnFRnrFibnF pXnpesn5uZsYgfG67djPLTsYu94FH2IU4GBU4uF1YO2KFWJNLCuuzD3EKMHBrCTCO0sGKMSb klhZlVqUH19UmpNafIjRFOificxSosn5wFSSVxJvaGpobmFpaG5sbmxmoSTO2yFwMEZIID2x JDU7NbUgtQimj4mDU6qB0bXZWSdMPKdE+vrT8wpn3jTNuWa487DI/efcW0+wWjaz3735U9x0 76WHks9nrPv1X85rSv+SC9pVCsdPT3BfqJR4N2HGsZeTQ1eyH4u/oezQeyhjYeL9xnuTn+za 1re8Q2+tqRmzTNAfL6ePzGGxr+IXxCSEaXu0ms4/wforbMOFTK4zOS/12JVYijMSDbWYi4oT ARfkJE7tAgAA X-CMS-MailID: 20190925054437eucas1p1faa58a48a75c43fd5b5c7424e3d658e7 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20190919142322eucas1p24bc477ee6e1bcd65546c305d55af097d X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20190919142322eucas1p24bc477ee6e1bcd65546c305d55af097d References: <20190919142236.4071-1-a.swigon@samsung.com> <20190919142236.4071-2-a.swigon@samsung.com> <2e49bd2c-e074-038b-f8a2-7dd8dea4a9af@samsung.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Fri, 2019-09-20 at 11:15 +0900, Chanwoo Choi wrote: > Hi, > > As I already replied on v1, patch1/2/3 clean-up code > for readability without any behavior changes. > > I think that you better to merge patch1/2/3 to one patch. Yes, when writing the cover letter I think I forgot to explain why I decided not to merge these patches. Basically, none of the diff algorithms available in git (I've got v2.17.1) is able to produce a readable patch with these changes combined together into a single patch (functions are intermixed together in the output, git thinks that 'exynos_bus_probe' is a new function). Please take a look at the diff at the bottom of this message to see how patches 01..03 look when combined. If such patch looks acceptable to you, I can merge. > On 19. 9. 19. 오후 11:22, Artur Świgoń wrote: > > From: Artur Świgoń > > > > This patch adds a new static function, exynos_bus_profile_init(), extracted > > from exynos_bus_probe(). > > > > Signed-off-by: Artur Świgoń > > --- > > drivers/devfreq/exynos-bus.c | 92 +++++++++++++++++++++--------------- > > 1 file changed, 53 insertions(+), 39 deletions(-) > > > > diff --git a/drivers/devfreq/exynos-bus.c b/drivers/devfreq/exynos-bus.c > > index 29f422469960..78f38b7fb596 100644 > > --- a/drivers/devfreq/exynos-bus.c > > +++ b/drivers/devfreq/exynos-bus.c > > @@ -287,12 +287,62 @@ static int exynos_bus_parse_of(struct device_node *np, > > return ret; > > } > > > > +static int exynos_bus_profile_init(struct exynos_bus *bus, > > + struct devfreq_dev_profile *profile) > > +{ > > + struct device *dev = bus->dev; > > + struct devfreq_simple_ondemand_data *ondemand_data; > > + int ret; > > + > > + /* Initialize the struct profile and governor data for parent device */ > > + profile->polling_ms = 50; > > + profile->target = exynos_bus_target; > > + profile->get_dev_status = exynos_bus_get_dev_status; > > + profile->exit = exynos_bus_exit; > > + > > + ondemand_data = devm_kzalloc(dev, sizeof(*ondemand_data), GFP_KERNEL); > > + if (!ondemand_data) { > > + ret = -ENOMEM; > > + goto err; > > + } > > + ondemand_data->upthreshold = 40; > > + ondemand_data->downdifferential = 5; > > + > > + /* Add devfreq device to monitor and handle the exynos bus */ > > + bus->devfreq = devm_devfreq_add_device(dev, profile, > > + DEVFREQ_GOV_SIMPLE_ONDEMAND, > > + ondemand_data); > > + if (IS_ERR(bus->devfreq)) { > > + dev_err(dev, "failed to add devfreq device\n"); > > + ret = PTR_ERR(bus->devfreq); > > + goto err; > > + } > > + > > + /* > > + * Enable devfreq-event to get raw data which is used to determine > > + * current bus load. > > + */ > > + ret = exynos_bus_enable_edev(bus); > > + if (ret < 0) { > > + dev_err(dev, "failed to enable devfreq-event devices\n"); > > + goto err; > > + } > > + > > + ret = exynos_bus_set_event(bus); > > + if (ret < 0) { > > + dev_err(dev, "failed to set event to devfreq-event devices\n"); > > + goto err; > > + } > > + > > +err: > > + return ret; > > +} > > + > > static int exynos_bus_probe(struct platform_device *pdev) > > { > > struct device *dev = &pdev->dev; > > struct device_node *np = dev->of_node, *node; > > struct devfreq_dev_profile *profile; > > - struct devfreq_simple_ondemand_data *ondemand_data; > > struct devfreq_passive_data *passive_data; > > struct devfreq *parent_devfreq; > > struct exynos_bus *bus; > > @@ -334,45 +384,9 @@ static int exynos_bus_probe(struct platform_device *pdev) > > if (passive) > > goto passive; > > > > - /* Initialize the struct profile and governor data for parent device */ > > - profile->polling_ms = 50; > > - profile->target = exynos_bus_target; > > - profile->get_dev_status = exynos_bus_get_dev_status; > > - profile->exit = exynos_bus_exit; > > - > > - ondemand_data = devm_kzalloc(dev, sizeof(*ondemand_data), GFP_KERNEL); > > - if (!ondemand_data) { > > - ret = -ENOMEM; > > + ret = exynos_bus_profile_init(bus, profile); > > + if (ret < 0) > > goto err; > > - } > > - ondemand_data->upthreshold = 40; > > - ondemand_data->downdifferential = 5; > > - > > - /* Add devfreq device to monitor and handle the exynos bus */ > > - bus->devfreq = devm_devfreq_add_device(dev, profile, > > - DEVFREQ_GOV_SIMPLE_ONDEMAND, > > - ondemand_data); > > - if (IS_ERR(bus->devfreq)) { > > - dev_err(dev, "failed to add devfreq device\n"); > > - ret = PTR_ERR(bus->devfreq); > > - goto err; > > - } > > - > > - /* > > - * Enable devfreq-event to get raw data which is used to determine > > - * current bus load. > > - */ > > - ret = exynos_bus_enable_edev(bus); > > - if (ret < 0) { > > - dev_err(dev, "failed to enable devfreq-event devices\n"); > > - goto err; > > - } > > - > > - ret = exynos_bus_set_event(bus); > > - if (ret < 0) { > > - dev_err(dev, "failed to set event to devfreq-event devices\n"); > > - goto err; > > - } > > > > goto out; > > passive: commit cacf8e4ea0e111908d11779977c81e29d6418801 Author: Artur Świgoń Date: Tue Aug 27 13:17:28 2019 +0200 tmp: merge patches 01-03 Signed-off-by: Artur Świgoń diff --git a/drivers/devfreq/exynos-bus.c b/drivers/devfreq/exynos-bus.c index 29f422469960..60ad4319fd80 100644 --- a/drivers/devfreq/exynos-bus.c +++ b/drivers/devfreq/exynos-bus.c @@ -287,52 +287,12 @@ static int exynos_bus_parse_of(struct device_node *np, return ret; } -static int exynos_bus_probe(struct platform_device *pdev) +static int exynos_bus_profile_init(struct exynos_bus *bus, + struct devfreq_dev_profile *profile) { - struct device *dev = &pdev->dev; - struct device_node *np = dev->of_node, *node; - struct devfreq_dev_profile *profile; + struct device *dev = bus->dev; struct devfreq_simple_ondemand_data *ondemand_data; - struct devfreq_passive_data *passive_data; - struct devfreq *parent_devfreq; - struct exynos_bus *bus; - int ret, max_state; - unsigned long min_freq, max_freq; - bool passive = false; - - if (!np) { - dev_err(dev, "failed to find devicetree node\n"); - return -EINVAL; - } - - bus = devm_kzalloc(&pdev->dev, sizeof(*bus), GFP_KERNEL); - if (!bus) - return -ENOMEM; - mutex_init(&bus->lock); - bus->dev = &pdev->dev; - platform_set_drvdata(pdev, bus); - - profile = devm_kzalloc(dev, sizeof(*profile), GFP_KERNEL); - if (!profile) - return -ENOMEM; - - node = of_parse_phandle(dev->of_node, "devfreq", 0); - if (node) { - of_node_put(node); - passive = true; - } else { - ret = exynos_bus_parent_parse_of(np, bus); - if (ret < 0) - return ret; - } - - /* Parse the device-tree to get the resource information */ - ret = exynos_bus_parse_of(np, bus); - if (ret < 0) - goto err_reg; - - if (passive) - goto passive; + int ret; /* Initialize the struct profile and governor data for parent device */ profile->polling_ms = 50; @@ -374,8 +334,18 @@ static int exynos_bus_probe(struct platform_device *pdev) goto err; } - goto out; -passive: +err: + return ret; +} + +static int exynos_bus_profile_init_passive(struct exynos_bus *bus, + struct devfreq_dev_profile *profile) +{ + 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; profile->exit = exynos_bus_passive_exit; @@ -404,7 +374,59 @@ static int exynos_bus_probe(struct platform_device *pdev) goto err; } -out: +err: + return ret; +} + +static int exynos_bus_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct device_node *np = dev->of_node, *node; + struct devfreq_dev_profile *profile; + struct exynos_bus *bus; + int ret, max_state; + unsigned long min_freq, max_freq; + bool passive = false; + + if (!np) { + dev_err(dev, "failed to find devicetree node\n"); + return -EINVAL; + } + + bus = devm_kzalloc(&pdev->dev, sizeof(*bus), GFP_KERNEL); + if (!bus) + return -ENOMEM; + mutex_init(&bus->lock); + bus->dev = &pdev->dev; + platform_set_drvdata(pdev, bus); + + profile = devm_kzalloc(dev, sizeof(*profile), GFP_KERNEL); + if (!profile) + return -ENOMEM; + + node = of_parse_phandle(dev->of_node, "devfreq", 0); + if (node) { + of_node_put(node); + passive = true; + } else { + ret = exynos_bus_parent_parse_of(np, bus); + if (ret < 0) + return ret; + } + + /* Parse the device-tree to get the resource information */ + ret = exynos_bus_parse_of(np, bus); + if (ret < 0) + goto err_reg; + + if (passive) + ret = exynos_bus_profile_init_passive(bus, profile); + else + ret = exynos_bus_profile_init(bus, profile); + + if (ret < 0) + goto err; + 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);