From patchwork Wed Mar 21 02:54:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aisheng Dong X-Patchwork-Id: 10298895 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A9112600F6 for ; Wed, 21 Mar 2018 07:56:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 99F162973D for ; Wed, 21 Mar 2018 07:56:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8E3D929742; Wed, 21 Mar 2018 07:56:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EBCAE2973D for ; Wed, 21 Mar 2018 07:56:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751676AbeCUHzv (ORCPT ); Wed, 21 Mar 2018 03:55:51 -0400 Received: from mail-bl2nam02on0041.outbound.protection.outlook.com ([104.47.38.41]:12512 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751626AbeCUHzr (ORCPT ); Wed, 21 Mar 2018 03:55:47 -0400 Received: from BN6PR03CA0061.namprd03.prod.outlook.com (2603:10b6:404:4c::23) by MWHPR03MB2767.namprd03.prod.outlook.com (2603:10b6:300:48::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.588.14; Wed, 21 Mar 2018 07:55:45 +0000 Received: from BY2FFO11FD006.protection.gbl (2a01:111:f400:7c0c::184) by BN6PR03CA0061.outlook.office365.com (2603:10b6:404:4c::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.609.10 via Frontend Transport; Wed, 21 Mar 2018 07:55:45 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=fail action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BY2FFO11FD006.mail.protection.outlook.com (10.1.14.127) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.527.18 via Frontend Transport; Wed, 21 Mar 2018 07:55:43 +0000 Received: from b29396-OptiPlex-7040.ap.freescale.net (b29396-OptiPlex-7040.ap.freescale.net [10.192.242.1]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id w2L2swcR020357; Tue, 20 Mar 2018 19:55:15 -0700 From: Dong Aisheng To: CC: , , , , , , , , , Dong Aisheng , Stephen Boyd Subject: [PATCH V2 3/4] clk: add managed version of clk_bulk_get_all Date: Wed, 21 Mar 2018 10:54:53 +0800 Message-ID: <1521600894-29919-4-git-send-email-aisheng.dong@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521600894-29919-1-git-send-email-aisheng.dong@nxp.com> References: <1521600894-29919-1-git-send-email-aisheng.dong@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131660925450075236; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:CAL; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(7966004)(346002)(376002)(39380400002)(396003)(39860400002)(2980300002)(1110001)(1109001)(339900001)(189003)(199004)(51416003)(105606002)(356003)(47776003)(77096007)(26005)(36756003)(106466001)(86362001)(305945005)(85426001)(336012)(76176011)(5660300001)(26826003)(54906003)(16586007)(104016004)(6666003)(508600001)(6916009)(2950100002)(2906002)(107886003)(53936002)(50466002)(81156014)(81166006)(48376002)(68736007)(8936002)(50226002)(8676002)(4326008)(450100002)(2351001)(97736004)(316002); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR03MB2767; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD006; 1:v22cTTxS7a5Hu+C7qd4gpw2RfIl9PmddLmmgzlvsvpN7pIDwe4rGmfKJJ067jHpN7dxxIwrStuXcAdmfySozmbSwzNyqwK1fjwkzchtaxs92qjwm/w2rnTy90t88Wufc MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 69787362-9198-4051-6e9a-08d58f01269f X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(5600026)(4604075)(2017052603328); SRVR:MWHPR03MB2767; X-Microsoft-Exchange-Diagnostics: 1; MWHPR03MB2767; 3:GI0OXUtolYwnZtaWJ8+Vf8NnhKSjcbiMN5b/WldQaNbQl1oBaZsl6A+eMTD1x0GjBRQmb5w46/6AAoJSd+LQl2gmm8VN8524RBnztHY7fCrS1OMVOdHH6GqqcqbyDrTa9HT4lIVW8bFVkoBfNhx0KUhJyW0izZCMyp7BL6G+345lnHGPohUNQCCh0vVVzdItjOxTxoWE5gJwiYsDOLg6fWT/jbhAK8S0qxj+z+Ez4L3tsQwjVwGfCt0xTZiQOD3mpnKwN0DZjz+79p7HjPHp2XqOLI6BSEG2H4W8HFsOAZzmuReb0ey4jtmMxZ82lhBFNV2pTEx+lbKl1WNJe44cf8N14kott+/vNOxdWOXBqVk=; 25:3OeiojTUuKxfg2FmQy3D1B/gIR4/3WXOPSGo2mK7BmDiLrgqjp0EBjPUw2LLdozDDV9ipzcspHGXwYuABywuAEklEXslXCVw0DpUU+oOCx7ZTTdPp5z8iBL4mAyVDIoXQAeiOtyadNytx7+OnQdO12RLh/rzQmK3qIIpo4zrCZk2RRYW3JAJrcUKvgRKHNGhA5c+/NihAnMeyaKiz7DdvFHiSrtoav5aFhX8NqQWmQeRJTNo4h7FAVLcWg6YMxnAMPWiQN3IaZhXFc8636DXxToKHmibYu75LEApZzvhxHk9HghjCgtl37o+KvFInpxI9iggaCkPvWkBKgmz7yN8rQ== X-MS-TrafficTypeDiagnostic: MWHPR03MB2767: X-Microsoft-Exchange-Diagnostics: 1; MWHPR03MB2767; 31:/V2zcXg+zAPkKzuqQ94wCeDS96/FnKdKr42JiEGKPU4QqLsF4bUsAxCbtk99Nv82tje5R4bGnAvgUjepLYOKVnrFWVb6qkczlavhXEiWSmo/+d49YdOh1u04o+oFMCS747ELFXTLgbfTeG3EfRFahX0g4NqD6osRkvsbP/3gsX3lA/klSMcAmnLhXfMShbOBR8CdyDwnmQDKpDhPZ8FfRQqpzq7W1ZraXc90xnyw+Ew=; 4:AWlHVHDzyEa4D0RquIVxYJ31f2K0kzfchyTrnaVAyM0+4680WxPnjQfVfV5VCtwfV0fCWVXrQ4qapmgwO34k3o3J2JESDfhKCTjkT+EbFvshyC5/Eo/mj1axXfopXt8p6VoWSiBb5O5l6KMJaDUqfaC9M2A0Dtv56I6PVNzs/rBL65+2WOzvK4WdP3a6cnSHbJ8Lm2YPVc4LtiGYxOYr0lFsy5Z5XnAyOJ0xnjkbnIDGKKlvtMsYgKktZVm9KEJmvlZtdgMN9dBHv9VA4aDXaOAl5S52OLUAuBhnpe/pOtCDv4tvTL2TYx8b6LKABfhw X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095135)(2401047)(8121501046)(5005006)(3231221)(944501320)(52105095)(93006095)(93001095)(10201501046)(3002001)(6055026)(6096035)(20161123563025)(20161123565025)(20161123559100)(20161123556025)(201703131430075)(201703131441075)(201703131448075)(201703131433075)(20161123561025)(201708071742011); SRVR:MWHPR03MB2767; BCL:0; PCL:0; RULEID:(400006); SRVR:MWHPR03MB2767; X-Forefront-PRVS: 0618E4E7E1 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; MWHPR03MB2767; 23:pjuSrsahxy/lWkytQv9h5hffNFyNxSkvQSildVQp3?= =?us-ascii?Q?23GMEQNY6NpPgRDi7i4iTnAEXAm7llTcCRvtaTyosB0deEQyN3LL2e2e3X2k?= =?us-ascii?Q?uoO8OdTLYfOOjaXGvXLQYvv1UM+oDw9X48vv1VeLQriYmV9M6T4K0L0WbOAb?= =?us-ascii?Q?JYBkju3ThJpOghJT3bcF3e6G96CZGZ4r1zJ+p6y9Wip+jhL04tjWkinMx0lp?= =?us-ascii?Q?Vk5L+9tDp+7zZGHrZmLcDFNv1KGmq2DBruJ4MIGtXsGUXnu0hm9ItV8jzFaw?= =?us-ascii?Q?jgxWRoh5QF4YHsk4tLQoMNupJFoTh3qxWbraRQrTmkMjZJTPqYbhPooqDJpd?= =?us-ascii?Q?GBhmZhgOp5ropru+o5lgSweZu3O2423xyjztMKlcmpLs++3Z+vtsy0kRKLkq?= =?us-ascii?Q?EEBTr3+kQ0EL3uTwNdqJooy06YfwOIBUWu+0HWs5/ZkF8C3HSVZn6O1EWICv?= =?us-ascii?Q?2BSYAd2veY4hYW+wZjUw4fQm4htU7JymiylIbIOzhk8Aixiz1sLG9V3Grk/W?= =?us-ascii?Q?79K/XEBryuknjCAZy56quBZpA0MM3xMgzeWa+Wome8I4K6mHFtM7xjwTNt0j?= =?us-ascii?Q?3kKZ1HJ76b/H28bVXl7XpDdmR9OLLvajj5m2kfNzedsCecBMa8ck1Y4jymHb?= =?us-ascii?Q?ViNruBdD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DhkbXm1wqsZl1pD24vhTEBd85TWdauB1T2L3zvU22ZWhDFpwXrHG897Ca7q2fMCMT3LZiG/O0V6qFLf1i2oND8yz6bHG5oJP7D7l/z1imSlIMAGrEGhQmdrvzQTBJlPHJHRmP5iV4+ukXg38G+oGlbylXm+UT3NYr/1hrHnnaFR+4SU3o5s1oOoT4=; 5:dqdqMlEumwlZRtXjBjSvFOiB/KWz0vrHcrfgR9cMvmhB12/ORXmG1rLhQDaj9z9RtK9N+oIm2djCHcl0c4MkBb7ygL8yjYuKYwecyMpeE5oYE4i9m1TSjaWjpT7FA878buhWMWp4i2W2GiZWidQgtMKaHd6T7DVc2k27un28mrM=; 24:7Lkdxbnx3gbsGMtbANoSzKOQYyd6dp50OSySGffgKHWAUOoSsQYtZkdOWzmyN6+5kLRrArEpS85Jq1LcoNSF9VAZtxUAJqj1hU1GrN1RpmU=; 7:FyNRNx+u4gOy40OAJLkH2nqwF/OdnugjlEmsZG7TIdK9jKD5f5UGiMmM+NTlqKpNgBwGH47kw0/sn7NU1OT1fuvNqRxhNkK1H8EpXz65xf7bRoG99dy2hrzKogSpfukPyVUkLBkSmvG+nOxWsdkN8xqe9BL2k0BftFaXDT27U1fPMjeL6YfXyJPMudGzG89oul0gqLgSUAFfHp/lhKUsMkRw5Y+IrCkw3/9DlRjAG3NXa5dI+Mcesk45qEZ7TLJB SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Mar 2018 07:55:43.1979 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 69787362-9198-4051-6e9a-08d58f01269f X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR03MB2767 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch introduces the managed version of clk_bulk_get_all. Cc: Michael Turquette Cc: Stephen Boyd Signed-off-by: Dong Aisheng --- v1->v2: * new patch --- drivers/clk/clk-devres.c | 24 ++++++++++++++++++++++++ include/linux/clk.h | 23 +++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/drivers/clk/clk-devres.c b/drivers/clk/clk-devres.c index d854e26..6d3ca5e 100644 --- a/drivers/clk/clk-devres.c +++ b/drivers/clk/clk-devres.c @@ -70,6 +70,30 @@ int __must_check devm_clk_bulk_get(struct device *dev, int num_clks, } EXPORT_SYMBOL_GPL(devm_clk_bulk_get); +int __must_check devm_clk_bulk_get_all(struct device *dev, + struct clk_bulk_data **clks) +{ + struct clk_bulk_devres *devres; + int ret; + + devres = devres_alloc(devm_clk_bulk_release, + sizeof(*devres), GFP_KERNEL); + if (!devres) + return -ENOMEM; + + ret = clk_bulk_get_all(dev, clks); + if (ret > 0) { + devres->clks = *clks; + devres->num_clks = ret; + devres_add(dev, devres); + } else { + devres_free(devres); + } + + return ret; +} +EXPORT_SYMBOL_GPL(devm_clk_bulk_get_all); + static int devm_clk_match(struct device *dev, void *res, void *data) { struct clk **c = res; diff --git a/include/linux/clk.h b/include/linux/clk.h index a76fdff..fe48e01 100644 --- a/include/linux/clk.h +++ b/include/linux/clk.h @@ -313,6 +313,22 @@ int __must_check clk_bulk_get_all(struct device *dev, */ int __must_check devm_clk_bulk_get(struct device *dev, int num_clks, struct clk_bulk_data *clks); +/** + * devm_clk_bulk_get_all - managed get multiple clk consumers + * @dev: device for clock "consumer" + * @clks: pointer to the clk_bulk_data table of consumer + * + * Returns a positive value for the number of clocks obtained while the + * clock references are stored in the clk_bulk_data table in @clks field. + * Returns 0 if there're none and a negative value if something failed. + * + * This helper function allows drivers to get several clk + * consumers in one operation with management, the clks will + * automatically be freed when the device is unbound. + */ + +int __must_check devm_clk_bulk_get_all(struct device *dev, + struct clk_bulk_data **clks); /** * devm_clk_get - lookup and obtain a managed reference to a clock producer. @@ -658,6 +674,13 @@ static inline int __must_check devm_clk_bulk_get(struct device *dev, int num_clk return 0; } +static inline int __must_check devm_clk_bulk_get_all(struct device *dev, + struct clk_bulk_data **clks); +{ + + return 0; +} + static inline struct clk *devm_get_clk_from_child(struct device *dev, struct device_node *np, const char *con_id) {