From nobody Mon Feb 9 19:04:55 2026 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 6F1481DC9AB for ; Sat, 25 Jan 2025 10:12:17 +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=1737799939; cv=none; b=qRGob9gupkKDuo3DMMPpREBrNCVl7YS9t7ilH2dbkly8n/d0THjypwnrkeVO0fNfNUhKHNAWm8XUiff8mF7fV08/+sZZX8DR4uCv29JGhchbK/VGsDF7i/ez59kTNv2oIccejokrNAQhqe0NTw3Oa4CcoqvgrScsRSiL2INDciw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737799939; c=relaxed/simple; bh=V7QmHqTxKbR1VZYmq5SXEzFAv73IkM2Fho9KqScgGvw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hIJ+wyrRBUTmNyn98TQQHZwcgfAFrzvTktH4RyGJtMnPfwWkg17q0x3QXoDSDivW9dGAw2ITQzZ4BWNQTX8pLFGdtqfCzhnNXeA353g6a/Z+w5hVNZTh1RSzrqoeL982JENI+ZiDu0OnVjglOYEBMHF2YbVBpyCwPn7jEx23Ip4= 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=gzne0aRI; 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="gzne0aRI" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1737799935; bh=V7QmHqTxKbR1VZYmq5SXEzFAv73IkM2Fho9KqScgGvw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=gzne0aRIlXxV3MDTGl2xiI2rOBS0fnXXHqcIzzZ5x2BR3ATJp4Oul1Bj6e9UUt/2G wM3CNpaR0CojBTpbJGwq8IMkryh4Q/FBrGkqoUe7DZYtEQJxeOSwgTcS7Zzw/1d76a PiQvGwmdmIKzdky36Ixq//vPjunr2ASOzgyG10h0= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sat, 25 Jan 2025 11:12:15 +0100 Subject: [PATCH v2 2/3] firmware: dmi: Define bin_attributes through macro Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250125-sysfs-const-bin_attr-dmi-v2-2-ece1895936f4@weissschuh.net> References: <20250125-sysfs-const-bin_attr-dmi-v2-0-ece1895936f4@weissschuh.net> In-Reply-To: <20250125-sysfs-const-bin_attr-dmi-v2-0-ece1895936f4@weissschuh.net> To: Jean Delvare Cc: linux-kernel@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=1737799934; l=3052; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=V7QmHqTxKbR1VZYmq5SXEzFAv73IkM2Fho9KqScgGvw=; b=/W/ryMV+DwOvbvKYFE9+3T7L3w3OynXIPwJeBWakKy7l4U/Kyye3GORUJfDSsNTFNG/rL1/rW FI2OuXZaDOAAZQe2Q4kkggI86i57IlzPkKkFmkKFextHhsApuEKeiP4 X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= The macro makes the code shorter and simplifies constification of the callback arguments. Signed-off-by: Thomas Wei=C3=9Fschuh --- drivers/firmware/dmi-sysfs.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/drivers/firmware/dmi-sysfs.c b/drivers/firmware/dmi-sysfs.c index 8d91997036e4c39731019e8082e80da3d733d4e3..6baa921a6664d087049bc15bf44= a32c520853526 100644 --- a/drivers/firmware/dmi-sysfs.c +++ b/drivers/firmware/dmi-sysfs.c @@ -431,9 +431,9 @@ static ssize_t dmi_sel_raw_read_helper(struct dmi_sysfs= _entry *entry, } } =20 -static ssize_t dmi_sel_raw_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, - char *buf, loff_t pos, size_t count) +static ssize_t raw_event_log_read(struct file *filp, struct kobject *kobj, + struct bin_attribute *bin_attr, + char *buf, loff_t pos, size_t count) { struct dmi_sysfs_entry *entry =3D to_entry(kobj->parent); struct dmi_read_state state =3D { @@ -445,10 +445,7 @@ static ssize_t dmi_sel_raw_read(struct file *filp, str= uct kobject *kobj, return find_dmi_entry(entry, dmi_sel_raw_read_helper, &state); } =20 -static struct bin_attribute dmi_sel_raw_attr =3D { - .attr =3D {.name =3D "raw_event_log", .mode =3D 0400}, - .read =3D dmi_sel_raw_read, -}; +static BIN_ATTR_ADMIN_RO(raw_event_log, 0); =20 static int dmi_system_event_log(struct dmi_sysfs_entry *entry) { @@ -464,7 +461,7 @@ static int dmi_system_event_log(struct dmi_sysfs_entry = *entry) if (ret) goto out_free; =20 - ret =3D sysfs_create_bin_file(entry->child, &dmi_sel_raw_attr); + ret =3D sysfs_create_bin_file(entry->child, &bin_attr_raw_event_log); if (ret) goto out_del; =20 @@ -537,10 +534,10 @@ static ssize_t dmi_entry_raw_read_helper(struct dmi_s= ysfs_entry *entry, &state->pos, dh, entry_length); } =20 -static ssize_t dmi_entry_raw_read(struct file *filp, - struct kobject *kobj, - struct bin_attribute *bin_attr, - char *buf, loff_t pos, size_t count) +static ssize_t raw_read(struct file *filp, + struct kobject *kobj, + struct bin_attribute *bin_attr, + char *buf, loff_t pos, size_t count) { struct dmi_sysfs_entry *entry =3D to_entry(kobj); struct dmi_read_state state =3D { @@ -552,10 +549,7 @@ static ssize_t dmi_entry_raw_read(struct file *filp, return find_dmi_entry(entry, dmi_entry_raw_read_helper, &state); } =20 -static const struct bin_attribute dmi_entry_raw_attr =3D { - .attr =3D {.name =3D "raw", .mode =3D 0400}, - .read =3D dmi_entry_raw_read, -}; +static const BIN_ATTR_ADMIN_RO(raw, 0); =20 static void dmi_sysfs_entry_release(struct kobject *kobj) { @@ -630,7 +624,7 @@ static void __init dmi_sysfs_register_handle(const stru= ct dmi_header *dh, goto out_err; =20 /* Create the raw binary file to access the entry */ - *ret =3D sysfs_create_bin_file(&entry->kobj, &dmi_entry_raw_attr); + *ret =3D sysfs_create_bin_file(&entry->kobj, &bin_attr_raw); if (*ret) goto out_err; =20 --=20 2.48.1