diff mbox series

[3/4] staging: media: zoran: replace all pr_err() with zrdev_err()

Message ID 20220423051821.293133-1-ian@linux.cowan.aero
State Superseded
Headers show
Series [1/4] staging: media: zoran: add zrdev_dbg() macros | expand

Commit Message

Ian Cowan April 23, 2022, 5:18 a.m. UTC
This replaces all of the pr_err() calls to the preferred zrdev_err()
macro that calls the dev_dbg() macro.

Signed-off-by: Ian Cowan <ian@linux.cowan.aero>
---
 drivers/staging/media/zoran/videocodec.c | 32 +++++++++++++-----------
 drivers/staging/media/zoran/zr36016.c    | 28 +++++++++++++--------
 drivers/staging/media/zoran/zr36050.c    |  5 ++--
 drivers/staging/media/zoran/zr36060.c    | 19 +++++++++-----
 4 files changed, 52 insertions(+), 32 deletions(-)

Comments

Dan Carpenter April 26, 2022, 8:05 a.m. UTC | #1
Hi Ian,

url:    https://github.com/intel-lab-lkp/linux/commits/Ian-Cowan/staging-media-zoran-add-zrdev_dbg-macros/20220425-092814
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git 1efba7ef1d7da5944493728c5375fef5b2130de4
config: i386-randconfig-m021-20220425 (https://download.01.org/0day-ci/archive/20220426/202204260911.PpSNCMg4-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.2.0-20) 11.2.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

smatch warnings:
drivers/staging/media/zoran/videocodec.c:55 videocodec_attach() warn: variable dereferenced before check 'master' (see line 50)
drivers/staging/media/zoran/videocodec.c:124 videocodec_detach() warn: variable dereferenced before check 'codec' (see line 120)
drivers/staging/media/zoran/videocodec.c:177 videocodec_register() warn: variable dereferenced before check 'codec' (see line 175)
drivers/staging/media/zoran/videocodec.c:210 videocodec_unregister() warn: variable dereferenced before check 'codec' (see line 208)

vim +/master +55 drivers/staging/media/zoran/videocodec.c

5e195bbddabdd9 Corentin Labbe 2020-09-25   47  struct videocodec *videocodec_attach(struct videocodec_master *master)
61c3b19f7b9eb7 Corentin Labbe 2020-09-25   48  {
61c3b19f7b9eb7 Corentin Labbe 2020-09-25   49  	struct codec_list *h = codeclist_top;
a0a095d4ab6241 Ian Cowan      2022-04-23  @50  	struct zoran *zr = videocodec_master_to_zoran(master);
                                                                                              ^^^^^^
Dereferenced inside function call.

61c3b19f7b9eb7 Corentin Labbe 2020-09-25   51  	struct attached_list *a, *ptr;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25   52  	struct videocodec *codec;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25   53  	int res;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25   54  
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  @55  	if (!master) {
                                                    ^^^^^^^
Checked too late.  The "master" pointer can't actually be NULL so just
delete this if statement.

a0a095d4ab6241 Ian Cowan      2022-04-23   56  		zrdev_err(zr, "%s: no data\n", __func__);
61c3b19f7b9eb7 Corentin Labbe 2020-09-25   57  		return NULL;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25   58  	}
61c3b19f7b9eb7 Corentin Labbe 2020-09-25   59  
a0a095d4ab6241 Ian Cowan      2022-04-23   60  	zrdev_dbg(zr, "%s: '%s', flags %lx, magic %lx\n", __func__,
61c3b19f7b9eb7 Corentin Labbe 2020-09-25   61  		  master->name, master->flags, master->magic);
61c3b19f7b9eb7 Corentin Labbe 2020-09-25   62  
61c3b19f7b9eb7 Corentin Labbe 2020-09-25   63  	if (!h) {
a0a095d4ab6241 Ian Cowan      2022-04-23   64  		zrdev_err(zr, "%s: no device available\n", __func__);
61c3b19f7b9eb7 Corentin Labbe 2020-09-25   65  		return NULL;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25   66  	}
61c3b19f7b9eb7 Corentin Labbe 2020-09-25   67  
61c3b19f7b9eb7 Corentin Labbe 2020-09-25   68  	while (h) {
61c3b19f7b9eb7 Corentin Labbe 2020-09-25   69  		// attach only if the slave has at least the flags
61c3b19f7b9eb7 Corentin Labbe 2020-09-25   70  		// expected by the master
61c3b19f7b9eb7 Corentin Labbe 2020-09-25   71  		if ((master->flags & h->codec->flags) == master->flags) {
5e195bbddabdd9 Corentin Labbe 2020-09-25   72  			dprintk(4, "%s: try '%s'\n", __func__, h->codec->name);
61c3b19f7b9eb7 Corentin Labbe 2020-09-25   73  
5e195bbddabdd9 Corentin Labbe 2020-09-25   74  			codec = kmemdup(h->codec, sizeof(struct videocodec), GFP_KERNEL);
5e195bbddabdd9 Corentin Labbe 2020-09-25   75  			if (!codec)
fe047de480ca23 Corentin Labbe 2021-12-14   76  				goto out_kfree;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25   77  
61c3b19f7b9eb7 Corentin Labbe 2020-09-25   78  			res = strlen(codec->name);
5e195bbddabdd9 Corentin Labbe 2020-09-25   79  			snprintf(codec->name + res, sizeof(codec->name) - res, "[%d]", h->attached);
61c3b19f7b9eb7 Corentin Labbe 2020-09-25   80  			codec->master_data = master;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25   81  			res = codec->setup(codec);
61c3b19f7b9eb7 Corentin Labbe 2020-09-25   82  			if (res == 0) {
5e195bbddabdd9 Corentin Labbe 2020-09-25   83  				dprintk(3, "%s: '%s'\n", __func__, codec->name);
5e195bbddabdd9 Corentin Labbe 2020-09-25   84  				ptr = kzalloc(sizeof(*ptr), GFP_KERNEL);
5e195bbddabdd9 Corentin Labbe 2020-09-25   85  				if (!ptr)
61c3b19f7b9eb7 Corentin Labbe 2020-09-25   86  					goto out_kfree;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25   87  				ptr->codec = codec;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25   88  
61c3b19f7b9eb7 Corentin Labbe 2020-09-25   89  				a = h->list;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25   90  				if (!a) {
61c3b19f7b9eb7 Corentin Labbe 2020-09-25   91  					h->list = ptr;
5e195bbddabdd9 Corentin Labbe 2020-09-25   92  					dprintk(4, "videocodec: first element\n");
61c3b19f7b9eb7 Corentin Labbe 2020-09-25   93  				} else {
61c3b19f7b9eb7 Corentin Labbe 2020-09-25   94  					while (a->next)
61c3b19f7b9eb7 Corentin Labbe 2020-09-25   95  						a = a->next;	// find end
61c3b19f7b9eb7 Corentin Labbe 2020-09-25   96  					a->next = ptr;
5e195bbddabdd9 Corentin Labbe 2020-09-25   97  					dprintk(4, "videocodec: in after '%s'\n", h->codec->name);
61c3b19f7b9eb7 Corentin Labbe 2020-09-25   98  				}
61c3b19f7b9eb7 Corentin Labbe 2020-09-25   99  
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  100  				h->attached += 1;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  101  				return codec;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  102  			} else {
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  103  				kfree(codec);
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  104  			}
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  105  		}
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  106  		h = h->next;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  107  	}
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  108  
a0a095d4ab6241 Ian Cowan      2022-04-23  109  	zrdev_err(zr, "%s: no codec found!\n", __func__);
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  110  	return NULL;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  111  
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  112   out_kfree:
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  113  	kfree(codec);
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  114  	return NULL;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  115  }
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  116  
5e195bbddabdd9 Corentin Labbe 2020-09-25  117  int videocodec_detach(struct videocodec *codec)
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  118  {
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  119  	struct codec_list *h = codeclist_top;
a0a095d4ab6241 Ian Cowan      2022-04-23 @120  	struct zoran *zr = videocodec_to_zoran(codec);
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  121  	struct attached_list *a, *prev;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  122  	int res;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  123  
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 @124  	if (!codec) {

The "codec" variable can be NULL so this code can crash.  Move the
dereference after the check.

a0a095d4ab6241 Ian Cowan      2022-04-23  125  		zrdev_err(zr, "%s: no data\n", __func__);
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  126  		return -EINVAL;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  127  	}
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  128  
5e195bbddabdd9 Corentin Labbe 2020-09-25  129  	dprintk(2, "%s: '%s', type: %x, flags %lx, magic %lx\n", __func__,
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  130  		codec->name, codec->type, codec->flags, codec->magic);
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  131  
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  132  	if (!h) {
a0a095d4ab6241 Ian Cowan      2022-04-23  133  		zrdev_err(zr, "%s: no device left...\n", __func__);
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  134  		return -ENXIO;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  135  	}
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  136  
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  137  	while (h) {
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  138  		a = h->list;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  139  		prev = NULL;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  140  		while (a) {
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  141  			if (codec == a->codec) {
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  142  				res = a->codec->unset(a->codec);
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  143  				if (res >= 0) {
5e195bbddabdd9 Corentin Labbe 2020-09-25  144  					dprintk(3, "%s: '%s'\n", __func__, a->codec->name);
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  145  					a->codec->master_data = NULL;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  146  				} else {
a0a095d4ab6241 Ian Cowan      2022-04-23  147  					zrdev_err(zr, "%s: '%s'\n", __func__, a->codec->name);
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  148  					a->codec->master_data = NULL;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  149  				}
5e195bbddabdd9 Corentin Labbe 2020-09-25  150  				if (!prev) {
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  151  					h->list = a->next;
5e195bbddabdd9 Corentin Labbe 2020-09-25  152  					dprintk(4, "videocodec: delete first\n");
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  153  				} else {
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  154  					prev->next = a->next;
5e195bbddabdd9 Corentin Labbe 2020-09-25  155  					dprintk(4, "videocodec: delete middle\n");
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  156  				}
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  157  				kfree(a->codec);
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  158  				kfree(a);
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  159  				h->attached -= 1;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  160  				return 0;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  161  			}
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  162  			prev = a;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  163  			a = a->next;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  164  		}
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  165  		h = h->next;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  166  	}
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  167  
a0a095d4ab6241 Ian Cowan      2022-04-23  168  	zrdev_err(zr, "%s: given codec not found!\n", __func__);
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  169  	return -EINVAL;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  170  }
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  171  
5e195bbddabdd9 Corentin Labbe 2020-09-25  172  int videocodec_register(const struct videocodec *codec)
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  173  {
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  174  	struct codec_list *ptr, *h = codeclist_top;
a0a095d4ab6241 Ian Cowan      2022-04-23 @175  	struct zoran *zr = videocodec_to_zoran((struct videocodec *)codec);
                                                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Dereference

61c3b19f7b9eb7 Corentin Labbe 2020-09-25  176  
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 @177  	if (!codec) {

Check

a0a095d4ab6241 Ian Cowan      2022-04-23  178  		zrdev_err(zr, "%s: no data!\n", __func__);
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  179  		return -EINVAL;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  180  	}
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  181  
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  182  	dprintk(2,
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  183  		"videocodec: register '%s', type: %x, flags %lx, magic %lx\n",
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  184  		codec->name, codec->type, codec->flags, codec->magic);
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  185  
5e195bbddabdd9 Corentin Labbe 2020-09-25  186  	ptr = kzalloc(sizeof(*ptr), GFP_KERNEL);
5e195bbddabdd9 Corentin Labbe 2020-09-25  187  	if (!ptr)
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  188  		return -ENOMEM;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  189  	ptr->codec = codec;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  190  
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  191  	if (!h) {
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  192  		codeclist_top = ptr;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  193  		dprintk(4, "videocodec: hooked in as first element\n");
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  194  	} else {
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  195  		while (h->next)
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  196  			h = h->next;	// find the end
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  197  		h->next = ptr;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  198  		dprintk(4, "videocodec: hooked in after '%s'\n",
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  199  			h->codec->name);
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  200  	}
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  201  
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  202  	return 0;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  203  }
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  204  
5e195bbddabdd9 Corentin Labbe 2020-09-25  205  int videocodec_unregister(const struct videocodec *codec)
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  206  {
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  207  	struct codec_list *prev = NULL, *h = codeclist_top;
a0a095d4ab6241 Ian Cowan      2022-04-23 @208  	struct zoran *zr = videocodec_to_zoran((struct videocodec *)codec);
                                                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Dereference

61c3b19f7b9eb7 Corentin Labbe 2020-09-25  209  
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 @210  	if (!codec) {

Check

a0a095d4ab6241 Ian Cowan      2022-04-23  211  		zrdev_err(zr, "%s: no data!\n", __func__);
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  212  		return -EINVAL;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25  213  	}
diff mbox series

Patch

diff --git a/drivers/staging/media/zoran/videocodec.c b/drivers/staging/media/zoran/videocodec.c
index 3af7d02bd910..cabb291d302c 100644
--- a/drivers/staging/media/zoran/videocodec.c
+++ b/drivers/staging/media/zoran/videocodec.c
@@ -47,20 +47,21 @@  static struct codec_list *codeclist_top;
 struct videocodec *videocodec_attach(struct videocodec_master *master)
 {
 	struct codec_list *h = codeclist_top;
+	struct zoran *zr = videocodec_master_to_zoran(master);
 	struct attached_list *a, *ptr;
 	struct videocodec *codec;
 	int res;
 
 	if (!master) {
-		pr_err("%s: no data\n", __func__);
+		zrdev_err(zr, "%s: no data\n", __func__);
 		return NULL;
 	}
 
-	dprintk(2, "%s: '%s', flags %lx, magic %lx\n", __func__,
-		master->name, master->flags, master->magic);
+	zrdev_dbg(zr, "%s: '%s', flags %lx, magic %lx\n", __func__,
+		  master->name, master->flags, master->magic);
 
 	if (!h) {
-		pr_err("%s: no device available\n", __func__);
+		zrdev_err(zr, "%s: no device available\n", __func__);
 		return NULL;
 	}
 
@@ -105,7 +106,7 @@  struct videocodec *videocodec_attach(struct videocodec_master *master)
 		h = h->next;
 	}
 
-	pr_err("%s: no codec found!\n", __func__);
+	zrdev_err(zr, "%s: no codec found!\n", __func__);
 	return NULL;
 
  out_kfree:
@@ -116,11 +117,12 @@  struct videocodec *videocodec_attach(struct videocodec_master *master)
 int videocodec_detach(struct videocodec *codec)
 {
 	struct codec_list *h = codeclist_top;
+	struct zoran *zr = videocodec_to_zoran(codec);
 	struct attached_list *a, *prev;
 	int res;
 
 	if (!codec) {
-		pr_err("%s: no data\n", __func__);
+		zrdev_err(zr, "%s: no data\n", __func__);
 		return -EINVAL;
 	}
 
@@ -128,7 +130,7 @@  int videocodec_detach(struct videocodec *codec)
 		codec->name, codec->type, codec->flags, codec->magic);
 
 	if (!h) {
-		pr_err("%s: no device left...\n", __func__);
+		zrdev_err(zr, "%s: no device left...\n", __func__);
 		return -ENXIO;
 	}
 
@@ -142,7 +144,7 @@  int videocodec_detach(struct videocodec *codec)
 					dprintk(3, "%s: '%s'\n", __func__, a->codec->name);
 					a->codec->master_data = NULL;
 				} else {
-					pr_err("%s: '%s'\n", __func__, a->codec->name);
+					zrdev_err(zr, "%s: '%s'\n", __func__, a->codec->name);
 					a->codec->master_data = NULL;
 				}
 				if (!prev) {
@@ -163,16 +165,17 @@  int videocodec_detach(struct videocodec *codec)
 		h = h->next;
 	}
 
-	pr_err("%s: given codec not found!\n", __func__);
+	zrdev_err(zr, "%s: given codec not found!\n", __func__);
 	return -EINVAL;
 }
 
 int videocodec_register(const struct videocodec *codec)
 {
 	struct codec_list *ptr, *h = codeclist_top;
+	struct zoran *zr = videocodec_to_zoran((struct videocodec *)codec);
 
 	if (!codec) {
-		pr_err("%s: no data!\n", __func__);
+		zrdev_err(zr, "%s: no data!\n", __func__);
 		return -EINVAL;
 	}
 
@@ -202,9 +205,10 @@  int videocodec_register(const struct videocodec *codec)
 int videocodec_unregister(const struct videocodec *codec)
 {
 	struct codec_list *prev = NULL, *h = codeclist_top;
+	struct zoran *zr = videocodec_to_zoran((struct videocodec *)codec);
 
 	if (!codec) {
-		pr_err("%s: no data!\n", __func__);
+		zrdev_err(zr, "%s: no data!\n", __func__);
 		return -EINVAL;
 	}
 
@@ -213,14 +217,14 @@  int videocodec_unregister(const struct videocodec *codec)
 		codec->name, codec->type, codec->flags, codec->magic);
 
 	if (!h) {
-		pr_err("%s: no device left...\n", __func__);
+		zrdev_err(zr, "%s: no device left...\n", __func__);
 		return -ENXIO;
 	}
 
 	while (h) {
 		if (codec == h->codec) {
 			if (h->attached) {
-				pr_err("videocodec: '%s' is used\n", h->codec->name);
+				zrdev_err(zr, "videocodec: '%s' is used\n", h->codec->name);
 				return -EBUSY;
 			}
 			dprintk(3, "videocodec: unregister '%s' is ok.\n",
@@ -241,7 +245,7 @@  int videocodec_unregister(const struct videocodec *codec)
 		h = h->next;
 	}
 
-	pr_err("%s: given codec not found!\n", __func__);
+	zrdev_err(zr, "%s: given codec not found!\n", __func__);
 	return -EINVAL;
 }
 
diff --git a/drivers/staging/media/zoran/zr36016.c b/drivers/staging/media/zoran/zr36016.c
index 26c7c32b6bc0..3e3376af0cfa 100644
--- a/drivers/staging/media/zoran/zr36016.c
+++ b/drivers/staging/media/zoran/zr36016.c
@@ -26,7 +26,6 @@  static int zr36016_debug;
 module_param(zr36016_debug, int, 0);
 MODULE_PARM_DESC(zr36016_debug, "Debug level (0-4)");
 
-
 #define dprintk(num, format, args...) \
 	do { \
 		if (zr36016_debug >= num) \
@@ -42,13 +41,14 @@  MODULE_PARM_DESC(zr36016_debug, "Debug level (0-4)");
 /* read and write functions */
 static u8 zr36016_read(struct zr36016 *ptr, u16 reg)
 {
+	struct zoran *zr = videocodec_to_zoran(ptr->codec);
 	u8 value = 0;
 
 	/* just in case something is wrong... */
 	if (ptr->codec->master_data->readreg)
 		value = (ptr->codec->master_data->readreg(ptr->codec, reg)) & 0xFF;
 	else
-		pr_err("%s: invalid I/O setup, nothing read!\n", ptr->name);
+		zrdev_err(zr, "%s: invalid I/O setup, nothing read!\n", ptr->name);
 
 	dprintk(4, "%s: reading from 0x%04x: %02x\n", ptr->name, reg, value);
 
@@ -57,13 +57,15 @@  static u8 zr36016_read(struct zr36016 *ptr, u16 reg)
 
 static void zr36016_write(struct zr36016 *ptr, u16 reg, u8 value)
 {
+	struct zoran *zr = videocodec_to_zoran(ptr->codec);
+
 	dprintk(4, "%s: writing 0x%02x to 0x%04x\n", ptr->name, value, reg);
 
 	// just in case something is wrong...
 	if (ptr->codec->master_data->writereg)
 		ptr->codec->master_data->writereg(ptr->codec, reg, value);
 	else
-		pr_err("%s: invalid I/O setup, nothing written!\n", ptr->name);
+		zrdev_err(zr, "%s: invalid I/O setup, nothing written!\n", ptr->name);
 }
 
 /* indirect read and write functions */
@@ -71,6 +73,7 @@  static void zr36016_write(struct zr36016 *ptr, u16 reg, u8 value)
  * writing it all time cost not much and is safer... */
 static u8 zr36016_readi(struct zr36016 *ptr, u16 reg)
 {
+	struct zoran *zr = videocodec_to_zoran(ptr->codec);
 	u8 value = 0;
 
 	/* just in case something is wrong... */
@@ -78,7 +81,7 @@  static u8 zr36016_readi(struct zr36016 *ptr, u16 reg)
 		ptr->codec->master_data->writereg(ptr->codec, ZR016_IADDR, reg & 0x0F);	// ADDR
 		value = (ptr->codec->master_data->readreg(ptr->codec, ZR016_IDATA)) & 0xFF;	// DATA
 	} else {
-		pr_err("%s: invalid I/O setup, nothing read (i)!\n", ptr->name);
+		zrdev_err(zr, "%s: invalid I/O setup, nothing read (i)!\n", ptr->name);
 	}
 
 	dprintk(4, "%s: reading indirect from 0x%04x: %02x\n", ptr->name, reg, value);
@@ -87,6 +90,8 @@  static u8 zr36016_readi(struct zr36016 *ptr, u16 reg)
 
 static void zr36016_writei(struct zr36016 *ptr, u16 reg, u8 value)
 {
+	struct zoran *zr = videocodec_to_zoran(ptr->codec);
+
 	dprintk(4, "%s: writing indirect 0x%02x to 0x%04x\n", ptr->name,
 		value, reg);
 
@@ -95,7 +100,7 @@  static void zr36016_writei(struct zr36016 *ptr, u16 reg, u8 value)
 		ptr->codec->master_data->writereg(ptr->codec, ZR016_IADDR, reg & 0x0F);	// ADDR
 		ptr->codec->master_data->writereg(ptr->codec, ZR016_IDATA, value & 0x0FF);	// DATA
 	} else {
-		pr_err("%s: invalid I/O setup, nothing written (i)!\n", ptr->name);
+		zrdev_err(zr, "%s: invalid I/O setup, nothing written (i)!\n", ptr->name);
 	}
 }
 
@@ -120,6 +125,8 @@  static u8 zr36016_read_version(struct zr36016 *ptr)
 
 static int zr36016_basic_test(struct zr36016 *ptr)
 {
+	struct zoran *zr = videocodec_to_zoran(ptr->codec);
+
 	if (zr36016_debug) {
 		int i;
 
@@ -133,19 +140,19 @@  static int zr36016_basic_test(struct zr36016 *ptr)
 	// it back in both cases
 	zr36016_writei(ptr, ZR016I_PAX_LO, 0x00);
 	if (zr36016_readi(ptr, ZR016I_PAX_LO) != 0x0) {
-		pr_err("%s: attach failed, can't connect to vfe processor!\n", ptr->name);
+		zrdev_err(zr, "%s: attach failed, can't connect to vfe processor!\n", ptr->name);
 		return -ENXIO;
 	}
 	zr36016_writei(ptr, ZR016I_PAX_LO, 0x0d0);
 	if (zr36016_readi(ptr, ZR016I_PAX_LO) != 0x0d0) {
-		pr_err("%s: attach failed, can't connect to vfe processor!\n", ptr->name);
+		zrdev_err(zr, "%s: attach failed, can't connect to vfe processor!\n", ptr->name);
 		return -ENXIO;
 	}
 	// we allow version numbers from 0-3, should be enough, though
 	zr36016_read_version(ptr);
 	if (ptr->version & 0x0c) {
-		pr_err("%s: attach failed, suspicious version %d found...\n", ptr->name,
-		       ptr->version);
+		zrdev_err(zr, "%s: attach failed, suspicious version %d found...\n", ptr->name,
+			  ptr->version);
 		return -ENXIO;
 	}
 
@@ -351,13 +358,14 @@  static int zr36016_unset(struct videocodec *codec)
 
 static int zr36016_setup(struct videocodec *codec)
 {
+	struct zoran *zr = videocodec_to_zoran(codec);
 	struct zr36016 *ptr;
 	int res;
 
 	dprintk(2, "zr36016: initializing VFE subsystem #%d.\n", zr36016_codecs);
 
 	if (zr36016_codecs == MAX_CODECS) {
-		pr_err("zr36016: Can't attach more codecs!\n");
+		zrdev_err(zr, "zr36016: Can't attach more codecs!\n");
 		return -ENOSPC;
 	}
 	//mem structure init
diff --git a/drivers/staging/media/zoran/zr36050.c b/drivers/staging/media/zoran/zr36050.c
index 38f7021e7b06..950dd79f5c81 100644
--- a/drivers/staging/media/zoran/zr36050.c
+++ b/drivers/staging/media/zoran/zr36050.c
@@ -385,6 +385,7 @@  static int zr36050_set_dri(struct zr36050 *ptr)
    ========================================================================= */
 static void zr36050_init(struct zr36050 *ptr)
 {
+	struct zoran *zr = videocodec_to_zoran(ptr->codec);
 	int sum = 0;
 	long bitcnt, tmp;
 
@@ -446,7 +447,7 @@  static void zr36050_init(struct zr36050 *ptr)
 			ptr->name, ptr->status1);
 
 		if ((ptr->status1 & 0x4) == 0) {
-			pr_err("%s: init aborted!\n", ptr->name);
+			zrdev_err(zr, "%s: init aborted!\n", ptr->name);
 			return;	// something is wrong, its timed out!!!!
 		}
 
@@ -515,7 +516,7 @@  static void zr36050_init(struct zr36050 *ptr)
 			ptr->name, ptr->status1);
 
 		if ((ptr->status1 & 0x4) == 0) {
-			pr_err("%s: init aborted!\n", ptr->name);
+			zrdev_err(zr, "%s: init aborted!\n", ptr->name);
 			return;	// something is wrong, its timed out!!!!
 		}
 
diff --git a/drivers/staging/media/zoran/zr36060.c b/drivers/staging/media/zoran/zr36060.c
index d0c369e31c81..c09910669585 100644
--- a/drivers/staging/media/zoran/zr36060.c
+++ b/drivers/staging/media/zoran/zr36060.c
@@ -50,26 +50,29 @@  MODULE_PARM_DESC(zr36060_debug, "Debug level (0-4)");
 
 static u8 zr36060_read(struct zr36060 *ptr, u16 reg)
 {
+	struct zoran *zr = videocodec_to_zoran(ptr->codec);
 	u8 value = 0;
 
 	// just in case something is wrong...
 	if (ptr->codec->master_data->readreg)
 		value = (ptr->codec->master_data->readreg(ptr->codec, reg)) & 0xff;
 	else
-		pr_err("%s: invalid I/O setup, nothing read!\n", ptr->name);
+		zrdev_err(zr, "%s: invalid I/O setup, nothing read!\n", ptr->name);
 
 	return value;
 }
 
 static void zr36060_write(struct zr36060 *ptr, u16 reg, u8 value)
 {
+	struct zoran *zr = videocodec_to_zoran(ptr->codec);
+
 	dprintk(4, "0x%02x @0x%04x\n", value, reg);
 
 	// just in case something is wrong...
 	if (ptr->codec->master_data->writereg)
 		ptr->codec->master_data->writereg(ptr->codec, reg, value);
 	else
-		pr_err("%s: invalid I/O setup, nothing written!\n", ptr->name);
+		zrdev_err(zr, "%s: invalid I/O setup, nothing written!\n", ptr->name);
 }
 
 /* =========================================================================
@@ -117,15 +120,17 @@  static void zr36060_wait_end(struct zr36060 *ptr)
 /* Basic test of "connectivity", writes/reads to/from memory the SOF marker */
 static int zr36060_basic_test(struct zr36060 *ptr)
 {
+	struct zoran *zr = videocodec_to_zoran(ptr->codec);
+
 	if ((zr36060_read(ptr, ZR060_IDR_DEV) != 0x33) &&
 	    (zr36060_read(ptr, ZR060_IDR_REV) != 0x01)) {
-		pr_err("%s: attach failed, can't connect to jpeg processor!\n", ptr->name);
+		zrdev_err(zr, "%s: attach failed, can't connect to jpeg processor!\n", ptr->name);
 		return -ENXIO;
 	}
 
 	zr36060_wait_end(ptr);
 	if (ptr->status & ZR060_CFSR_BUSY) {
-		pr_err("%s: attach failed, jpeg processor failed (end flag)!\n", ptr->name);
+		zrdev_err(zr, "%s: attach failed, jpeg processor failed (end flag)!\n", ptr->name);
 		return -EBUSY;
 	}
 
@@ -319,6 +324,7 @@  static int zr36060_set_dri(struct zr36060 *ptr)
  */
 static void zr36060_init(struct zr36060 *ptr)
 {
+	struct zoran *zr = videocodec_to_zoran(ptr->codec);
 	int sum = 0;
 	long bitcnt, tmp;
 
@@ -444,7 +450,7 @@  static void zr36060_init(struct zr36060 *ptr)
 	dprintk(2, "%s: Status after table preload: 0x%02x\n", ptr->name, ptr->status);
 
 	if (ptr->status & ZR060_CFSR_BUSY) {
-		pr_err("%s: init aborted!\n", ptr->name);
+		zrdev_err(zr, "%s: init aborted!\n", ptr->name);
 		return;		// something is wrong, its timed out!!!!
 	}
 }
@@ -777,13 +783,14 @@  static int zr36060_unset(struct videocodec *codec)
  */
 static int zr36060_setup(struct videocodec *codec)
 {
+	struct zoran *zr = videocodec_to_zoran(codec);
 	struct zr36060 *ptr;
 	int res;
 
 	dprintk(2, "zr36060: initializing MJPEG subsystem #%d.\n", zr36060_codecs);
 
 	if (zr36060_codecs == MAX_CODECS) {
-		pr_err("zr36060: Can't attach more codecs!\n");
+		zrdev_err(zr, "zr36060: Can't attach more codecs!\n");
 		return -ENOSPC;
 	}
 	//mem structure init