Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp1392499lqt; Sat, 20 Apr 2024 13:04:28 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXKCqukP5WgJs8cE3Na9WkTWpfWOp8kV1ny6xjZOqfwQtnJ2nnDFWkCAu7H3+eiR9iK7WVL/tFEohUQj+xBwSp43nm8Jbzm1iH5ufYhJw== X-Google-Smtp-Source: AGHT+IE/P/ECXsbA3ky72EseKrea3EfbaCoHVCW77dARQzo4bz1jm4BD/YqFcoCkCtxM47Ba/DJ/ X-Received: by 2002:a05:6870:5490:b0:239:709c:13e5 with SMTP id f16-20020a056870549000b00239709c13e5mr6065381oan.2.1713643468426; Sat, 20 Apr 2024 13:04:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713643468; cv=pass; d=google.com; s=arc-20160816; b=xLf19mFhaKOPjfWPuYmvvsY32sPiI7ygigEbaWvwq9fIOlg44uYgswnYmss+QWqgMa 6UuhyU1Mw7O2mTumMcIaup8Dv2uH1mwn/XeFt6LJLSX6BVUV6ITKDShF7GiBVnr/HbES sS1YUiflCBTBhSfvXwy4/nwOtDCfASyWCBdqlTVmmVG8vr08i3Ktu/0dPicVilhyjUls RZWWShLqyaYv/C6sHa+8Ly50hK18eTBdIeNtESW6LZvi/agqHwhMi4PfI6jPmtD+o+TJ YLvjJpUHFtfDI1dtLeV1uqiATSDyGejEqFanEbnQX05NqQ0C6kmgRS+Luf4cGD/fYdXC VMTQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:cc:to:subject :date:from:references:in-reply-to:message-id; bh=Ffdmw4TY2DykJ75y6Vh72OowFDTKaWiprpxm3BuPycQ=; fh=5McCow2a3hjPiwmeqqGTNpiIYZHjq30hY2vyxe4U53Q=; b=a5MwkUPvQ4vxzx50zsg6U9HnUdb1ZLBshPhte4/+4hiiq3H4OUQQNqhTEy22tlvJj5 guqjhXEv+4IyccpInrTTCjztYPjHegjZoBezOL2zS0HYx1cBNbiGVzY6CGvQntgHtVOQ Cljod+u8BjxArU2OEdy8n5TZbQQ2E8bRfeoKKsQQtQ8Ty1lITmTZfllUWhVc8MCpz5C8 XnAUoqFeXacQzjaU2zUf5tPuN25YdbvGQfYpFcDmp9E4erJ7q0D9nzWcvxUoZrGUs5ZR FM8SBFgE2aqfQ9oS8R51M3ya2ozkBuR1DRfZOzlbX1w6sMzUfFAEGOD3/dtGrcZ423j4 7Ywg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=wunner.de); spf=pass (google.com: domain of linux-kernel+bounces-152367-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-152367-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 12-20020a630e4c000000b005fd0965eb78si685288pgo.27.2024.04.20.13.04.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Apr 2024 13:04:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-152367-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=wunner.de); spf=pass (google.com: domain of linux-kernel+bounces-152367-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-152367-linux.lists.archive=gmail.com@vger.kernel.org" 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 066992815F7 for ; Sat, 20 Apr 2024 20:04:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5526E47F7F; Sat, 20 Apr 2024 20:04:08 +0000 (UTC) Received: from bmailout3.hostsharing.net (bmailout3.hostsharing.net [176.9.242.62]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CE16547F41; Sat, 20 Apr 2024 20:04:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=176.9.242.62 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713643447; cv=none; b=LzDwkP+kzujEA2gFec0PfKYuriwPsnEnD5mH3U2ZezktVGTiqollw7Cjqio2fvrgOd37XxV3bdta1u9fG31N2f+EuC6znplF5WoxesqNCyTc9WLaconojStXcGrR0zQhaIWqzN7w0Qzupc+mB1mnARZLHCYu5orKQ6PfjDcfmeo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713643447; c=relaxed/simple; bh=7otAGZc9k9MKc/6B4+yMK3GVBxObnZ7gLnUmDP9hJug=; h=Message-ID:In-Reply-To:References:From:Date:Subject:To:Cc; b=fOGHHe6HUqFiQUT3QyN68Wn5laV0YCl15WziYN0wfjYq6BPDKV0tdzXfOQOEDL40lasaiMAsOh6HAX/jVHugGLeQzOyEVzxZNLAUArrswx55/bdYXKbJNXyNhbKapwrA8uQubJym0XV8XvGJ0WpehmGuYjcAe5BA6p4NdVyHTxU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=wunner.de; spf=pass smtp.mailfrom=wunner.de; arc=none smtp.client-ip=176.9.242.62 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=wunner.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wunner.de Received: from h08.hostsharing.net (h08.hostsharing.net [83.223.95.28]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "*.hostsharing.net", Issuer "RapidSSL TLS RSA CA G1" (verified OK)) by bmailout3.hostsharing.net (Postfix) with ESMTPS id 246B71003D027; Sat, 20 Apr 2024 22:03:58 +0200 (CEST) Received: by h08.hostsharing.net (Postfix, from userid 100393) id D4A3610C1A8; Sat, 20 Apr 2024 22:03:57 +0200 (CEST) Message-ID: <23c2031acaa64f1c02f00e817c3f7e4466d17ab2.1713608122.git.lukas@wunner.de> In-Reply-To: References: From: Lukas Wunner Date: Sat, 20 Apr 2024 22:00:02 +0200 Subject: [PATCH 2/6] hwmon: Use device_show_string() helper for sysfs attributes To: Greg Kroah-Hartman , "Rafael J. Wysocki" , linux-kernel@vger.kernel.org Cc: Jean Delvare , Guenter Roeck , linux-hwmon@vger.kernel.org Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Deduplicate sysfs ->show() callbacks which expose a string at a static memory location. Use the newly introduced device_show_string() helper in the driver core instead by declaring those sysfs attributes with DEVICE_STRING_ATTR_RO(). No functional change intended. Signed-off-by: Lukas Wunner --- drivers/hwmon/i5k_amb.c | 15 ++++----------- drivers/hwmon/ibmpex.c | 14 ++++---------- 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/drivers/hwmon/i5k_amb.c b/drivers/hwmon/i5k_amb.c index ff48913fe6bf..02f5d35dd319 100644 --- a/drivers/hwmon/i5k_amb.c +++ b/drivers/hwmon/i5k_amb.c @@ -101,14 +101,7 @@ struct i5k_amb_data { unsigned int num_attrs; }; -static ssize_t name_show(struct device *dev, struct device_attribute *devattr, - char *buf) -{ - return sprintf(buf, "%s\n", DRVNAME); -} - - -static DEVICE_ATTR_RO(name); +static DEVICE_STRING_ATTR_RO(name, 0444, DRVNAME); static struct platform_device *amb_pdev; @@ -373,7 +366,7 @@ static int i5k_amb_hwmon_init(struct platform_device *pdev) } } - res = device_create_file(&pdev->dev, &dev_attr_name); + res = device_create_file(&pdev->dev, &dev_attr_name.attr); if (res) goto exit_remove; @@ -386,7 +379,7 @@ static int i5k_amb_hwmon_init(struct platform_device *pdev) return res; exit_remove: - device_remove_file(&pdev->dev, &dev_attr_name); + device_remove_file(&pdev->dev, &dev_attr_name.attr); for (i = 0; i < data->num_attrs; i++) device_remove_file(&pdev->dev, &data->attrs[i].s_attr.dev_attr); kfree(data->attrs); @@ -561,7 +554,7 @@ static void i5k_amb_remove(struct platform_device *pdev) struct i5k_amb_data *data = platform_get_drvdata(pdev); hwmon_device_unregister(data->hwmon_dev); - device_remove_file(&pdev->dev, &dev_attr_name); + device_remove_file(&pdev->dev, &dev_attr_name.attr); for (i = 0; i < data->num_attrs; i++) device_remove_file(&pdev->dev, &data->attrs[i].s_attr.dev_attr); kfree(data->attrs); diff --git a/drivers/hwmon/ibmpex.c b/drivers/hwmon/ibmpex.c index db066b368918..228c5f6c6f38 100644 --- a/drivers/hwmon/ibmpex.c +++ b/drivers/hwmon/ibmpex.c @@ -256,12 +256,7 @@ static struct ibmpex_bmc_data *get_bmc_data(int iface) return NULL; } -static ssize_t name_show(struct device *dev, struct device_attribute *devattr, - char *buf) -{ - return sprintf(buf, "%s\n", DRVNAME); -} -static SENSOR_DEVICE_ATTR_RO(name, name, 0); +static DEVICE_STRING_ATTR_RO(name, 0444, DRVNAME); static ssize_t ibmpex_show_sensor(struct device *dev, struct device_attribute *devattr, @@ -415,8 +410,7 @@ static int ibmpex_find_sensors(struct ibmpex_bmc_data *data) if (err) goto exit_remove; - err = device_create_file(data->bmc_device, - &sensor_dev_attr_name.dev_attr); + err = device_create_file(data->bmc_device, &dev_attr_name.attr); if (err) goto exit_remove; @@ -425,7 +419,7 @@ static int ibmpex_find_sensors(struct ibmpex_bmc_data *data) exit_remove: device_remove_file(data->bmc_device, &sensor_dev_attr_reset_high_low.dev_attr); - device_remove_file(data->bmc_device, &sensor_dev_attr_name.dev_attr); + device_remove_file(data->bmc_device, &dev_attr_name.attr); for (i = 0; i < data->num_sensors; i++) for (j = 0; j < PEX_NUM_SENSOR_FUNCS; j++) { if (!data->sensors[i].attr[j].dev_attr.attr.name) @@ -516,7 +510,7 @@ static void ibmpex_bmc_delete(struct ibmpex_bmc_data *data) device_remove_file(data->bmc_device, &sensor_dev_attr_reset_high_low.dev_attr); - device_remove_file(data->bmc_device, &sensor_dev_attr_name.dev_attr); + device_remove_file(data->bmc_device, &dev_attr_name.attr); for (i = 0; i < data->num_sensors; i++) for (j = 0; j < PEX_NUM_SENSOR_FUNCS; j++) { if (!data->sensors[i].attr[j].dev_attr.attr.name) -- 2.43.0