Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp1004515lqd; Thu, 25 Apr 2024 03:17:26 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV1D5iUej53PtSss7M3VeSZW0nNl0d56cU+YLf4VD44KRghMdKcbuwiZsn12RzlmT7rFOCmEAPX5mcGGFvqCJuVdMLtV3SFmP00/eqyyw== X-Google-Smtp-Source: AGHT+IEmiDCPsraDw52riyQygxUxhfkwH9QEax55wlPZpm5MElOOQAme/U45pvK78I7fMddF/goj X-Received: by 2002:a05:6a00:2e89:b0:6ee:1508:edd4 with SMTP id fd9-20020a056a002e8900b006ee1508edd4mr6827331pfb.7.1714040246178; Thu, 25 Apr 2024 03:17:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714040246; cv=pass; d=google.com; s=arc-20160816; b=Xj/J7mqlPyQeWuY9LN7idraqIYBMZenqBNmVPPYUj557sVtrAUSDnoz2YjubGmzm4u DlyqarVscCTqGUq+GZrQUCUL+Y/RTILk6M0f4OPpnx43pnD7svwkT+ibmZkACwYQqSzm HJ4neynZOUQxYDq8kcwHTt0bVlzyNB2gig9M7GTz9ycF1K/+H8Al1WlE8jRYf2sLwYSp gmcDJ5znlSswzUGyD1sSyBJO2+JJZUKCk+dZjSDZnqnPXPu3hoXqWa+UGtmcm596xieB UYtqq06HNJc2tKJbxImfDlTK3+Ts52jlDxiHQd0psmzp536bqEH/X4pd+/a9jfcuvt2i ovxA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=rk5LPWQLoL0mOBXdRCO3wblAuxieiGS9nszgRdpKbTE=; fh=C/5mBkpfl7JbocND1/IrxMGiEk0Omoh3QT07/Pta/fM=; b=HuuDW9AQM5CKspz8pT0mTnYbQfaFAZqxd1o9WSdHzTd0euIjvEasFa6q199Hr7JOJ3 BZmQ7v2wFNGCfwEdk2KOSjcZT0L+J5CdyPyRN/LudZ3cbOPfJ/xkHOdOLcsjKvt3DQUr 9A9clzay/rXgE+Rqcvo1lav46tczU8XbRb4Ysvzz9D/tIDYrK6mCWVHMhNK1lYFkHR4E mt7woPNYn+yEdoCBbA4+2jJb9kb2v8VFw2vrPIg92OdBIOMvBFoLWNgtH3QXYJloZBXc Vj6RwvufV/5ngKhpEZCeWMZjlNww/G/GOUCanDNH3oznabFy8r+fAAocwaxhWBpyDUFm 00jQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@9elements.com header.s=google header.b=H2pvX2M9; arc=pass (i=1 spf=pass spfdomain=9elements.com dkim=pass dkdomain=9elements.com dmarc=pass fromdomain=9elements.com); spf=pass (google.com: domain of linux-kernel+bounces-158332-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158332-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=9elements.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id h26-20020a63f91a000000b005e858e6a1e5si13095482pgi.585.2024.04.25.03.17.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 03:17:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-158332-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@9elements.com header.s=google header.b=H2pvX2M9; arc=pass (i=1 spf=pass spfdomain=9elements.com dkim=pass dkdomain=9elements.com dmarc=pass fromdomain=9elements.com); spf=pass (google.com: domain of linux-kernel+bounces-158332-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158332-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=9elements.com 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 57743B21E49 for ; Thu, 25 Apr 2024 09:51:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0D1CB86262; Thu, 25 Apr 2024 09:50:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=9elements.com header.i=@9elements.com header.b="H2pvX2M9" Received: from mail-pg1-f182.google.com (mail-pg1-f182.google.com [209.85.215.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E62508614D for ; Thu, 25 Apr 2024 09:50:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714038649; cv=none; b=TF0JaWOk2xWNH3TZS+oyCvT+QL+7tewzDPHGkR3+KNgXuvSOAlKSG726C5Uy1Dbcz/+7eOVG6U+B8w785ERvDKvywdZFseuP3oIgyWWprXAoe6KXnTUZ/fw5qxASog3+joyH8slHujmBcGe1JI6goCe7jM4xfkUJI63lu6wBAug= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714038649; c=relaxed/simple; bh=qdRiSYw8YShEsbcnjovffFj4XN41isfrJsatmjc2y5E=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=l5t/9fLteZajqlnHXquLyPPB0BoQCTFmQfp/QxIX24IUmp5vCYCiwFYGAjJiJTsJiLH+xMldyrqatsGhF1jksiIJBvMtlfn8vL8Dg7xbVu2cF5/qsUQm3Rt5ZofxOtxXB4ES0OGgIFjmddpPkc3uKmPf9WDNAMOP36SVHs0K+lg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=9elements.com; spf=pass smtp.mailfrom=9elements.com; dkim=pass (2048-bit key) header.d=9elements.com header.i=@9elements.com header.b=H2pvX2M9; arc=none smtp.client-ip=209.85.215.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=9elements.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=9elements.com Received: by mail-pg1-f182.google.com with SMTP id 41be03b00d2f7-5f415fd71f8so619465a12.3 for ; Thu, 25 Apr 2024 02:50:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=9elements.com; s=google; t=1714038646; x=1714643446; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=rk5LPWQLoL0mOBXdRCO3wblAuxieiGS9nszgRdpKbTE=; b=H2pvX2M96rZ3oBI+OY4Pw8a3jIvv0yC+/wikhfeddZdOrykrgvCCKG826HnKq5zo0K eS1ag1C3zvZEZQbcoSG3/T+64cVdSpDkPHNRSZHg/Sr57SFs42NDn3skD+McXE9znlX7 QFhVpHC0bBI1/zfK4y768U/CHnRCGzPoMy6qvvmq/Tt4EbafJ9bhRuhGnyE2y7kjOPrY Lav4nrAMzQUScajTlJyg+9ra9OUrSAdczL1aGB/fMkH9fHFEP9Ho3b/gxXci3ssDY5eg +VnTkoV30BcHHK6lYFDcQxTVtKMW5dIwt4COoPFZBsyazO93wIU7IjteaaZRn94kYnOQ O3UQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714038646; x=1714643446; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=rk5LPWQLoL0mOBXdRCO3wblAuxieiGS9nszgRdpKbTE=; b=KaS09eggCDTX+D0DqI1UpftPe5l9tl41RWQtaNGAu6mxuFkh/3ZseBggl9yFroj2Oz 2nkYzqY0B7rJ9jhrAc1f+XfL6iE2iCrLpYiJ2rUo7/JOCntP4QETP4Uw7Dm3uNGdw1+O jCSibkEWiCNZjrlGeDaw9zrzdf+1ug52l3pBXkCMTDYPm0Lp8IQikudVg8X/Y+9wPvHY 0QULkwYhaqplieBzoQ7OIjc27lv1hUw0vMTf977YrwouMv41ZvJiVsk1CX2SfU9+LEGQ fkhUhAwLQFAS5bpBajt+Zu5IDlENjriKKj8xLhtkVl+uLH3QEhjtpPYus5D6w7AG8wt8 G72A== X-Forwarded-Encrypted: i=1; AJvYcCUKYabWkWoofqWv05rsaN8ZQH53omjdNW0Q0qrLZTGbLbKO3PyNDxFuc5SZOt+uvbQD6qCN4RPruzsbeuVbN6LrZxgYzQyjcxYJdMtw X-Gm-Message-State: AOJu0YyU5x0edtNiY60mJXGqcuI8ykhguOdEW7W9n2/PjrpDrqfffB2W Zps9AVXw16t0WkHofyZTYerH/eZZuIx6KdUEEvquciGc2XbRhbAVTnE6FZs9zwx+F5uRwwmkCq0 nxwTToa9eEWu7SN8IMrIeHoC843kYiCLwy2qb+Q== X-Received: by 2002:a17:90a:6808:b0:2a2:55de:93eb with SMTP id p8-20020a17090a680800b002a255de93ebmr4873824pjj.33.1714038646123; Thu, 25 Apr 2024 02:50:46 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240416171720.2875916-1-naresh.solanki@9elements.com> <65607114-89f8-4f48-83fc-b89d87fee247@roeck-us.net> <116aeea1-c648-4abe-9ab2-693bf64000fc@roeck-us.net> In-Reply-To: <116aeea1-c648-4abe-9ab2-693bf64000fc@roeck-us.net> From: Naresh Solanki Date: Thu, 25 Apr 2024 15:20:35 +0530 Message-ID: Subject: Re: [PATCH 1/4] hwmon (max6639): Use regmap To: Guenter Roeck Cc: krzysztof.kozlowski+dt@linaro.org, u.kleine-koenig@pengutronix.de, Jean Delvare , linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Hi Guenter, On Mon, 22 Apr 2024 at 21:32, Guenter Roeck wrote: > > On Mon, Apr 22, 2024 at 04:06:16PM +0530, Naresh Solanki wrote: > > Hi Guenter, > > > > On Wed, 17 Apr 2024 at 02:55, Guenter Roeck wrote: > > > > > > On Tue, Apr 16, 2024 at 10:47:14PM +0530, Naresh Solanki wrote: > > > > Add regmap support. > > > > > > > > > > Missing (and not really utilizing) the benefits of using regmap. > > This is just replacing with regmap support > > > > > > > Signed-off-by: Naresh Solanki > > > > --- > > > > drivers/hwmon/Kconfig | 1 + > > > > drivers/hwmon/max6639.c | 157 ++++++++++++++++++++-------------------- > > > > 2 files changed, 80 insertions(+), 78 deletions(-) > > > > > > > > diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig > > > > index c89776d91795..257ec5360e35 100644 > > > > --- a/drivers/hwmon/Kconfig > > > > +++ b/drivers/hwmon/Kconfig > > > > @@ -1223,6 +1223,7 @@ config SENSORS_MAX6621 > > > > config SENSORS_MAX6639 > > > > tristate "Maxim MAX6639 sensor chip" > > > > depends on I2C > > > > + select REGMAP_I2C > > > > help > > > > If you say yes here you get support for the MAX6639 > > > > sensor chips. > > > > diff --git a/drivers/hwmon/max6639.c b/drivers/hwmon/max6639.c > > > > index aa7f21ab2395..1af93fc53cb5 100644 > > > > --- a/drivers/hwmon/max6639.c > > > > +++ b/drivers/hwmon/max6639.c > > > > @@ -20,6 +20,7 @@ > > > > #include > > > > #include > > > > #include > > > > +#include > > > > > > > > /* Addresses to scan */ > > > > static const unsigned short normal_i2c[] = { 0x2c, 0x2e, 0x2f, I2C_CLIENT_END }; > > > > @@ -57,6 +58,8 @@ static const unsigned short normal_i2c[] = { 0x2c, 0x2e, 0x2f, I2C_CLIENT_END }; > > > > > > > > #define MAX6639_FAN_CONFIG3_THERM_FULL_SPEED 0x40 > > > > > > > > +#define MAX6639_NDEV 2 > > > > + > > > > static const int rpm_ranges[] = { 2000, 4000, 8000, 16000 }; > > > > > > > > #define FAN_FROM_REG(val, rpm_range) ((val) == 0 || (val) == 255 ? \ > > > > @@ -67,7 +70,7 @@ static const int rpm_ranges[] = { 2000, 4000, 8000, 16000 }; > > > > * Client data (each client gets its own) > > > > */ > > > > struct max6639_data { > > > > - struct i2c_client *client; > > > > + struct regmap *regmap; > > > > struct mutex update_lock; > > > > bool valid; /* true if following fields are valid */ > > > > unsigned long last_updated; /* In jiffies */ > > > > @@ -95,9 +98,8 @@ struct max6639_data { > > > > static struct max6639_data *max6639_update_device(struct device *dev) > > > > { > > > > struct max6639_data *data = dev_get_drvdata(dev); > > > > - struct i2c_client *client = data->client; > > > > struct max6639_data *ret = data; > > > > - int i; > > > > + int i, err; > > > > int status_reg; > > > > > > > > mutex_lock(&data->update_lock); > > > > @@ -105,39 +107,35 @@ static struct max6639_data *max6639_update_device(struct device *dev) > > > > > > Conversions to regmap should drop all local caching and use regmap > > > for caching (where appropriate) instead. > > max6639_update_device deals with volatile registers & caching isn't > > available for these. > > > > So ? Unless you replace caching (and accept that volatile registers > are not cached) I do not see the value of this patch. Replacing direct > chip accesses with regmap should have a reason better than "because". > Using regmap for caching would be a valid reason. At the same time, > the value of caching volatile registers is very much questionable. This driver has 27 regmap accesses. Except volatile registers, others are cached by regmap. Some function which only access volatile registers will not be able to take advantage of caching. This is also the case in various other drivers for similar devices. Also regmap offers bit handling which makes the code much cleaner. Regards, Naresh > > Guenter