Skip to content

Commit

Permalink
nfc: constify nfc_ops
Browse files Browse the repository at this point in the history
Neither the core nor the drivers modify the passed pointer to struct
nfc_ops, so make it a pointer to const for correctness and safety.

Signed-off-by: Krzysztof Kozlowski <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
krzk authored and davem330 committed Jul 25, 2021
1 parent 5f3e639 commit f6c802a
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
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
4 changes: 2 additions & 2 deletions include/net/nfc/nfc.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,14 @@ struct nfc_dev {
const struct nfc_vendor_cmd *vendor_cmds;
int n_vendor_cmds;

struct nfc_ops *ops;
const struct nfc_ops *ops;
struct genl_info *cur_cmd_info;
};
#define to_nfc_dev(_dev) container_of(_dev, struct nfc_dev, dev)

extern struct class nfc_class;

struct nfc_dev *nfc_allocate_device(struct nfc_ops *ops,
struct nfc_dev *nfc_allocate_device(const struct nfc_ops *ops,
u32 supported_protocols,
int tx_headroom,
int tx_tailroom);
Expand Down
2 changes: 1 addition & 1 deletion net/nfc/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,7 @@ struct nfc_dev *nfc_get_device(unsigned int idx)
* @tx_headroom: reserved space at beginning of skb
* @tx_tailroom: reserved space at end of skb
*/
struct nfc_dev *nfc_allocate_device(struct nfc_ops *ops,
struct nfc_dev *nfc_allocate_device(const struct nfc_ops *ops,
u32 supported_protocols,
int tx_headroom, int tx_tailroom)
{
Expand Down
2 changes: 1 addition & 1 deletion net/nfc/digital_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ static int digital_in_send(struct nfc_dev *nfc_dev, struct nfc_target *target,
return rc;
}

static struct nfc_ops digital_nfc_ops = {
static const struct nfc_ops digital_nfc_ops = {
.dev_up = digital_dev_up,
.dev_down = digital_dev_down,
.start_poll = digital_start_poll,
Expand Down
2 changes: 1 addition & 1 deletion net/nfc/hci/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,7 @@ static int hci_fw_download(struct nfc_dev *nfc_dev, const char *firmware_name)
return hdev->ops->fw_download(hdev, firmware_name);
}

static struct nfc_ops hci_nfc_ops = {
static const struct nfc_ops hci_nfc_ops = {
.dev_up = hci_dev_up,
.dev_down = hci_dev_down,
.start_poll = hci_start_poll,
Expand Down
2 changes: 1 addition & 1 deletion net/nfc/nci/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1102,7 +1102,7 @@ static int nci_fw_download(struct nfc_dev *nfc_dev, const char *firmware_name)
return ndev->ops->fw_download(ndev, firmware_name);
}

static struct nfc_ops nci_nfc_ops = {
static const struct nfc_ops nci_nfc_ops = {
.dev_up = nci_dev_up,
.dev_down = nci_dev_down,
.start_poll = nci_start_poll,
Expand Down

0 comments on commit f6c802a

Please sign in to comment.