Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp758612rwl; Wed, 5 Apr 2023 07:22:51 -0700 (PDT) X-Google-Smtp-Source: AKy350bHapXocE433h5B0eP+/FPQTkCkgL5EzJe2Se8udkSPiGrwAg2O6WHRYkJ/U28jJ6xxNE+s X-Received: by 2002:a17:902:ebd0:b0:19f:2328:beee with SMTP id p16-20020a170902ebd000b0019f2328beeemr4704242plg.11.1680704571644; Wed, 05 Apr 2023 07:22:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680704571; cv=none; d=google.com; s=arc-20160816; b=mUYYROVXgupvvy7JslRGJ5XfiR2QgTJzux62xtbeEk3tIfQtiIGmr7UDDbHBhPxjq9 csHrSH/Z8QkG7+1Im5QKyU8Do8gEPLganGWkBP2f78+zg/unck0mSVOCMgxsjY1TwFZY aCb0nUrk5a/+Mu837l6kTE0OCeBD4XXunHqeKnNxNqYv2W/4G5ZO0wnlGu2AEQOdMKg2 UCGmDl7nnl2JK80Hl9yoeTQ+8nJIXdLtQB+OxihDrvSjRXCKdj1vbew5EC6f61/vlAka TnhH/PFiK4t+kJW/4Rtu7Yso3wNuSW6ETMOHdqdYfkb1A2W+viePvvhllOtPDP+nB/Ui siBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=nr9B9YoFHcdAnOk7XIXV4TXm5HEeAm6xhWvRCkvPnGM=; b=Ku53Z8Ds328z9QNET8g3BE8Tnv7Id8H+F+0VvIKVrPbJaOiD/a1V5S1Vf3d9su7n9W kc3OQSV3wYI8vUyp/csPxovFW+cHAzrbxQJwbjh6HKL7UMLU8aA/MGbgmnDri0GnvlSW Ny4Xv1XP2uczAb6Ri3u3qMRLxqKHK5fq1lxMI9K8/nbHs4qn+w5a25iymDFY24dKPJ+d TXzjpDoU7NqhmGDsX84qiAnP9MLiWyCA0YJjH2qpt2P/bRyPjtHhX8yGdNCiWFpo8cmP 8FLkMoZLmAaNhYs6ujI1Dlv6o2llQ77KuPvMMhBEGOvZX7Hz8sSKHGMmBMgbTCkc1ywq iYGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@metafoo.de header.s=default2002 header.b=lg1cvw0E; 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=pass (p=NONE sp=NONE dis=NONE) header.from=metafoo.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d17-20020a170903231100b00192721d6a97si12648725plh.499.2023.04.05.07.22.40; Wed, 05 Apr 2023 07:22:51 -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; dkim=pass header.i=@metafoo.de header.s=default2002 header.b=lg1cvw0E; 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=pass (p=NONE sp=NONE dis=NONE) header.from=metafoo.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238339AbjDEOUX (ORCPT + 99 others); Wed, 5 Apr 2023 10:20:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238471AbjDEOT5 (ORCPT ); Wed, 5 Apr 2023 10:19:57 -0400 Received: from www381.your-server.de (www381.your-server.de [78.46.137.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3F906E97; Wed, 5 Apr 2023 07:19:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=metafoo.de; s=default2002; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:Cc:To:Subject:MIME-Version:Date:Message-ID:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID; bh=nr9B9YoFHcdAnOk7XIXV4TXm5HEeAm6xhWvRCkvPnGM=; b=lg1cvw0Ep9UfBxMr4NkkCG2qNy Vo2pSByM8dzATy23gBaOsMupsW2sOxcdSAK3k4B2GwHL0S7DTWM7U/lWiWZbPe4UAgqgA9Qr4LOcf ImiXZtqi3eo6X3x8Wwq4m8U92HJA97/1GFKLsNDrQn1QD+2449d84Mr7YEOIFOPeR2aHiA16Gj6p4 nt5YQ2YP90y5PLSQEFNHyINfL2MC7CxLEh37JTE30r6xe8d21LDkYHIgy+wKY8CgvrJ+UsLUDkecv SbWV+OIjUydKC5gHLZ8UuMGegMh+iljDpYOME4X0ABdXJuw7PUpbYOlFaxU2dDCiBYiw8jS5soJUX tqfwA2PQ==; Received: from sslproxy02.your-server.de ([78.47.166.47]) by www381.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1pk3yL-0004CV-2A; Wed, 05 Apr 2023 16:18:49 +0200 Received: from [2604:5500:c0e5:eb00:da5e:d3ff:feff:933b] by sslproxy02.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pk3yK-000UOi-Na; Wed, 05 Apr 2023 16:18:48 +0200 Message-ID: <9a203f56-c19a-48f2-f10c-ca0794ce79ed@metafoo.de> Date: Wed, 5 Apr 2023 07:18:46 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [PATCH 4/4] iio: dac: mcp4922: add support for mcp48xx series chips Content-Language: en-US To: Nicolas Frattaroli , Jonathan Cameron Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org References: <20230405140114.99011-1-frattaroli.nicolas@gmail.com> <20230405140114.99011-5-frattaroli.nicolas@gmail.com> From: Lars-Peter Clausen In-Reply-To: <20230405140114.99011-5-frattaroli.nicolas@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Authenticated-Sender: lars@metafoo.de X-Virus-Scanned: Clear (ClamAV 0.103.8/26866/Wed Apr 5 09:23:41 2023) X-Spam-Status: No, score=-1.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 Hi, Looks very good. A few small comments inline. [...] > @@ -50,6 +58,35 @@ struct mcp4922_state { > }, \ > } > > +static bool mcp4922_needs_vref(int device_id) `enum mcp4922_supported_device_ids` instead of `int`. Same for num_channels() below. > +{ > + switch (device_id) { > + case ID_MCP4902: > + case ID_MCP4912: > + case ID_MCP4921: > + case ID_MCP4922: > + return true; > + default: > + return false; > + } > +} > [...] > static int mcp4922_spi_write(struct mcp4922_state *state, u8 addr, u32 val) > { > state->mosi[1] = val & 0xff; > @@ -108,11 +145,17 @@ static int mcp4922_write_raw(struct iio_dev *indio_dev, > } > } > > -static const struct iio_chan_spec mcp4922_channels[4][MCP4922_NUM_CHANNELS] = { > +static const struct iio_chan_spec mcp4922_channels[10][MCP4922_NUM_CHANNELS] = { mcp4922_channels[][MCP4922_NUM_CHANNELS] So it does not have to be changed again when adding additional devices in the future. > [...] > @@ -197,11 +244,14 @@ static void mcp4922_remove(struct spi_device *spi) > { > struct iio_dev *indio_dev = spi_get_drvdata(spi); > struct mcp4922_state *state; > + const struct spi_device_id *id = spi_get_device_id(spi); > > iio_device_unregister(indio_dev); > state = iio_priv(indio_dev); > regulator_disable(state->vdd_reg); > - regulator_disable(state->vref_reg); > + if (mcp4922_needs_vref(id->driver_data)) { Could be `if (state->vref_reg)`, this way you don't need to lookup the spi_device_id. But either way is fine. > + regulator_disable(state->vref_reg); > + } > } > > [...]