nfc: constify nci_driver_ops (prop_ops and core_ops)
authorKrzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Sat, 24 Jul 2021 21:47:35 +0000 (23:47 +0200)
committerDavid S. Miller <davem@davemloft.net>
Sun, 25 Jul 2021 08:21:21 +0000 (09:21 +0100)
Neither the core nor the drivers modify the passed pointer to struct
nci_driver_ops (consisting of function pointers), so make it a pointer
to const for correctness and safety.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/nfc/fdp/fdp.c
drivers/nfc/s3fwrn5/nci.c
drivers/nfc/s3fwrn5/nci.h
drivers/nfc/st-nci/core.c
include/net/nfc/nci_core.h
net/nfc/nci/core.c

index 73f51848a693ebc104055a66e83eca501410250e..4d88a617d0e854c798e39e6b345a51724a5eb680 100644 (file)
@@ -651,7 +651,7 @@ static int fdp_nci_core_get_config_rsp_packet(struct nci_dev *ndev,
        return 0;
 }
 
-static struct nci_driver_ops fdp_core_ops[] = {
+static const struct nci_driver_ops fdp_core_ops[] = {
        {
                .opcode = NCI_OP_CORE_GET_CONFIG_RSP,
                .rsp = fdp_nci_core_get_config_rsp_packet,
@@ -662,7 +662,7 @@ static struct nci_driver_ops fdp_core_ops[] = {
        },
 };
 
-static struct nci_driver_ops fdp_prop_ops[] = {
+static const struct nci_driver_ops fdp_prop_ops[] = {
        {
                .opcode = nci_opcode_pack(NCI_GID_PROP, NCI_OP_PROP_PATCH_OID),
                .rsp = fdp_nci_prop_patch_rsp_packet,
index 819e3474a4373f3622cc0d7897898043b59b9d9f..e374e670b36b191e6266a8414d2614184ed50cdd 100644 (file)
@@ -20,7 +20,7 @@ static int s3fwrn5_nci_prop_rsp(struct nci_dev *ndev, struct sk_buff *skb)
        return 0;
 }
 
-struct nci_driver_ops s3fwrn5_nci_prop_ops[4] = {
+const struct nci_driver_ops s3fwrn5_nci_prop_ops[4] = {
        {
                .opcode = nci_opcode_pack(NCI_GID_PROPRIETARY,
                                NCI_PROP_SET_RFREG),
index 5c22c5315f79da329d393a11421ad14813798deb..c2d906591e9e8fba7f5d1964b76d02396b565f8f 100644 (file)
@@ -50,7 +50,7 @@ struct nci_prop_fw_cfg_rsp {
        __u8 status;
 };
 
-extern struct nci_driver_ops s3fwrn5_nci_prop_ops[4];
+extern const struct nci_driver_ops s3fwrn5_nci_prop_ops[4];
 int s3fwrn5_nci_rf_configure(struct s3fwrn5_info *info, const char *fw_name);
 
 #endif /* __LOCAL_S3FWRN5_NCI_H_ */
index f6fce34a77dae2b70cf768e27c28b51701d332eb..72bb51efdf9c3f86fc6b610dc912414bc5e77f79 100644 (file)
@@ -86,7 +86,7 @@ static int st_nci_prop_rsp_packet(struct nci_dev *ndev,
        return 0;
 }
 
-static struct nci_driver_ops st_nci_prop_ops[] = {
+static const struct nci_driver_ops st_nci_prop_ops[] = {
        {
                .opcode = nci_opcode_pack(NCI_GID_PROPRIETARY,
                                          ST_NCI_CORE_PROP),
index 5dae7e2cbc496afeb90dabe07f232cc4cd8a7aba..e7118e0cc3b1dfa5c7a638c7308380130144f10d 100644 (file)
@@ -82,10 +82,10 @@ struct nci_ops {
        void  (*hci_cmd_received)(struct nci_dev *ndev, u8 pipe, u8 cmd,
                                  struct sk_buff *skb);
 
-       struct nci_driver_ops *prop_ops;
+       const struct nci_driver_ops *prop_ops;
        size_t n_prop_ops;
 
-       struct nci_driver_ops *core_ops;
+       const struct nci_driver_ops *core_ops;
        size_t n_core_ops;
 };
 
index a7d26f2791b0d399724dac568ae6a1d57d81c1cb..50c625940fa378044daa87ab559055ed26a960b9 100644 (file)
@@ -1363,12 +1363,12 @@ int nci_send_cmd(struct nci_dev *ndev, __u16 opcode, __u8 plen, const void *payl
 EXPORT_SYMBOL(nci_send_cmd);
 
 /* Proprietary commands API */
-static struct nci_driver_ops *ops_cmd_lookup(struct nci_driver_ops *ops,
-                                            size_t n_ops,
-                                            __u16 opcode)
+static const struct nci_driver_ops *ops_cmd_lookup(const struct nci_driver_ops *ops,
+                                                  size_t n_ops,
+                                                  __u16 opcode)
 {
        size_t i;
-       struct nci_driver_ops *op;
+       const struct nci_driver_ops *op;
 
        if (!ops || !n_ops)
                return NULL;
@@ -1383,10 +1383,10 @@ static struct nci_driver_ops *ops_cmd_lookup(struct nci_driver_ops *ops,
 }
 
 static int nci_op_rsp_packet(struct nci_dev *ndev, __u16 rsp_opcode,
-                            struct sk_buff *skb, struct nci_driver_ops *ops,
+                            struct sk_buff *skb, const struct nci_driver_ops *ops,
                             size_t n_ops)
 {
-       struct nci_driver_ops *op;
+       const struct nci_driver_ops *op;
 
        op = ops_cmd_lookup(ops, n_ops, rsp_opcode);
        if (!op || !op->rsp)
@@ -1396,10 +1396,10 @@ static int nci_op_rsp_packet(struct nci_dev *ndev, __u16 rsp_opcode,
 }
 
 static int nci_op_ntf_packet(struct nci_dev *ndev, __u16 ntf_opcode,
-                            struct sk_buff *skb, struct nci_driver_ops *ops,
+                            struct sk_buff *skb, const struct nci_driver_ops *ops,
                             size_t n_ops)
 {
-       struct nci_driver_ops *op;
+       const struct nci_driver_ops *op;
 
        op = ops_cmd_lookup(ops, n_ops, ntf_opcode);
        if (!op || !op->ntf)