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);