mirror of https://gitee.com/openkylin/linux.git
staging: vt6656: Use const for read only data
Use const for the arrays that are used as "read only". Also, modify the prototype of vnt_control_out_blocks() function to use a pointer to a const type. The vnt_vt3184_al2230 array can't be converted to const as it's modified later. Then in the vnt_vt3184_init() function use two types of pointers (to const type and to no const type) to avoid the compiler warning: assignment discards 'const' qualifiers from pointer target type This way decrease the .data section and increase the .rodata section limiting the surface attack. Before this change: ------------------- drivers/staging/vt6656/baseband.o : section size addr .text 1278 0 .data 576 0 .bss 0 0 .rodata 319 0 .comment 45 0 .note.GNU-stack 0 0 .note.gnu.property 32 0 Total 2250 After this change: ------------------ drivers/staging/vt6656/baseband.o : section size addr .text 1278 0 .data 256 0 .bss 0 0 .rodata 640 0 .comment 45 0 .note.GNU-stack 0 0 .note.gnu.property 32 0 Total 2251 Signed-off-by: Oscar Carter <oscar.carter@gmx.com> Link: https://lore.kernel.org/r/20200504171414.11307-1-oscar.carter@gmx.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
0729bb9b2a
commit
2e11cc1ab7
|
@ -31,7 +31,7 @@
|
|||
#include "rf.h"
|
||||
#include "usbpipe.h"
|
||||
|
||||
static u8 vnt_vt3184_agc[] = {
|
||||
static const u8 vnt_vt3184_agc[] = {
|
||||
0x00, 0x00, 0x02, 0x02, 0x04, 0x04, 0x06, 0x06,
|
||||
0x08, 0x08, 0x0a, 0x0a, 0x0c, 0x0c, 0x0e, 0x0e, /* 0x0f */
|
||||
0x10, 0x10, 0x12, 0x12, 0x14, 0x14, 0x16, 0x16,
|
||||
|
@ -78,7 +78,7 @@ static u8 vnt_vt3184_al2230[] = {
|
|||
};
|
||||
|
||||
/* {{RobertYu:20060515, new BB setting for VT3226D0 */
|
||||
static u8 vnt_vt3184_vt3226d0[] = {
|
||||
static const u8 vnt_vt3184_vt3226d0[] = {
|
||||
0x31, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
|
||||
0x70, 0x45, 0x2a, 0x76, 0x00, 0x00, 0x80, 0x00, /* 0x0f */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
@ -243,7 +243,8 @@ int vnt_vt3184_init(struct vnt_private *priv)
|
|||
{
|
||||
int ret;
|
||||
u16 length;
|
||||
u8 *addr;
|
||||
u8 *addr = NULL;
|
||||
const u8 *c_addr;
|
||||
u8 data;
|
||||
|
||||
ret = vnt_control_in(priv, MESSAGE_TYPE_READ, 0, MESSAGE_REQUEST_EEPROM,
|
||||
|
@ -275,7 +276,7 @@ int vnt_vt3184_init(struct vnt_private *priv)
|
|||
(priv->rf_type == RF_VT3342A0)) {
|
||||
priv->bb_rx_conf = vnt_vt3184_vt3226d0[10];
|
||||
length = sizeof(vnt_vt3184_vt3226d0);
|
||||
addr = vnt_vt3184_vt3226d0;
|
||||
c_addr = vnt_vt3184_vt3226d0;
|
||||
|
||||
priv->bb_vga[0] = 0x20;
|
||||
priv->bb_vga[1] = 0x10;
|
||||
|
@ -291,8 +292,11 @@ int vnt_vt3184_init(struct vnt_private *priv)
|
|||
goto end;
|
||||
}
|
||||
|
||||
if (addr)
|
||||
c_addr = addr;
|
||||
|
||||
ret = vnt_control_out_blocks(priv, VNT_REG_BLOCK_SIZE,
|
||||
MESSAGE_REQUEST_BBREG, length, addr);
|
||||
MESSAGE_REQUEST_BBREG, length, c_addr);
|
||||
if (ret)
|
||||
goto end;
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ int vnt_control_out_u8(struct vnt_private *priv, u8 reg, u8 reg_off, u8 data)
|
|||
}
|
||||
|
||||
int vnt_control_out_blocks(struct vnt_private *priv,
|
||||
u16 block, u8 reg, u16 length, u8 *data)
|
||||
u16 block, u8 reg, u16 length, const u8 *data)
|
||||
{
|
||||
int ret = 0, i;
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ int vnt_control_out_u8(struct vnt_private *priv, u8 reg, u8 ref_off, u8 data);
|
|||
int vnt_control_in_u8(struct vnt_private *priv, u8 reg, u8 reg_off, u8 *data);
|
||||
|
||||
int vnt_control_out_blocks(struct vnt_private *priv,
|
||||
u16 block, u8 reg, u16 len, u8 *data);
|
||||
u16 block, u8 reg, u16 len, const u8 *data);
|
||||
|
||||
int vnt_start_interrupt_urb(struct vnt_private *priv);
|
||||
int vnt_submit_rx_urb(struct vnt_private *priv, struct vnt_rcb *rcb);
|
||||
|
|
Loading…
Reference in New Issue