]> www.infradead.org Git - nvme.git/commitdiff
net: microchip: Constify struct vcap_operations
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Sun, 16 Jun 2024 07:57:56 +0000 (09:57 +0200)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 18 Jun 2024 13:26:39 +0000 (15:26 +0200)
"struct vcap_operations" are not modified in these drivers.

Constifying this structure moves some data to a read-only section, so
increase overall security.

In order to do it, "struct vcap_control" also needs to be adjusted to this
new const qualifier.

As an example, on a x86_64, with allmodconfig:
Before:
======
   text    data     bss     dec     hex filename
  15176    1094      16   16286    3f9e drivers/net/ethernet/microchip/lan966x/lan966x_vcap_impl.o

After:
=====
   text    data     bss     dec     hex filename
  15268     998      16   16282    3f9a drivers/net/ethernet/microchip/lan966x/lan966x_vcap_impl.o

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Daniel Machon <daniel.machon@microchip.com>
Link: https://lore.kernel.org/r/d8e76094d2e98ebb5bfc8205799b3a9db0b46220.1718524644.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/ethernet/microchip/lan966x/lan966x_vcap_impl.c
drivers/net/ethernet/microchip/sparx5/sparx5_vcap_impl.c
drivers/net/ethernet/microchip/vcap/vcap_api.h
drivers/net/ethernet/microchip/vcap/vcap_api_debugfs_kunit.c
drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c

index a4414f63c9b1cc02acbb5f80ce52fb83139d5f2d..a1471e38d118982091cafe8ffabd75f254eec857 100644 (file)
@@ -581,7 +581,7 @@ static void lan966x_vcap_move(struct net_device *dev,
        lan966x_vcap_wait_update(lan966x, admin->tgt_inst);
 }
 
-static struct vcap_operations lan966x_vcap_ops = {
+static const struct vcap_operations lan966x_vcap_ops = {
        .validate_keyset = lan966x_vcap_validate_keyset,
        .add_default_fields = lan966x_vcap_add_default_fields,
        .cache_erase = lan966x_vcap_cache_erase,
index 187efa1fc904f53f9fc498a3b38f504a21dc4f50..967c8621c25051aae8ed1546c98c503f96864e84 100644 (file)
@@ -1507,7 +1507,7 @@ static void sparx5_vcap_move(struct net_device *ndev, struct vcap_admin *admin,
        }
 }
 
-static struct vcap_operations sparx5_vcap_ops = {
+static const struct vcap_operations sparx5_vcap_ops = {
        .validate_keyset = sparx5_vcap_validate_keyset,
        .add_default_fields = sparx5_vcap_add_default_fields,
        .cache_erase = sparx5_vcap_cache_erase,
index 9eccfa633c1afbeb0822eddc515e4000bb5f926f..6069ad95c27e93b60ae406da9834dba4767ac419 100644 (file)
@@ -271,7 +271,7 @@ struct vcap_operations {
 
 /* VCAP API Client control interface */
 struct vcap_control {
-       struct vcap_operations *ops;  /* client supplied operations */
+       const struct vcap_operations *ops;  /* client supplied operations */
        const struct vcap_info *vcaps; /* client supplied vcap models */
        const struct vcap_statistics *stats; /* client supplied vcap stats */
        struct list_head list; /* list of vcap instances */
index b23c11b0647c9eab54fabc48fea78e0d0e12b8ed..9c9d380421255d62dfb2d7a272c5cff6fb2f92ac 100644 (file)
@@ -221,7 +221,7 @@ static int vcap_test_port_info(struct net_device *ndev,
        return 0;
 }
 
-static struct vcap_operations test_callbacks = {
+static const struct vcap_operations test_callbacks = {
        .validate_keyset = test_val_keyset,
        .add_default_fields = test_add_def_fields,
        .cache_erase = test_cache_erase,
index fe4e166de8a0458ffa509f2238a45ae33920743a..51d9423b08a63aec1277c46a96c0a2c915f4e19a 100644 (file)
@@ -211,7 +211,7 @@ static int vcap_test_port_info(struct net_device *ndev,
        return 0;
 }
 
-static struct vcap_operations test_callbacks = {
+static const struct vcap_operations test_callbacks = {
        .validate_keyset = test_val_keyset,
        .add_default_fields = test_add_def_fields,
        .cache_erase = test_cache_erase,