Skip to content

Commit

Permalink
Merge branch 'nfc-const'
Browse files Browse the repository at this point in the history
Krzysztof Kozlowski says:

====================
nfc: constify data structures

Constify pointers to several data structures which are not modified by
NFC core or by drivers to make it slightly safer.  No functional impact
expected.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Jul 25, 2021
2 parents c538115 + 7186aac commit 0e80432
Show file tree
Hide file tree
Showing 46 changed files with 108 additions and 112 deletions.
2 changes: 1 addition & 1 deletion Documentation/driver-api/nfc/nfc-hci.rst
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ xmit_from_hci():
The llc must be registered with nfc before it can be used. Do that by
calling::

nfc_llc_register(const char *name, struct nfc_llc_ops *ops);
nfc_llc_register(const char *name, const struct nfc_llc_ops *ops);

Again, note that the llc does not handle the physical link. It is thus very
easy to mix any physical link with any llc for a given chip driver.
Expand Down
11 changes: 6 additions & 5 deletions drivers/nfc/fdp/fdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -675,7 +675,7 @@ static struct nci_driver_ops fdp_prop_ops[] = {
},
};

static struct nci_ops nci_ops = {
static const struct nci_ops nci_ops = {
.open = fdp_nci_open,
.close = fdp_nci_close,
.send = fdp_nci_send,
Expand All @@ -687,7 +687,7 @@ static 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)
Expand Down Expand Up @@ -718,6 +718,7 @@ int fdp_nci_probe(struct fdp_i2c_phy *phy, struct nfc_phy_ops *phy_ops,
NFC_PROTO_NFC_DEP_MASK |
NFC_PROTO_ISO15693_MASK;

BUILD_BUG_ON(ARRAY_SIZE(fdp_prop_ops) > NCI_MAX_PROPRIETARY_CMD);
ndev = nci_allocate_device(&nci_ops, protocols, tx_headroom,
tx_tailroom);
if (!ndev) {
Expand Down
2 changes: 1 addition & 1 deletion drivers/nfc/fdp/fdp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion drivers/nfc/fdp/i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion drivers/nfc/mei_phy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion drivers/nfc/mei_phy.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion drivers/nfc/microread/i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 6 additions & 6 deletions drivers/nfc/microread/microread.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
#define MICROREAD_ELT_ID_SE2 0x04
#define MICROREAD_ELT_ID_SE3 0x05

static struct nfc_hci_gate microread_gates[] = {
static const struct nfc_hci_gate microread_gates[] = {
{MICROREAD_GATE_ID_ADM, MICROREAD_PIPE_ID_ADMIN},
{MICROREAD_GATE_ID_LOOPBACK, MICROREAD_PIPE_ID_HDS_LOOPBACK},
{MICROREAD_GATE_ID_IDT, MICROREAD_PIPE_ID_HDS_IDT},
Expand All @@ -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;
Expand Down Expand Up @@ -625,7 +625,7 @@ static int microread_event_received(struct nfc_hci_dev *hdev, u8 pipe,
return r;
}

static struct nfc_hci_ops microread_hci_ops = {
static const struct nfc_hci_ops microread_hci_ops = {
.open = microread_open,
.close = microread_close,
.hci_ready = microread_hci_ready,
Expand All @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions drivers/nfc/microread/microread.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion drivers/nfc/nfcmrvl/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ static int nfcmrvl_nci_fw_download(struct nci_dev *ndev,
return nfcmrvl_fw_dnld_start(ndev, firmware_name);
}

static struct nci_ops nfcmrvl_nci_ops = {
static const struct nci_ops nfcmrvl_nci_ops = {
.open = nfcmrvl_nci_open,
.close = nfcmrvl_nci_close,
.send = nfcmrvl_nci_send,
Expand Down
2 changes: 1 addition & 1 deletion drivers/nfc/nfcsim.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ static int nfcsim_tg_listen(struct nfc_digital_dev *ddev, u16 timeout,
return nfcsim_send(ddev, NULL, timeout, cb, arg);
}

static struct nfc_digital_ops nfcsim_digital_ops = {
static const struct nfc_digital_ops nfcsim_digital_ops = {
.in_configure_hw = nfcsim_in_configure_hw,
.in_send_cmd = nfcsim_in_send_cmd,

Expand Down
2 changes: 1 addition & 1 deletion drivers/nfc/nxp-nci/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ static int nxp_nci_send(struct nci_dev *ndev, struct sk_buff *skb)
return r;
}

static struct nci_ops nxp_nci_ops = {
static const struct nci_ops nxp_nci_ops = {
.open = nxp_nci_open,
.close = nxp_nci_close,
.send = nxp_nci_send,
Expand Down
2 changes: 1 addition & 1 deletion drivers/nfc/pn533/pn533.c
Original file line number Diff line number Diff line change
Expand Up @@ -2623,7 +2623,7 @@ static int pn533_dev_down(struct nfc_dev *nfc_dev)
return ret;
}

static struct nfc_ops pn533_nfc_ops = {
static const struct nfc_ops pn533_nfc_ops = {
.dev_up = pn533_dev_up,
.dev_down = pn533_dev_down,
.dep_link_up = pn533_dep_link_up,
Expand Down
2 changes: 1 addition & 1 deletion drivers/nfc/pn544/i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
13 changes: 7 additions & 6 deletions drivers/nfc/pn544/pn544.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ enum pn544_state {
#define PN544_HCI_CMD_ATTREQUEST 0x12
#define PN544_HCI_CMD_CONTINUE_ACTIVATION 0x13

static struct nfc_hci_gate pn544_gates[] = {
static const struct nfc_hci_gate pn544_gates[] = {
{NFC_HCI_ADMIN_GATE, NFC_HCI_INVALID_PIPE},
{NFC_HCI_LOOPBACK_GATE, NFC_HCI_INVALID_PIPE},
{NFC_HCI_ID_MGMT_GATE, NFC_HCI_INVALID_PIPE},
Expand All @@ -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;
Expand Down Expand Up @@ -881,7 +881,7 @@ static int pn544_hci_disable_se(struct nfc_hci_dev *hdev, u32 se_idx)
}
}

static struct nfc_hci_ops pn544_hci_ops = {
static const struct nfc_hci_ops pn544_hci_ops = {
.open = pn544_hci_open,
.close = pn544_hci_close,
.hci_ready = pn544_hci_ready,
Expand All @@ -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;
Expand Down
7 changes: 4 additions & 3 deletions drivers/nfc/pn544/pn544.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
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_ */
2 changes: 1 addition & 1 deletion drivers/nfc/port100.c
Original file line number Diff line number Diff line change
Expand Up @@ -1463,7 +1463,7 @@ static int port100_listen(struct nfc_digital_dev *ddev, u16 timeout,
return port100_tg_send_cmd(ddev, skb, timeout, cb, arg);
}

static struct nfc_digital_ops port100_digital_ops = {
static const struct nfc_digital_ops port100_digital_ops = {
.in_configure_hw = port100_in_configure_hw,
.in_send_cmd = port100_in_send_cmd,

Expand Down
7 changes: 3 additions & 4 deletions drivers/nfc/s3fwrn5/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,13 @@ static int s3fwrn5_nci_post_setup(struct nci_dev *ndev)
return nci_core_init(info->ndev);
}

static struct nci_ops s3fwrn5_nci_ops = {
static const struct nci_ops s3fwrn5_nci_ops = {
.open = s3fwrn5_nci_open,
.close = s3fwrn5_nci_close,
.send = s3fwrn5_nci_send,
.post_setup = s3fwrn5_nci_post_setup,
.prop_ops = s3fwrn5_nci_prop_ops,
.n_prop_ops = ARRAY_SIZE(s3fwrn5_nci_prop_ops),
};

int s3fwrn5_probe(struct nci_dev **ndev, void *phy_id, struct device *pdev,
Expand All @@ -167,9 +169,6 @@ int s3fwrn5_probe(struct nci_dev **ndev, void *phy_id, struct device *pdev,

s3fwrn5_set_mode(info, S3FWRN5_MODE_COLD);

s3fwrn5_nci_get_prop_ops(&s3fwrn5_nci_ops.prop_ops,
&s3fwrn5_nci_ops.n_prop_ops);

info->ndev = nci_allocate_device(&s3fwrn5_nci_ops,
S3FWRN5_NFC_PROTOCOLS, 0, 0);
if (!info->ndev)
Expand Down
8 changes: 1 addition & 7 deletions drivers/nfc/s3fwrn5/nci.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ static int s3fwrn5_nci_prop_rsp(struct nci_dev *ndev, struct sk_buff *skb)
return 0;
}

static struct nci_driver_ops s3fwrn5_nci_prop_ops[] = {
const struct nci_driver_ops s3fwrn5_nci_prop_ops[4] = {
{
.opcode = nci_opcode_pack(NCI_GID_PROPRIETARY,
NCI_PROP_SET_RFREG),
Expand All @@ -43,12 +43,6 @@ static struct nci_driver_ops s3fwrn5_nci_prop_ops[] = {
},
};

void s3fwrn5_nci_get_prop_ops(struct nci_driver_ops **ops, size_t *n)
{
*ops = s3fwrn5_nci_prop_ops;
*n = ARRAY_SIZE(s3fwrn5_nci_prop_ops);
}

#define S3FWRN5_RFREG_SECTION_SIZE 252

int s3fwrn5_nci_rf_configure(struct s3fwrn5_info *info, const char *fw_name)
Expand Down
2 changes: 1 addition & 1 deletion drivers/nfc/s3fwrn5/nci.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ struct nci_prop_fw_cfg_rsp {
__u8 status;
};

void s3fwrn5_nci_get_prop_ops(struct nci_driver_ops **ops, size_t *n);
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_ */
5 changes: 3 additions & 2 deletions drivers/nfc/st-nci/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@ 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),
.rsp = st_nci_prop_rsp_packet,
},
};

static struct nci_ops st_nci_ops = {
static const struct nci_ops st_nci_ops = {
.init = st_nci_init,
.open = st_nci_open,
.close = st_nci_close,
Expand Down Expand Up @@ -131,6 +131,7 @@ int st_nci_probe(struct llt_ndlc *ndlc, int phy_headroom,
| NFC_PROTO_ISO15693_MASK
| NFC_PROTO_NFC_DEP_MASK;

BUILD_BUG_ON(ARRAY_SIZE(st_nci_prop_ops) > NCI_MAX_PROPRIETARY_CMD);
ndlc->ndev = nci_allocate_device(&st_nci_ops, protocols,
phy_headroom, phy_tailroom);
if (!ndlc->ndev) {
Expand Down
2 changes: 1 addition & 1 deletion drivers/nfc/st-nci/i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions drivers/nfc/st-nci/ndlc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
8 changes: 4 additions & 4 deletions drivers/nfc/st-nci/ndlc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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__ */
Loading

0 comments on commit 0e80432

Please sign in to comment.