Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp655373pxb; Tue, 1 Feb 2022 07:48:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJzGD0DKThwFUlZOO9MgobCsXUd2fmm20n54Cr1XgKgD9OigdcZ4Is6EHiD/wAOHIUU3LOO9 X-Received: by 2002:a17:902:7209:: with SMTP id ba9mr26170422plb.166.1643730506037; Tue, 01 Feb 2022 07:48:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643730506; cv=none; d=google.com; s=arc-20160816; b=uv1oHjpPcPo9wT6RIX2jwXhJ6fPQATCthlI00yaA6gE/VzSaD1BQUQM4B+9Pcc7fZw qo4e9JF398Tme2F6jAB0U5c+eds91OeFKgiFBTSL4QOyP0K+brIH5VvtvL0QUCgRsHkR yqrsmL1/E4jyDnlRVc8gqkbvDqBYRt/B5pGYOhDaD7QZ40GwKGcqeFFUW0oik2PRJFJw MyS02dy5PB74tbPsCHvlcOml4Jo0R1whgd+OBh0evrcBFBwgUhYJ4EwYWlOe7mbwVXiD U0MLxA15xnjMOXvIua3U+W6YtyW7/jdXHPETX/8fEUL6I/eOzWCi5sh9essSEVcysXWV e+BA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=t7jPwPhPro6Iv9HSiNOKR1rT0o1K1FCdRP2oY2jpf+w=; b=yR9RVnGV5ixBHJ8utMFqXMGeIL/F3x1kK9Y1m8t4aBu3+PBji5blRkeKffS0nZpotz XVNAYhU2wiQiupQm+OepEpA1p5HnOOCXws/zMNuF7Hg/teXiiG9ln0O0pqaGHjouUNlC DYivHlXE2N74Rzjfl9w+csmwLa44jKxYv8Rm20m/4kLBMoUHrnqlsCSLnF822/dsVCQ4 yRhF9YjjY0sd4s/blKdpo2aCTH0AO+4BJbTbx3GJO2vVKCoRwZ/VK2+46LCmVTU3gG91 gR/ofOLNBRy/U0+WSsQjL1mlXbz62UhVgA76nz3CzF6LzOh6Cv/Db5fNTviKLfqXFs0G Klfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QzZYqxia; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f18si17395143pfc.201.2022.02.01.07.48.14; Tue, 01 Feb 2022 07:48:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QzZYqxia; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344144AbiAaIrk (ORCPT + 99 others); Mon, 31 Jan 2022 03:47:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233613AbiAaIrh (ORCPT ); Mon, 31 Jan 2022 03:47:37 -0500 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 706B5C06173B for ; Mon, 31 Jan 2022 00:47:37 -0800 (PST) Received: by mail-wr1-x42b.google.com with SMTP id v13so23818631wrv.10 for ; Mon, 31 Jan 2022 00:47:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=t7jPwPhPro6Iv9HSiNOKR1rT0o1K1FCdRP2oY2jpf+w=; b=QzZYqxiaPC9Nq5ye22er2udgF5fExREUxs03Oa7WhWa6T3IpYz+t8negIwYhl+jGHa CgdYaW+6E75ONwCsuBQZMdPmo8762DvgwHsw8SGZ9ywzd0fQedjjAtVEZrI77yxMZhbq 4kZAR8qrJmQ2GmQ3iqLVH9jgpMX072Clf65RoR/S/diKjC/XHFDc5ZBR7ad2bARR7vnv FQV+AnulBMJz0XfAWygjxA3XSv5YnwRhjn/Bl+NggIK97vEu6PXPUoN8nzhp6hs5unP5 hBSH8uwTk13nzmkUZCwsPV9VJ3XXmCNpySljO21CZHxJxBwdwh9xtSjnfyAwemnt22n6 Z3Zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=t7jPwPhPro6Iv9HSiNOKR1rT0o1K1FCdRP2oY2jpf+w=; b=YX3l7tNxDbA9hkQyWoa6xWheSv0XnIQu0RgCOV91ARnxVrex7W1f0TILvz6FCFJhsY Qw/Uav3B5gPw9Jh2gzr7rFgjPr8qXwm0hLwAJCc7/Gj/arTirAo8Z5TldYLWp+P9iQRu eWMp+1q87e1Pc7eGUn94IETqqoeXI+8Athd6hLN14yi1YDluoL2YQp7o3iRe+2Cuys1l I5sQCtqznhGNBR0U6tmAL67P8KkTl/SdSx9ChwrJLzI61oke82eVF7Xt4alKe4hEoFuM sKDnKb/oV55bK98gaxnfZLn7+anZo9XMNVpecCNxeKKovuKyOcLGn9awu142IdVa2wia /CjA== X-Gm-Message-State: AOAM533R8m3vp56xbEkqiVv5VxXwJzp84mqSehfXDdeqmSdZ+Kv+XKxt 9VQlOA84R2p87YeF4sMX0iZi0A== X-Received: by 2002:a05:6000:1848:: with SMTP id c8mr10310760wri.241.1643618855967; Mon, 31 Jan 2022 00:47:35 -0800 (PST) Received: from google.com (cpc106310-bagu17-2-0-cust853.1-3.cable.virginm.net. [86.15.223.86]) by smtp.gmail.com with ESMTPSA id a14sm13421217wri.25.2022.01.31.00.47.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jan 2022 00:47:35 -0800 (PST) Date: Mon, 31 Jan 2022 08:47:33 +0000 From: Lee Jones To: Colin Foster Cc: linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, 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 , katie.morris@in-advantage.com Subject: Re: [RFC v6 net-next 5/9] mfd: add interface to check whether a device is mfd Message-ID: References: <20220129220221.2823127-1-colin.foster@in-advantage.com> <20220129220221.2823127-6-colin.foster@in-advantage.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220129220221.2823127-6-colin.foster@in-advantage.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 29 Jan 2022, Colin Foster wrote: > 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); As I said before, I really don't want MFDness leaking out into other parts of the kernel. Please find another way to differentiate between devices registered via the MFD API and by other means. I'm happy to help here. How else could these devices be enumerated? > 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 -- Lee Jones [李琼斯] Principal Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog