Skip to content

Commit 42d5179

Browse files
rikardfalkebornjgunthorpe
authored andcommitted
RDMA/core: Constify struct attribute_group
The only usage of the pma_table field in the ib_port struct is to pass its address to sysfs_create_group() and sysfs_remove_group(). Make it const to make it possible to constify a couple of static struct attribute_group. This allows the compiler to put them in read-only memory. Link: https://lore.kernel.org/r/20200930224004.24279-2-rikard.falkeborn@gmail.com Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
1 parent a03bfc3 commit 42d5179

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

drivers/infiniband/core/sysfs.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ struct ib_port {
5959
struct gid_attr_group *gid_attr_group;
6060
struct attribute_group gid_group;
6161
struct attribute_group *pkey_group;
62-
struct attribute_group *pma_table;
62+
const struct attribute_group *pma_table;
6363
struct attribute_group *hw_stats_ag;
6464
struct rdma_hw_stats *hw_stats;
6565
u8 port_num;
@@ -653,17 +653,17 @@ static struct attribute *pma_attrs_noietf[] = {
653653
NULL
654654
};
655655

656-
static struct attribute_group pma_group = {
656+
static const struct attribute_group pma_group = {
657657
.name = "counters",
658658
.attrs = pma_attrs
659659
};
660660

661-
static struct attribute_group pma_group_ext = {
661+
static const struct attribute_group pma_group_ext = {
662662
.name = "counters",
663663
.attrs = pma_attrs_ext
664664
};
665665

666-
static struct attribute_group pma_group_noietf = {
666+
static const struct attribute_group pma_group_noietf = {
667667
.name = "counters",
668668
.attrs = pma_attrs_noietf
669669
};
@@ -778,8 +778,8 @@ alloc_group_attrs(ssize_t (*show)(struct ib_port *,
778778
* Figure out which counter table to use depending on
779779
* the device capabilities.
780780
*/
781-
static struct attribute_group *get_counter_table(struct ib_device *dev,
782-
int port_num)
781+
static const struct attribute_group *get_counter_table(struct ib_device *dev,
782+
int port_num)
783783
{
784784
struct ib_class_port_info cpi;
785785

0 commit comments

Comments
 (0)