From patchwork Sat Jan 29 22:02:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12729671 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id ADF36C433F5 for ; Sat, 29 Jan 2022 22:06:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=HpiJ4cFR9LtNzsp2iJ0UfH1SjKoDMNvDjZ+xDThLpOM=; b=sQ7aUaCNympEu0 QFcKk9u2j4GQqY4PUH9gl5SoKvFIixTWVlSUZK5aHXJyjutHqKovCDVCIn/bfBPY38hr6xhkmLvKd qU85EiwqS1qs82DcGZwRqtnGLMuIgIpuo2jlhe0OKmmL2uBErHnhOgBekEvcbY5SQryJpg1nesddb 1jL0/GsxW4vId0xsm4uMqtuqyEPMryiIPrQAlWbj7DtubHEtwgoPmo8896ob34RcSOy5Z3ywWFZdT TtjJzbQSL6GwZKQs96SCojiVYtePJVvUdZ2Nk0gyIodwiAneghE6hxLzqg1WoxNyyUvrcbXKENnik t/d6vsn/e/e7RnR+qmLQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nDvpi-005UUF-1O; Sat, 29 Jan 2022 22:04:34 +0000 Received: from mail-dm3nam07on2093.outbound.protection.outlook.com ([40.107.95.93] helo=NAM02-DM3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nDvo2-005Tof-PY for linux-arm-kernel@lists.infradead.org; Sat, 29 Jan 2022 22:02:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gEAV1pT1nBT0+KD3ebLlEJrN6P3hecq5EyR6W75IvnMpwjwNnbmBQ6/OhozDIbYsIuO99gxm00cvP8uIoien1sNBWMKOMK+45Q8rwBDCDQKytcOmnDxL64YRqBzIkCRJolmZYLOfD2Ca5d7N4YegsGJLcH1x+PLEkQZ645WB9LeRzIlINNyfxF+AuxuSA41FRk2kQ7SAvYvk3AxIkwgmdtPsUL4fheMTMwaqBzmtqWevHuJd6mz1w5Sg9GKsB52AiQjiUxIx0klomG4i2yiCC881oGz2ifoCFbTBP00Q57fBQpRdfAZ1H331wZ6QnV/DqYtzPYTA8eHTGSpns/OCsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=l19gVSLOw5HzIj0qk6WuM2K7zkumJPbMEI9N3iDsGbM=; b=ZeAB63SeXjTqQ6wVrAU4nTtGIn7jbZOXbpbVeqQBi6vAUIvEswDk3DUIzXZEzv3r86czgzFc+dV/8jb6fKmznjpnzqSc7EzpelUbm867mzHQfQYBLehDOwPyiabmp89Y48dJhWdPkofY0ly5iVtuky4pFHD+sypPZrzGoxW8RuOGbbnPCRsuNrMncS69CO0J084U2iQg+4ouxh9pvcw+gGByp0002m//vYJLMy8cIs5rRWvuYN87CG4e7qe9qNm/2okGUMo7ro1NgFhJHOl2w3hdjJeIEjCkJT5lEeFpNSGNsGwqqI0q6XmwP0xRAoRz/QD7fhAGARyms2+bJBliYA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inadvantage.onmicrosoft.com; s=selector2-inadvantage-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=l19gVSLOw5HzIj0qk6WuM2K7zkumJPbMEI9N3iDsGbM=; b=DQZlabjaVKdAdwgGgVDo49lndPsX+Gi2LgKGbhXn6wr7UhPAwOOsMlbbudr1FrGXJc+9YFBQM4tNzUrXui41gJrmLKiSYEBwwtGIFQ0tgNWTzPvvbhpGi2vYOMhI1qQ8REXsxTyQ0fSOwZs/tB//18loOs7tBA5FNW7HoVfT89A= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=in-advantage.com; Received: from MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) by BYAPR10MB2968.namprd10.prod.outlook.com (2603:10b6:a03:85::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.18; Sat, 29 Jan 2022 22:02:43 +0000 Received: from MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::2d52:2a96:7e6c:460f]) by MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::2d52:2a96:7e6c:460f%4]) with mapi id 15.20.4930.020; Sat, 29 Jan 2022 22:02:43 +0000 From: Colin Foster To: linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Steen Hegelund , Lars Povlsen , Linus Walleij , Russell King , Heiner Kallweit , Jakub Kicinski , "David S. Miller" , Florian Fainelli , Vivien Didelot , Andrew Lunn , UNGLinuxDriver@microchip.com, Alexandre Belloni , Claudiu Manoil , Vladimir Oltean , Lee Jones , katie.morris@in-advantage.com Subject: [RFC v6 net-next 5/9] mfd: add interface to check whether a device is mfd Date: Sat, 29 Jan 2022 14:02:17 -0800 Message-Id: <20220129220221.2823127-6-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220129220221.2823127-1-colin.foster@in-advantage.com> References: <20220129220221.2823127-1-colin.foster@in-advantage.com> X-ClientProxiedBy: CO1PR15CA0113.namprd15.prod.outlook.com (2603:10b6:101:21::33) To MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c5a8abb1-2371-4709-a03a-08d9e3731303 X-MS-TrafficTypeDiagnostic: BYAPR10MB2968:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4303; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OjXE7PWmGirYtVnU+6+nZ0cLmhd/dopYWYDOQ5I7Y3n6SrPEhCSF+HsbrVVt9rQgHl6wvp28KEr9SKzZyzO49hB4GmOoneVNEbekpBi6MkhBJreu9qL+p9Fv1SQWdRyOofMRkMvBt0LiUSbSSfWmECaDD4ymOFzUsyM1WJ3hLXUBsncJhmsKYgkxF5VTw4JH5DtnYiNKC33AX6CCgvEllrVsAs6Vc7/r1UBqea/XfLfehwAizxdxvEaw6i1SMPZWEGgRFNJRZBkBiKFoLDS26zTGt6fPSh5TqC2JVYCWsCCVW1zr+w6CVID42bDShpFbr90rgPUFxXKDquPPFABAz2MwUvd18eNumGcfCAH2DQi3DHQdfx0gfb+jO0Q858lqAsbnwcf9o2b/wKMyEeOG7Ae2+6FVL65TbWkjYUkhxC/CnTIrK97DzEbl1lqF8ixkmSSKEY2RVGup87lu9Jws5Iu7z5eehzvdNU2Ki5ziZAM1sQKz1h7pXMldCXx1wKwbTU0hxpNF+G2ANkQ/hfzka5DVz3zvCnvvC+xYBcinm5MuSbfewu0/MafoS4yelqG1n6bUY3NJG9TN56wXRfnzZCbdbx9znD1fU7WL/qLaYMOg07Ey3IX8QnBlQrt4DjGYvI7STsshOGag8OKW8zqQpP/lloj30FOnbLbu17JmXPc3jWnObWzIdj1Z6QM14XYwmNBlcu7MDmqPnkZLvXnwjA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR1001MB2351.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(136003)(376002)(346002)(42606007)(396003)(39830400003)(366004)(186003)(508600001)(5660300002)(6486002)(1076003)(86362001)(66946007)(8676002)(66476007)(26005)(4326008)(66556008)(8936002)(7416002)(107886003)(6506007)(38350700002)(6512007)(2906002)(44832011)(6666004)(2616005)(52116002)(38100700002)(83380400001)(316002)(36756003)(54906003)(20210929001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +mXanTi+Xlxscve8ICfwsm0adz3d46DiCTJzlLSfw4Gu9A6b9xfwsqpBvfRLm4SY1stJCYiGvF9pd5UHMAPFOEpOLrIK7LdTFDcgmNShFBt9Je71yjhk/BifERpAWIOOz5Z9AbOv/bUBYPBqfVNSJIKP1uLvBFo9WcONzHMG0gLrMfvRtjMd8HLQv5757a2ZOvx4DKRg+Rl8gY+3oNoQ1mN172igwpTnKMSeekKOVyH5WjdlrgvsZrGYNbQnAGoSKksiokqtFBNty3hunFM1HyPANEj6EHbE93GT4Obsx7x3kf99A7LuK60kHIlSt39SJS13L7JFlB8x4sYme1mwHlyUrhBO6k1WNbe5r2jWOEpT5te+BTTqcRVUuHZ67jtw8a9PVdPgItykfgcHUPFPHl09jdyVUval21gAj2jABqN3DAAlrYcqa3NdrtiCtqLK3XvqyxjMqUYc6lPKuupb1sqLnwmiXX/rFx1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YQVwkFle4CESKco2tntDomstV8Hk9vLQzQ2W2hgfPmjxpacJx4ZlwsA9Da3Hr04HLT3r5vNHLzm1QVTpSOjJqAI91wdB1OsR481qqP2tYu94lsyIu4N/Ok7/Fivg== X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: c5a8abb1-2371-4709-a03a-08d9e3731303 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2022 22:02:43.1415 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 48e842ca-fbd8-4633-a79d-0c955a7d3aae X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: xk1yPu9KSGLRITdm4TIWUNy/u95hX1lndqCFIwKBLB7xSRXOFiT050MxFvfLaiE2tiENNssC2JdvHmT31VayV/iEHA4G2m86WeFPSbQgemA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2968 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220129_140250_904602_CD266A66 X-CRM114-Status: GOOD ( 14.57 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Some drivers will need to create regmaps differently based on whether they are a child of an MFD or a standalone device. An example of this would be if a regmap were directly memory-mapped or an external bus. In the memory-mapped case a call to devm_regmap_init_mmio would return the correct regmap. In the case of an MFD, the regmap would need to be requested from the parent device. This addition allows the driver to correctly reason about these scenarios. Signed-off-by: Colin Foster --- drivers/mfd/mfd-core.c | 6 ++++++ include/linux/mfd/core.h | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c index 684a011a6396..2ba6a692499b 100644 --- a/drivers/mfd/mfd-core.c +++ b/drivers/mfd/mfd-core.c @@ -33,6 +33,12 @@ static struct device_type mfd_dev_type = { .name = "mfd_device", }; +int device_is_mfd(struct platform_device *pdev) +{ + return (!strcmp(pdev->dev.type->name, mfd_dev_type.name)); +} +EXPORT_SYMBOL(device_is_mfd); + int mfd_cell_enable(struct platform_device *pdev) { const struct mfd_cell *cell = mfd_get_cell(pdev); diff --git a/include/linux/mfd/core.h b/include/linux/mfd/core.h index 0bc7cba798a3..c0719436b652 100644 --- a/include/linux/mfd/core.h +++ b/include/linux/mfd/core.h @@ -10,6 +10,7 @@ #ifndef MFD_CORE_H #define MFD_CORE_H +#include #include #define MFD_RES_SIZE(arr) (sizeof(arr) / sizeof(struct resource)) @@ -123,6 +124,15 @@ struct mfd_cell { int num_parent_supplies; }; +#ifdef CONFIG_MFD_CORE +int device_is_mfd(struct platform_device *pdev); +#else +static inline int device_is_mfd(struct platform_device *pdev) +{ + return 0; +} +#endif + /* * Convenience functions for clients using shared cells. Refcounting * happens automatically, with the cell's enable/disable callbacks