Skip to content

Commit 662fb4f

Browse files
committed
media: atomisp: get rid of a string_support.h abstraction layer
Some parts of the driver have their own implementation of memcpy() & friends. Replace all of them by strscpy(). Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent 48b532b commit 662fb4f

File tree

8 files changed

+38
-215
lines changed

8 files changed

+38
-215
lines changed

drivers/staging/media/atomisp/pci/hive_isp_css_include/string_support.h

Lines changed: 0 additions & 165 deletions
This file was deleted.

drivers/staging/media/atomisp/pci/isp/kernels/ctc/ctc_1.0/ia_css_ctc_table.host.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
* more details.
1414
*/
1515

16+
#include <linux/string.h> /* for memcpy() */
17+
1618
#include <type_support.h>
17-
#include <string_support.h> /* memcpy */
1819
#include "system_global.h"
1920
#include "vamem.h"
2021
#include "ia_css_types.h"

drivers/staging/media/atomisp/pci/isp/kernels/gc/gc_1.0/ia_css_gc_table.host.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
* more details.
1414
*/
1515

16+
#include <linux/string.h> /* for memcpy() */
17+
1618
#include <type_support.h>
17-
#include <string_support.h> /* memcpy */
1819
#include "system_global.h"
1920
#include "vamem.h"
2021
#include "ia_css_types.h"

drivers/staging/media/atomisp/pci/isp/kernels/gc/gc_2/ia_css_gc2_table.host.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
* more details.
1414
*/
1515

16+
#include <linux/string.h> /* for memcpy() */
17+
1618
#include <type_support.h>
17-
#include <string_support.h> /* memcpy */
1819
#include "system_global.h"
1920
#include "vamem.h"
2021
#include "ia_css_types.h"

drivers/staging/media/atomisp/pci/isp/kernels/xnr/xnr_1.0/ia_css_xnr_table.host.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
* more details.
1414
*/
1515

16+
#include <linux/string.h> /* for memcpy() */
17+
1618
#include <type_support.h>
17-
#include <string_support.h> /* memcpy */
1819
#include "system_global.h"
1920
#include "vamem.h"
2021
#include "ia_css_types.h"

drivers/staging/media/atomisp/pci/runtime/debug/src/ia_css_debug.c

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
#define __INLINE_STREAM2MMIO__
3232
#endif
3333

34+
#include <linux/string.h> /* for strscpy() */
35+
3436
#include "ia_css_debug.h"
3537
#include "ia_css_debug_pipe.h"
3638
#include "ia_css_irq.h"
@@ -47,7 +49,6 @@
4749
#include "system_local.h"
4850
#include "assert_support.h"
4951
#include "print_support.h"
50-
#include "string_support.h"
5152

5253
#include "fifo_monitor.h"
5354

@@ -2769,8 +2770,9 @@ ia_css_debug_pipe_graph_dump_stage(
27692770
stage->binary->info->blob->name, stage->stage_num);
27702771
} else if (stage->firmware) {
27712772
bin_type = "firmware";
2772-
strncpy_s(blob_name, sizeof(blob_name),
2773-
IA_CSS_EXT_ISP_PROG_NAME(stage->firmware), sizeof(blob_name));
2773+
2774+
strscpy(blob_name, IA_CSS_EXT_ISP_PROG_NAME(stage->firmware),
2775+
sizeof(blob_name));
27742776
}
27752777

27762778
/* Guard in case of binaries that don't have any binary_info */
@@ -2836,10 +2838,8 @@ ia_css_debug_pipe_graph_dump_stage(
28362838
while (ei[p] != ',')
28372839
p--;
28382840
/* Last comma found, copy till that comma */
2839-
strncpy_s(enable_info1,
2840-
sizeof(enable_info1),
2841-
ei, p);
2842-
enable_info1[p] = '\0';
2841+
strscpy(enable_info1, ei,
2842+
p > sizeof(enable_info1) ? sizeof(enable_info1) : p);
28432843

28442844
ei += p + 1;
28452845
l = strlen(ei);
@@ -2849,10 +2849,10 @@ ia_css_debug_pipe_graph_dump_stage(
28492849
/* we cannot use ei as argument because
28502850
* it is not guaranteed dword aligned
28512851
*/
2852-
strncpy_s(enable_info2,
2853-
sizeof(enable_info2),
2854-
ei, l);
2855-
enable_info2[l] = '\0';
2852+
2853+
strscpy(enable_info2, ei,
2854+
l > sizeof(enable_info2) ? sizeof(enable_info2) : l);
2855+
28562856
snprintf(enable_info, sizeof(enable_info), "%s\\n%s",
28572857
enable_info1, enable_info2);
28582858

@@ -2861,10 +2861,10 @@ ia_css_debug_pipe_graph_dump_stage(
28612861
p = ENABLE_LINE_MAX_LENGTH;
28622862
while (ei[p] != ',')
28632863
p--;
2864-
strncpy_s(enable_info2,
2865-
sizeof(enable_info2),
2866-
ei, p);
2867-
enable_info2[p] = '\0';
2864+
2865+
strscpy(enable_info2, ei,
2866+
p > sizeof(enable_info2) ? sizeof(enable_info2) : p);
2867+
28682868
ei += p + 1;
28692869
l = strlen(ei);
28702870

@@ -2873,9 +2873,8 @@ ia_css_debug_pipe_graph_dump_stage(
28732873
/* we cannot use ei as argument because
28742874
* it is not guaranteed dword aligned
28752875
*/
2876-
strcpy_s(enable_info3,
2877-
sizeof(enable_info3), ei);
2878-
enable_info3[l] = '\0';
2876+
strscpy(enable_info3, ei,
2877+
sizeof(enable_info3));
28792878
snprintf(enable_info, sizeof(enable_info),
28802879
"%s\\n%s\\n%s",
28812880
enable_info1, enable_info2,
@@ -2885,13 +2884,11 @@ ia_css_debug_pipe_graph_dump_stage(
28852884
p = ENABLE_LINE_MAX_LENGTH;
28862885
while (ei[p] != ',')
28872886
p--;
2888-
strncpy_s(enable_info3,
2889-
sizeof(enable_info3),
2890-
ei, p);
2891-
enable_info3[p] = '\0';
2887+
strscpy(enable_info3, ei,
2888+
p > sizeof(enable_info3) ? sizeof(enable_info3) : p);
28922889
ei += p + 1;
2893-
strcpy_s(enable_info3,
2894-
sizeof(enable_info3), ei);
2890+
strscpy(enable_info3, ei,
2891+
sizeof(enable_info3));
28952892
snprintf(enable_info, sizeof(enable_info),
28962893
"%s\\n%s\\n%s",
28972894
enable_info1, enable_info2,

drivers/staging/media/atomisp/pci/runtime/isys/src/virtual_isys.c

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@
1313
* more details.
1414
*/
1515

16+
#include <linux/string.h> /* for memcpy() */
17+
1618
#include "system_global.h"
1719

1820
#ifdef USE_INPUT_SYSTEM_VERSION_2401
1921

2022
#include "ia_css_isys.h"
2123
#include "ia_css_debug.h"
2224
#include "math_support.h"
23-
#include "string_support.h"
2425
#include "virtual_isys.h"
2526
#include "isp.h"
2627
#include "sh_css_defs.h"
@@ -650,14 +651,8 @@ static bool calculate_tpg_cfg(
650651
input_system_cfg_t *isys_cfg,
651652
pixelgen_tpg_cfg_t *cfg)
652653
{
653-
(void)channel;
654-
(void)input_port;
654+
memcpy(cfg, &isys_cfg->tpg_port_attr, sizeof(pixelgen_tpg_cfg_t));
655655

656-
memcpy_s(
657-
(void *)cfg,
658-
sizeof(pixelgen_tpg_cfg_t),
659-
(void *)(&isys_cfg->tpg_port_attr),
660-
sizeof(pixelgen_tpg_cfg_t));
661656
return true;
662657
}
663658

@@ -667,14 +662,8 @@ static bool calculate_prbs_cfg(
667662
input_system_cfg_t *isys_cfg,
668663
pixelgen_prbs_cfg_t *cfg)
669664
{
670-
(void)channel;
671-
(void)input_port;
665+
memcpy(cfg, &isys_cfg->prbs_port_attr, sizeof(pixelgen_prbs_cfg_t));
672666

673-
memcpy_s(
674-
(void *)cfg,
675-
sizeof(pixelgen_prbs_cfg_t),
676-
(void *)(&isys_cfg->prbs_port_attr),
677-
sizeof(pixelgen_prbs_cfg_t));
678667
return true;
679668
}
680669

@@ -692,12 +681,10 @@ static bool calculate_be_cfg(
692681
bool metadata,
693682
csi_rx_backend_cfg_t *cfg)
694683
{
695-
memcpy_s(
696-
(void *)(&cfg->lut_entry),
697-
sizeof(csi_rx_backend_lut_entry_t),
698-
metadata ? (void *)(&input_port->metadata.backend_lut_entry) :
699-
(void *)(&input_port->csi_rx.backend_lut_entry),
700-
sizeof(csi_rx_backend_lut_entry_t));
684+
memcpy(&cfg->lut_entry,
685+
metadata ? &input_port->metadata.backend_lut_entry :
686+
&input_port->csi_rx.backend_lut_entry,
687+
sizeof(csi_rx_backend_lut_entry_t));
701688

702689
cfg->csi_mipi_cfg.virtual_channel = isys_cfg->csi_port_attr.ch_id;
703690
if (metadata) {

drivers/staging/media/atomisp/pci/sh_css_firmware.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* more details.
1414
*/
1515

16+
#include <linux/string.h> /* for memcpy() */
1617
#include <linux/slab.h>
1718
#include <linux/vmalloc.h>
1819

@@ -28,7 +29,6 @@
2829
#include "ia_css_isp_param.h"
2930

3031
#include "assert_support.h"
31-
#include "string_support.h"
3232

3333
#include "isp.h" /* PMEM_WIDTH_LOG2 */
3434

0 commit comments

Comments
 (0)