#include <media/v4l2-event.h>
 #include <media/v4l2-ctrls.h>
 #include <linux/module.h>
+#include <linux/kernel.h>
 
 static int max_memory = 32;
 
    due to this, it's impossible to provide additional *packed* formats, which are simply byte swapped
    (like V4L2_PIX_FMT_YUYV) ... 8-( */
 
-static int NUM_FORMATS = sizeof(formats)/sizeof(struct saa7146_format);
-
 struct saa7146_format* saa7146_format_by_fourcc(struct saa7146_dev *dev, int fourcc)
 {
-       int i, j = NUM_FORMATS;
+       int i;
 
-       for (i = 0; i < j; i++) {
+       for (i = 0; i < ARRAY_SIZE(formats); i++) {
                if (formats[i].pixelformat == fourcc) {
                        return formats+i;
                }
 
 static int vidioc_enum_fmt_vid_cap(struct file *file, void *fh, struct v4l2_fmtdesc *f)
 {
-       if (f->index >= NUM_FORMATS)
+       if (f->index >= ARRAY_SIZE(formats))
                return -EINVAL;
        strlcpy((char *)f->description, formats[f->index].name,
                        sizeof(f->description));
 
 #include <linux/math64.h>
 #include <linux/log2.h>
 #include <linux/dynamic_debug.h>
+#include <linux/kernel.h>
 
 #include "dvb_math.h"
 #include "dvb_frontend.h"
                min_index = 0;
                if (delsys == SYS_DVBS) {
                        cn_data = s_cn_data;
-                       max_index = sizeof(s_cn_data) /
-                               sizeof(s_cn_data[0]) - 1;
+                       max_index = ARRAY_SIZE(s_cn_data) - 1;
                } else {
                        cn_data = s2_cn_data;
-                       max_index = sizeof(s2_cn_data) /
-                               sizeof(s2_cn_data[0]) - 1;
+                       max_index = ARRAY_SIZE(s2_cn_data) - 1;
                }
                if (value >= cn_data[min_index].value) {
                        res = cn_data[min_index].cnr_x1000;
 
 
 #include <media/drv-intf/saa7146_vv.h>
 #include <linux/module.h>
+#include <linux/kernel.h>
 
 static int debug;
 module_param(debug, int, 0);
        .inputs = HEXIUM_INPUTS,
        .capabilities = 0,
        .stds = &hexium_standards[0],
-       .num_stds = sizeof(hexium_standards) / sizeof(struct saa7146_standard),
+       .num_stds = ARRAY_SIZE(hexium_standards),
        .std_callback = &std_callback,
 };
 
 
 
 #include <media/drv-intf/saa7146_vv.h>
 #include <linux/module.h>
+#include <linux/kernel.h>
 
 static int debug;
 module_param(debug, int, 0);
        .inputs = HEXIUM_INPUTS,
        .capabilities = 0,
        .stds = &hexium_standards[0],
-       .num_stds = sizeof(hexium_standards) / sizeof(struct saa7146_standard),
+       .num_stds = ARRAY_SIZE(hexium_standards),
        .std_callback = &std_callback,
 };
 
 
 #include <media/v4l2-common.h>
 #include <media/i2c/saa7115.h>
 #include <linux/module.h>
+#include <linux/kernel.h>
 
 #include "tea6415c.h"
 #include "tea6420.h"
        .inputs         = MXB_INPUTS,
        .capabilities   = V4L2_CAP_TUNER | V4L2_CAP_VBI_CAPTURE | V4L2_CAP_AUDIO,
        .stds           = &standard[0],
-       .num_stds       = sizeof(standard)/sizeof(struct saa7146_standard),
+       .num_stds       = ARRAY_SIZE(standard),
        .std_callback   = &std_callback,
 };
 
 
 #include <media/tuner.h>
 #include <linux/vmalloc.h>
 #include <linux/slab.h>
+#include <linux/kernel.h>
 
 #include "cxusb.h"
 
                        0x0e, 0x2, 0x47, 0x88,
                };
                msleep(20);
-               for (i = 0; i < sizeof(bufs)/sizeof(u8); i += 4/sizeof(u8)) {
+               for (i = 0; i < ARRAY_SIZE(bufs); i += 4 / sizeof(u8)) {
                        ret = cxusb_ctrl_msg(d, CMD_I2C_WRITE,
                                             bufs+i, 4, &buf, 1);
                        if (ret)
 
 #include <linux/init.h>
 #include <linux/string.h>
 #include <linux/slab.h>
+#include <linux/kernel.h>
 
 #include "friio.h"
 
        {0x76, 0x0C},
 };
 
-static const int init_code_len = sizeof(init_code) / sizeof(u8[2]);
-
 static int jdvbt90502_init(struct dvb_frontend *fe)
 {
        int i = -1;
        msg.addr = state->config.demod_address;
        msg.flags = 0;
        msg.len = 2;
-       for (i = 0; i < init_code_len; i++) {
+       for (i = 0; i < ARRAY_SIZE(init_code); i++) {
                msg.buf = init_code[i];
                ret = i2c_transfer(state->i2c, &msg, 1);
                if (ret != 1)