nfc: constify pointed data - missed part
Subsystems (3)
v3 cover nfc: constify pointed data - missed part
Hi,
This was previously sent [1] but got lost. It was a prerequisite to part two of NFC const [2].
Changes since v2:
1. Drop patch previously 7/8 which cases new warnings "warning: Using plain integer as NULL pointer".
Changes since v1:
1. Add patch 1/8 fixing up nfcmrvl_spi_parse_dt()
[1] https://lore.kernel.org/lkml/20210726145224.146006-1-krzysztof.kozlowski(a)canonical.com/
[2] https://lore.kernel.org/linux-nfc/20210729104022.47761-1-krzysztof.kozlowski(a)canonical.com/T/#m199fbdde180fa005a10addf28479fcbdc6263eab
Best regards,
Krzysztof
Krzysztof Kozlowski (7):
nfc: mrvl: correct nfcmrvl_spi_parse_dt() device_node argument
nfc: annotate af_nfc_exit() as __exit
nfc: hci: annotate nfc_llc_init() as __init
nfc: constify several pointers to u8, char and sk_buff
nfc: constify local pointer variables
nfc: nci: constify several pointers to u8, sk_buff and other structs
nfc: hci: cleanup unneeded spaces
drivers/nfc/nfcmrvl/spi.c | 2 +- drivers/nfc/pn544/pn544.c | 4 +- include/net/nfc/nci_core.h | 14 +++--- include/net/nfc/nfc.h | 4 +- net/nfc/af_nfc.c | 2 +- net/nfc/core.c | 6 +-- net/nfc/hci/core.c | 8 ++-- net/nfc/hci/llc.c | 2 +- net/nfc/hci/llc_shdlc.c | 10 ++--- net/nfc/llcp.h | 8 ++-- net/nfc/llcp_commands.c | 46 +++++++++++--------- net/nfc/llcp_core.c | 44 ++++++++++--------- net/nfc/nci/core.c | 48 +++++++++++---------- net/nfc/nci/data.c | 12 +++--- net/nfc/nci/hci.c | 38 ++++++++--------- net/nfc/nci/ntf.c | 87 ++++++++++++++++++++------------------ net/nfc/nci/rsp.c | 48 +++++++++++---------- net/nfc/nci/spi.c | 2 +- net/nfc/netlink.c | 2 +- net/nfc/nfc.h | 2 +- 20 files changed, 206 insertions(+), 183 deletions(-)
Signature · 1 line
2.27.0
PATCH v3 1/7 nfc: mrvl: correct nfcmrvl_spi_parse_dt() device_node argument
The device_node in nfcmrvl_spi_parse_dt() cannot be const as it is passed to OF functions which modify it.
--- drivers/nfc/nfcmrvl/spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nfc/nfcmrvl/spi.c +1 -1
@@ -106,7 +106,7 @@ static const struct nfcmrvl_if_ops spi_ops = { .nci_update_config = nfcmrvl_spi_nci_update_config, }; -static int nfcmrvl_spi_parse_dt (const struct device_node *node, +static int nfcmrvl_spi_parse_dt (struct device_node *node,struct nfcmrvl_platform_data *pdata) {int ret;
Signature · 1 line
2.27.0
PATCH v3 2/7 nfc: annotate af_nfc_exit() as __exit
In reply to Krzysztof KozlowskiThe af_nfc_exit() is used only in other __exit annotated context (nfc_exit()).
--- net/nfc/af_nfc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/nfc/af_nfc.c +1 -1
@@ -79,7 +79,7 @@ int __init af_nfc_init(void)return sock_register (&nfc_sock_family_ops); } -void af_nfc_exit (void ) +void __exit af_nfc_exit(void) {sock_unregister (PF_NFC ); }
Signature · 1 line
2.27.0
PATCH v3 3/7 nfc: hci: annotate nfc_llc_init() as __init
In reply to Krzysztof KozlowskiThe nfc_llc_init() is used only in other __init annotated context.
--- net/nfc/hci/llc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/nfc/hci/llc.c +1 -1
@@ -11,7 +11,7 @@static LIST_HEAD (llc_engines); -int nfc_llc_init (void ) +int __init nfc_llc_init (void ) {int r;
Signature · 1 line
2.27.0
PATCH v3 4/7 nfc: constify several pointers to u8, char and sk_buff
In reply to Krzysztof KozlowskiSeveral functions receive pointers to u8, char or sk_buff but do not modify the contents so make them const. This allows doing the same for local variables and in total makes the code a little bit safer.
--- include/net/nfc/nfc.h | 4 ++-- net/nfc/core.c | 4 ++-- net/nfc/hci/llc_shdlc.c | 10 ++++----- net/nfc/llcp.h | 8 +++---- net/nfc/llcp_commands.c | 46 ++++++++++++++++++++++------------------- net/nfc/llcp_core.c | 44 +++++++++++++++++++++------------------ net/nfc/nfc.h | 2 +- 7 files changed, 63 insertions(+), 55 deletions(-)
include/net/nfc/nfc.h +2 -2
@@ -266,7 +266,7 @@ struct sk_buff *nfc_alloc_send_skb(struct nfc_dev *dev, struct sock *sk,struct sk_buff *nfc_alloc_recv_skb (unsigned int size,gfp_t gfp);int nfc_set_remote_general_bytes (struct nfc_dev *dev, -u8 *gt,u8 gt_len); +const u8 *gt,u8 gt_len);u8 *nfc_get_local_general_bytes (struct nfc_dev *dev,size_t *gb_len); int nfc_fw_download_done(struct nfc_dev *dev, const char *firmware_name,
@@ -280,7 +280,7 @@ int nfc_dep_link_is_up(struct nfc_dev *dev, u32 target_idx, u8 comm_mode, u8 rf_mode);int nfc_tm_activated (struct nfc_dev *dev,u32 protocol,u8 comm_mode, -u8 *gb,size_t gb_len); +const u8 *gb,size_t gb_len);int nfc_tm_deactivated (struct nfc_dev *dev);int nfc_tm_data_received (struct nfc_dev *dev,struct sk_buff *skb);
net/nfc/core.c +2 -2
@@ -636,7 +636,7 @@ int nfc_disable_se(struct nfc_dev *dev, u32 se_idx)return rc; } -int nfc_set_remote_general_bytes (struct nfc_dev *dev,u8 *gb,u8 gb_len) +int nfc_set_remote_general_bytes (struct nfc_dev *dev,const u8 *gb,u8 gb_len) {pr_debug ("dev_name=%s gb_len=%d\n" ,dev_name (&dev->dev), gb_len);
@@ -665,7 +665,7 @@ int nfc_tm_data_received(struct nfc_dev *dev, struct sk_buff *skb)EXPORT_SYMBOL (nfc_tm_data_received);int nfc_tm_activated (struct nfc_dev *dev,u32 protocol,u8 comm_mode, -u8 *gb,size_t gb_len) +const u8 *gb,size_t gb_len) {int rc;
net/nfc/hci/llc_shdlc.c +5 -5
@@ -123,7 +123,7 @@ static bool llc_shdlc_x_lteq_y_lt_z(int x, int y, int z)return ((y >= x) || (y < z)) ? true : false; } -static struct sk_buff *llc_shdlc_alloc_skb (struct llc_shdlc *shdlc, +static struct sk_buff *llc_shdlc_alloc_skb (const struct llc_shdlc *shdlc,int payload_len) {struct sk_buff *skb;
@@ -137,7 +137,7 @@ static struct sk_buff *llc_shdlc_alloc_skb(struct llc_shdlc *shdlc, }/* immediately sends an S frame. */ -static int llc_shdlc_send_s_frame (struct llc_shdlc *shdlc, +static int llc_shdlc_send_s_frame (const struct llc_shdlc *shdlc,enum sframe_type sframe_type,int nr) {int r;
@@ -159,7 +159,7 @@ static int llc_shdlc_send_s_frame(struct llc_shdlc *shdlc, }/* immediately sends an U frame. skb may contain optional payload */ -static int llc_shdlc_send_u_frame (struct llc_shdlc *shdlc, +static int llc_shdlc_send_u_frame (const struct llc_shdlc *shdlc,struct sk_buff *skb,enum uframe_modifier uframe_modifier) {
@@ -361,7 +361,7 @@ static void llc_shdlc_connect_complete(struct llc_shdlc *shdlc, int r)wake_up (shdlc->connect_wq); } -static int llc_shdlc_connect_initiate (struct llc_shdlc *shdlc) +static int llc_shdlc_connect_initiate (const struct llc_shdlc *shdlc) {struct sk_buff *skb;
@@ -377,7 +377,7 @@ static int llc_shdlc_connect_initiate(struct llc_shdlc *shdlc)return llc_shdlc_send_u_frame (shdlc, skb,U_FRAME_RSET ); } -static int llc_shdlc_connect_send_ua (struct llc_shdlc *shdlc) +static int llc_shdlc_connect_send_ua (const struct llc_shdlc *shdlc) {struct sk_buff *skb;
net/nfc/llcp.h +4 -4
@@ -221,15 +221,15 @@ struct sock *nfc_llcp_accept_dequeue(struct sock *sk, struct socket *newsock);/* TLV API */ int nfc_llcp_parse_gb_tlv (struct nfc_llcp_local *local, -u8 *tlv_array,u16 tlv_array_len); +const u8 *tlv_array,u16 tlv_array_len);int nfc_llcp_parse_connection_tlv (struct nfc_llcp_sock *sock, -u8 *tlv_array,u16 tlv_array_len); +const u8 *tlv_array,u16 tlv_array_len);/* Commands API */ void nfc_llcp_recv (void *data,struct sk_buff *skb,int err); -u8 *nfc_llcp_build_tlv (u8 type,u8 *value,u8 value_length,u8 *tlv_length); +u8 *nfc_llcp_build_tlv (u8 type,const u8 *value,u8 value_length,u8 *tlv_length);struct nfc_llcp_sdp_tlv *nfc_llcp_build_sdres_tlv (u8 tid,u8 sap); -struct nfc_llcp_sdp_tlv *nfc_llcp_build_sdreq_tlv (u8 tid,char *uri, +struct nfc_llcp_sdp_tlv *nfc_llcp_build_sdreq_tlv (u8 tid,const char *uri,size_t uri_len);void nfc_llcp_free_sdp_tlv (struct nfc_llcp_sdp_tlv *sdp);void nfc_llcp_free_sdp_tlv_list (struct hlist_head *sdp_head);
net/nfc/llcp_commands.c +25 -21
132 lines not on this page · raw message
net/nfc/llcp_core.c +24 -20
142 lines not on this page · raw message
net/nfc/nfc.h +1 -1
@@ -48,7 +48,7 @@ void nfc_llcp_mac_is_up(struct nfc_dev *dev, u32 target_idx, u8 comm_mode, u8 rf_mode);int nfc_llcp_register_device (struct nfc_dev *dev);void nfc_llcp_unregister_device (struct nfc_dev *dev); -int nfc_llcp_set_remote_gb (struct nfc_dev *dev,u8 *gb,u8 gb_len); +int nfc_llcp_set_remote_gb (struct nfc_dev *dev,const u8 *gb,u8 gb_len);u8 *nfc_llcp_general_bytes (struct nfc_dev *dev,size_t *general_bytes_len);int nfc_llcp_data_received (struct nfc_dev *dev,struct sk_buff *skb);struct nfc_llcp_local *nfc_llcp_find_local (struct nfc_dev *dev);
Signature · 1 line
2.27.0
PATCH v3 5/7 nfc: constify local pointer variables
In reply to Krzysztof KozlowskiFew pointers to struct nfc_target and struct nfc_se can be made const.
--- drivers/nfc/pn544/pn544.c | 4 ++-- net/nfc/core.c | 2 +- net/nfc/hci/core.c | 8 ++++---- net/nfc/netlink.c | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-)
drivers/nfc/pn544/pn544.c +2 -2
@@ -809,7 +809,7 @@ static int pn544_hci_discover_se(struct nfc_hci_dev *hdev)#define PN544_SE_MODE_ON 0x01static int pn544_hci_enable_se (struct nfc_hci_dev *hdev,u32 se_idx) { -struct nfc_se *se; +const struct nfc_se *se;u8 enable =PN544_SE_MODE_ON ; static struct uicc_gatelist { u8 head;
@@ -864,7 +864,7 @@ static int pn544_hci_enable_se(struct nfc_hci_dev *hdev, u32 se_idx)static int pn544_hci_disable_se (struct nfc_hci_dev *hdev,u32 se_idx) { -struct nfc_se *se; +const struct nfc_se *se;u8 disable =PN544_SE_MODE_OFF ; se =nfc_find_se (hdev->ndev, se_idx);
net/nfc/core.c +1 -1
@@ -824,7 +824,7 @@ EXPORT_SYMBOL(nfc_targets_found);*/ int nfc_target_lost (struct nfc_dev *dev,u32 target_idx) { -struct nfc_target *tg; +const struct nfc_target *tg;int i;pr_debug ("dev_name %s n_target %d\n" ,dev_name (&dev->dev), target_idx);
net/nfc/hci/core.c +4 -4
@@ -128,7 +128,7 @@ static void nfc_hci_msg_rx_work(struct work_struct *work) struct nfc_hci_dev *hdev = container_of(work, struct nfc_hci_dev, msg_rx_work);struct sk_buff *skb; -struct hcp_message *message; +const struct hcp_message *message;u8 pipe;u8 type;u8 instruction;
@@ -182,9 +182,9 @@ void nfc_hci_cmd_received(struct nfc_hci_dev *hdev, u8 pipe, u8 cmd, struct sk_buff *skb) {u8 status =NFC_HCI_ANY_OK ; -struct hci_create_pipe_resp *create_info; -struct hci_delete_pipe_noti *delete_info; -struct hci_all_pipe_cleared_noti *cleared_info; +const struct hci_create_pipe_resp *create_info; +const struct hci_delete_pipe_noti *delete_info; +const struct hci_all_pipe_cleared_noti *cleared_info;u8 gate;pr_debug ("from pipe %x cmd %x\n" , pipe, cmd);
net/nfc/netlink.c +1 -1
@@ -530,7 +530,7 @@ int nfc_genl_se_transaction(struct nfc_dev *dev, u8 se_idx,int nfc_genl_se_connectivity (struct nfc_dev *dev,u8 se_idx) { -struct nfc_se *se; +const struct nfc_se *se;struct sk_buff *msg;void *hdr;
Signature · 1 line
2.27.0
PATCH v3 6/7 nfc: nci: constify several pointers to u8, sk_buff and other structs
In reply to Krzysztof KozlowskiSeveral functions receive pointers to u8, sk_buff or other structs but do not modify the contents so make them const. This allows doing the same for local variables and in total makes the code a little bit safer.
This makes const also data passed as "unsigned long opt" argument to nci_request() function. Usual flow for such functions is:
1. Receive "u8 *" and store it (the pointer) in a structure allocated on stack (e.g. struct nci_set_config_param),
2. Call nci_request() or __nci_request() passing a callback function an the pointer to the structure via an "unsigned long opt",
3. nci_request() calls the callback which dereferences "unsigned long opt" in a read-only way.
This converts all above paths to use proper pointer to const data, so entire flow is safer.
--- include/net/nfc/nci_core.h | 14 ++++--- net/nfc/nci/core.c | 40 +++++++++--------- net/nfc/nci/data.c | 12 +++--- net/nfc/nci/hci.c | 24 +++++------ net/nfc/nci/ntf.c | 83 +++++++++++++++++++++----------------- net/nfc/nci/rsp.c | 46 +++++++++++---------- net/nfc/nci/spi.c | 2 +- 7 files changed, 118 insertions(+), 103 deletions(-)
include/net/nfc/nci_core.h +8 -6
@@ -278,23 +278,25 @@ int nci_request(struct nci_dev *ndev,void (*req)(struct nci_dev *ndev,unsigned long opt), unsigned long opt, __u32 timeout); -int nci_prop_cmd (struct nci_dev *ndev,__u8 oid,size_t len,__u8 *payload); -int nci_core_cmd (struct nci_dev *ndev,__u16 opcode,size_t len,__u8 *payload); +int nci_prop_cmd (struct nci_dev *ndev,__u8 oid,size_t len, +const __u8 *payload); +int nci_core_cmd (struct nci_dev *ndev,__u16 opcode,size_t len, +const __u8 *payload);int nci_core_reset (struct nci_dev *ndev);int nci_core_init (struct nci_dev *ndev);int nci_recv_frame (struct nci_dev *ndev,struct sk_buff *skb);int nci_send_frame (struct nci_dev *ndev,struct sk_buff *skb); -int nci_set_config (struct nci_dev *ndev,__u8 id,size_t len,__u8 *val); +int nci_set_config (struct nci_dev *ndev,__u8 id,size_t len,const __u8 *val);int nci_nfcee_discover (struct nci_dev *ndev,u8 action);int nci_nfcee_mode_set (struct nci_dev *ndev,u8 nfcee_id,u8 nfcee_mode);int nci_core_conn_create (struct nci_dev *ndev,u8 destination_type,u8 number_destination_params,size_t params_len, -struct core_conn_create_dest_spec_params *params); +const struct core_conn_create_dest_spec_params *params);int nci_core_conn_close (struct nci_dev *ndev,u8 conn_id); -int nci_nfcc_loopback (struct nci_dev *ndev,void *data,size_t data_len, +int nci_nfcc_loopback (struct nci_dev *ndev,const void *data,size_t data_len,struct sk_buff **resp);struct nci_hci_dev *nci_hci_allocate (struct nci_dev *ndev);
@@ -378,7 +380,7 @@ void nci_req_complete(struct nci_dev *ndev, int result);struct nci_conn_info *nci_get_conn_info_by_conn_id (struct nci_dev *ndev,int conn_id);int nci_get_conn_info_by_dest_type_params (struct nci_dev *ndev,u8 dest_type, -struct dest_spec_params *params); +const struct dest_spec_params *params);/* ----- NCI status code ----- */ int nci_to_errno (__u8 code);
net/nfc/nci/core.c +21 -19
@@ -53,9 +53,9 @@ struct nci_conn_info *nci_get_conn_info_by_conn_id(struct nci_dev *ndev, }int nci_get_conn_info_by_dest_type_params (struct nci_dev *ndev,u8 dest_type, -struct dest_spec_params *params) +const struct dest_spec_params *params) { -struct nci_conn_info *conn_info; +const struct nci_conn_info *conn_info;list_for_each_entry (conn_info, &ndev->conn_info_list, list) {if (conn_info->dest_type == dest_type) {
@@ -210,14 +210,15 @@ static void nci_init_complete_req(struct nci_dev *ndev, unsigned long opt) }struct nci_set_config_param { -__u8 id; -size_t len; -__u8 *val; +__u8 id; +size_t len; +const __u8 *val; };static void nci_set_config_req (struct nci_dev *ndev,unsigned long opt) { -struct nci_set_config_param *param = (struct nci_set_config_param *)opt; +const struct nci_set_config_param *param = + (struct nci_set_config_param *)opt;struct nci_core_set_config_cmd cmd;BUG_ON (param->len >NCI_MAX_PARAM_LEN );
@@ -237,7 +238,7 @@ struct nci_rf_discover_param {static void nci_rf_discover_req (struct nci_dev *ndev,unsigned long opt) { -struct nci_rf_discover_param *param = +const struct nci_rf_discover_param *param = (struct nci_rf_discover_param *)opt;struct nci_rf_disc_cmd cmd;
@@ -303,7 +304,7 @@ struct nci_rf_discover_select_param {static void nci_rf_discover_select_req (struct nci_dev *ndev,unsigned long opt) { -struct nci_rf_discover_select_param *param = +const struct nci_rf_discover_select_param *param = (struct nci_rf_discover_select_param *)opt;struct nci_rf_discover_select_cmd cmd;
@@ -341,18 +342,18 @@ static void nci_rf_deactivate_req(struct nci_dev *ndev, unsigned long opt)struct nci_cmd_param {__u16 opcode;size_t len; -__u8 *payload; +const __u8 *payload; };static void nci_generic_req (struct nci_dev *ndev,unsigned long opt) { -struct nci_cmd_param *param = +const struct nci_cmd_param *param = (struct nci_cmd_param *)opt;nci_send_cmd (ndev, param->opcode, param->len, param->payload); } -int nci_prop_cmd (struct nci_dev *ndev,__u8 oid,size_t len,__u8 *payload) +int nci_prop_cmd (struct nci_dev *ndev,__u8 oid,size_t len,const __u8 *payload) {struct nci_cmd_param param;
@@ -365,7 +366,8 @@ int nci_prop_cmd(struct nci_dev *ndev, __u8 oid, size_t len, __u8 *payload) }EXPORT_SYMBOL (nci_prop_cmd); -int nci_core_cmd (struct nci_dev *ndev,__u16 opcode,size_t len,__u8 *payload) +int nci_core_cmd (struct nci_dev *ndev,__u16 opcode,size_t len, +const __u8 *payload) {struct nci_cmd_param param;
@@ -399,7 +401,7 @@ struct nci_loopback_data {static void nci_send_data_req (struct nci_dev *ndev,unsigned long opt) { -struct nci_loopback_data *data = (struct nci_loopback_data *)opt; +const struct nci_loopback_data *data = (struct nci_loopback_data *)opt;nci_send_data (ndev, data->conn_id, data->data); }
@@ -420,7 +422,7 @@ static void nci_nfcc_loopback_cb(void *context, struct sk_buff *skb, int err)nci_req_complete (ndev,NCI_STATUS_OK ); } -int nci_nfcc_loopback (struct nci_dev *ndev,void *data,size_t data_len, +int nci_nfcc_loopback (struct nci_dev *ndev,const void *data,size_t data_len,struct sk_buff **resp) {int r;
@@ -624,7 +626,7 @@ static int nci_dev_down(struct nfc_dev *nfc_dev)return nci_close_device (ndev); } -int nci_set_config (struct nci_dev *ndev,__u8 id,size_t len,__u8 *val) +int nci_set_config (struct nci_dev *ndev,__u8 id,size_t len,const __u8 *val) {struct nci_set_config_param param;
@@ -659,7 +661,7 @@ EXPORT_SYMBOL(nci_nfcee_discover);static void nci_nfcee_mode_set_req (struct nci_dev *ndev,unsigned long opt) { -struct nci_nfcee_mode_set_cmd *cmd = +const struct nci_nfcee_mode_set_cmd *cmd = (struct nci_nfcee_mode_set_cmd *)opt; nci_send_cmd(ndev, NCI_OP_NFCEE_MODE_SET_CMD,
@@ -681,7 +683,7 @@ EXPORT_SYMBOL(nci_nfcee_mode_set);static void nci_core_conn_create_req (struct nci_dev *ndev,unsigned long opt) { -struct core_conn_create_data *data = +const struct core_conn_create_data *data = (struct core_conn_create_data *)opt;nci_send_cmd (ndev,NCI_OP_CORE_CONN_CREATE_CMD , data->length, data->cmd);
@@ -690,7 +692,7 @@ static void nci_core_conn_create_req(struct nci_dev *ndev, unsigned long opt)int nci_core_conn_create (struct nci_dev *ndev,u8 destination_type,u8 number_destination_params,size_t params_len, -struct core_conn_create_dest_spec_params *params) +const struct core_conn_create_dest_spec_params *params) {int r;struct nci_core_conn_create_cmd *cmd;
@@ -863,7 +865,7 @@ static int nci_activate_target(struct nfc_dev *nfc_dev, {struct nci_dev *ndev =nfc_get_drvdata (nfc_dev);struct nci_rf_discover_select_param param; -struct nfc_target *nci_target =NULL ; +const struct nfc_target *nci_target =NULL ;int i;int rc =0 ;
net/nfc/nci/data.c +6 -6
@@ -26,7 +26,7 @@void nci_data_exchange_complete (struct nci_dev *ndev,struct sk_buff *skb,__u8 conn_id,int err) { -struct nci_conn_info *conn_info; +const struct nci_conn_info *conn_info;data_exchange_cb_t cb;void *cb_context;
@@ -80,7 +80,7 @@ static inline void nci_push_data_hdr(struct nci_dev *ndev,int nci_conn_max_data_pkt_payload_size (struct nci_dev *ndev,__u8 conn_id) { -struct nci_conn_info *conn_info; +const struct nci_conn_info *conn_info; conn_info =nci_get_conn_info_by_conn_id (ndev, conn_id);if (!conn_info)
@@ -93,9 +93,9 @@ EXPORT_SYMBOL(nci_conn_max_data_pkt_payload_size);static int nci_queue_tx_data_frags (struct nci_dev *ndev,__u8 conn_id,struct sk_buff *skb) { -struct nci_conn_info *conn_info; +const struct nci_conn_info *conn_info;int total_len = skb->len; -unsigned char *data = skb->data; +const unsigned char *data = skb->data;unsigned long flags;struct sk_buff_head frags_q;struct sk_buff *skb_frag;
@@ -166,7 +166,7 @@ static int nci_queue_tx_data_frags(struct nci_dev *ndev,/* Send NCI data */ int nci_send_data (struct nci_dev *ndev,__u8 conn_id,struct sk_buff *skb) { -struct nci_conn_info *conn_info; +const struct nci_conn_info *conn_info;int rc =0 ;pr_debug ("conn_id 0x%x, plen %d\n" , conn_id, skb->len);
@@ -269,7 +269,7 @@ void nci_rx_data_packet(struct nci_dev *ndev, struct sk_buff *skb)__u8 pbf =nci_pbf (skb->data);__u8 status =0 ;__u8 conn_id =nci_conn_id (skb->data); -struct nci_conn_info *conn_info; +const struct nci_conn_info *conn_info;pr_debug ("len %d\n" , skb->len);
net/nfc/nci/hci.c +12 -12
@@ -142,7 +142,7 @@ static int nci_hci_send_data(struct nci_dev *ndev, u8 pipe, const u8 data_type, const u8 *data, size_t data_len) { - struct nci_conn_info *conn_info; + const struct nci_conn_info *conn_info;struct sk_buff *skb;int len, i, r;u8 cb = pipe;
@@ -197,7 +197,7 @@ static int nci_hci_send_data(struct nci_dev *ndev, u8 pipe,static void nci_hci_send_data_req (struct nci_dev *ndev,unsigned long opt) { -struct nci_data *data = (struct nci_data *)opt; +const struct nci_data *data = (struct nci_data *)opt;nci_hci_send_data (ndev, data->pipe, data->cmd, data->data, data->data_len);
@@ -221,8 +221,8 @@ int nci_hci_send_cmd(struct nci_dev *ndev, u8 gate, u8 cmd, const u8 *param, size_t param_len, struct sk_buff **skb) { - struct nci_hcp_message *message; -struct nci_conn_info *conn_info; + const struct nci_hcp_message *message; +const struct nci_conn_info *conn_info;struct nci_data data;int r;u8 pipe = ndev->hci_dev->gate2pipe[gate];
@@ -406,7 +406,7 @@ static void nci_hci_msg_rx_work(struct work_struct *work)struct nci_hci_dev *hdev = container_of(work, struct nci_hci_dev, msg_rx_work);struct sk_buff *skb; -struct nci_hcp_message *message; +const struct nci_hcp_message *message;u8 pipe, type, instruction;while ((skb =skb_dequeue (&hdev->msg_rx_queue)) !=NULL ) {
@@ -498,7 +498,7 @@ void nci_hci_data_received_cb(void *context,int nci_hci_open_pipe (struct nci_dev *ndev,u8 pipe) {struct nci_data data; -struct nci_conn_info *conn_info; +const struct nci_conn_info *conn_info; conn_info = ndev->hci_dev->conn_info;if (!conn_info)
@@ -523,7 +523,7 @@ static u8 nci_hci_create_pipe(struct nci_dev *ndev, u8 dest_host,u8 pipe;struct sk_buff *skb;struct nci_hci_create_pipe_params params; -struct nci_hci_create_pipe_resp *resp; +const struct nci_hci_create_pipe_resp *resp;pr_debug ("gate=%d\n" , dest_gate);
@@ -557,8 +557,8 @@ static int nci_hci_delete_pipe(struct nci_dev *ndev, u8 pipe)int nci_hci_set_param (struct nci_dev *ndev,u8 gate,u8 idx,const u8 *param,size_t param_len) { -struct nci_hcp_message *message; -struct nci_conn_info *conn_info; +const struct nci_hcp_message *message; +const struct nci_conn_info *conn_info;struct nci_data data;int r;u8 *tmp;
@@ -605,8 +605,8 @@ EXPORT_SYMBOL(nci_hci_set_param);int nci_hci_get_param (struct nci_dev *ndev,u8 gate,u8 idx,struct sk_buff **skb) { -struct nci_hcp_message *message; -struct nci_conn_info *conn_info; +const struct nci_hcp_message *message; +const struct nci_conn_info *conn_info;struct nci_data data;int r;u8 pipe = ndev->hci_dev->gate2pipe[gate];
@@ -697,7 +697,7 @@ EXPORT_SYMBOL(nci_hci_connect_gate);static int nci_hci_dev_connect_gates (struct nci_dev *ndev,u8 gate_count, -struct nci_hci_gate *gates) +const struct nci_hci_gate *gates) {int r;
net/nfc/nci/ntf.c +45 -38
202 lines not on this page · raw message
net/nfc/nci/rsp.c +25 -21
132 lines not on this page · raw message
net/nfc/nci/spi.c +1 -1
@@ -27,7 +27,7 @@#define CRC_INIT 0xFFFF -static int __nci_spi_send (struct nci_spi *nspi,struct sk_buff *skb, +static int __nci_spi_send (struct nci_spi *nspi,const struct sk_buff *skb,int cs_change) {struct spi_message m;
Signature · 1 line
2.27.0
PATCH v3 7/7 nfc: hci: cleanup unneeded spaces
In reply to Krzysztof KozlowskiNo need for multiple spaces in variable declaration (the code does not use them in other places). No functional change.
--- net/nfc/nci/core.c | 8 ++++---- net/nfc/nci/hci.c | 14 +++++++------- net/nfc/nci/ntf.c | 4 ++-- net/nfc/nci/rsp.c | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-)
net/nfc/nci/core.c +4 -4
@@ -409,7 +409,7 @@ static void nci_send_data_req(struct nci_dev *ndev, unsigned long opt)static void nci_nfcc_loopback_cb (void *context,struct sk_buff *skb,int err) {struct nci_dev *ndev = (struct nci_dev *)context; -struct nci_conn_info *conn_info; +struct nci_conn_info *conn_info; conn_info =nci_get_conn_info_by_conn_id (ndev, ndev->cur_conn_id);if (!conn_info) {
@@ -1006,7 +1006,7 @@ static int nci_transceive(struct nfc_dev *nfc_dev, struct nfc_target *target, {struct nci_dev *ndev =nfc_get_drvdata (nfc_dev);int rc; -struct nci_conn_info *conn_info; +struct nci_conn_info *conn_info; conn_info = ndev->rf_conn_info;if (!conn_info)
@@ -1271,7 +1271,7 @@ EXPORT_SYMBOL(nci_register_device);*/ void nci_unregister_device (struct nci_dev *ndev) { -struct nci_conn_info *conn_info, *n; +struct nci_conn_info *conn_info, *n;nci_close_device (ndev);
@@ -1443,7 +1443,7 @@ int nci_core_ntf_packet(struct nci_dev *ndev, __u16 opcode,static void nci_tx_work (struct work_struct *work) { struct nci_dev *ndev = container_of(work, struct nci_dev, tx_work); -struct nci_conn_info *conn_info; +struct nci_conn_info *conn_info;struct sk_buff *skb; conn_info =nci_get_conn_info_by_conn_id (ndev, ndev->cur_conn_id);
net/nfc/nci/hci.c +7 -7
@@ -16,11 +16,11 @@#include <linux/nfc.h> struct nci_data { -u8 conn_id; -u8 pipe; -u8 cmd; -const u8 *data; -u32 data_len; +u8 conn_id; +u8 pipe; +u8 cmd; +const u8 *data; +u32 data_len; } __packed;struct nci_hci_create_pipe_params {
@@ -363,7 +363,7 @@ static void nci_hci_cmd_received(struct nci_dev *ndev, u8 pipe,static void nci_hci_resp_received (struct nci_dev *ndev,u8 pipe,struct sk_buff *skb) { -struct nci_conn_info *conn_info; +struct nci_conn_info *conn_info; conn_info = ndev->hci_dev->conn_info;if (!conn_info)
@@ -714,7 +714,7 @@ static int nci_hci_dev_connect_gates(struct nci_dev *ndev,int nci_hci_dev_session_init (struct nci_dev *ndev) { -struct nci_conn_info *conn_info; +struct nci_conn_info *conn_info;struct sk_buff *skb;int r;
net/nfc/nci/ntf.c +2 -2
@@ -48,7 +48,7 @@ static void nci_core_conn_credits_ntf_packet(struct nci_dev *ndev, struct sk_buff *skb) {struct nci_core_conn_credit_ntf *ntf = (void *) skb->data; -struct nci_conn_info *conn_info; +struct nci_conn_info *conn_info;int i;pr_debug ("num_entries %d\n" , ntf->num_entries);
@@ -528,7 +528,7 @@ static int nci_store_general_bytes_nfc_dep(struct nci_dev *ndev,static void nci_rf_intf_activated_ntf_packet (struct nci_dev *ndev,const struct sk_buff *skb) { -struct nci_conn_info *conn_info; +struct nci_conn_info *conn_info;struct nci_rf_intf_activated_ntf ntf;const __u8 *data = skb->data;int err =NCI_STATUS_OK ;
net/nfc/nci/rsp.c +1 -1
@@ -185,7 +185,7 @@ static void nci_rf_disc_map_rsp_packet(struct nci_dev *ndev,static void nci_rf_disc_rsp_packet (struct nci_dev *ndev,const struct sk_buff *skb) { -struct nci_conn_info *conn_info; +struct nci_conn_info *conn_info;__u8 status = skb->data[0 ];pr_debug ("status 0x%x\n" , status);
Signature · 1 line
2.27.0
This series was applied to netdev/net-next.git (refs/heads/master):
Hello:
This series was applied to netdev/net-next.git (refs/heads/master):
Quoted 9 lines · On Fri, 30 Jul 2021 16:41:55 +0200 you wrote:
Hi,
This was previously sent [1] but got lost. It was a prerequisite to part two of NFC const [2].
Changes since v2:
1. Drop patch previously 7/8 which cases new warnings "warning: Using plain integer as NULL pointer".[...]
Here is the summary with links:
- [v3,1/7] nfc: mrvl: correct nfcmrvl_spi_parse_dt() device_node argument
https://git.kernel.org/netdev/net-next/c/3833b87408e5 - [v3,2/7] nfc: annotate af_nfc_exit() as __exit https://git.kernel.org/netdev/net-next/c/bf6cd7720b08 - [v3,3/7] nfc: hci: annotate nfc_llc_init() as __init https://git.kernel.org/netdev/net-next/c/4932c37878c9 - [v3,4/7] nfc: constify several pointers to u8, char and sk_buff https://git.kernel.org/netdev/net-next/c/3df40eb3a2ea - [v3,5/7] nfc: constify local pointer variables https://git.kernel.org/netdev/net-next/c/f2479c0a2294 - [v3,6/7] nfc: nci: constify several pointers to u8, sk_buff and other structs https://git.kernel.org/netdev/net-next/c/ddecf5556f7f - [v3,7/7] nfc: hci: cleanup unneeded spaces https://git.kernel.org/netdev/net-next/c/77411df5f293
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html