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=-10.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 A4FF4C4320A for ; Fri, 6 Aug 2021 08:21:29 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 6CAB56120D for ; Fri, 6 Aug 2021 08:21:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6CAB56120D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org 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:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ULD8TNaJazZcbBgdsaMcCxofK9QvUqLotU+VubPSwPA=; b=FL67qWpCjfdIQJ rb/CBqxKif4c0HxYDPwM+TZ9ZvZZleDxzxgjBQSM2PUIZ0sjaiym9sao0ck9Q57bOtcuJkMnj8mlT gzxpEKWuwwyesQsYnNe3WAtpe0nVOWbYSh0SM3UM4+tJejNhRVSBbfZmmPn+kCuN5eehnzO/W0iDy RicWs4DCz4ZuBzBK9XwF1iS1dfyqam6QwNa/1IN/Nm9q+QK9QHp4zmjiM4HdF4vv4qqAfOo9ua1j8 q24fr7BraFMsr9S1lv69efJ9R/qADAt7Z+hYY3Kzi41sqOEXimo1vadRx838jZfzH/rZUExSp0pSB eT8VMNWwAnHH1Sjk87xg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mBv4P-00BqPj-UN; Fri, 06 Aug 2021 08:19:10 +0000 Received: from mail-il1-x12a.google.com ([2607:f8b0:4864:20::12a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mBv4M-00BqP7-Bt for linux-arm-kernel@lists.infradead.org; Fri, 06 Aug 2021 08:19:07 +0000 Received: by mail-il1-x12a.google.com with SMTP id i9so7995905ilk.9 for ; Fri, 06 Aug 2021 01:19:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=vIww8QZWLaOp0+QSkUA4VMHuBwDjb/r3R281dHn75KE=; b=DAzYPGXRjFlLoNcLfn3esPMzHD5carrhiX2mMEp2UY/biI8oVc45OAusfeo6lcxebK knI3kCjRuBW8AQqxcG3lGuLMrE5JrDueJVc6sG8r1ipD4Mk+SSeMUbi6sTo8ZV1x2r+d Ny3Ps5QIbfXAkjpcjGeuKexumCRdiUe1KO7T9r2VkSEi6JXeJgE3SF3WObLeBy28mxkq KkvqabSpKsqSw1jalEOld4SXo+o1GijxNMeZABTmw11AiuxO+/thjY/ZE+uhB8WOvtE5 LAgujoc/O1MninAV3coQ5daNXFuC+5/VHrQApI/d4hVfDqcADAhhwfhq9kwPZAdepaBC B2Nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=vIww8QZWLaOp0+QSkUA4VMHuBwDjb/r3R281dHn75KE=; b=YiSC/7OSCYem0t2HCWesHCXDrEtENvq2a5FZSFKt18UxtRgOUKaJFWpdyPEldepZXt gDndiZirU3QzMFVD+G7cnybRveHaFvaGY+MWB9e89JUrVIbuOBT8obLNwd1ltsOoBKyB dIRQfpsJt+kRb5W5CJwCGz93eCpciMFUo7pzJmfq2nMyffUUW34j3g/mzznK+TgJnPIz +4k7wJF7f0ApLGNkGO9H6FTxm6u9SPA6VAhVNZUiVwMJmFkm3faNmqyhJLlqRDcwKeMJ /tBsSrcRYaXnAp6PHqDdGxgSnOJkE8aArnecsVVeOHLgDMFtfjaE7asiTsEodQFDM55X vIfA== X-Gm-Message-State: AOAM531MaZb+mfruDr3bAJq9+84d8Wq4iAgIB49M1AIQ6YjXD4vflL21 iy8E5cAk9Bvp+pnAhAa3zAZBBqSIREZn7t4PG1M= X-Google-Smtp-Source: ABdhPJyTM2uCk42ks+bpzHCrhp6hZ6u5kPffe8NAkVWdbwtdxxyC1VNflgzgzhm0QYxHLS8QLMDYAvUETXDpODIKaYM= X-Received: by 2002:a05:6e02:1d8d:: with SMTP id h13mr215231ila.40.1628237944603; Fri, 06 Aug 2021 01:19:04 -0700 (PDT) MIME-Version: 1.0 References: <20210805085611.864188-1-lee.jones@linaro.org> In-Reply-To: <20210805085611.864188-1-lee.jones@linaro.org> From: Alistair Francis Date: Fri, 6 Aug 2021 18:19:00 +1000 Message-ID: Subject: Re: [PATCH v2 1/1] mfd: simple-mfd-i2c: Add support for registering devices via MFD cells To: Lee Jones Cc: linux-arm-kernel , Linux Kernel Mailing List , Michael Walle , Mark Brown X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210806_011906_459358_647CD5FC X-CRM114-Status: GOOD ( 32.84 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Aug 5, 2021 at 6:56 PM Lee Jones wrote: > > More devices are cropping up requiring only Regmap initialisation and > child registration functionality. We currently only support that if > all required devices are represented by their own Device Tree nodes > complete with compatible strings. > > However, not everyone is happy with adding empty nodes that provide no > additional device information into the Device Tree. > > Rather than have a plethora of mostly empty, function-less drivers in > MFD, we'll support those simple cases in here instead via MFD cells. > > Cc: Michael Walle > Cc: Mark Brown > Cc: Alistair Francis > Signed-off-by: Lee Jones > --- > v2: > - Check for empty of_device_id .data entry > > drivers/mfd/simple-mfd-i2c.c | 41 +++++++++++++++++++++++++++++------- > drivers/mfd/simple-mfd-i2c.h | 32 ++++++++++++++++++++++++++++ > 2 files changed, 65 insertions(+), 8 deletions(-) > create mode 100644 drivers/mfd/simple-mfd-i2c.h > > diff --git a/drivers/mfd/simple-mfd-i2c.c b/drivers/mfd/simple-mfd-i2c.c > index 87f684cff9a17..583e8c7924af0 100644 > --- a/drivers/mfd/simple-mfd-i2c.c > +++ b/drivers/mfd/simple-mfd-i2c.c > @@ -2,39 +2,64 @@ > /* > * Simple MFD - I2C > * > + * Author(s): > + * Michael Walle > + * Lee Jones > + * > * This driver creates a single register map with the intention for it to be > * shared by all sub-devices. Children can use their parent's device structure > * (dev.parent) in order to reference it. > * > * Once the register map has been successfully initialised, any sub-devices > - * represented by child nodes in Device Tree will be subsequently registered. > + * represented by child nodes in Device Tree or via the MFD cells in this file > + * will be subsequently registered. > */ > > #include > #include > +#include > #include > #include > #include > > -static const struct regmap_config simple_regmap_config = { > +#include "simple-mfd-i2c.h" > + > +static const struct regmap_config regmap_config_8r_8v = { > .reg_bits = 8, > .val_bits = 8, > }; > > static int simple_mfd_i2c_probe(struct i2c_client *i2c) > { > - const struct regmap_config *config; > + const struct simple_mfd_data *simple_mfd_data; > + const struct regmap_config *regmap_config; > struct regmap *regmap; > + int ret; > + > + simple_mfd_data = device_get_match_data(&i2c->dev); > > - config = device_get_match_data(&i2c->dev); > - if (!config) > - config = &simple_regmap_config; > + /* If no regmap_config is specified, use the default 8reg and 8val bits */ > + if (!simple_mfd_data || !simple_mfd_data->regmap_config) > + regmap_config = ®map_config_8r_8v; > + else > + regmap_config = simple_mfd_data->regmap_config; > > - regmap = devm_regmap_init_i2c(i2c, config); > + regmap = devm_regmap_init_i2c(i2c, regmap_config); > if (IS_ERR(regmap)) > return PTR_ERR(regmap); > > - return devm_of_platform_populate(&i2c->dev); > + /* If no MFD cells are spedified, use register the DT child nodes instead */ > + if (!simple_mfd_data || !simple_mfd_data->mfd_cell) > + return devm_of_platform_populate(&i2c->dev); > + > + ret = devm_mfd_add_devices(&i2c->dev, PLATFORM_DEVID_AUTO, > + simple_mfd_data->mfd_cell, > + simple_mfd_data->mfd_cell_size, > + NULL, 0, NULL); > + if (!ret) Shouldn't this be `if (ret)` instead? With that changed this works for me as well: Reviewed-by: Alistair Francis Tested-by: Alistair Francis Alistair > + dev_err(&i2c->dev, "Failed to add child devices\n"); > + > + return ret; > } > > static const struct of_device_id simple_mfd_i2c_of_match[] = { > diff --git a/drivers/mfd/simple-mfd-i2c.h b/drivers/mfd/simple-mfd-i2c.h > new file mode 100644 > index 0000000000000..7cb2bdd347d97 > --- /dev/null > +++ b/drivers/mfd/simple-mfd-i2c.h > @@ -0,0 +1,32 @@ > +// SPDX-License-Identifier: GPL-2.0-only > +/* > + * Simple MFD - I2C > + * > + * Author: Lee Jones > + * > + * This driver creates a single register map with the intention for it to be > + * shared by all sub-devices. Children can use their parent's device structure > + * (dev.parent) in order to reference it. > + * > + * This driver creates a single register map with the intention for it to be > + * shared by all sub-devices. Children can use their parent's device structure > + * (dev.parent) in order to reference it. > + * > + * Once the register map has been successfully initialised, any sub-devices > + * represented by child nodes in Device Tree or via the MFD cells in the > + * associated C file will be subsequently registered. > + */ > + > +#ifndef __MFD_SIMPLE_MFD_I2C_H > +#define __MFD_SIMPLE_MFD_I2C_H > + > +#include > +#include > + > +struct simple_mfd_data { > + const struct regmap_config *regmap_config; > + const struct mfd_cell *mfd_cell; > + size_t mfd_cell_size; > +}; > + > +#endif /* __MFD_SIMPLE_MFD_I2C_H */ > -- > 2.32.0.605.g8dce9f2422-goog > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel