]> err.no Git - linux-2.6/commitdiff
V4L/DVB (5091): Pvrusb2: Use kzalloc in place of kmalloc/memset pairs
authorMike Isely <isely@pobox.com>
Sat, 20 Jan 2007 03:37:11 +0000 (00:37 -0300)
committerMauro Carvalho Chehab <mchehab@infradead.org>
Wed, 21 Feb 2007 15:34:41 +0000 (13:34 -0200)
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
12 files changed:
drivers/media/video/pvrusb2/pvrusb2-audio.c
drivers/media/video/pvrusb2/pvrusb2-context.c
drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c
drivers/media/video/pvrusb2/pvrusb2-hdw.c
drivers/media/video/pvrusb2/pvrusb2-i2c-core.c
drivers/media/video/pvrusb2/pvrusb2-io.c
drivers/media/video/pvrusb2/pvrusb2-ioread.c
drivers/media/video/pvrusb2/pvrusb2-std.c
drivers/media/video/pvrusb2/pvrusb2-sysfs.c
drivers/media/video/pvrusb2/pvrusb2-tuner.c
drivers/media/video/pvrusb2/pvrusb2-video-v4l.c
drivers/media/video/pvrusb2/pvrusb2-wm8775.c

index 5d30c93661442c5203c8845096ca7677a91696f0..7e61d4a17846b2442297859e394e31012621b5b1 100644 (file)
@@ -152,9 +152,8 @@ int pvr2_i2c_msp3400_setup(struct pvr2_hdw *hdw,struct pvr2_i2c_client *cp)
        struct pvr2_msp3400_handler *ctxt;
        if (cp->handler) return 0;
 
-       ctxt = kmalloc(sizeof(*ctxt),GFP_KERNEL);
+       ctxt = kzalloc(sizeof(*ctxt),GFP_KERNEL);
        if (!ctxt) return 0;
-       memset(ctxt,0,sizeof(*ctxt));
 
        ctxt->i2c_handler.func_data = ctxt;
        ctxt->i2c_handler.func_table = &msp3400_funcs;
index cf129746205dbae6e1775cd8fb7d0350b9ea5bcd..6bbed88d7867af00ae9de1cafe2751ec35d56bee 100644 (file)
@@ -83,9 +83,8 @@ struct pvr2_context *pvr2_context_create(
        void (*setup_func)(struct pvr2_context *))
 {
        struct pvr2_context *mp = NULL;
-       mp = kmalloc(sizeof(*mp),GFP_KERNEL);
+       mp = kzalloc(sizeof(*mp),GFP_KERNEL);
        if (!mp) goto done;
-       memset(mp,0,sizeof(*mp));
        pvr2_trace(PVR2_TRACE_STRUCT,"Creating pvr_main id=%p",mp);
        mp->setup_func = setup_func;
        mutex_init(&mp->mutex);
index a3357bf2a1af4b5c20560a1ab64563df26bb1214..851099a85e5a481c00679cb76aea4892d50a900b 100644 (file)
@@ -231,9 +231,8 @@ int pvr2_i2c_cx2584x_v4l_setup(struct pvr2_hdw *hdw,
        if (cp->handler) return 0;
        if (!decoder_detect(cp)) return 0;
 
-       ctxt = kmalloc(sizeof(*ctxt),GFP_KERNEL);
+       ctxt = kzalloc(sizeof(*ctxt),GFP_KERNEL);
        if (!ctxt) return 0;
-       memset(ctxt,0,sizeof(*ctxt));
 
        ctxt->handler.func_data = ctxt;
        ctxt->handler.func_table = &hfuncs;
index 1c79ce1e16c42638962cfe765664de23ab450758..7f916853824515fbdd2f1286d90a3b9a4626abae 100644 (file)
@@ -1934,20 +1934,18 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf,
                return NULL;
        }
 
-       hdw = kmalloc(sizeof(*hdw),GFP_KERNEL);
+       hdw = kzalloc(sizeof(*hdw),GFP_KERNEL);
        pvr2_trace(PVR2_TRACE_INIT,"pvr2_hdw_create: hdw=%p, type \"%s\"",
                   hdw,pvr2_device_names[hdw_type]);
        if (!hdw) goto fail;
-       memset(hdw,0,sizeof(*hdw));
        hdw->tuner_signal_stale = !0;
        cx2341x_fill_defaults(&hdw->enc_ctl_state);
 
        hdw->control_cnt = CTRLDEF_COUNT;
        hdw->control_cnt += MPEGDEF_COUNT;
-       hdw->controls = kmalloc(sizeof(struct pvr2_ctrl) * hdw->control_cnt,
+       hdw->controls = kzalloc(sizeof(struct pvr2_ctrl) * hdw->control_cnt,
                                GFP_KERNEL);
        if (!hdw->controls) goto fail;
-       memset(hdw->controls,0,sizeof(struct pvr2_ctrl) * hdw->control_cnt);
        hdw->hdw_type = hdw_type;
        for (idx = 0; idx < hdw->control_cnt; idx++) {
                cptr = hdw->controls + idx;
@@ -1961,11 +1959,9 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf,
                cptr->info = control_defs+idx;
        }
        /* Define and configure additional controls from cx2341x module. */
-       hdw->mpeg_ctrl_info = kmalloc(
+       hdw->mpeg_ctrl_info = kzalloc(
                sizeof(*(hdw->mpeg_ctrl_info)) * MPEGDEF_COUNT, GFP_KERNEL);
        if (!hdw->mpeg_ctrl_info) goto fail;
-       memset(hdw->mpeg_ctrl_info,0,
-              sizeof(*(hdw->mpeg_ctrl_info)) * MPEGDEF_COUNT);
        for (idx = 0; idx < MPEGDEF_COUNT; idx++) {
                cptr = hdw->controls + idx + CTRLDEF_COUNT;
                ciptr = &(hdw->mpeg_ctrl_info[idx].info);
@@ -2608,14 +2604,12 @@ void pvr2_hdw_cpufw_set_enabled(struct pvr2_hdw *hdw, int enable_flag)
                pvr2_trace(PVR2_TRACE_FIRMWARE,
                           "Preparing to suck out CPU firmware");
                hdw->fw_size = 0x2000;
-               hdw->fw_buffer = kmalloc(hdw->fw_size,GFP_KERNEL);
+               hdw->fw_buffer = kzalloc(hdw->fw_size,GFP_KERNEL);
                if (!hdw->fw_buffer) {
                        hdw->fw_size = 0;
                        break;
                }
 
-               memset(hdw->fw_buffer,0,hdw->fw_size);
-
                /* We have to hold the CPU during firmware upload. */
                pvr2_hdw_cpureset_assert(hdw,1);
 
index a28299107be7a2aa0938b3cc0e19fcb9871fd873..223a571faff3658bcba3d44910f75580cc8ed2f8 100644 (file)
@@ -897,12 +897,11 @@ static int pvr2_i2c_attach_inform(struct i2c_client *client)
        struct pvr2_hdw *hdw = (struct pvr2_hdw *)(client->adapter->algo_data);
        struct pvr2_i2c_client *cp;
        int fl = !(hdw->i2c_pend_types & PVR2_I2C_PEND_ALL);
-       cp = kmalloc(sizeof(*cp),GFP_KERNEL);
+       cp = kzalloc(sizeof(*cp),GFP_KERNEL);
        trace_i2c("i2c_attach [client=%s @ 0x%x ctxt=%p]",
                  client->name,
                  client->addr,cp);
        if (!cp) return -ENOMEM;
-       memset(cp,0,sizeof(*cp));
        cp->hdw = hdw;
        INIT_LIST_HEAD(&cp->list);
        cp->client = client;
index 57fb32033543a1b4749cb429e8eb607b2f636f24..ce3c8982ffe088aa6378da27ef18a9af4e6e9545 100644 (file)
@@ -474,9 +474,8 @@ static void buffer_complete(struct urb *urb)
 struct pvr2_stream *pvr2_stream_create(void)
 {
        struct pvr2_stream *sp;
-       sp = kmalloc(sizeof(*sp),GFP_KERNEL);
+       sp = kzalloc(sizeof(*sp),GFP_KERNEL);
        if (!sp) return sp;
-       memset(sp,0,sizeof(*sp));
        pvr2_trace(PVR2_TRACE_INIT,"pvr2_stream_create: sp=%p",sp);
        pvr2_stream_init(sp);
        return sp;
index b71f9a961f8ac20461df5043b5487741607128c0..f782418afa45db71c6a07e27382db0e5a5637b3e 100644 (file)
@@ -87,10 +87,9 @@ static void pvr2_ioread_done(struct pvr2_ioread *cp)
 struct pvr2_ioread *pvr2_ioread_create(void)
 {
        struct pvr2_ioread *cp;
-       cp = kmalloc(sizeof(*cp),GFP_KERNEL);
+       cp = kzalloc(sizeof(*cp),GFP_KERNEL);
        if (!cp) return NULL;
        pvr2_trace(PVR2_TRACE_STRUCT,"pvr2_ioread_create id=%p",cp);
-       memset(cp,0,sizeof(*cp));
        if (pvr2_ioread_init(cp) < 0) {
                kfree(cp);
                return NULL;
index 30cceef0b1698f51cceadb0bdd0f86575b4ecfa6..81de26ba41d9af1527f87f6a68d7bf9cda025a7b 100644 (file)
@@ -359,9 +359,8 @@ struct v4l2_standard *pvr2_std_create_enum(unsigned int *countptr,
                   std_cnt);
        if (!std_cnt) return NULL; // paranoia
 
-       stddefs = kmalloc(sizeof(struct v4l2_standard) * std_cnt,
+       stddefs = kzalloc(sizeof(struct v4l2_standard) * std_cnt,
                          GFP_KERNEL);
-       memset(stddefs,0,sizeof(struct v4l2_standard) * std_cnt);
        for (idx = 0; idx < std_cnt; idx++) stddefs[idx].index = idx;
 
        idx = 0;
index 2f6568e7e6f271ae2e47b5e0f9351c71c62ed9d4..91396fd573e4a2c2a04f2b518d8a2811a8c60248 100644 (file)
@@ -501,9 +501,8 @@ static void pvr2_sysfs_add_control(struct pvr2_sysfs *sfp,int ctl_id)
        cptr = pvr2_hdw_get_ctrl_by_index(sfp->channel.hdw,ctl_id);
        if (!cptr) return;
 
-       cip = kmalloc(sizeof(*cip),GFP_KERNEL);
+       cip = kzalloc(sizeof(*cip),GFP_KERNEL);
        if (!cip) return;
-       memset(cip,0,sizeof(*cip));
        pvr2_sysfs_trace("Creating pvr2_sysfs_ctl_item id=%p",cip);
 
        cip->cptr = cptr;
@@ -613,9 +612,8 @@ static void pvr2_sysfs_add_debugifc(struct pvr2_sysfs *sfp)
        struct pvr2_sysfs_debugifc *dip;
        int ret;
 
-       dip = kmalloc(sizeof(*dip),GFP_KERNEL);
+       dip = kzalloc(sizeof(*dip),GFP_KERNEL);
        if (!dip) return;
-       memset(dip,0,sizeof(*dip));
        dip->attr_debugcmd.attr.owner = THIS_MODULE;
        dip->attr_debugcmd.attr.name = "debugcmd";
        dip->attr_debugcmd.attr.mode = S_IRUGO|S_IWUSR|S_IWGRP;
@@ -768,9 +766,8 @@ static void class_dev_create(struct pvr2_sysfs *sfp,
 
        usb_dev = pvr2_hdw_get_dev(sfp->channel.hdw);
        if (!usb_dev) return;
-       class_dev = kmalloc(sizeof(*class_dev),GFP_KERNEL);
+       class_dev = kzalloc(sizeof(*class_dev),GFP_KERNEL);
        if (!class_dev) return;
-       memset(class_dev,0,sizeof(*class_dev));
 
        pvr2_sysfs_trace("Creating class_dev id=%p",class_dev);
 
@@ -862,9 +859,8 @@ struct pvr2_sysfs *pvr2_sysfs_create(struct pvr2_context *mp,
                                     struct pvr2_sysfs_class *class_ptr)
 {
        struct pvr2_sysfs *sfp;
-       sfp = kmalloc(sizeof(*sfp),GFP_KERNEL);
+       sfp = kzalloc(sizeof(*sfp),GFP_KERNEL);
        if (!sfp) return sfp;
-       memset(sfp,0,sizeof(*sfp));
        pvr2_trace(PVR2_TRACE_STRUCT,"Creating pvr2_sysfs id=%p",sfp);
        pvr2_channel_init(&sfp->channel,mp);
        sfp->channel.check_func = pvr2_sysfs_internal_check;
@@ -885,9 +881,8 @@ static int pvr2_sysfs_hotplug(struct class_device *cd,char **envp,
 struct pvr2_sysfs_class *pvr2_sysfs_class_create(void)
 {
        struct pvr2_sysfs_class *clp;
-       clp = kmalloc(sizeof(*clp),GFP_KERNEL);
+       clp = kzalloc(sizeof(*clp),GFP_KERNEL);
        if (!clp) return clp;
-       memset(clp,0,sizeof(*clp));
        pvr2_sysfs_trace("Creating pvr2_sysfs_class id=%p",clp);
        clp->class.name = "pvrusb2";
        clp->class.class_release = pvr2_sysfs_class_release;
index bb17db3f6434a6e50f1bfea5bffe2095145bf26d..05e65ce2e3a96109684695c841b2cb06675cbc58 100644 (file)
@@ -93,9 +93,8 @@ int pvr2_i2c_tuner_setup(struct pvr2_hdw *hdw,struct pvr2_i2c_client *cp)
        struct pvr2_tuner_handler *ctxt;
        if (cp->handler) return 0;
 
-       ctxt = kmalloc(sizeof(*ctxt),GFP_KERNEL);
+       ctxt = kzalloc(sizeof(*ctxt),GFP_KERNEL);
        if (!ctxt) return 0;
-       memset(ctxt,0,sizeof(*ctxt));
 
        ctxt->i2c_handler.func_data = ctxt;
        ctxt->i2c_handler.func_table = &tuner_funcs;
index 7f42042c201635f7b818d3aba1ba718867e50e29..61efa6f02200e74dee598bf1d1ee765aed3faea9 100644 (file)
@@ -206,9 +206,8 @@ int pvr2_i2c_decoder_v4l_setup(struct pvr2_hdw *hdw,
        if (cp->handler) return 0;
        if (!decoder_detect(cp)) return 0;
 
-       ctxt = kmalloc(sizeof(*ctxt),GFP_KERNEL);
+       ctxt = kzalloc(sizeof(*ctxt),GFP_KERNEL);
        if (!ctxt) return 0;
-       memset(ctxt,0,sizeof(*ctxt));
 
        ctxt->handler.func_data = ctxt;
        ctxt->handler.func_table = &hfuncs;
index 234adf7aa614e62ad5fc2e0f675bd48baeba32b9..66b4d36ef76585f23af0c7e44cc7334e15490c17 100644 (file)
@@ -144,9 +144,8 @@ int pvr2_i2c_wm8775_setup(struct pvr2_hdw *hdw,struct pvr2_i2c_client *cp)
 
        if (cp->handler) return 0;
 
-       ctxt = kmalloc(sizeof(*ctxt),GFP_KERNEL);
+       ctxt = kzalloc(sizeof(*ctxt),GFP_KERNEL);
        if (!ctxt) return 0;
-       memset(ctxt,0,sizeof(*ctxt));
 
        ctxt->handler.func_data = ctxt;
        ctxt->handler.func_table = &hfuncs;