Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp770196rdb; Thu, 30 Nov 2023 19:26:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IGthWZj344NTfLT46JwOs3+om3dGuZIji82koLf0tV0Ah3ucmQ6ECZRGHgKrnQHkGO1NSyq X-Received: by 2002:a05:6a20:160d:b0:187:60da:4767 with SMTP id l13-20020a056a20160d00b0018760da4767mr36641255pzj.25.1701401201889; Thu, 30 Nov 2023 19:26:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701401201; cv=none; d=google.com; s=arc-20160816; b=Ap8pSuehQNunBqbqyhdSR5fW9283n4jUx2YJ15sgR2i9ZKM5OC/R+5vyuQ7LTvoslq +AirYdymLS5t/YOKcp9EM1GvmyI3/61aq/r0jrWTV66AE7dZOdnDmGHBwkZdTm3aYiKB FmSNlCrxWLbIKc6oObts6sIWmYjlcj1s7uWPdPlY5kaYhzLcxFP2hDYqVdU9BYjbWe50 EJIrhnmWMpg3dUBqzBDW5vw2IX1zcUZhpegrd1JLzMeMhPS4hW6mK5Fiw7b9jX7RgC/K S4yCuuhPkCqtxamoel6LDfB8JXqaGvegxC5f7Fk/K0AUpBzbTZ9zkBmXXZIwJIZl2fHg hBkw== 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:autocrypt :from:references:cc:to:content-language:subject:user-agent :mime-version:date:message-id:sender:dkim-signature; bh=fvebJ5QToydTLWgRyxHFD+Ru+EdCC8PFScYOP2fmWDk=; fh=VxI5cUkM2Q3hcg7eK5zkgxzoWDYHvY3a1I4e6Suy8kA=; b=Mq41DkfHk9EuhaA2ELWXz6pGBpRfGjjl0ul5Fs3RG1tqs+UZLfZ0k8InKvYCEVJse9 Bd/lZoUc2+MopejxXFz1Yuvuef95eP48FFW8xjHrH4PD+XfgB4RRJudHeaIwjQZeSKKX aMi9ruaPct3ew16dkqt0F/B/aUOiAKUoVqzzfFkx/aYWjBfox+ErWPb6TFFeJBjXEXlx Dc/YfihzClh+UzASaX3osvqKSk6sty4PAhPm/47MFMm0eWh9u/eNOJMmclpV0wTiIv6i ELLqDMpzEWCYa0Dw8cHl89lj3tHkoUUr6HT88VkUdhvRrLZi4K0ZRxmufqm7VuhARnCT Zx8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=MXMZe047; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id y33-20020a634961000000b005b896ecd1efsi2635237pgk.172.2023.11.30.19.26.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 19:26:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=MXMZe047; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 781DA80DF27D; Thu, 30 Nov 2023 19:26:40 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230098AbjLAD0a (ORCPT + 99 others); Thu, 30 Nov 2023 22:26:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229523AbjLAD03 (ORCPT ); Thu, 30 Nov 2023 22:26:29 -0500 Received: from mail-ot1-x333.google.com (mail-ot1-x333.google.com [IPv6:2607:f8b0:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D36D31717; Thu, 30 Nov 2023 19:26:34 -0800 (PST) Received: by mail-ot1-x333.google.com with SMTP id 46e09a7af769-6d83ff72dbbso47785a34.1; Thu, 30 Nov 2023 19:26:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701401194; x=1702005994; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=fvebJ5QToydTLWgRyxHFD+Ru+EdCC8PFScYOP2fmWDk=; b=MXMZe047HX0MGLmuuuvZc8cl0jVRZc2JJnoVdncQ0YLOAgnIzDtiDwwBHzFUij45Do Vu7eXAYWRYNHQpslfko+5onC+7HnReBTfeI8RxY23h6vUchNTpXe30eFb6Zk3d/pevvN uIDFI9hsDhOMl06s0ci2eDrYKKbtYJIDSEjeA5Y0FBadnx3ZcPb1HWSSZkThmhob0DOk Ezr5RjKi11v1e1hPDk9maoDKv8Zm23H4BvBqIJHVNQsoLXvCyEHgnPj45ldBEmJPe6Yp sARaYOY7Gpga41q0assB9sk9lkxSLxrzM+H6xA2NWPwXWhD2Ih61JUHI8lxDqAm8x/SX SaWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701401194; x=1702005994; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=fvebJ5QToydTLWgRyxHFD+Ru+EdCC8PFScYOP2fmWDk=; b=iftv3Q3FV+rrlj74KhTTcg72Us75gwRpVGhbdxhHGvtwBYIIOhXxNJvNGJkXAMham3 T+ud6kBkvolkC3tKnaapoiPxu7touIwcYel2supf69yabQVrKN04jN3Xn1bVvlR4GgNt u8BXG65BILJ/jZ+QcNAI5pN4FgJTk540PsbG935fDrQPpWYnWneqm4P0eRpsShOrMgHN EVfPg2J2s5ivHIton3dvRBk+78O6ou2qZrp9y3M8+ZSocOvS71ZZ+RdLaqmAyRLKCG5C DBdPaROCheN7GJGazLQmmX0YmudFoxTRYHfiOG/YRag2e4W6a/SfMBJEpnJpN4oAXXIw Wvig== X-Gm-Message-State: AOJu0YyC91m7Z5YhaHaxne98UfbfkWXqg0U7xry/arm09AKFg2vUCl5X hJHhToFLumojtDV3yWP4j/jGIsMH6EI= X-Received: by 2002:a9d:630e:0:b0:6c4:56b4:e91c with SMTP id q14-20020a9d630e000000b006c456b4e91cmr895317otk.7.1701401194098; Thu, 30 Nov 2023 19:26:34 -0800 (PST) Received: from ?IPV6:2600:1700:e321:62f0:329c:23ff:fee3:9d7c? ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id u12-20020a056830118c00b006ce2db9e6c4sm363220otq.36.2023.11.30.19.26.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 30 Nov 2023 19:26:33 -0800 (PST) Sender: Guenter Roeck Message-ID: Date: Thu, 30 Nov 2023 19:26:31 -0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/3] hwmon: (coretemp) Remove unnecessary dependency of array index Content-Language: en-US To: Ashok Raj , Zhang Rui Cc: jdelvare@suse.com, fenghua.yu@intel.com, linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, Ashok Raj References: <20231127131651.476795-1-rui.zhang@intel.com> <20231127131651.476795-3-rui.zhang@intel.com> From: Guenter Roeck Autocrypt: addr=linux@roeck-us.net; keydata= xsFNBE6H1WcBEACu6jIcw5kZ5dGeJ7E7B2uweQR/4FGxH10/H1O1+ApmcQ9i87XdZQiB9cpN RYHA7RCEK2dh6dDccykQk3bC90xXMPg+O3R+C/SkwcnUak1UZaeK/S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ECAA8CGwwFAlVcpi8FCRmg08MACgkQyx8mb86fmYHNRQ/+ J0OZsBYP4leJvQF8lx9zif+v4ZY/6C9tTcUv/KNAE5leyrD4IKbnV4PnbrVhjq861it/zRQW cFpWQszZyWRwNPWUUz7ejmm9lAwPbr8xWT4qMSA43VKQ7ZCeTQJ4TC8kjqtcbw41SjkjrcTG wF52zFO4bOWyovVAPncvV9eGA/vtnd3xEZXQiSt91kBSqK28yjxAqK/c3G6i7IX2rg6pzgqh hiH3/1qM2M/LSuqAv0Rwrt/k+pZXE+B4Ud42hwmMr0TfhNxG+X7YKvjKC+SjPjqp0CaztQ0H nsDLSLElVROxCd9m8CAUuHplgmR3seYCOrT4jriMFBtKNPtj2EE4DNV4s7k0Zy+6iRQ8G8ng QjsSqYJx8iAR8JRB7Gm2rQOMv8lSRdjva++GT0VLXtHULdlzg8VjDnFZ3lfz5PWEOeIMk7Rj trjv82EZtrhLuLjHRCaG50OOm0hwPSk1J64R8O3HjSLdertmw7eyAYOo4RuWJguYMg5DRnBk WkRwrSuCn7UG+qVWZeKEsFKFOkynOs3pVbcbq1pxbhk3TRWCGRU5JolI4ohy/7JV1TVbjiDI HP/aVnm6NC8of26P40Pg8EdAhajZnHHjA7FrJXsy3cyIGqvg9os4rNkUWmrCfLLsZDHD8FnU mDW4+i+XlNFUPUYMrIKi9joBhu18ssf5i5Q= In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 30 Nov 2023 19:26:40 -0800 (PST) On 11/30/23 17:27, Ashok Raj wrote: > On Mon, Nov 27, 2023 at 09:16:50PM +0800, Zhang Rui wrote: >> When sensor_device_attribute pointer is available, use container_of() to >> get the temp_data address. >> >> This removes the unnecessary dependency of cached index in >> pdata->core_data[]. >> >> Signed-off-by: Zhang Rui >> --- >> drivers/hwmon/coretemp.c | 15 +++++---------- >> 1 file changed, 5 insertions(+), 10 deletions(-) >> >> diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c >> index 6053ed3761c2..cef43fedbd58 100644 >> --- a/drivers/hwmon/coretemp.c >> +++ b/drivers/hwmon/coretemp.c >> @@ -342,7 +342,7 @@ static ssize_t show_label(struct device *dev, >> { >> struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); >> struct platform_data *pdata = dev_get_drvdata(dev); >> - struct temp_data *tdata = pdata->core_data[attr->index]; >> + struct temp_data *tdata = container_of(attr, struct temp_data, sd_attrs[ATTR_LABEL]); >> >> if (tdata->is_pkg_data) >> return sprintf(buf, "Package id %u\n", pdata->pkg_id); >> @@ -355,8 +355,7 @@ static ssize_t show_crit_alarm(struct device *dev, >> { >> u32 eax, edx; >> struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); >> - struct platform_data *pdata = dev_get_drvdata(dev); >> - struct temp_data *tdata = pdata->core_data[attr->index]; >> + struct temp_data *tdata = container_of(attr, struct temp_data, sd_attrs[ATTR_CRIT_ALARM]); >> >> mutex_lock(&tdata->update_lock); >> rdmsr_on_cpu(tdata->cpu, tdata->status_reg, &eax, &edx); >> @@ -369,8 +368,7 @@ static ssize_t show_tjmax(struct device *dev, >> struct device_attribute *devattr, char *buf) >> { >> struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); >> - struct platform_data *pdata = dev_get_drvdata(dev); >> - struct temp_data *tdata = pdata->core_data[attr->index]; >> + struct temp_data *tdata = container_of(attr, struct temp_data, sd_attrs[ATTR_TJMAX]); >> int tjmax; >> >> mutex_lock(&tdata->update_lock); >> @@ -384,8 +382,7 @@ static ssize_t show_ttarget(struct device *dev, >> struct device_attribute *devattr, char *buf) >> { >> struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); >> - struct platform_data *pdata = dev_get_drvdata(dev); >> - struct temp_data *tdata = pdata->core_data[attr->index]; >> + struct temp_data *tdata = container_of(attr, struct temp_data, sd_attrs[ATTR_TTARGET]); >> int ttarget; >> >> mutex_lock(&tdata->update_lock); >> @@ -402,8 +399,7 @@ static ssize_t show_temp(struct device *dev, >> { >> u32 eax, edx; >> struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); >> - struct platform_data *pdata = dev_get_drvdata(dev); >> - struct temp_data *tdata = pdata->core_data[attr->index]; >> + struct temp_data *tdata = container_of(attr, struct temp_data, sd_attrs[ATTR_TEMP]); >> int tjmax; >> >> mutex_lock(&tdata->update_lock); >> @@ -445,7 +441,6 @@ static int create_core_attrs(struct temp_data *tdata, struct device *dev, >> tdata->sd_attrs[i].dev_attr.attr.name = tdata->attr_name[i]; >> tdata->sd_attrs[i].dev_attr.attr.mode = 0444; >> tdata->sd_attrs[i].dev_attr.show = rd_ptr[i]; >> - tdata->sd_attrs[i].index = attr_no; > > I was naively thinking if we could nuke that "index". I can see that used > in couple macros, but seems like we can lose it? > > Completely untested.. and uncertain :-) > If you had suggested to replace struct sensor_device_attribute sd_attrs[TOTAL_ATTRS]; with struct device_attribute sd_attrs[TOTAL_ATTRS]; what you suggested may actually be possible and make sense. However, suggesting to dump the index parameter of SENSOR_ATTR() completely because _this_ driver may no longer need it seems to be a little excessive. > > diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h > index d896713359cd..4855893f9401 100644 > --- a/include/linux/hwmon-sysfs.h > +++ b/include/linux/hwmon-sysfs.h > @@ -12,36 +12,35 @@ > > struct sensor_device_attribute{ > struct device_attribute dev_attr; > - int index; > }; > #define to_sensor_dev_attr(_dev_attr) \ > container_of(_dev_attr, struct sensor_device_attribute, dev_attr) > > -#define SENSOR_ATTR(_name, _mode, _show, _store, _index) \ > +#define SENSOR_ATTR(_name, _mode, _show, _store) \ > { .dev_attr = __ATTR(_name, _mode, _show, _store), \ > - .index = _index } > + } > > -#define SENSOR_ATTR_RO(_name, _func, _index) \ > +#define SENSOR_ATTR_RO(_name, _func) \ > SENSOR_ATTR(_name, 0444, _func##_show, NULL, _index) > > -#define SENSOR_ATTR_RW(_name, _func, _index) \ > - SENSOR_ATTR(_name, 0644, _func##_show, _func##_store, _index) > +#define SENSOR_ATTR_RW(_name, _func) \ > + SENSOR_ATTR(_name, 0644, _func##_show, _func##_store) > > -#define SENSOR_ATTR_WO(_name, _func, _index) \ > - SENSOR_ATTR(_name, 0200, NULL, _func##_store, _index) > +#define SENSOR_ATTR_WO(_name, _func) \ > + SENSOR_ATTR(_name, 0200, NULL, _func##_store) > > -#define SENSOR_DEVICE_ATTR(_name, _mode, _show, _store, _index) \ > +#define SENSOR_DEVICE_ATTR(_name, _mode, _show, _store) \ > struct sensor_device_attribute sensor_dev_attr_##_name \ > - = SENSOR_ATTR(_name, _mode, _show, _store, _index) > + = SENSOR_ATTR(_name, _mode, _show, _store) > > -#define SENSOR_DEVICE_ATTR_RO(_name, _func, _index) \ > - SENSOR_DEVICE_ATTR(_name, 0444, _func##_show, NULL, _index) > +#define SENSOR_DEVICE_ATTR_RO(_name, _func) \ > + SENSOR_DEVICE_ATTR(_name, 0444, _func##_show, NULL) > > #define SENSOR_DEVICE_ATTR_RW(_name, _func, _index) \ > - SENSOR_DEVICE_ATTR(_name, 0644, _func##_show, _func##_store, _index) > + SENSOR_DEVICE_ATTR(_name, 0644, _func##_show, _func##_store) > > -#define SENSOR_DEVICE_ATTR_WO(_name, _func, _index) \ > - SENSOR_DEVICE_ATTR(_name, 0200, NULL, _func##_store, _index) > +#define SENSOR_DEVICE_ATTR_WO(_name, _func) \ > + SENSOR_DEVICE_ATTR(_name, 0200, NULL, _func##_store) > > struct sensor_device_attribute_2 { > struct device_attribute dev_attr; > diff --git a/drivers/gpu/drm/i915/i915_hwmon.c b/drivers/gpu/drm/i915/i915_hwmon.c > index 975da8e7f2a9..c3bbf2f7d6eb 100644 > --- a/drivers/gpu/drm/i915/i915_hwmon.c > +++ b/drivers/gpu/drm/i915/i915_hwmon.c > @@ -239,7 +239,7 @@ hwm_power1_max_interval_store(struct device *dev, > > static SENSOR_DEVICE_ATTR(power1_max_interval, 0664, > hwm_power1_max_interval_show, > - hwm_power1_max_interval_store, 0); > + hwm_power1_max_interval_store); > That driver could and should have used DEVICE_ATTR() instead of SENSOR_DEVICE_ATTR(), and there are various other drivers where that would have made sense. Actually, it should have used DEVICE_ATTR_RW() but that is just a detail. However, there are more than 2,000 uses of SENSOR_DEVICE_ATTR() and derived macros in the kernel. The large majority of those do set index to values != 0, and the affected drivers would not be happy if that argument disappeared. Frankly, I am not entirely sure if you were serious with your suggestion. I tried to give a serious reply, but I am not entirely sure if I succeeded. My apologies if some sarcasm was bleeding through. Guenter