Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp361620lqh; Thu, 28 Mar 2024 04:37:42 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVuZJzdbU/r/8yHItCYPUJ2xjUeoWmpgn6PsIo7+QsicI3OJhorZijAyERpCWoQ9Wy9/evGx0enCSFIiZQQC5CIjMGtvW+wp1d92P2UHw== X-Google-Smtp-Source: AGHT+IGYMzkXyOOG7VoIg+NMQxZ62rksuPnSCd/6AzCRsg0rfV7ymZ7Z6+XxUyErn/HfdumG43ki X-Received: by 2002:a05:622a:13c7:b0:431:2a50:a853 with SMTP id p7-20020a05622a13c700b004312a50a853mr2305573qtk.48.1711625861991; Thu, 28 Mar 2024 04:37:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711625861; cv=pass; d=google.com; s=arc-20160816; b=TSH8yityy+jDVLKmN2qKVUDuopjEFY6tUfkFH9Bz76pRbrKM741O5Wb7eJUjTb8W76 9TDLmdv6iAAlhueuWlo89MB5O3W2A7Avq7Cq9Ja9djYj7XTr9qEDOEUXZuffjWL0gBty OrY5Lxu7hcilVaVnPxTjj5Gys/WO63kwEvme/L8oQ60ZL1M8z/aaXWdYtur7tZGy2lh+ J8WF8QSk7sM719jU+CsAjzxBZAZfCBgRWBBehdOZ8/hg6p9C9dsmYxKQus41hB/VADBU JtLchnOYssOwUWv+PA9oISmnF5QqZZYjXBBVw8na116Se39tPhZIqvzGTGxg+vI0CwT0 d7Mw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=tFo9+D0gH8F43F/nHjpisCwcxjFAz+/OaAaJ5KOcwzE=; fh=NpB1cigfGn1oO/TOmiuB6T5Q1I2XIDRIbElFqm4bJ1U=; b=DWWvOfsyFwTxJB/Y8ETg0r49NZHLxG6jmpn/AEtTRJjbxXkSRkIPlolWo5H0PTcUWu zDTuOqedXnfCxB1Ya4XeKBWABybIKuwdhe5/6Jaay5WSUb7My5h/WiXiTj2TObIaOLRS TvFbNLkj9TtSl7f0j3PFsvZ0+V+odJLmlj8vuCX7ddR3gr6Ead2n964xPcYgcr4RjUFd 7YsfDMxwrl6YwA4l+u5DLbqulipPSBftH8ByBOrG7fdQgh4dyRFMjJfdIlnoY0hZ2yCs N0NlOsF37b3oE+rjez+h+350IuwSrjw0ltBs6qq+scgZnMbpoRWNt8DJ/K48L5J7lTQT 1f3A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=J7uMJjyR; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-122840-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-122840-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id b20-20020ac85bd4000000b00431023071efsi1166772qtb.752.2024.03.28.04.37.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 04:37:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-122840-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=J7uMJjyR; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-122840-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-122840-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id A5B681C28945 for ; Thu, 28 Mar 2024 11:37:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 491787BB01; Thu, 28 Mar 2024 11:37:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="J7uMJjyR" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4B1C7374F9; Thu, 28 Mar 2024 11:37:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711625852; cv=none; b=CRWn6pskGkRZugffrCI+9a6dQMNkh6xDlZpybe+t31xly7Sy7vQDLKvCjEOUDfTC34kk2CwB3wcB9+IVrItkkZUWjmP9Qmxro5tl8IVKbIEmxwhX+EZ0nVYYq6Am84OhoQmn/tp5O6PomhSPakgM4WXcsgVoMtQPNKcrei5p+3E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711625852; c=relaxed/simple; bh=PVbCQcBD9CWn/gNAbIGipQTz8wnyniImrlBgL0zkhjw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=IfFrn9ZK28RrjQ/fWbiWPbnlLCrRnOiRzoWhS9kqkatJKuvxnSbcZKlBzJYcSaHIHlLcGsGNEcH75x038S8E2mdmSc29iZRH4k8VED5sIM/xyJ694PjWW5kk9QJlGfLWxrjo+cjhEVHuzVfsbRDX8m8IirCdnQ8/5vdjhjm++fk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=J7uMJjyR; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2206EC433C7; Thu, 28 Mar 2024 11:37:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711625851; bh=PVbCQcBD9CWn/gNAbIGipQTz8wnyniImrlBgL0zkhjw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=J7uMJjyRckdKZmMRdYNjQ7wUziTu9fqjJYx9lm0PzzjjqYb3/imPJtrkbwmxHidrs 2pqpPaAvH/1mJ22XEtyQxLKt/GJyZd+tuOHleveFBqrp5wUEdZVpYfnTt9iXDkUBBj P+WXZaWVYJOlR0qVK5RZPP1KH3SY8dAzLpZxROH9gRFr0ZqPf7yBj43v6qoAyqU5Pw K8TXc6il04eknWpAT7jnwaYHAi3qTXBEnAOWIyzzUGHK3I7w0bVKU93UVzNU82DPKu yizSp53bq538s9z6mUtDCFCuk/83Tu7T8qeVzN73hYU5B9jvFgvtHRQAeUW9uIeGVz DV+8ZifBpt+DQ== Date: Thu, 28 Mar 2024 11:37:25 +0000 From: Lee Jones To: Bhargav Raviprakash Cc: linux-kernel@vger.kernel.org, m.nirmaladevi@ltts.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, jpanis@baylibre.com, devicetree@vger.kernel.org, arnd@arndb.de, gregkh@linuxfoundation.org, lgirdwood@gmail.com, broonie@kernel.org, linus.walleij@linaro.org, linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, nm@ti.com, vigneshr@ti.com, kristo@kernel.org, eblanc@baylibre.com Subject: Re: [PATCH v4 03/11] mfd: tps6594: add regmap config in match data Message-ID: <20240328113725.GA13211@google.com> References: <20240320102559.464981-1-bhargav.r@ltts.com> <20240320102559.464981-4-bhargav.r@ltts.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240320102559.464981-4-bhargav.r@ltts.com> On Wed, 20 Mar 2024, Bhargav Raviprakash wrote: > Introduces a new struct tps6594_match_data. This struct holds fields for > chip id and regmap config. Using this struct in of_device_id data field. > This helps in adding support for TPS65224 PMIC. > > Signed-off-by: Bhargav Raviprakash > Acked-by: Julien Panis > --- > drivers/mfd/tps6594-i2c.c | 24 ++++++++++++++++-------- > drivers/mfd/tps6594-spi.c | 24 ++++++++++++++++-------- > include/linux/mfd/tps6594.h | 11 +++++++++++ > 3 files changed, 43 insertions(+), 16 deletions(-) Mostly fine, just a couple of nits. Firstly the subject lines for the entire set are inconsistent. Please use the style set by the subsystem: `git log --oneline -- ` is your friend. > diff --git a/drivers/mfd/tps6594-i2c.c b/drivers/mfd/tps6594-i2c.c > index c125b474b..9e2ed48b7 100644 > --- a/drivers/mfd/tps6594-i2c.c > +++ b/drivers/mfd/tps6594-i2c.c > @@ -192,10 +192,16 @@ static const struct regmap_config tps6594_i2c_regmap_config = { > .write = tps6594_i2c_write, > }; > > +static const struct tps6594_match_data match_data[] = { > + [TPS6594] = {TPS6594, &tps6594_i2c_regmap_config}, > + [TPS6593] = {TPS6593, &tps6594_i2c_regmap_config}, > + [LP8764] = {LP8764, &tps6594_i2c_regmap_config}, Spaces after the '{' and before the '}' please. > +}; > + > static const struct of_device_id tps6594_i2c_of_match_table[] = { > - { .compatible = "ti,tps6594-q1", .data = (void *)TPS6594, }, > - { .compatible = "ti,tps6593-q1", .data = (void *)TPS6593, }, > - { .compatible = "ti,lp8764-q1", .data = (void *)LP8764, }, > + { .compatible = "ti,tps6594-q1", .data = &match_data[TPS6594], }, > + { .compatible = "ti,tps6593-q1", .data = &match_data[TPS6593], }, > + { .compatible = "ti,lp8764-q1", .data = &match_data[LP8764], }, > {} > }; > MODULE_DEVICE_TABLE(of, tps6594_i2c_of_match_table); > @@ -205,6 +211,7 @@ static int tps6594_i2c_probe(struct i2c_client *client) > struct device *dev = &client->dev; > struct tps6594 *tps; > const struct of_device_id *match; > + const struct tps6594_match_data *mdata; > > tps = devm_kzalloc(dev, sizeof(*tps), GFP_KERNEL); > if (!tps) > @@ -216,14 +223,15 @@ static int tps6594_i2c_probe(struct i2c_client *client) > tps->reg = client->addr; > tps->irq = client->irq; > > - tps->regmap = devm_regmap_init(dev, NULL, client, &tps6594_i2c_regmap_config); > - if (IS_ERR(tps->regmap)) > - return dev_err_probe(dev, PTR_ERR(tps->regmap), "Failed to init regmap\n"); > - > match = of_match_device(tps6594_i2c_of_match_table, dev); > if (!match) > return dev_err_probe(dev, -EINVAL, "Failed to find matching chip ID\n"); > - tps->chip_id = (unsigned long)match->data; > + mdata = (struct tps6594_match_data *)match->data; What happens when you drop this case? I was under the impression this was not required when casting from (void *) > + tps->chip_id = mdata->chip_id; > + > + tps->regmap = devm_regmap_init(dev, NULL, client, mdata->config); > + if (IS_ERR(tps->regmap)) > + return dev_err_probe(dev, PTR_ERR(tps->regmap), "Failed to init regmap\n"); "initialise" > > crc8_populate_msb(tps6594_i2c_crc_table, TPS6594_CRC8_POLYNOMIAL); > > diff --git a/drivers/mfd/tps6594-spi.c b/drivers/mfd/tps6594-spi.c > index 5afb1736f..82a1c02e3 100644 > --- a/drivers/mfd/tps6594-spi.c > +++ b/drivers/mfd/tps6594-spi.c > @@ -77,10 +77,16 @@ static const struct regmap_config tps6594_spi_regmap_config = { > .use_single_write = true, > }; > > +static const struct tps6594_match_data match_data[] = { > + [TPS6594] = {TPS6594, &tps6594_spi_regmap_config}, > + [TPS6593] = {TPS6593, &tps6594_spi_regmap_config}, > + [LP8764] = {LP8764, &tps6594_spi_regmap_config}, As above. > +}; > + > static const struct of_device_id tps6594_spi_of_match_table[] = { > - { .compatible = "ti,tps6594-q1", .data = (void *)TPS6594, }, > - { .compatible = "ti,tps6593-q1", .data = (void *)TPS6593, }, > - { .compatible = "ti,lp8764-q1", .data = (void *)LP8764, }, > + { .compatible = "ti,tps6594-q1", .data = &match_data[TPS6594], }, > + { .compatible = "ti,tps6593-q1", .data = &match_data[TPS6593], }, > + { .compatible = "ti,lp8764-q1", .data = &match_data[LP8764], }, > {} > }; > MODULE_DEVICE_TABLE(of, tps6594_spi_of_match_table); > @@ -90,6 +96,7 @@ static int tps6594_spi_probe(struct spi_device *spi) > struct device *dev = &spi->dev; > struct tps6594 *tps; > const struct of_device_id *match; > + const struct tps6594_match_data *mdata; > > tps = devm_kzalloc(dev, sizeof(*tps), GFP_KERNEL); > if (!tps) > @@ -101,14 +108,15 @@ static int tps6594_spi_probe(struct spi_device *spi) > tps->reg = spi_get_chipselect(spi, 0); > tps->irq = spi->irq; > > - tps->regmap = devm_regmap_init(dev, NULL, spi, &tps6594_spi_regmap_config); > - if (IS_ERR(tps->regmap)) > - return dev_err_probe(dev, PTR_ERR(tps->regmap), "Failed to init regmap\n"); > - > match = of_match_device(tps6594_spi_of_match_table, dev); > if (!match) > return dev_err_probe(dev, -EINVAL, "Failed to find matching chip ID\n"); > - tps->chip_id = (unsigned long)match->data; > + mdata = (struct tps6594_match_data *)match->data; > + tps->chip_id = mdata->chip_id; > + > + tps->regmap = devm_regmap_init(dev, NULL, spi, mdata->config); > + if (IS_ERR(tps->regmap)) > + return dev_err_probe(dev, PTR_ERR(tps->regmap), "Failed to init regmap\n"); > > crc8_populate_msb(tps6594_spi_crc_table, TPS6594_CRC8_POLYNOMIAL); > > diff --git a/include/linux/mfd/tps6594.h b/include/linux/mfd/tps6594.h > index 16543fd4d..d781e0fe3 100644 > --- a/include/linux/mfd/tps6594.h > +++ b/include/linux/mfd/tps6594.h > @@ -1337,6 +1337,17 @@ struct tps6594 { > struct regmap_irq_chip_data *irq_data; > }; > > +/** > + * struct tps6594_match_data - of match data of PMIC > + * > + * @chip_id: chip ID of PMIC > + * @config: regmap config of PMIC > + */ > +struct tps6594_match_data { > + unsigned long chip_id; > + const struct regmap_config *config; > +}; > + > extern const struct regmap_access_table tps6594_volatile_table; > extern const struct regmap_access_table tps65224_volatile_table; > > -- > 2.25.1 > -- Lee Jones [李琼斯]