media: go7007: remove redundant initialization
authorPavel Skripkin <paskripkin@gmail.com>
Sun, 20 Jun 2021 19:45:42 +0000 (21:45 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Sep 2021 09:42:59 +0000 (11:42 +0200)
[ Upstream commit 6f5885a7750545973bf1a942d2f0f129aef0aa06 ]

In go7007_alloc() kzalloc() is used for struct go7007
allocation. It means that there is no need in zeroing
any members, because kzalloc will take care of it.

Removing these reduntant initialization steps increases
execution speed a lot:

Before:
+ 86.802 us   |    go7007_alloc();
After:
+ 29.595 us   |    go7007_alloc();

Fixes: 866b8695d67e8 ("Staging: add the go7007 video driver")
Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/media/usb/go7007/go7007-driver.c

index 05b1126f263ef234015261b010439f9fc6e75bc8..d861d7225f49d983fd79b2a3fd7de393dea6ad97 100644 (file)
@@ -698,49 +698,23 @@ struct go7007 *go7007_alloc(const struct go7007_board_info *board,
                                                struct device *dev)
 {
        struct go7007 *go;
-       int i;
 
        go = kzalloc(sizeof(struct go7007), GFP_KERNEL);
        if (go == NULL)
                return NULL;
        go->dev = dev;
        go->board_info = board;
-       go->board_id = 0;
        go->tuner_type = -1;
-       go->channel_number = 0;
-       go->name[0] = 0;
        mutex_init(&go->hw_lock);
        init_waitqueue_head(&go->frame_waitq);
        spin_lock_init(&go->spinlock);
        go->status = STATUS_INIT;
-       memset(&go->i2c_adapter, 0, sizeof(go->i2c_adapter));
-       go->i2c_adapter_online = 0;
-       go->interrupt_available = 0;
        init_waitqueue_head(&go->interrupt_waitq);
-       go->input = 0;
        go7007_update_board(go);
-       go->encoder_h_halve = 0;
-       go->encoder_v_halve = 0;
-       go->encoder_subsample = 0;
        go->format = V4L2_PIX_FMT_MJPEG;
        go->bitrate = 1500000;
        go->fps_scale = 1;
-       go->pali = 0;
        go->aspect_ratio = GO7007_RATIO_1_1;
-       go->gop_size = 0;
-       go->ipb = 0;
-       go->closed_gop = 0;
-       go->repeat_seqhead = 0;
-       go->seq_header_enable = 0;
-       go->gop_header_enable = 0;
-       go->dvd_mode = 0;
-       go->interlace_coding = 0;
-       for (i = 0; i < 4; ++i)
-               go->modet[i].enable = 0;
-       for (i = 0; i < 1624; ++i)
-               go->modet_map[i] = 0;
-       go->audio_deliver = NULL;
-       go->audio_enabled = 0;
 
        return go;
 }