if ((master->flags & h->codec->flags) == master->flags) {
dprintk(4, "videocodec_attach: try '%s'\n",
h->codec->name);
+
+ if (!try_module_get(h->codec->owner))
+ return NULL;
+
codec =
kmalloc(sizeof(struct videocodec), GFP_KERNEL);
if (!codec) {
dprintk(1,
KERN_ERR
"videocodec_attach: no mem\n");
- return NULL;
+ goto out_module_put;
}
memcpy(codec, h->codec, sizeof(struct videocodec));
dprintk(1,
KERN_ERR
"videocodec_attach: no memory\n");
- kfree(codec);
- return NULL;
+ goto out_kfree;
}
memset(ptr, 0,
sizeof(struct attached_list));
ptr->codec = codec;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
- MOD_INC_USE_COUNT;
-#else
- if (!try_module_get(THIS_MODULE)) {
- dprintk(1,
- KERN_ERR
- "videocodec: failed to increment usecount\n");
- kfree(codec);
- kfree(ptr);
- return NULL;
- }
-#endif
-
a = h->list;
if (!a) {
h->list = ptr;
dprintk(1, KERN_ERR "videocodec_attach: no codec found!\n");
return NULL;
+
+ out_module_put:
+ module_put(h->codec->owner);
+ out_kfree:
+ kfree(codec);
+ return NULL;
}
int
dprintk(4,
"videocodec: delete middle\n");
}
+ module_put(a->codec->owner);
kfree(a->codec);
kfree(a);
h->attached -= 1;
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
- MOD_DEC_USE_COUNT;
-#else
- module_put(THIS_MODULE);
-#endif
-
return 0;
}
prev = a;
memset(ptr, 0, sizeof(struct codec_list));
ptr->codec = codec;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
- MOD_INC_USE_COUNT;
-#else
- if (!try_module_get(THIS_MODULE)) {
- dprintk(1,
- KERN_ERR
- "videocodec: failed to increment module count\n");
- kfree(ptr);
- return -ENODEV;
- }
-#endif
-
if (!h) {
codeclist_top = ptr;
dprintk(4, "videocodec: hooked in as first element\n");
"videocodec: delete middle element\n");
}
kfree(h);
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
- MOD_DEC_USE_COUNT;
-#else
- module_put(THIS_MODULE);
-#endif
-
return 0;
}
prev = h;
};
struct videocodec {
+ struct module *owner;
/* -- filled in by slave device during register -- */
char name[32];
unsigned long magic; /* may be used for client<->master attaching */
codec->data = NULL;
zr36016_codecs--;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
- MOD_DEC_USE_COUNT;
-#else
- module_put(THIS_MODULE);
-#endif
-
return 0;
}
ptr->num = zr36016_codecs++;
ptr->codec = codec;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
- MOD_INC_USE_COUNT;
-#else
- if (!try_module_get(THIS_MODULE)) {
- dprintk(1,
- KERN_ERR
- "zr36016: failed to increase module use count\n");
- kfree(ptr);
- zr36016_codecs--;
- return -ENODEV;
- }
-#endif
-
//testing
res = zr36016_basic_test(ptr);
if (res < 0) {
}
static const struct videocodec zr36016_codec = {
+ .owner = THIS_MODULE,
.name = "zr36016",
.magic = 0L, // magic not used
.flags =
codec->data = NULL;
zr36050_codecs--;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
- MOD_DEC_USE_COUNT;
-#else
- module_put(THIS_MODULE);
-#endif
-
return 0;
}
ptr->num = zr36050_codecs++;
ptr->codec = codec;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
- MOD_INC_USE_COUNT;
-#else
- if (!try_module_get(THIS_MODULE)) {
- dprintk(1,
- KERN_ERR
- "zr36050: failed to increase module use count\n");
- kfree(ptr);
- zr36050_codecs--;
- return -ENODEV;
- }
-#endif
-
//testing
res = zr36050_basic_test(ptr);
if (res < 0) {
}
static const struct videocodec zr36050_codec = {
+ .owner = THIS_MODULE,
.name = "zr36050",
.magic = 0L, // magic not used
.flags =
codec->data = NULL;
zr36060_codecs--;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
- MOD_DEC_USE_COUNT;
-#else
- module_put(THIS_MODULE);
-#endif
-
return 0;
}
ptr->num = zr36060_codecs++;
ptr->codec = codec;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
- MOD_INC_USE_COUNT;
-#else
- if (!try_module_get(THIS_MODULE)) {
- dprintk(1,
- KERN_ERR
- "zr36060: failed to increase module use count\n");
- kfree(ptr);
- zr36060_codecs--;
- return -ENODEV;
- }
-#endif
-
//testing
res = zr36060_basic_test(ptr);
if (res < 0) {
}
static const struct videocodec zr36060_codec = {
+ .owner = THIS_MODULE,
.name = "zr36060",
.magic = 0L, // magic not used
.flags =