nfc: constify nfc_phy_ops
authorKrzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Sat, 24 Jul 2021 21:47:36 +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
nfc_phy_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>
18 files changed:
drivers/nfc/fdp/fdp.c
drivers/nfc/fdp/fdp.h
drivers/nfc/fdp/i2c.c
drivers/nfc/mei_phy.c
drivers/nfc/mei_phy.h
drivers/nfc/microread/i2c.c
drivers/nfc/microread/microread.c
drivers/nfc/microread/microread.h
drivers/nfc/pn544/i2c.c
drivers/nfc/pn544/pn544.c
drivers/nfc/pn544/pn544.h
drivers/nfc/st-nci/i2c.c
drivers/nfc/st-nci/ndlc.c
drivers/nfc/st-nci/ndlc.h
drivers/nfc/st-nci/spi.c
drivers/nfc/st21nfca/core.c
drivers/nfc/st21nfca/i2c.c
drivers/nfc/st21nfca/st21nfca.h

index 4d88a617d0e854c798e39e6b345a51724a5eb680..3e542b7389cb0bebca85065772b166a9cc955eb2 100644 (file)
@@ -38,7 +38,7 @@
 #define NCI_OP_PROP_SET_PDATA_OID              0x23
 
 struct fdp_nci_info {
-       struct nfc_phy_ops *phy_ops;
+       const struct nfc_phy_ops *phy_ops;
        struct fdp_i2c_phy *phy;
        struct nci_dev *ndev;
 
@@ -687,7 +687,7 @@ static const struct nci_ops nci_ops = {
        .n_core_ops = ARRAY_SIZE(fdp_core_ops),
 };
 
-int fdp_nci_probe(struct fdp_i2c_phy *phy, struct nfc_phy_ops *phy_ops,
+int fdp_nci_probe(struct fdp_i2c_phy *phy, const struct nfc_phy_ops *phy_ops,
                        struct nci_dev **ndevp, int tx_headroom,
                        int tx_tailroom, u8 clock_type, u32 clock_freq,
                        u8 *fw_vsc_cfg)
index ead3b21ccae68eb8e2f0509b070c22f15c0c119e..dc048d4b977e683d69b9ef7417a0faf5a43ed73b 100644 (file)
@@ -21,7 +21,7 @@ struct fdp_i2c_phy {
        uint16_t next_read_size;
 };
 
-int fdp_nci_probe(struct fdp_i2c_phy *phy, struct nfc_phy_ops *phy_ops,
+int fdp_nci_probe(struct fdp_i2c_phy *phy, const struct nfc_phy_ops *phy_ops,
                  struct nci_dev **ndev, int tx_headroom, int tx_tailroom,
                  u8 clock_type, u32 clock_freq, u8 *fw_vsc_cfg);
 void fdp_nci_remove(struct nci_dev *ndev);
index c5596e514648c73da0ad08727f6892b8ef1299a5..98e1876c9468faf2356983314e020e491041bad3 100644 (file)
@@ -120,7 +120,7 @@ static int fdp_nci_i2c_write(void *phy_id, struct sk_buff *skb)
        return r;
 }
 
-static struct nfc_phy_ops i2c_phy_ops = {
+static const struct nfc_phy_ops i2c_phy_ops = {
        .write = fdp_nci_i2c_write,
        .enable = fdp_nci_i2c_enable,
        .disable = fdp_nci_i2c_disable,
index e56cea716cd2f93515cd3b7389a5c7af5597bc1e..41146bb99474c0a0ea6ca6a6a639104269d96892 100644 (file)
@@ -362,7 +362,7 @@ static void nfc_mei_phy_disable(void *phy_id)
        phy->powered = 0;
 }
 
-struct nfc_phy_ops mei_phy_ops = {
+const struct nfc_phy_ops mei_phy_ops = {
        .write = nfc_mei_phy_write,
        .enable = nfc_mei_phy_enable,
        .disable = nfc_mei_phy_disable,
index 51bd44f5f3b80d94c265314d1d77ada6c939bd96..2b1edb3eba15940b1f5e7185190a26f61165670c 100644 (file)
@@ -45,7 +45,7 @@ struct nfc_mei_phy {
        int hard_fault;
 };
 
-extern struct nfc_phy_ops mei_phy_ops;
+extern const struct nfc_phy_ops mei_phy_ops;
 
 struct nfc_mei_phy *nfc_mei_phy_alloc(struct mei_cl_device *device);
 void nfc_mei_phy_free(struct nfc_mei_phy *phy);
index dd78d987e6c9d581b8af7c55f115800ff6e3871b..f91760c784553ebddeb969056a24c19347012d64 100644 (file)
@@ -225,7 +225,7 @@ static irqreturn_t microread_i2c_irq_thread_fn(int irq, void *phy_id)
        return IRQ_HANDLED;
 }
 
-static struct nfc_phy_ops i2c_phy_ops = {
+static const struct nfc_phy_ops i2c_phy_ops = {
        .write = microread_i2c_write,
        .enable = microread_i2c_enable,
        .disable = microread_i2c_disable,
index b1d3975e8a81cabd689d45eb630585ae21e972af..a5d5c3ec65f9d796499ac94b0a040167d0e03fd6 100644 (file)
@@ -152,7 +152,7 @@ static struct nfc_hci_gate microread_gates[] = {
 #define MICROREAD_CMD_TAILROOM 2
 
 struct microread_info {
-       struct nfc_phy_ops *phy_ops;
+       const struct nfc_phy_ops *phy_ops;
        void *phy_id;
 
        struct nfc_hci_dev *hdev;
@@ -641,9 +641,9 @@ static struct nfc_hci_ops microread_hci_ops = {
        .event_received = microread_event_received,
 };
 
-int microread_probe(void *phy_id, struct nfc_phy_ops *phy_ops, char *llc_name,
-                   int phy_headroom, int phy_tailroom, int phy_payload,
-                   struct nfc_hci_dev **hdev)
+int microread_probe(void *phy_id, const struct nfc_phy_ops *phy_ops,
+                   char *llc_name, int phy_headroom, int phy_tailroom,
+                   int phy_payload, struct nfc_hci_dev **hdev)
 {
        struct microread_info *info;
        unsigned long quirks = 0;
index 044f5e45637534e861b583901bbcb4922414c4e0..76152d7aa53cd2cb708ae59d621aab35575519b4 100644 (file)
@@ -10,9 +10,9 @@
 
 #define DRIVER_DESC "NFC driver for microread"
 
-int microread_probe(void *phy_id, struct nfc_phy_ops *phy_ops, char *llc_name,
-                   int phy_headroom, int phy_tailroom, int phy_payload,
-                   struct nfc_hci_dev **hdev);
+int microread_probe(void *phy_id, const struct nfc_phy_ops *phy_ops,
+                   char *llc_name, int phy_headroom, int phy_tailroom,
+                   int phy_payload, struct nfc_hci_dev **hdev);
 
 void microread_remove(struct nfc_hci_dev *hdev);
 
index de59e439c369db05e34c7f81480ff628c127c889..37d26f01986b4099d9133f47c5e514659ac60260 100644 (file)
@@ -515,7 +515,7 @@ static irqreturn_t pn544_hci_i2c_irq_thread_fn(int irq, void *phy_id)
        return IRQ_HANDLED;
 }
 
-static struct nfc_phy_ops i2c_phy_ops = {
+static const struct nfc_phy_ops i2c_phy_ops = {
        .write = pn544_hci_i2c_write,
        .enable = pn544_hci_i2c_enable,
        .disable = pn544_hci_i2c_disable,
index b788870473e85d7d1c89493fce399ee37993b138..23faa46bb48636c86a9570845f45dfccdda6f9af 100644 (file)
@@ -108,7 +108,7 @@ static struct nfc_hci_gate pn544_gates[] = {
 #define PN544_CMDS_HEADROOM    2
 
 struct pn544_hci_info {
-       struct nfc_phy_ops *phy_ops;
+       const struct nfc_phy_ops *phy_ops;
        void *phy_id;
 
        struct nfc_hci_dev *hdev;
@@ -901,9 +901,10 @@ static struct nfc_hci_ops pn544_hci_ops = {
        .disable_se = pn544_hci_disable_se,
 };
 
-int pn544_hci_probe(void *phy_id, struct nfc_phy_ops *phy_ops, char *llc_name,
-                   int phy_headroom, int phy_tailroom, int phy_payload,
-                   fw_download_t fw_download, struct nfc_hci_dev **hdev)
+int pn544_hci_probe(void *phy_id, const struct nfc_phy_ops *phy_ops,
+                   char *llc_name, int phy_headroom, int phy_tailroom,
+                   int phy_payload, fw_download_t fw_download,
+                   struct nfc_hci_dev **hdev)
 {
        struct pn544_hci_info *info;
        u32 protocols;
index 5634ba215eada4a98bc60f3b3fda257945c05ed9..c6fe3e11e0c8e373643bb10ece413ff8a85cd5e4 100644 (file)
 typedef int (*fw_download_t)(void *context, const char *firmware_name,
                                u8 hw_variant);
 
-int pn544_hci_probe(void *phy_id, struct nfc_phy_ops *phy_ops, char *llc_name,
-                   int phy_headroom, int phy_tailroom, int phy_payload,
-                   fw_download_t fw_download, struct nfc_hci_dev **hdev);
+int pn544_hci_probe(void *phy_id, const struct nfc_phy_ops *phy_ops,
+                   char *llc_name, int phy_headroom, int phy_tailroom,
+                   int phy_payload, fw_download_t fw_download,
+                   struct nfc_hci_dev **hdev);
 void pn544_hci_remove(struct nfc_hci_dev *hdev);
 
 #endif /* __LOCAL_PN544_H_ */
index 46981405e8b1bdf95a6c277af3ece8ee7533abfe..ccf6152ebb9f2680664146b7e9423d045733d848 100644 (file)
@@ -186,7 +186,7 @@ static irqreturn_t st_nci_irq_thread_fn(int irq, void *phy_id)
        return IRQ_HANDLED;
 }
 
-static struct nfc_phy_ops i2c_phy_ops = {
+static const struct nfc_phy_ops i2c_phy_ops = {
        .write = st_nci_i2c_write,
        .enable = st_nci_i2c_enable,
        .disable = st_nci_i2c_disable,
index 5d74c674368a5481701b0dec38b1af1114f4de28..e9dc313b333e299f39d22b5e80dbc3ede9d67491 100644 (file)
@@ -253,9 +253,9 @@ static void ndlc_t2_timeout(struct timer_list *t)
        schedule_work(&ndlc->sm_work);
 }
 
-int ndlc_probe(void *phy_id, struct nfc_phy_ops *phy_ops, struct device *dev,
-              int phy_headroom, int phy_tailroom, struct llt_ndlc **ndlc_id,
-              struct st_nci_se_status *se_status)
+int ndlc_probe(void *phy_id, const struct nfc_phy_ops *phy_ops,
+              struct device *dev, int phy_headroom, int phy_tailroom,
+              struct llt_ndlc **ndlc_id, struct st_nci_se_status *se_status)
 {
        struct llt_ndlc *ndlc;
 
index 066e2fd75238a42b4add18e638e125509a7ad5c4..c24ce9b0df52e82db277f1ca4f7a65614488091a 100644 (file)
@@ -16,7 +16,7 @@ struct st_nci_se_status;
 /* Low Level Transport description */
 struct llt_ndlc {
        struct nci_dev *ndev;
-       struct nfc_phy_ops *ops;
+       const struct nfc_phy_ops *ops;
        void *phy_id;
 
        struct timer_list t1_timer;
@@ -45,8 +45,8 @@ int ndlc_open(struct llt_ndlc *ndlc);
 void ndlc_close(struct llt_ndlc *ndlc);
 int ndlc_send(struct llt_ndlc *ndlc, struct sk_buff *skb);
 void ndlc_recv(struct llt_ndlc *ndlc, struct sk_buff *skb);
-int ndlc_probe(void *phy_id, struct nfc_phy_ops *phy_ops, struct device *dev,
-              int phy_headroom, int phy_tailroom, struct llt_ndlc **ndlc_id,
-              struct st_nci_se_status *se_status);
+int ndlc_probe(void *phy_id, const struct nfc_phy_ops *phy_ops,
+              struct device *dev, int phy_headroom, int phy_tailroom,
+              struct llt_ndlc **ndlc_id, struct st_nci_se_status *se_status);
 void ndlc_remove(struct llt_ndlc *ndlc);
 #endif /* __LOCAL_NDLC_H__ */
index 250d56f204c3e7d7fb04d8e2ffcd7d0ef95d1fe2..a620c34790e6d7af34d456e2dd0c54f9fa2c15f7 100644 (file)
@@ -198,7 +198,7 @@ static irqreturn_t st_nci_irq_thread_fn(int irq, void *phy_id)
        return IRQ_HANDLED;
 }
 
-static struct nfc_phy_ops spi_phy_ops = {
+static const struct nfc_phy_ops spi_phy_ops = {
        .write = st_nci_spi_write,
        .enable = st_nci_spi_enable,
        .disable = st_nci_spi_disable,
index 6ca0d2f56b18dfa3d60c7748a2721bfd36ba2cac..583c36d4ff672cd862648f81b09b57d4999d77a2 100644 (file)
@@ -935,7 +935,7 @@ static struct nfc_hci_ops st21nfca_hci_ops = {
        .se_io = st21nfca_hci_se_io,
 };
 
-int st21nfca_hci_probe(void *phy_id, struct nfc_phy_ops *phy_ops,
+int st21nfca_hci_probe(void *phy_id, const struct nfc_phy_ops *phy_ops,
                       char *llc_name, int phy_headroom, int phy_tailroom,
                       int phy_payload, struct nfc_hci_dev **hdev,
                           struct st21nfca_se_status *se_status)
index 7a9f4d71707e0b70144390f0c0f9d4a09212ae30..9dc9693a735682221f4aa8583762f52bcb33a12b 100644 (file)
@@ -482,7 +482,7 @@ static irqreturn_t st21nfca_hci_irq_thread_fn(int irq, void *phy_id)
        return IRQ_HANDLED;
 }
 
-static struct nfc_phy_ops i2c_phy_ops = {
+static const struct nfc_phy_ops i2c_phy_ops = {
        .write = st21nfca_hci_i2c_write,
        .enable = st21nfca_hci_i2c_enable,
        .disable = st21nfca_hci_i2c_disable,
index 5e0de0fef1d4ecfaac811bcc2a66b082bf361a1f..cb6ad916be91153e6b0fe49c2737229f8e740440 100644 (file)
@@ -144,7 +144,7 @@ struct st21nfca_se_info {
 };
 
 struct st21nfca_hci_info {
-       struct nfc_phy_ops *phy_ops;
+       const struct nfc_phy_ops *phy_ops;
        void *phy_id;
 
        struct nfc_hci_dev *hdev;
@@ -163,7 +163,7 @@ struct st21nfca_hci_info {
        struct st21nfca_vendor_info vendor_info;
 };
 
-int st21nfca_hci_probe(void *phy_id, struct nfc_phy_ops *phy_ops,
+int st21nfca_hci_probe(void *phy_id, const struct nfc_phy_ops *phy_ops,
                       char *llc_name, int phy_headroom, int phy_tailroom,
                       int phy_payload, struct nfc_hci_dev **hdev,
                       struct st21nfca_se_status *se_status);