Received: by 2002:a05:7412:f584:b0:e2:908c:2ebd with SMTP id eh4csp685311rdb; Sun, 3 Sep 2023 06:11:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IELCqcKum2N1U2jTm1nJ1QjuP2tTAPupCpwyz0SW6mZGLxfPhz6KA8tPAgfPth2+sWrgxcr X-Received: by 2002:a2e:7d18:0:b0:2bc:d634:2210 with SMTP id y24-20020a2e7d18000000b002bcd6342210mr4894672ljc.16.1693746715170; Sun, 03 Sep 2023 06:11:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693746715; cv=none; d=google.com; s=arc-20160816; b=SiT3i0hB00KXpQaUNR7p9GSBTkBDzs4iFpnlSXfJoki6vHkv4sZ6DtE8xb3Xed1eNZ mnGQ1LIK/bkG5a/EWCOcIfF7aOoLWpRsZsh943XhGSq57/v/0Z9AFblu9LrVM3318K2E tywGgDNBDGcq6k/9GiCzljl0QbIcEjWKti+Jvgk3oczZj9okAH1eYNB1kaccN0x5ZOYU szyHRm/f2GRQzaZTnSLEhf91/PUM63zsSqFt4SPOu/c5Ko1XyHefy8JPx62VbtS+ONn1 9XZkwJkmxgJj810saDzUTBpMP4aeLwLGAAi8G/BXAfC0OJ6pvGVw4L3TBUs3UROUyLcq c7rA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=QlmN1+Owa3qNW9JR2g3kWD0GZqUv8YDWile7H6JJxzQ=; fh=pnZF6rzA50VQ06Ks8UUSgsDCVUaPEFlTI8rdPUngd8k=; b=xcKTf4aKymrnrHi1jZ/lUo36GDhbm+nOkyWwrXq1US0cqXTu+9egeTanie3c49jh9R OzMVCCArsh1OwEmHhSLk2ErvvSsrLtf2jdrNY53e+mCQMwHvSQVnrX9fHpD1I1yhThs9 zYahNoK5FpSP/olCsbVFmH3YbhcEzAGMjSlLh75DB12MbaXqqgGATbudP5QVFddBONoJ Gm4/v++YNqwQQQ4mMD3/ndCZV9eWenOa3RFUFOnCxvqg10iIp47bCCeTxS1tbHPuXpiK 0tgq0zLqfxy3b5zVFwmzjV1s6Ik46r/ex4cSIv96ysOlXciEv5e1Qb/puFjpGe+wnTEp kDRA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=renesas.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x18-20020a170906805200b009655fcff588si5098343ejw.835.2023.09.03.06.11.19; Sun, 03 Sep 2023 06:11:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=renesas.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236934AbjICL4S (ORCPT + 99 others); Sun, 3 Sep 2023 07:56:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230102AbjICL4S (ORCPT ); Sun, 3 Sep 2023 07:56:18 -0400 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 902EFE5D; Sun, 3 Sep 2023 04:56:08 -0700 (PDT) X-IronPort-AV: E=Sophos;i="6.02,224,1688396400"; d="scan'208";a="178550485" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 03 Sep 2023 20:56:08 +0900 Received: from localhost.localdomain (unknown [10.226.92.30]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 7053F41C2D99; Sun, 3 Sep 2023 20:56:05 +0900 (JST) From: Biju Das To: Jonathan Cameron Cc: Biju Das , Lars-Peter Clausen , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Marek Vasut , Andy Shevchenko , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Biju Das Subject: [PATCH v3 4/4] iio: dac: mcp4725: Add dac_reg_offset to struct mcp4725_chip_info Date: Sun, 3 Sep 2023 12:55:48 +0100 Message-Id: <20230903115548.59306-5-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230903115548.59306-1-biju.das.jz@bp.renesas.com> References: <20230903115548.59306-1-biju.das.jz@bp.renesas.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The MCP4725 has a register offset '3' for reading DAC value compared to '4' for MCP4726. Add dac_reg_offset variable to struct mcp4725_chip_info to handle this difference. Drop chip_id from struct mcp4725_chip_info as it is unused. Signed-off-by: Biju Das --- v3: * New patch. --- drivers/iio/dac/mcp4725.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/iio/dac/mcp4725.c b/drivers/iio/dac/mcp4725.c index 9cbea6f223e4..25bb1c0490af 100644 --- a/drivers/iio/dac/mcp4725.c +++ b/drivers/iio/dac/mcp4725.c @@ -32,7 +32,7 @@ struct mcp4725_chip_info { const struct iio_chan_spec *chan_spec; - unsigned int chip_id; + u8 dac_reg_offset; bool use_ext_ref_voltage; }; @@ -463,7 +463,7 @@ static int mcp4725_probe(struct i2c_client *client) indio_dev->modes = INDIO_DIRECT_MODE; /* read current DAC value and settings */ - err = i2c_master_recv(client, inbuf, info->chip_id == MCP4725 ? 3 : 4); + err = i2c_master_recv(client, inbuf, info->dac_reg_offset); if (err < 0) { dev_err(&client->dev, "failed to read DAC value"); @@ -515,13 +515,13 @@ static void mcp4725_remove(struct i2c_client *client) static const struct mcp4725_chip_info mcp4725 = { .chan_spec = &mcp472x_channel[MCP4725], - .chip_id = MCP4725, + .dac_reg_offset = 3, .use_ext_ref_voltage = true, }; static const struct mcp4725_chip_info mcp4726 = { .chan_spec = &mcp472x_channel[MCP4726], - .chip_id = MCP4726, + .dac_reg_offset = 4, }; static const struct i2c_device_id mcp4725_id[] = { -- 2.25.1