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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D6E07C433FE for ; Wed, 29 Dec 2021 15:24:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240523AbhL2PYG (ORCPT ); Wed, 29 Dec 2021 10:24:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240514AbhL2PYF (ORCPT ); Wed, 29 Dec 2021 10:24:05 -0500 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0381C06173E for ; Wed, 29 Dec 2021 07:24:04 -0800 (PST) Received: by mail-wr1-x42f.google.com with SMTP id r17so45092023wrc.3 for ; Wed, 29 Dec 2021 07:24:04 -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=LZQ2uT+dEDdcfo6GdsvFMg5+lwEKUwPetYi8+iOsNTE=; b=g/BtKfrE39CwIcZaRrFrzcFAcOo2HU9xLitA2rLAs+sZo1JTwMpnrghiftDw6poaLd He50o4JOWuTaTkDV9XN2FmtEOsVK0kLXLsXApfSsmRnpnPiBw8lnJT+o3ooUMkeHOkZ5 szGZGGV1dInrwoVLs8qvTc0i9nKXwFzwTJh/1327gNE7Khbd+FV4hUtgnC54VDILcxF9 OobNnOF5/Y2nDFeHfWzUTLpoWjyfN7tw0+sSsG/YxzWGcj44dp9NfbUUfn2uiDePHABp N3skC7MAmZfyfYVH1kdfdu1E/SHlULXIHqYprX4r3qC7saf6SFtRJSQfds7+oD501XuI tEMw== 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=LZQ2uT+dEDdcfo6GdsvFMg5+lwEKUwPetYi8+iOsNTE=; b=h60bmRW+Fe4bUIDh9SCNGwxsm6WNEBSL95sZWnsQippGeZ+v8QbcW+g54gt6YwPCqM //jUy0JjaDUDYVHvxukPVqZXF5J94vK570Acl/bcs+Zpdi6RVw2t8lzEFcwfkYgrY7q/ PRCPPhoStWvfJxndh9fDsXtTEBWOVc/TOYpz3BJ+yi3UOynXaHzmv1pSn95orvanMKLP AtdjHtfFxnmOISljl98E3PLrVyGWbwMsVtpqPsci+4S3Fg9Kw8/FsqbcW930WYzS1VDo X5wmBbGpBX6LjGHtm9mVAyuakOcgZJ0wtNv0h3uSyGw345KXH4zmNuV+SIG9zJ9k6Oew FMBg== X-Gm-Message-State: AOAM5302+Z0EMChhEavN4QAHJsZtHeqhJ3SC/nAIPGwcTxlC1cpk/uEK HSKK/ulN9V58bMlsqQp7w2pqvQ== X-Google-Smtp-Source: ABdhPJx27hQZtD1q76IBUMnEd1Xg0f7/2/Jw1Bws56rnUP8BCeQIA9tfDcTTsNw6NPF8VRPLqDpGxQ== X-Received: by 2002:a05:6000:1ac6:: with SMTP id i6mr21307251wry.373.1640791443205; Wed, 29 Dec 2021 07:24:03 -0800 (PST) Received: from google.com ([2.31.167.18]) by smtp.gmail.com with ESMTPSA id b10sm21383326wrg.19.2021.12.29.07.24.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Dec 2021 07:24:02 -0800 (PST) Date: Wed, 29 Dec 2021 15:23:59 +0000 From: Lee Jones To: Colin Foster Cc: linux-gpio@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, 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 Subject: Re: [RFC v5 net-next 02/13] mfd: ocelot: offer an interface for MFD children to get regmaps Message-ID: References: <20211218214954.109755-1-colin.foster@in-advantage.com> <20211218214954.109755-3-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: <20211218214954.109755-3-colin.foster@in-advantage.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 18 Dec 2021, Colin Foster wrote: > Child devices need to get a regmap from a resource struct, specifically > from the MFD parent. The MFD parent has the interface to the hardware > layer, which could be I2C, SPI, PCIe, etc. > > This is somewhat a hack... ideally child devices would interface with the > struct device* directly, by way of a function like > devm_get_regmap_from_resource which would be akin to > devm_get_and_ioremap_resource. A less ideal option would be to interface > directly with MFD to get a regmap from the parent. > > This solution is even less ideal than both of the two suggestions, so is > intentionally left in a separate commit after the initial MFD addition. > > Signed-off-by: Colin Foster > --- > drivers/mfd/ocelot-core.c | 9 +++++++++ > include/soc/mscc/ocelot.h | 12 ++++++++++++ > 2 files changed, 21 insertions(+) > > diff --git a/drivers/mfd/ocelot-core.c b/drivers/mfd/ocelot-core.c > index a65619a8190b..09132ea52760 100644 > --- a/drivers/mfd/ocelot-core.c > +++ b/drivers/mfd/ocelot-core.c > @@ -94,6 +94,15 @@ static struct regmap *ocelot_mfd_regmap_init(struct ocelot_mfd_core *core, > return regmap; > } > > +struct regmap *ocelot_mfd_get_regmap_from_resource(struct device *dev, > + const struct resource *res) > +{ > + struct ocelot_mfd_core *core = dev_get_drvdata(dev); > + > + return ocelot_mfd_regmap_init(core, res); > +} > +EXPORT_SYMBOL(ocelot_mfd_get_regmap_from_resource); This is almost certainly not the right way to do whatever it is you're trying to do! Please don't try to upstream "somewhat a hack"s into the Mainline kernel. -- Lee Jones [李琼斯] Senior Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog