From patchwork Mon Dec 2 19:00:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13891208 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (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 490561DE3D4 for ; Mon, 2 Dec 2024 19:00:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733166042; cv=none; b=RUM9mSZgU7HlkZ9U29AlGszjsR1dAPVUzOJRRzWQbPcpchZ05MXz3tdRouj6uxSrJL7Ywp9QASckv4qlGTRtGa4nzxGT9tESkktR1+O6pRRxyJZpLqqJo3K9rr4spgtbjk+W+NYv8PnvJ3k1Og6AEe7yu/5D9dbHXPQR/hSGzb0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733166042; c=relaxed/simple; bh=c+OK0c9DqudvV6de1q2cguTuEZ7rc+EiMnpII+VV+gk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Hs67NXjXl1A7AW09f88xZwX1TiBYgndrSszK6ScRPpz6qQhGPpjaJ8ZtpVkIV1bP3Hwh+v30TYTp3kIl/UuVxuw+braMv2I/1Eqo8bci2WmHMwyvKxFMD8TBiJfxags1rORCD55p8GFgCko0KXvzRcv2V8FIiMi7ktuTvszH7Og= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=PRoJTN2/; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="PRoJTN2/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1733166037; bh=c+OK0c9DqudvV6de1q2cguTuEZ7rc+EiMnpII+VV+gk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=PRoJTN2/WD38X6ex2MklShCZg4/Zhp1aBS6bQhM8KrWUKqsIfTO3E8JpPTZQWn4yX i5z49I+Y6UsDRqwh7UMg09/F+TG8YXqtHA7xPEWaCEmYJ+9zF+wZlqRnJCyDh2xJeW xqMnqBJ6ZG0AY934vDKCRdaTH8lcC+h9nHW3odGI= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Mon, 02 Dec 2024 20:00:36 +0100 Subject: [PATCH 1/5] sysfs: add macro BIN_ATTR_ADMIN_WO() Precedence: bulk X-Mailing-List: chrome-platform@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241202-sysfs-const-bin_attr-admin_wo-v1-1-f489116210bf@weissschuh.net> References: <20241202-sysfs-const-bin_attr-admin_wo-v1-0-f489116210bf@weissschuh.net> In-Reply-To: <20241202-sysfs-const-bin_attr-admin_wo-v1-0-f489116210bf@weissschuh.net> To: Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Naveen N Rao , Madhavan Srinivasan , Tzung-Bi Shih , Brian Norris , Julius Werner , "James E.J. Bottomley" , "Martin K. Petersen" Cc: linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, chrome-platform@lists.linux.dev, linux-scsi@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1733166036; l=1326; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=c+OK0c9DqudvV6de1q2cguTuEZ7rc+EiMnpII+VV+gk=; b=fYgHqAdIAZatDuw8uWF0U9ElsIjChzM1qpbbyZvPW4NW8SrhhzeOs4sK7avctzwIrWksSbzAm jxiHNn1GgsFDhjK/57O009WAci/xOF8vWIVviFFNIlMNHEynIxZO/h2 X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= The macros BIN_ATTR_RO/BIN_ATTR_WO/BIN_ATTR_WR and BIN_ATTR_ADMIN_RO/BIN_ATTR_ADMIN_RW already exist. To complete the collection also add BIN_ATTR_ADMIN_WO. Signed-off-by: Thomas Weißschuh Reviewed-by: Tzung-Bi Shih --- include/linux/sysfs.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h index 0f2fcd244523f050c5286f19d4fe1846506f9214..bcae49105e54a79b7d8a610f17212cb5920c205a 100644 --- a/include/linux/sysfs.h +++ b/include/linux/sysfs.h @@ -385,12 +385,18 @@ struct bin_attribute bin_attr_##_name = __BIN_ATTR_RW(_name, _size) #define __BIN_ATTR_ADMIN_RO(_name, _size) \ __BIN_ATTR(_name, 0400, _name##_read, NULL, _size) +#define __BIN_ATTR_ADMIN_WO(_name, _size) \ + __BIN_ATTR(_name, 0200, NULL, _name##_write, _size) + #define __BIN_ATTR_ADMIN_RW(_name, _size) \ __BIN_ATTR(_name, 0600, _name##_read, _name##_write, _size) #define BIN_ATTR_ADMIN_RO(_name, _size) \ struct bin_attribute bin_attr_##_name = __BIN_ATTR_ADMIN_RO(_name, _size) +#define BIN_ATTR_ADMIN_WO(_name, _size) \ +struct bin_attribute bin_attr_##_name = __BIN_ATTR_ADMIN_WO(_name, _size) + #define BIN_ATTR_ADMIN_RW(_name, _size) \ struct bin_attribute bin_attr_##_name = __BIN_ATTR_ADMIN_RW(_name, _size) From patchwork Mon Dec 2 19:00:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13891207 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (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 9EA8B1DE3CB for ; Mon, 2 Dec 2024 19:00:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733166042; cv=none; b=EAjp150YXSGemvTTDBM9kzQMYzpLDh0qse1jLGf5yw0Ta3V48yIpO20ySijuUVJH83Ji+mLtE1o+0CYFQ5kj6aEX+wrr+l5ydc6FqyhdT0rvX5Kpry6I995iM72bVlH5PSbm8Bs/LTdrLttWs/Am384Sbosc1ETnIUMyxRVFi74= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733166042; c=relaxed/simple; bh=xou28swiaoBiDmWpjvH656ao7GcdNsfrzFboEHzP1GM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ECYQu0kZ4H3CWCpLWG8HR8LGVRznyu20iJBD8POLjQD2KtiOGCAEfFx/rSO+n9jIMyVl+YyqmutNUHp356/dUJSzGr4g4vBsUUkOW2PG8RDNRUaP4iRLG3hIY00ofhKr0G5r9E3z487jEAnN7DbkmzYUEwWKOoUieapy9q6TQMk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=VqX26pnl; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="VqX26pnl" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1733166037; bh=xou28swiaoBiDmWpjvH656ao7GcdNsfrzFboEHzP1GM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=VqX26pnlkKD4n+vv/jNOMJWWV3ESbtROgqI/ThqvtEtZ4dhs0a0zruOYJPBUNnoyF PL9lyngKcbu8L/cn+IzJbZKlApbrEiP0EgrTjmkCX0o9HdgNFxI7KFB9PRs/HlRoHa xiD+Ep6fGcSkjH2TV8X9Ca69OaWAHpV45r7ymKEQ= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Mon, 02 Dec 2024 20:00:37 +0100 Subject: [PATCH 2/5] s390/sclp_config: use BIN_ATTR_ADMIN_WO() for bin_attribute definition Precedence: bulk X-Mailing-List: chrome-platform@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241202-sysfs-const-bin_attr-admin_wo-v1-2-f489116210bf@weissschuh.net> References: <20241202-sysfs-const-bin_attr-admin_wo-v1-0-f489116210bf@weissschuh.net> In-Reply-To: <20241202-sysfs-const-bin_attr-admin_wo-v1-0-f489116210bf@weissschuh.net> To: Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Naveen N Rao , Madhavan Srinivasan , Tzung-Bi Shih , Brian Norris , Julius Werner , "James E.J. Bottomley" , "Martin K. Petersen" Cc: linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, chrome-platform@lists.linux.dev, linux-scsi@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1733166036; l=1812; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=xou28swiaoBiDmWpjvH656ao7GcdNsfrzFboEHzP1GM=; b=vfWtzqSvOITqm9SIRme74Qk53uJwokLIIK0tBYouqbxDGe+gNmhS3pAcZF3um7CX0Thy4ZYvi H8BDLWi3jB1Ckix9bcV5uNOkUK2JN6TmlPQN38QAc33eOmKZczOf8Yb X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Using the macro saves some lines of code and prepares the attribute for the general constifications of struct bin_attributes. While at it also constify the callback parameter. Signed-off-by: Thomas Weißschuh Reviewed-by: Tzung-Bi Shih --- drivers/s390/char/sclp_config.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/s390/char/sclp_config.c b/drivers/s390/char/sclp_config.c index f56ea9b60e08e817652a9b7d19d420e9977c6552..0fe0782ccd325c1c3907e5d6272f770477e9ea46 100644 --- a/drivers/s390/char/sclp_config.c +++ b/drivers/s390/char/sclp_config.c @@ -127,9 +127,9 @@ static int sclp_ofb_send_req(char *ev_data, size_t len) return rc; } -static ssize_t sysfs_ofb_data_write(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, - char *buf, loff_t off, size_t count) +static ssize_t event_data_write(struct file *filp, struct kobject *kobj, + const struct bin_attribute *bin_attr, + char *buf, loff_t off, size_t count) { int rc; @@ -137,13 +137,7 @@ static ssize_t sysfs_ofb_data_write(struct file *filp, struct kobject *kobj, return rc ?: count; } -static const struct bin_attribute ofb_bin_attr = { - .attr = { - .name = "event_data", - .mode = S_IWUSR, - }, - .write = sysfs_ofb_data_write, -}; +static const BIN_ATTR_ADMIN_WO(event_data, 0); #endif static int __init sclp_ofb_setup(void) @@ -155,7 +149,7 @@ static int __init sclp_ofb_setup(void) ofb_kset = kset_create_and_add("ofb", NULL, firmware_kobj); if (!ofb_kset) return -ENOMEM; - rc = sysfs_create_bin_file(&ofb_kset->kobj, &ofb_bin_attr); + rc = sysfs_create_bin_file(&ofb_kset->kobj, &bin_attr_event_data); if (rc) { kset_unregister(ofb_kset); return rc; From patchwork Mon Dec 2 19:00:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13891205 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (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 9EA1E1DE3A4 for ; Mon, 2 Dec 2024 19:00:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733166041; cv=none; b=VxcaVOBg2sf2bK3WRlxGjBir81nTu3hwPBBRzIpL2+BNfgyBdqFumYrR6ZAn01esDQ2/zVNFm0RLBMrjyT0ugRPVUauMip3moqh5PTpJjMIpWayUw2jxwij49v2K4fyyHVEg677qPXFTq/SxHzdNyy+C4CcRA74usIsFHXwTjiA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733166041; c=relaxed/simple; bh=8pXu+KIDxnIkhmw4RN4FUIaU1wDaZ00iHKd989Tn4us=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=txsJ11nDtOjEX/BgRwlroW1NYXQ8LOlfnEk42/BCL57J5FWhsWblZGQdlo5y3KCNTUbP/y0fbdSI4vbGRT2djAN8j0VbstKP2Y8LUuE8RnrG9zoNPvb4C5A+TWRerJtL8KmlSFTBHJbUoKzC4OeQUva9n3cCr/0FhfFJWDOpcY0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=gBFUrsr+; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="gBFUrsr+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1733166037; bh=8pXu+KIDxnIkhmw4RN4FUIaU1wDaZ00iHKd989Tn4us=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=gBFUrsr+Y5gbKfCIBnN+mVBBLd2ht/Yzp1ZH68AnyWMsUH4frA+qekk4i7UYOFI0e RqmX5J+DxnEU0LTjzjOYyubiCNThRXZ56K6Eeuvec0cCO4nkiBkYsp6kBWYN1kA7cX 610RLvEWkMG/ATbdxyi5CBTAICClHMTtMw/KhT8s= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Mon, 02 Dec 2024 20:00:38 +0100 Subject: [PATCH 3/5] powerpc/powernv/flash: Use BIN_ATTR_ADMIN_WO() for bin_attribute definition Precedence: bulk X-Mailing-List: chrome-platform@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241202-sysfs-const-bin_attr-admin_wo-v1-3-f489116210bf@weissschuh.net> References: <20241202-sysfs-const-bin_attr-admin_wo-v1-0-f489116210bf@weissschuh.net> In-Reply-To: <20241202-sysfs-const-bin_attr-admin_wo-v1-0-f489116210bf@weissschuh.net> To: Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Naveen N Rao , Madhavan Srinivasan , Tzung-Bi Shih , Brian Norris , Julius Werner , "James E.J. Bottomley" , "Martin K. Petersen" Cc: linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, chrome-platform@lists.linux.dev, linux-scsi@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1733166036; l=2014; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=8pXu+KIDxnIkhmw4RN4FUIaU1wDaZ00iHKd989Tn4us=; b=HSh67zAWq4cTiwB5DE8N7fJi0p97k9R1Vmirv2ID1DlZHm9pe/UI8TBVHOAvhFnWJM+PYdtth zpBnll2/qZKAZPIjlMaeAO9ZGuBUFjgAjH5JihuVFiUP5OozHEDK1It X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Using the macro saves some lines of code and prepares the attribute for the general constifications of struct bin_attributes. While at it also constify the callback parameter. Signed-off-by: Thomas Weißschuh Reviewed-by: Tzung-Bi Shih --- arch/powerpc/platforms/powernv/opal-flash.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/arch/powerpc/platforms/powernv/opal-flash.c b/arch/powerpc/platforms/powernv/opal-flash.c index d5ea04e8e4c526b99ca8f1ab613266b385362d82..76e3818601e5610f48bb8a6fd325239d6ad39723 100644 --- a/arch/powerpc/platforms/powernv/opal-flash.c +++ b/arch/powerpc/platforms/powernv/opal-flash.c @@ -431,9 +431,9 @@ static int alloc_image_buf(char *buffer, size_t count) * Parse candidate image header to get total image size * and pre-allocate required memory. */ -static ssize_t image_data_write(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, - char *buffer, loff_t pos, size_t count) +static ssize_t image_write(struct file *filp, struct kobject *kobj, + const struct bin_attribute *bin_attr, + char *buffer, loff_t pos, size_t count) { int rc; @@ -490,11 +490,7 @@ static ssize_t image_data_write(struct file *filp, struct kobject *kobj, * update_flash : Flash new firmware image * */ -static const struct bin_attribute image_data_attr = { - .attr = {.name = "image", .mode = 0200}, - .size = MAX_IMAGE_SIZE, /* Limit image size */ - .write = image_data_write, -}; +static const BIN_ATTR_ADMIN_WO(image, MAX_IMAGE_SIZE); static struct kobj_attribute validate_attribute = __ATTR(validate_flash, 0600, validate_show, validate_store); @@ -544,7 +540,7 @@ void __init opal_flash_update_init(void) goto nokobj; } - ret = sysfs_create_bin_file(opal_kobj, &image_data_attr); + ret = sysfs_create_bin_file(opal_kobj, &bin_attr_image); if (ret) { pr_warn("FLASH: Failed to create sysfs files\n"); goto nosysfs_file; From patchwork Mon Dec 2 19:00:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13891209 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (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 9BB961DE3A5 for ; Mon, 2 Dec 2024 19:00:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733166044; cv=none; b=rNFyhhtueQm92agp9imceqsYuieDA50dWOsIpWZ3ZCimemtYDtYMFLKQTyqqDcmowAODmMsZpvp/bVqcELyrRT0Hj5JqZvga6hsvsrWtHEHIsdX6nEZxmnHSli6j+caq7CdM04auue6LefVeg4Hc1To4bAYiUJYNYBKmsr4hejY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733166044; c=relaxed/simple; bh=+arb4UAMXaf51SIDs7YdZ7RZB12zGnsK5LernLVB4+0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=QfH37jT2VK/XDF8qae/Cbm9qkpkdDLZpRWPM0uaBX0vEXGfY1eeFjuaGn0AdEHnGuMbAjleZJHEwYECJ5OZY69/Ms0mgSqrvrxuNXiC03lCdh1tgWyWPKn7uRev7dThUfBEf0IhP9UmXfGCJjl7nuvCeWcAW5Opb9gnTkU/tnMc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=ThF6iULN; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="ThF6iULN" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1733166037; bh=+arb4UAMXaf51SIDs7YdZ7RZB12zGnsK5LernLVB4+0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ThF6iULNZ7DQJIv5R4Hc+nABWuz2CXsroKR2IL96Lww5yAzqcqyOFzP2KUPsddAzL 6VPpbB9bQcdgMtx9kcgoMZO6ezbbY8jljpLWK+GEHv5+4v3OD9ZFn/Ho5WSfPUmpqx UwDl45hT0Cmsv5u/Vj5Ui4aPXAfVpX/KxBsIVbgE= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Mon, 02 Dec 2024 20:00:39 +0100 Subject: [PATCH 4/5] firmware: google: gsmi: Use BIN_ATTR_ADMIN_WO() for bin_attribute definition Precedence: bulk X-Mailing-List: chrome-platform@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241202-sysfs-const-bin_attr-admin_wo-v1-4-f489116210bf@weissschuh.net> References: <20241202-sysfs-const-bin_attr-admin_wo-v1-0-f489116210bf@weissschuh.net> In-Reply-To: <20241202-sysfs-const-bin_attr-admin_wo-v1-0-f489116210bf@weissschuh.net> To: Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Naveen N Rao , Madhavan Srinivasan , Tzung-Bi Shih , Brian Norris , Julius Werner , "James E.J. Bottomley" , "Martin K. Petersen" Cc: linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, chrome-platform@lists.linux.dev, linux-scsi@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1733166036; l=2521; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=+arb4UAMXaf51SIDs7YdZ7RZB12zGnsK5LernLVB4+0=; b=vs/2qmzMQ2i0kyAzZ0xLNPY2RWbz1iPcaFTdxlz5AdVN+D//QkatZ10EMOrH1vwujAOmcl20z TfIbn4l+sK0Cyv5rUwyZivbShgztDbnhu1XZhF5TMYQdLbZA2Ek09Ca X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Using the macro saves some lines of code and prepares the attribute for the general constifications of struct bin_attributes. While at it also constify the callback parameter. Signed-off-by: Thomas Weißschuh Acked-by: Tzung-Bi Shih --- drivers/firmware/google/gsmi.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/firmware/google/gsmi.c b/drivers/firmware/google/gsmi.c index 24e666d5c3d1a231d611ad3c20816c1d223a0dc5..cd946633ef727e826449a7b307a15a2c9f07d655 100644 --- a/drivers/firmware/google/gsmi.c +++ b/drivers/firmware/google/gsmi.c @@ -487,9 +487,9 @@ static const struct efivar_operations efivar_ops = { #endif /* CONFIG_EFI */ -static ssize_t eventlog_write(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, - char *buf, loff_t pos, size_t count) +static ssize_t append_to_eventlog_write(struct file *filp, struct kobject *kobj, + const struct bin_attribute *bin_attr, + char *buf, loff_t pos, size_t count) { struct gsmi_set_eventlog_param param = { .data_ptr = gsmi_dev.data_buf->address, @@ -528,10 +528,7 @@ static ssize_t eventlog_write(struct file *filp, struct kobject *kobj, } -static struct bin_attribute eventlog_bin_attr = { - .attr = {.name = "append_to_eventlog", .mode = 0200}, - .write = eventlog_write, -}; +static const BIN_ATTR_ADMIN_WO(append_to_eventlog, 0); static ssize_t gsmi_clear_eventlog_store(struct kobject *kobj, struct kobj_attribute *attr, @@ -1017,7 +1014,7 @@ static __init int gsmi_init(void) } /* Setup eventlog access */ - ret = sysfs_create_bin_file(gsmi_kobj, &eventlog_bin_attr); + ret = sysfs_create_bin_file(gsmi_kobj, &bin_attr_append_to_eventlog); if (ret) { printk(KERN_INFO "gsmi: Failed to setup eventlog"); goto out_err; @@ -1049,7 +1046,7 @@ static __init int gsmi_init(void) return 0; out_remove_bin_file: - sysfs_remove_bin_file(gsmi_kobj, &eventlog_bin_attr); + sysfs_remove_bin_file(gsmi_kobj, &bin_attr_append_to_eventlog); out_err: kobject_put(gsmi_kobj); gsmi_buf_free(gsmi_dev.param_buf); @@ -1076,7 +1073,7 @@ static void __exit gsmi_exit(void) #endif sysfs_remove_files(gsmi_kobj, gsmi_attrs); - sysfs_remove_bin_file(gsmi_kobj, &eventlog_bin_attr); + sysfs_remove_bin_file(gsmi_kobj, &bin_attr_append_to_eventlog); kobject_put(gsmi_kobj); gsmi_buf_free(gsmi_dev.param_buf); gsmi_buf_free(gsmi_dev.data_buf); From patchwork Mon Dec 2 19:00:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13891210 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (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 6615F1DE4CE for ; Mon, 2 Dec 2024 19:00:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733166045; cv=none; b=aleZLOsHU6LUymvO0uOquzrjlSiKOLqC58IhaaCCcwyilJRYS3CZEvvIQdIGljbhdqEghT/i4aTrIGKS5C1uvS2HdooQCvujVpf0kqMaE9BE+XrvibJ8eO6O1Y0W3/VMv5JRwcr2+Esq2eiCMWKMYoJly42O36OdIzJDG+bvZpY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733166045; c=relaxed/simple; bh=6f4mNkpvqRUUeyyo/NJcoh7bQ9hdy8tWinO29V+C6p4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=F8lSgy7GSD5WkjwLJn7s4+tNIC7haiewWMkvYKr876fr084mLklKdAfiYKTdV5Z/1aUvrRQDSB1pGtqF5HWcy2K8fpelq6MbCvHki86Mxbid9uKHjN7FoOHOxsyvZXyrV7DjPymm/WFJyXiAqLjhhCYKSg6s1KCIrEJ2NoCOl4I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=btGY7MOa; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="btGY7MOa" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1733166038; bh=6f4mNkpvqRUUeyyo/NJcoh7bQ9hdy8tWinO29V+C6p4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=btGY7MOaNEAELCcGQDyjd+njX9nVHFypYDtpB/GQKbJV1iIi5gtyX6lfQLN7FWOuO bRv+xU7gwx500gh/9MMVmfaAtXQQ8JGkfIy68gIH6SKOtmJKqw+r0n4opaFZwZlINv 6+f7CdANi7p7PQi79BD4w4Iln7oPIuGuojs0Y12Y= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Mon, 02 Dec 2024 20:00:40 +0100 Subject: [PATCH 5/5] scsi: arcmsr: Use BIN_ATTR_ADMIN_WO() for bin_attribute definitions Precedence: bulk X-Mailing-List: chrome-platform@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241202-sysfs-const-bin_attr-admin_wo-v1-5-f489116210bf@weissschuh.net> References: <20241202-sysfs-const-bin_attr-admin_wo-v1-0-f489116210bf@weissschuh.net> In-Reply-To: <20241202-sysfs-const-bin_attr-admin_wo-v1-0-f489116210bf@weissschuh.net> To: Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Naveen N Rao , Madhavan Srinivasan , Tzung-Bi Shih , Brian Norris , Julius Werner , "James E.J. Bottomley" , "Martin K. Petersen" Cc: linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, chrome-platform@lists.linux.dev, linux-scsi@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1733166036; l=5414; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=6f4mNkpvqRUUeyyo/NJcoh7bQ9hdy8tWinO29V+C6p4=; b=X+0t7vXFXcE/fxGdmCbWy1dFY2LlFh9Er23M7zOt4ShPWbyx8SOdqDkvlV+lJJOf3qu+NW089 pkVCKYBLt9UDGRGnD6yU5YvE+wYS5X+ZbLLkLjH9v7kC4Ht9hxJJQuG X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Using the macro saves some lines of code and prepares the attributes for the general constifications of struct bin_attributes. While at it also constify the callback parameters. Signed-off-by: Thomas Weißschuh Reviewed-by: Martin K. Petersen Reviewed-by: Tzung-Bi Shih --- drivers/scsi/arcmsr/arcmsr_attr.c | 73 ++++++++++++++------------------------- 1 file changed, 26 insertions(+), 47 deletions(-) diff --git a/drivers/scsi/arcmsr/arcmsr_attr.c b/drivers/scsi/arcmsr/arcmsr_attr.c index baeb5e79569026f1af6612705689219bb4a7052f..af7750b551910b06254e443c25bebf323e29f162 100644 --- a/drivers/scsi/arcmsr/arcmsr_attr.c +++ b/drivers/scsi/arcmsr/arcmsr_attr.c @@ -58,11 +58,11 @@ #include #include "arcmsr.h" -static ssize_t arcmsr_sysfs_iop_message_read(struct file *filp, - struct kobject *kobj, - struct bin_attribute *bin, - char *buf, loff_t off, - size_t count) +static ssize_t mu_read_read(struct file *filp, + struct kobject *kobj, + const struct bin_attribute *bin, + char *buf, loff_t off, + size_t count) { struct device *dev = container_of(kobj,struct device,kobj); struct Scsi_Host *host = class_to_shost(dev); @@ -105,11 +105,11 @@ static ssize_t arcmsr_sysfs_iop_message_read(struct file *filp, return allxfer_len; } -static ssize_t arcmsr_sysfs_iop_message_write(struct file *filp, - struct kobject *kobj, - struct bin_attribute *bin, - char *buf, loff_t off, - size_t count) +static ssize_t mu_write_write(struct file *filp, + struct kobject *kobj, + const struct bin_attribute *bin, + char *buf, loff_t off, + size_t count) { struct device *dev = container_of(kobj,struct device,kobj); struct Scsi_Host *host = class_to_shost(dev); @@ -153,11 +153,11 @@ static ssize_t arcmsr_sysfs_iop_message_write(struct file *filp, } } -static ssize_t arcmsr_sysfs_iop_message_clear(struct file *filp, - struct kobject *kobj, - struct bin_attribute *bin, - char *buf, loff_t off, - size_t count) +static ssize_t mu_clear_write(struct file *filp, + struct kobject *kobj, + const struct bin_attribute *bin, + char *buf, loff_t off, + size_t count) { struct device *dev = container_of(kobj,struct device,kobj); struct Scsi_Host *host = class_to_shost(dev); @@ -188,58 +188,37 @@ static ssize_t arcmsr_sysfs_iop_message_clear(struct file *filp, return 1; } -static const struct bin_attribute arcmsr_sysfs_message_read_attr = { - .attr = { - .name = "mu_read", - .mode = S_IRUSR , - }, - .size = ARCMSR_API_DATA_BUFLEN, - .read = arcmsr_sysfs_iop_message_read, -}; +static const BIN_ATTR_ADMIN_RO(mu_read, ARCMSR_API_DATA_BUFLEN); -static const struct bin_attribute arcmsr_sysfs_message_write_attr = { - .attr = { - .name = "mu_write", - .mode = S_IWUSR, - }, - .size = ARCMSR_API_DATA_BUFLEN, - .write = arcmsr_sysfs_iop_message_write, -}; +static const BIN_ATTR_ADMIN_WO(mu_write, ARCMSR_API_DATA_BUFLEN); -static const struct bin_attribute arcmsr_sysfs_message_clear_attr = { - .attr = { - .name = "mu_clear", - .mode = S_IWUSR, - }, - .size = 1, - .write = arcmsr_sysfs_iop_message_clear, -}; +static const BIN_ATTR_ADMIN_WO(mu_clear, 1); int arcmsr_alloc_sysfs_attr(struct AdapterControlBlock *acb) { struct Scsi_Host *host = acb->host; int error; - error = sysfs_create_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_read_attr); + error = sysfs_create_bin_file(&host->shost_dev.kobj, &bin_attr_mu_read); if (error) { printk(KERN_ERR "arcmsr: alloc sysfs mu_read failed\n"); goto error_bin_file_message_read; } - error = sysfs_create_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_write_attr); + error = sysfs_create_bin_file(&host->shost_dev.kobj, &bin_attr_mu_write); if (error) { printk(KERN_ERR "arcmsr: alloc sysfs mu_write failed\n"); goto error_bin_file_message_write; } - error = sysfs_create_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_clear_attr); + error = sysfs_create_bin_file(&host->shost_dev.kobj, &bin_attr_mu_clear); if (error) { printk(KERN_ERR "arcmsr: alloc sysfs mu_clear failed\n"); goto error_bin_file_message_clear; } return 0; error_bin_file_message_clear: - sysfs_remove_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_write_attr); + sysfs_remove_bin_file(&host->shost_dev.kobj, &bin_attr_mu_write); error_bin_file_message_write: - sysfs_remove_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_read_attr); + sysfs_remove_bin_file(&host->shost_dev.kobj, &bin_attr_mu_read); error_bin_file_message_read: return error; } @@ -248,9 +227,9 @@ void arcmsr_free_sysfs_attr(struct AdapterControlBlock *acb) { struct Scsi_Host *host = acb->host; - sysfs_remove_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_clear_attr); - sysfs_remove_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_write_attr); - sysfs_remove_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_read_attr); + sysfs_remove_bin_file(&host->shost_dev.kobj, &bin_attr_mu_clear); + sysfs_remove_bin_file(&host->shost_dev.kobj, &bin_attr_mu_write); + sysfs_remove_bin_file(&host->shost_dev.kobj, &bin_attr_mu_read); }