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 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 67AAEC48BC1 for ; Wed, 14 Feb 2024 18:10:34 +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:Message-ID:Date:References :In-Reply-To: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=UAgvFyU3rgGzb2rWk6FsMGZ3d9N0G0GBwSH8jb3cKlU=; b=TCclqquDeyfZXm a7+PhGyEVJmldsO/CiN8Gw+jwQ1Jy2y8+gf43V1SCWYp0N/Nr8h++LrifVX86i4lDZRhEBtBzoiOv xvQfv4dS4VjiQdn686M5hTIydssFYbV46IBKbNryzp+V9LQCG+VPd502KgSC6Gzx2aKZu9ujTVVRO CXL1zP9wQtjNRm9HK58/gXWmgvdtR6ytH588sLB1+F0EVtYxjsjr9720s2hTYuPhBzx+GaaVV2rLd FCdWCLE+mx6LSy2Jx3bqwn08fEMXnT/geq4/cTCQnVXy6KgI0Z5a1rCJBC6wp4K/Ok93bRsVNDCE6 VOuBVkqbqqatLeFN4nZA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raJi9-0000000DsZM-1yBQ; Wed, 14 Feb 2024 18:10:21 +0000 Received: from mail-pf1-f176.google.com ([209.85.210.176]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raJi6-0000000DsYX-3G0U for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 18:10:20 +0000 Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-6e0aa4bb62fso50033b3a.1 for ; Wed, 14 Feb 2024 10:10:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707934218; x=1708539018; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=n+mkaTMkL4XuODOYIB1UDzOU7ovvrohzK27gHXfKWZ0=; b=HAIfSC5KgnZhebHARmsEL/p34wh8R9W5W8KZ0jn4z6DfsLzuWhthl2u9hsJ1+YcdeJ iEDTmtQKOZoPozQddJopnlS1/0GyWu9SbeAATgxl9DBYxSaN3SpW86h59A2oh6JxfPuj xYf1kisIyTPwtaazKQtMiOCEHsqXUeAXoqm3bvJ0rBv/w95/WEC+XkHnXc/oDP6C1yLA AvNBH1wlklQ5MtyNvHjK23NDLd1LscYTbNR6knFTvoZGiJdskleDojQtGSIR+L7hrnsW AkroxMBULSghJdZiOTM89vbZ7qy5er1xHned7/A/ZW46ltLOVzoZbmud3p2sD0stf9VH kI9Q== X-Forwarded-Encrypted: i=1; AJvYcCVwvufD/5ypsWj62k8zgBaOAq8rY/c8GmPK8l+m5ya2oQ0JdTl4ixLhHJKqrNv4/nkcgxmeG+gbFZBrbQiKAkoVaYMqeqgGKI8NKx0e4XoyuDm06aA= X-Gm-Message-State: AOJu0Yxw0f/vKqy5J9FSwURwuzTEOoxAFSAh+iGu3ezvpwuGCTrCIdOX hzesu4cwdSxKgvYmlzgoPrMDxTz7lTn5RP+x1LOnBLr19pk75Wv1ANfDIi5jzCupKBR+K6aaitM eh7U= X-Google-Smtp-Source: AGHT+IFK8wvq8PyTXN9WiF1EgezBeODa2rncnP+7DQvKpvpDW4iDd5x4TKvcCiEvEGI0JGnO+CQD1A== X-Received: by 2002:a17:90a:c38e:b0:297:966:8f4d with SMTP id h14-20020a17090ac38e00b0029709668f4dmr3199103pjt.46.1707934218133; Wed, 14 Feb 2024 10:10:18 -0800 (PST) Received: from localhost (71-212-63-227.tukw.qwest.net. [71.212.63.227]) by smtp.gmail.com with ESMTPSA id sb14-20020a17090b50ce00b00298bc475539sm1766130pjb.33.2024.02.14.10.10.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 10:10:17 -0800 (PST) From: Kevin Hilman To: Bhargav Raviprakash , linux-kernel@vger.kernel.org Cc: m.nirmaladevi@ltts.com, lee@kernel.org, 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, Bhargav Raviprakash Subject: Re: [RESEND PATCH v1 05/13] mfd: tps6594-spi: Add TI TPS65224 PMIC SPI In-Reply-To: <20240208105343.1212902-6-bhargav.r@ltts.com> References: <20240208105343.1212902-1-bhargav.r@ltts.com> <20240208105343.1212902-6-bhargav.r@ltts.com> Date: Wed, 14 Feb 2024 10:10:17 -0800 Message-ID: <7hcysy6ho6.fsf@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_101018_836640_0DB77EF6 X-CRM114-Status: GOOD ( 19.27 ) 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 Bhargav Raviprakash writes: > Add support for TPS65224 PMIC in the TPS6594 driver as they share > significant functional overlap. > > Signed-off-by: Bhargav Raviprakash > --- > drivers/mfd/tps6594-spi.c | 16 ++++++++++------ > 1 file changed, 10 insertions(+), 6 deletions(-) > > diff --git a/drivers/mfd/tps6594-spi.c b/drivers/mfd/tps6594-spi.c > index 5afb1736f..7ec66d31b 100644 > --- a/drivers/mfd/tps6594-spi.c > +++ b/drivers/mfd/tps6594-spi.c > @@ -1,6 +1,6 @@ > // SPDX-License-Identifier: GPL-2.0 > /* > - * SPI access driver for TI TPS6594/TPS6593/LP8764 PMICs > + * SPI access driver for TI TPS65224/TPS6594/TPS6593/LP8764 PMICs > * > * Copyright (C) 2023 BayLibre Incorporated - https://www.baylibre.com/ > */ > @@ -66,7 +66,7 @@ static int tps6594_spi_reg_write(void *context, unsigned int reg, unsigned int v > return spi_write(spi, buf, count); > } > > -static const struct regmap_config tps6594_spi_regmap_config = { > +static struct regmap_config tps6594_spi_regmap_config = { > .reg_bits = 16, > .val_bits = 8, > .max_register = TPS6594_REG_DWD_FAIL_CNT_REG, > @@ -81,6 +81,7 @@ 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,tps65224-q1", .data = (void *)TPS65224, }, > {} > }; > MODULE_DEVICE_TABLE(of, tps6594_spi_of_match_table); > @@ -101,15 +102,18 @@ 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; > > + if (tps->chip_id == TPS65224) > + tps6594_spi_regmap_config.volatile_table = &tps65224_volatile_table; Similar to my comment on the i2c series, but to be more specific: Rather than use the .data pointer in the of_match_table as simply a chip_id, instead make that into a struct that can contain chip-specific values/pointers etc, and then each compatible can have a custom struct (if needed.) This way, at probe/match time, all the chip-specific data is setup using that struct, so that at runtime, there doesn't need to be any "if (chip_id)" checking. Kevin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel