media: rkisp1: make a few const arrays static
Subsystems (4)
PATCH 1/1 media: rkisp1: make a few const arrays static
Don't populate the const arrays on the stack, instead make them static. Also makes the object code smaller.
--- .../platform/rockchip/rkisp1/rkisp1-capture.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c +9 -6
@@ -1131,10 +1131,12 @@ static void rkisp1_try_fmt(const struct rkisp1_capture *cap,const struct rkisp1_capture_config *config = cap->config;const struct rkisp1_capture_fmt_cfg *fmt;const struct v4l2_format_info *info; -const unsigned int max_widths[] = {RKISP1_RSZ_MP_SRC_MAX_WIDTH , -RKISP1_RSZ_SP_SRC_MAX_WIDTH }; -const unsigned int max_heights[] = {RKISP1_RSZ_MP_SRC_MAX_HEIGHT , -RKISP1_RSZ_SP_SRC_MAX_HEIGHT }; +static const unsigned int max_widths[] = { +RKISP1_RSZ_MP_SRC_MAX_WIDTH ,RKISP1_RSZ_SP_SRC_MAX_WIDTH + }; +static const unsigned int max_heights[] = { +RKISP1_RSZ_MP_SRC_MAX_HEIGHT ,RKISP1_RSZ_SP_SRC_MAX_HEIGHT + }; fmt =rkisp1_find_fmt_cfg (cap, pixm->pixelformat);if (!fmt) {
@@ -1336,8 +1338,9 @@ void rkisp1_capture_devs_unregister(struct rkisp1_device *rkisp1)static int rkisp1_register_capture (struct rkisp1_capture *cap) { -const char *const dev_names[] = {RKISP1_MP_DEV_NAME , -RKISP1_SP_DEV_NAME }; +static const char *const dev_names[] = { +RKISP1_MP_DEV_NAME ,RKISP1_SP_DEV_NAME + };struct v4l2_device *v4l2_dev = &cap->rkisp1->v4l2_dev;struct video_device *vdev = &cap->vnode.vdev;struct rkisp1_vdev_node *node;
Signature · 1 line
2.30.2
Hi Ian,
Am Donnerstag, 5. Januar 2023, 19:44:03 CET schrieb Colin Ian King:
Quoted 2 lines
Don't populate the const arrays on the stack, instead make them static. Also makes the object code smaller.
While I don't dislike this change itself, are you sure about the size change?
bloat-o-meter shows an overall increase:
Quoted 11 lines
./scripts/bloat-o-meter/tmp/rkisp1-capture_old.o/tmp/rkisp1-capture_new.o
add/remove: 3/0 grow/shrink: 1/2 up/down: 256/-116 (140)
Function old new deltarkisp1_try_fmt_vid_cap_mplane56 280 +224dev_names - 16 +16 max_widths - 8 +8 max_heights - 8 +8 rkisp1_try_fmt 356 304 -52 rkisp1_register_capture 548 484 -64Total: Before=12333, After=12473, chg +1.14%
To be honest I don't know why GCC now inlines rkisp1_try_fmt() in rkisp1_try_fmt_vid_cap_mplane.
Best regards,
Alexander
Quoted 13 lines
Signed-off-by Colin Ian King <[email protected]>--- .../platform/rockchip/rkisp1/rkisp1-capture.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)(quoted diff) +0
-0
b/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.cindexd4540684ea9a..d1d1fdce03e3100644drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c +0
-0@@ -1131,10 +1131,12 @@ static void rkisp1_try_fmt(const struct
rkisp1_capture*cap, const structrkisp1_capture_config*config =cap->config;
drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c static void rkisp1_try_fmt(const struct rkisp1_capture *cap,
Quoted 4 lines
drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c +0
-2const struct rkisp1_capture_fmt_cfg *fmt;const struct v4l2_format_info *info; -const unsigned int max_widths[] = {RKISP1_RSZ_MP_SRC_MAX_WIDTH , -
RKISP1_RSZ_SP_SRC_MAX_WIDTH };
drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c
Quoted 2 lines
drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c +0
-2-const unsigned int max_heights[] = {RKISP1_RSZ_MP_SRC_MAX_HEIGHT , -
RKISP1_RSZ_SP_SRC_MAX_HEIGHT};
Quoted 22 lines
drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c +9
-2+static const unsigned int max_widths[] = { +RKISP1_RSZ_MP_SRC_MAX_WIDTH ,RKISP1_RSZ_SP_SRC_MAX_WIDTH + }; +static const unsigned int max_heights[] = { +RKISP1_RSZ_MP_SRC_MAX_HEIGHT ,RKISP1_RSZ_SP_SRC_MAX_HEIGHT + }; fmt =rkisp1_find_fmt_cfg (cap, pixm->pixelformat);if (!fmt) {@@ -1336,8 +1338,9 @@ void rkisp1_capture_devs_unregister(struct rkisp1_device *rkisp1)static int rkisp1_register_capture (struct rkisp1_capture *cap) { -const char *const dev_names[] = {RKISP1_MP_DEV_NAME , -RKISP1_SP_DEV_NAME }; +static const char *const dev_names[] = { +RKISP1_MP_DEV_NAME ,RKISP1_SP_DEV_NAME + };struct v4l2_device *v4l2_dev = &cap->rkisp1->v4l2_dev;struct video_device *vdev = &cap->vnode.vdev;struct
rkisp1_vdev_node*node;