diff options
author | Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 2012-11-22 18:50:34 (GMT) |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2013-01-10 10:25:12 (GMT) |
commit | 8d640ad394d71a2467d0e08a3337fdad828786bb (patch) | |
tree | 3e2793f82b6a856b5337c5a7adb1aef2ddbf3dde | |
parent | d3eeee6846c9a38b867616905df2327017ed3cd8 (diff) | |
download | linux-fsl-qoriq-8d640ad394d71a2467d0e08a3337fdad828786bb.tar.xz |
usb: gadget: ncm: make global variable ndp*_opts read only
There is ndp16_opts and ndp32_opts which are both global and only one
member is ever written. This patch makes the variable read-only and
moves the one member that is ever written into the private struct f_ncm.
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
-rw-r--r-- | drivers/usb/gadget/f_ncm.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/drivers/usb/gadget/f_ncm.c b/drivers/usb/gadget/f_ncm.c index 6c8362f..5e7557e 100644 --- a/drivers/usb/gadget/f_ncm.c +++ b/drivers/usb/gadget/f_ncm.c @@ -56,8 +56,9 @@ struct f_ncm { u8 notify_state; bool is_open; - struct ndp_parser_opts *parser_opts; + const struct ndp_parser_opts *parser_opts; bool is_crc; + u32 ndp_sign; /* * for notification, it is accessed from both @@ -390,8 +391,8 @@ struct ndp_parser_opts { .next_fp_index = 2, \ } -static struct ndp_parser_opts ndp16_opts = INIT_NDP16_OPTS; -static struct ndp_parser_opts ndp32_opts = INIT_NDP32_OPTS; +static const struct ndp_parser_opts ndp16_opts = INIT_NDP16_OPTS; +static const struct ndp_parser_opts ndp32_opts = INIT_NDP32_OPTS; static inline void put_ncm(__le16 **p, unsigned size, unsigned val) { @@ -732,8 +733,7 @@ static int ncm_setup(struct usb_function *f, const struct usb_ctrlrequest *ctrl) default: goto invalid; } - ncm->parser_opts->ndp_sign &= ~NCM_NDP_HDR_CRC_MASK; - ncm->parser_opts->ndp_sign |= ndp_hdr_crc; + ncm->ndp_sign = ncm->parser_opts->ndp_sign | ndp_hdr_crc; value = 0; break; } @@ -875,7 +875,7 @@ static struct sk_buff *ncm_wrap_ntb(struct gether *port, int ndp_align; int ndp_pad; unsigned max_size = ncm->port.fixed_in_len; - struct ndp_parser_opts *opts = ncm->parser_opts; + const struct ndp_parser_opts *opts = ncm->parser_opts; unsigned crc_len = ncm->is_crc ? sizeof(uint32_t) : 0; div = le16_to_cpu(ntb_parameters.wNdpInDivisor); @@ -921,7 +921,7 @@ static struct sk_buff *ncm_wrap_ntb(struct gether *port, tmp = (void *)tmp + ndp_pad; /* NDP */ - put_unaligned_le32(opts->ndp_sign, tmp); /* dwSignature */ + put_unaligned_le32(ncm->ndp_sign, tmp); /* dwSignature */ tmp += 2; /* wLength */ put_unaligned_le16(ncb_len - opts->nth_size - pad, tmp++); @@ -965,7 +965,7 @@ static int ncm_unwrap_ntb(struct gether *port, struct sk_buff *skb2; int ret = -EINVAL; unsigned max_size = le32_to_cpu(ntb_parameters.dwNtbOutMaxSize); - struct ndp_parser_opts *opts = ncm->parser_opts; + const struct ndp_parser_opts *opts = ncm->parser_opts; unsigned crc_len = ncm->is_crc ? sizeof(uint32_t) : 0; int dgram_counter; @@ -1002,7 +1002,7 @@ static int ncm_unwrap_ntb(struct gether *port, /* walk through NDP */ tmp = ((void *)skb->data) + index; - if (get_unaligned_le32(tmp) != opts->ndp_sign) { + if (get_unaligned_le32(tmp) != ncm->ndp_sign) { INFO(port->func.config->cdev, "Wrong NDP SIGN\n"); goto err; } |