Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 7b53e92

Browse files
l1kgregkh
authored andcommitted
IB/qib: Use device_show_string() helper for sysfs attributes
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 <lukas@wunner.de> Link: https://lore.kernel.org/r/185a88dd3e6e18bf508a875d87c95ea2a5c3fa13.1713608122.git.lukas@wunner.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent aa1fd9c commit 7b53e92

File tree

3 files changed

+2
-15
lines changed

3 files changed

+2
-15
lines changed

drivers/infiniband/hw/qib/qib.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1359,7 +1359,6 @@ static inline u32 qib_get_rcvhdrtail(const struct qib_ctxtdata *rcd)
13591359
* sysfs interface.
13601360
*/
13611361

1362-
extern const char ib_qib_version[];
13631362
extern const struct attribute_group qib_attr_group;
13641363
extern const struct attribute_group *qib_attr_port_groups[];
13651364

drivers/infiniband/hw/qib/qib_driver.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,6 @@
4444

4545
#include "qib.h"
4646

47-
/*
48-
* The size has to be longer than this string, so we can append
49-
* board/chip information to it in the init code.
50-
*/
51-
const char ib_qib_version[] = QIB_DRIVER_VERSION "\n";
52-
5347
DEFINE_MUTEX(qib_mutex); /* general driver use */
5448

5549
unsigned qib_ibmtu;

drivers/infiniband/hw/qib/qib_sysfs.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -585,13 +585,7 @@ static ssize_t hca_type_show(struct device *device,
585585
static DEVICE_ATTR_RO(hca_type);
586586
static DEVICE_ATTR(board_id, 0444, hca_type_show, NULL);
587587

588-
static ssize_t version_show(struct device *device,
589-
struct device_attribute *attr, char *buf)
590-
{
591-
/* The string printed here is already newline-terminated. */
592-
return sysfs_emit(buf, "%s", (char *)ib_qib_version);
593-
}
594-
static DEVICE_ATTR_RO(version);
588+
static DEVICE_STRING_ATTR_RO(version, 0444, QIB_DRIVER_VERSION);
595589

596590
static ssize_t boardversion_show(struct device *device,
597591
struct device_attribute *attr, char *buf)
@@ -721,7 +715,7 @@ static struct attribute *qib_attributes[] = {
721715
&dev_attr_hw_rev.attr,
722716
&dev_attr_hca_type.attr,
723717
&dev_attr_board_id.attr,
724-
&dev_attr_version.attr,
718+
&dev_attr_version.attr.attr,
725719
&dev_attr_nctxts.attr,
726720
&dev_attr_nfreectxts.attr,
727721
&dev_attr_serial.attr,

0 commit comments

Comments
 (0)