Skip to content

Commit

Permalink
staging: media: zoran: replace dprintk with zrdev_dbg
Browse files Browse the repository at this point in the history
This replaces all of the dprintk() macro calls to the zrdev_dbg(),
zrdev_info(), or zrdev_err() calls as appropriate. This allows for the
removal of the dprintk() macro from each file it is defined in, along
with removal of the module params that track the debugging level.

In the case that a debugging level was used in a comparison, this has
been replaced with checking the console level debugging and making a
decision from there. If the console debugging level is at least the
KERN_ debugging level equivalent, then the comparison will evaluate as
true.

There are a few instances where pr_debug() must be used over the
zrdev_dbg(). These occur in the module cleanup functions because there
should be no devices defined once we get to those modules, so we have no
devices to pass to zrdev_dbg().

Signed-off-by: Ian Cowan <ian@linux.cowan.aero>
  • Loading branch information
iccowan authored and intel-lab-lkp committed Apr 25, 2022
1 parent a0a095d commit 6febc7a
Show file tree
Hide file tree
Showing 4 changed files with 143 additions and 177 deletions.
55 changes: 21 additions & 34 deletions drivers/staging/media/zoran/videocodec.c
Expand Up @@ -16,16 +16,6 @@

#include "videocodec.h"

static int videocodec_debug;
module_param(videocodec_debug, int, 0);
MODULE_PARM_DESC(videocodec_debug, "Debug level (0-4)");

#define dprintk(num, format, args...) \
do { \
if (videocodec_debug >= num) \
printk(format, ##args); \
} while (0)

struct attached_list {
struct videocodec *codec;
struct attached_list *next;
Expand Down Expand Up @@ -69,7 +59,7 @@ struct videocodec *videocodec_attach(struct videocodec_master *master)
// attach only if the slave has at least the flags
// expected by the master
if ((master->flags & h->codec->flags) == master->flags) {
dprintk(4, "%s: try '%s'\n", __func__, h->codec->name);
zrdev_dbg(zr, "%s: try '%s'\n", __func__, h->codec->name);

codec = kmemdup(h->codec, sizeof(struct videocodec), GFP_KERNEL);
if (!codec)
Expand All @@ -80,7 +70,7 @@ struct videocodec *videocodec_attach(struct videocodec_master *master)
codec->master_data = master;
res = codec->setup(codec);
if (res == 0) {
dprintk(3, "%s: '%s'\n", __func__, codec->name);
zrdev_dbg(zr, "%s: '%s'\n", __func__, codec->name);
ptr = kzalloc(sizeof(*ptr), GFP_KERNEL);
if (!ptr)
goto out_kfree;
Expand All @@ -89,12 +79,13 @@ struct videocodec *videocodec_attach(struct videocodec_master *master)
a = h->list;
if (!a) {
h->list = ptr;
dprintk(4, "videocodec: first element\n");
zrdev_dbg(zr, "videocodec: first element\n");
} else {
while (a->next)
a = a->next; // find end
a->next = ptr;
dprintk(4, "videocodec: in after '%s'\n", h->codec->name);
zrdev_dbg(zr, "videocodec: in after '%s'\n",
h->codec->name);
}

h->attached += 1;
Expand Down Expand Up @@ -126,8 +117,8 @@ int videocodec_detach(struct videocodec *codec)
return -EINVAL;
}

dprintk(2, "%s: '%s', type: %x, flags %lx, magic %lx\n", __func__,
codec->name, codec->type, codec->flags, codec->magic);
zrdev_dbg(zr, "%s: '%s', type: %x, flags %lx, magic %lx\n", __func__,
codec->name, codec->type, codec->flags, codec->magic);

if (!h) {
zrdev_err(zr, "%s: no device left...\n", __func__);
Expand All @@ -141,18 +132,18 @@ int videocodec_detach(struct videocodec *codec)
if (codec == a->codec) {
res = a->codec->unset(a->codec);
if (res >= 0) {
dprintk(3, "%s: '%s'\n", __func__, a->codec->name);
zrdev_dbg(zr, "%s: '%s'\n", __func__, a->codec->name);
a->codec->master_data = NULL;
} else {
zrdev_err(zr, "%s: '%s'\n", __func__, a->codec->name);
a->codec->master_data = NULL;
}
if (!prev) {
h->list = a->next;
dprintk(4, "videocodec: delete first\n");
zrdev_dbg(zr, "videocodec: delete first\n");
} else {
prev->next = a->next;
dprintk(4, "videocodec: delete middle\n");
zrdev_dbg(zr, "videocodec: delete middle\n");
}
kfree(a->codec);
kfree(a);
Expand All @@ -179,9 +170,8 @@ int videocodec_register(const struct videocodec *codec)
return -EINVAL;
}

dprintk(2,
"videocodec: register '%s', type: %x, flags %lx, magic %lx\n",
codec->name, codec->type, codec->flags, codec->magic);
zrdev_dbg(zr, "videocodec: register '%s', type: %x, flags %lx, magic %lx\n",
codec->name, codec->type, codec->flags, codec->magic);

ptr = kzalloc(sizeof(*ptr), GFP_KERNEL);
if (!ptr)
Expand All @@ -190,13 +180,13 @@ int videocodec_register(const struct videocodec *codec)

if (!h) {
codeclist_top = ptr;
dprintk(4, "videocodec: hooked in as first element\n");
zrdev_dbg(zr, "videocodec: hooked in as first element\n");
} else {
while (h->next)
h = h->next; // find the end
h->next = ptr;
dprintk(4, "videocodec: hooked in after '%s'\n",
h->codec->name);
zrdev_dbg(zr, "videocodec: hooked in after '%s'\n",
h->codec->name);
}

return 0;
Expand All @@ -212,9 +202,8 @@ int videocodec_unregister(const struct videocodec *codec)
return -EINVAL;
}

dprintk(2,
"videocodec: unregister '%s', type: %x, flags %lx, magic %lx\n",
codec->name, codec->type, codec->flags, codec->magic);
zrdev_dbg(zr, "videocodec: unregister '%s', type: %x, flags %lx, magic %lx\n",
codec->name, codec->type, codec->flags, codec->magic);

if (!h) {
zrdev_err(zr, "%s: no device left...\n", __func__);
Expand All @@ -227,16 +216,14 @@ int videocodec_unregister(const struct videocodec *codec)
zrdev_err(zr, "videocodec: '%s' is used\n", h->codec->name);
return -EBUSY;
}
dprintk(3, "videocodec: unregister '%s' is ok.\n",
h->codec->name);
zrdev_dbg(zr, "videocodec: unregister '%s' is ok.\n",
h->codec->name);
if (!prev) {
codeclist_top = h->next;
dprintk(4,
"videocodec: delete first element\n");
zrdev_dbg(zr, "videocodec: delete first element\n");
} else {
prev->next = h->next;
dprintk(4,
"videocodec: delete middle element\n");
zrdev_dbg(zr, "videocodec: delete middle element\n");
}
kfree(h);
return 0;
Expand Down
60 changes: 27 additions & 33 deletions drivers/staging/media/zoran/zr36016.c
Expand Up @@ -22,16 +22,6 @@
/* amount of chips attached via this driver */
static int zr36016_codecs;

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) \
printk(format, ##args); \
} while (0)

/* =========================================================================
Local hardware I/O functions:
Expand All @@ -50,7 +40,7 @@ static u8 zr36016_read(struct zr36016 *ptr, u16 reg)
else
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);
zrdev_dbg(zr, "%s: reading from 0x%04x: %02x\n", ptr->name, reg, value);

return value;
}
Expand All @@ -59,7 +49,7 @@ 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);
zrdev_dbg(zr, "%s: writing 0x%02x to 0x%04x\n", ptr->name, value, reg);

// just in case something is wrong...
if (ptr->codec->master_data->writereg)
Expand All @@ -84,16 +74,16 @@ static u8 zr36016_readi(struct zr36016 *ptr, u16 reg)
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);
zrdev_dbg(zr, "%s: reading indirect from 0x%04x: %02x\n", ptr->name, reg, value);
return value;
}

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);
zrdev_dbg(zr, "%s: writing indirect 0x%02x to 0x%04x\n", ptr->name,
value, reg);

/* just in case something is wrong... */
if (ptr->codec->master_data->writereg) {
Expand Down Expand Up @@ -127,14 +117,14 @@ static int zr36016_basic_test(struct zr36016 *ptr)
{
struct zoran *zr = videocodec_to_zoran(ptr->codec);

if (zr36016_debug) {
if (*KERN_INFO <= CONSOLE_LOGLEVEL_DEFAULT) {
int i;

zr36016_writei(ptr, ZR016I_PAX_LO, 0x55);
dprintk(1, KERN_INFO "%s: registers: ", ptr->name);
zrdev_info(zr, "%s: registers: ", ptr->name);
for (i = 0; i <= 0x0b; i++)
dprintk(1, "%02x ", zr36016_readi(ptr, i));
dprintk(1, "\n");
zrdev_dbg(zr, "%02x ", zr36016_readi(ptr, i));
zrdev_dbg(zr, "\n");
}
// for testing just write 0, then the default value to a register and read
// it back in both cases
Expand Down Expand Up @@ -171,10 +161,11 @@ static int zr36016_pushit(struct zr36016 *ptr,
u16 len,
const char *data)
{
struct zoran *zr = videocodec_to_zoran(ptr->codec);
int i = 0;

dprintk(4, "%s: write data block to 0x%04x (len=%d)\n",
ptr->name, startreg, len);
zrdev_dbg(zr, "%s: write data block to 0x%04x (len=%d)\n",
ptr->name, startreg, len);
while (i < len) {
zr36016_writei(ptr, startreg++, data[i++]);
}
Expand Down Expand Up @@ -232,8 +223,9 @@ static void zr36016_init(struct zr36016 *ptr)
static int zr36016_set_mode(struct videocodec *codec, int mode)
{
struct zr36016 *ptr = (struct zr36016 *)codec->data;
struct zoran *zr = videocodec_to_zoran(codec);

dprintk(2, "%s: set_mode %d call\n", ptr->name, mode);
zrdev_dbg(zr, "%s: set_mode %d call\n", ptr->name, mode);

if ((mode != CODEC_DO_EXPANSION) && (mode != CODEC_DO_COMPRESSION))
return -EINVAL;
Expand All @@ -249,11 +241,12 @@ static int zr36016_set_video(struct videocodec *codec, const struct tvnorm *norm
struct vfe_settings *cap, struct vfe_polarity *pol)
{
struct zr36016 *ptr = (struct zr36016 *)codec->data;
struct zoran *zr = videocodec_to_zoran(codec);

dprintk(2, "%s: set_video %d.%d, %d/%d-%dx%d (0x%x) call\n",
ptr->name, norm->h_start, norm->v_start,
cap->x, cap->y, cap->width, cap->height,
cap->decimation);
zrdev_dbg(zr, "%s: set_video %d.%d, %d/%d-%dx%d (0x%x) call\n",
ptr->name, norm->h_start, norm->v_start,
cap->x, cap->y, cap->width, cap->height,
cap->decimation);

/* if () return -EINVAL;
* trust the master driver that it knows what it does - so
Expand Down Expand Up @@ -283,9 +276,10 @@ static int zr36016_set_video(struct videocodec *codec, const struct tvnorm *norm
static int zr36016_control(struct videocodec *codec, int type, int size, void *data)
{
struct zr36016 *ptr = (struct zr36016 *)codec->data;
struct zoran *zr = videocodec_to_zoran(codec);
int *ival = (int *)data;

dprintk(2, "%s: control %d call with %d byte\n", ptr->name, type, size);
zrdev_dbg(zr, "%s: control %d call with %d byte\n", ptr->name, type, size);

switch (type) {
case CODEC_G_STATUS: /* get last status - we don't know it ... */
Expand Down Expand Up @@ -332,11 +326,12 @@ static int zr36016_control(struct videocodec *codec, int type, int size, void *d
static int zr36016_unset(struct videocodec *codec)
{
struct zr36016 *ptr = codec->data;
struct zoran *zr = videocodec_to_zoran(codec);

if (ptr) {
/* do wee need some codec deinit here, too ???? */

dprintk(1, "%s: finished codec #%d\n", ptr->name, ptr->num);
zrdev_dbg(zr, "%s: finished codec #%d\n", ptr->name, ptr->num);
kfree(ptr);
codec->data = NULL;

Expand All @@ -362,7 +357,7 @@ static int zr36016_setup(struct videocodec *codec)
struct zr36016 *ptr;
int res;

dprintk(2, "zr36016: initializing VFE subsystem #%d.\n", zr36016_codecs);
zrdev_dbg(zr, "zr36016: initializing VFE subsystem #%d.\n", zr36016_codecs);

if (zr36016_codecs == MAX_CODECS) {
zrdev_err(zr, "zr36016: Can't attach more codecs!\n");
Expand Down Expand Up @@ -392,7 +387,7 @@ static int zr36016_setup(struct videocodec *codec)
ptr->ydec = 0;
zr36016_init(ptr);

dprintk(1, KERN_INFO "%s: codec v%d attached and running\n", ptr->name, ptr->version);
zrdev_info(zr, "%s: codec v%d attached and running\n", ptr->name, ptr->version);

return 0;
}
Expand Down Expand Up @@ -425,9 +420,8 @@ int zr36016_init_module(void)
void zr36016_cleanup_module(void)
{
if (zr36016_codecs) {
dprintk(1,
"zr36016: something's wrong - %d codecs left somehow.\n",
zr36016_codecs);
pr_debug("zr36016: something's wrong - %d codecs left somehow.\n",
zr36016_codecs);
}
videocodec_unregister(&zr36016_codec);
}

0 comments on commit 6febc7a

Please sign in to comment.