Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp3709649pxt; Tue, 10 Aug 2021 09:32:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwOX7Mq7FBeDej1Zf6UT6VwCtfhF81bu+DrGseYNGeafmNWCAYi43KMWkyB+DyapF+7eru/ X-Received: by 2002:a05:6402:d49:: with SMTP id ec9mr5888422edb.333.1628613152853; Tue, 10 Aug 2021 09:32:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628613152; cv=none; d=google.com; s=arc-20160816; b=ONrGdIVqZPvx1tboWjykX1xy5P9kWcopG7RCmhPUYb2Bl++DwbLuwBO+PVOzgBrHlG TidMvk+LxUd25cIfMJExhW7KIL0fh+UH5hMBRfdtZjE97Vz8DppzzxixjmBK4KwTvpZO jWfz9cnQOv8nWrYZTnlV3b/vsVjXUirwXHUnk6ggiI/REl1sV8UXC28I02DbFWug126M Ih+AZRkOgHVTxBhKtXN8mFZi1DarKfuc7DZYr5hJXgbNXSXqBvP45jfRQhJEH1oWpw8C cTaEuyoYAM6+bJcelv+mwdBWSzhM+Jv7NIow7tZDUecBqEyo8ZKIcV80pczUKEKkgWCS vqfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=JJJ/oLxgNHBZEDzCWs8ydO8BoNOUNRkg/djNHlTwyhc=; b=FyZHgGnUPCFBC6Ba6/TG2eOBrHuMmnP+RNmYsaO230JeuDrf4dNdOQALWXUVKanGkc 5qkUg/I0PgCiXnhznjzt2NoUYYXh2JEf93pA4j/btVpTr0drofs9f9MmOL6M95i2KIoj vK2YaF65QuBrWcBQm5z4cOASdT1GzRgvJkDliWhkhpex3Vx0N8lvidmxBcuBXoV/acIS EALrbWP70A+YvL93V/MjVb3U5W/YHEXEOK5GZs3TP6fNPG53YhVP2PmUHfMyJ7j7zDVW hH0OYoUmG3XSTfjYx5xzO92LPCmBChFgr8AJ9oQo4Pl+1oQpK/JVk2U9dpQNcagJR0Bp elPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=RqbzGJ2E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m26si22073947edp.375.2021.08.10.09.32.08; Tue, 10 Aug 2021 09:32:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=RqbzGJ2E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240862AbhHJMuw (ORCPT + 99 others); Tue, 10 Aug 2021 08:50:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240849AbhHJMuv (ORCPT ); Tue, 10 Aug 2021 08:50:51 -0400 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B80DC0613D3; Tue, 10 Aug 2021 05:50:29 -0700 (PDT) Received: by mail-pj1-x1035.google.com with SMTP id u21-20020a17090a8915b02901782c36f543so4156225pjn.4; Tue, 10 Aug 2021 05:50:29 -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:content-transfer-encoding; bh=JJJ/oLxgNHBZEDzCWs8ydO8BoNOUNRkg/djNHlTwyhc=; b=RqbzGJ2EljHTfkynsVwTFsWP+yfheO6qjj+QZRbcjoczrxOg9RjpyuhrAGPzGtxldK ISmCzYtzvg7kSnEBnrAElNCOYoyzDeiyo4B9B0QvBMMp2/9QB/PiKYDzKMdqtfDk2uzY thSb2TfQHmYRpFKn3KRf0e84AhVMg0Am8MMgtsVABnR2+tCBh5JIYgPVdUYSlbfx9y22 e9e+r31LgDJ/qB3dPLkWsP/DsLnLEV2ByUuOsvW69n5Ml5ffVch6GMlh/7WdjXM6L46X 4RzZt6+fC0KscmhuJiJ/rUgPOS3ImWVgByXyhUn/uOd4PGERKbV4xUUsAFuswSOOt7zi 2hAA== 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:content-transfer-encoding; bh=JJJ/oLxgNHBZEDzCWs8ydO8BoNOUNRkg/djNHlTwyhc=; b=W38T4TB/vlWZhfnFir5rCa0ESFxpy0zCHmNwmofnRxpCMCu7wM/etLHbDOT7T8IWYS xtbq3hRLM2612o2ml3lNF2FVy2LLP6fA/99+O7rEmpajY/HgoR9ZErZhhsDE6ejla4F2 xk8pzJxykOUGF7MVkVnGxALLo+MP8kQPdBa8DDTCIZyMyIEo06Zk/dgDHDBJSd/S4BkV noMXqsKLkFChVtjQdrJncrnpKgCjUzSG0vtUvelVC6Rs/WFKe6ziXgVnA2m0JL+7Opes Pr5ue4IdtY8XpbUU5xP1yhy00ByNZRpUhGNH9Ybjc7H19yJaX1rVp5ONgYlEgMw/9b9H bejg== X-Gm-Message-State: AOAM532eBGwuSGGzqY77MmKnIHTUhWrOXKSYoqUztJBwrl1gNZ0rAINJ aN89KLrVjdeRAsmd9U0ByvLvvNdPInjNsXwZSfc= X-Received: by 2002:a17:902:b713:b029:12b:b249:693f with SMTP id d19-20020a170902b713b029012bb249693fmr11178496pls.17.1628599828711; Tue, 10 Aug 2021 05:50:28 -0700 (PDT) MIME-Version: 1.0 References: <20210809075745.160042-1-dmugil2000@gmail.com> <20210809075745.160042-3-dmugil2000@gmail.com> In-Reply-To: <20210809075745.160042-3-dmugil2000@gmail.com> From: Andy Shevchenko Date: Tue, 10 Aug 2021 15:49:52 +0300 Message-ID: Subject: Re: [PATCH v2 2/2] iio: potentiometer: Add driver support for AD5110 To: Mugilraj Dhavachelvan Cc: "Bogdan, Dragos" , Darius , Rob Herring , Jonathan Cameron , Lars-Peter Clausen , Michael Hennerich , Guenter Roeck , Chris Packham , Slawomir Stepien , Krzysztof Kozlowski , Alexandre Belloni , Alexandru Ardelean , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 9, 2021 at 10:59 AM Mugilraj Dhavachelvan wrote: > > The AD5110/AD5112/AD5114 provide a nonvolatile solution > for 128-/64-/32-position adjustment applications, offering > guaranteed low resistor tolerance errors of =C2=B18% and up to > =C2=B16 mA current density. ... > +/* > + * Analog Devices AD5110 digital potentiometer driver > + * > + * Copyright (C) 2021 Mugilraj Dhavachelvan > + * > + * Datasheet: https://www.analog.com/media/en/technical-documentation/da= ta-sheets/AD5110_5112_5114.pdf > + * Redundant blank line. > + */ ... > +#define WIPER_RESISTANCE 70 Missed prefix? ... > +static const struct iio_chan_spec ad5110_channels[] =3D { > + { > + .type =3D IIO_RESISTANCE, > + .output =3D 1, > + .info_mask_separate =3D BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_= CHAN_INFO_OFFSET) | > + BIT(IIO_CHAN_INFO_SCALE) | BIT(II= O_CHAN_INFO_ENABLE), > + } + comma. > +}; ... > + ret =3D i2c_master_send_dmasafe(data->client, data->buf, sizeof(d= ata->buf)); > + if (ret !=3D sizeof(data->buf)) { > + ret =3D -EIO; Shadowed error code when ret < 0. > + goto error; > + } ... > + ret =3D i2c_master_send_dmasafe(data->client, data->buf, sizeof(d= ata->buf)); > + if (ret !=3D sizeof(data->buf)) > + ret =3D -EIO; Ditto. > + mutex_unlock(&data->lock); > + > + return ret < 0 ? ret : 0; > +} ... > + data->tol =3D data->cfg->kohms * (val & GENMASK(6, 0)) * 10 / 8; > + if (!(val & BIT(7))) > + data->tol *=3D -1; Shouldn't you simple use corresponding sign_extend*()? ... > + ret =3D ad5110_write(data, AD5110_EEPROM_WR, 0); > + if (ret) { > + dev_err(&data->client->dev, "RDAC to EEPROM write failed\= n"); > + return ret; > + } > + msleep(20); Each long sleeps like this must be explained. ... > +static IIO_DEVICE_ATTR(store_eeprom, 0644, > + ad5110_eeprom_read, > + ad5110_eeprom_write, 0); IIO_DEVICE_ATTR_RW() ? ... > +static struct attribute *ad5110_attributes[] =3D { > + &iio_dev_attr_store_eeprom.dev_attr.attr, > + NULL, No comma for a terminator line. > +}; ... > + data->cfg =3D device_get_match_data(dev); > + if (!data->cfg) > + data->cfg =3D &ad5110_cfg[i2c_match_id(ad5110_id, client)= ->driver_data]; Not sure this is not a dead code since you are using ->probe_new(). ... > +static struct i2c_driver ad5110_driver =3D { > + .driver =3D { > + .name =3D "ad5110", > + .of_match_table =3D ad5110_of_match, > + }, > + .probe_new =3D ad5110_probe, > + .id_table =3D ad5110_id, > +}; > + Redundant blank line. > +module_i2c_driver(ad5110_driver); --=20 With Best Regards, Andy Shevchenko