Re: [PATCH 11/25] [media] dvb-core: use pr_foo() instead of printk()

2017-05-03 Thread Arnd Bergmann
On Friday, October 14, 2016 2:45:49 PM CEST Mauro Carvalho Chehab wrote:
> 
> -#define dprintkif (debug) printk
> +#define dprintk(fmt, arg...) do {  \
> +   if (debug)  \
> +   printk(KERN_DEBUG pr_fmt("%s: " fmt),   \
> +   __func__, ##arg);   \
> +} while (0)
> 

Why not just use pr_debug() or dev_dbg() here? They already
have a way to control output at runtime (CONFIG_DYNAMIC_DEBUG).

Arnd


Re: [PATCH 11/25] [media] dvb-core: use pr_foo() instead of printk()

2016-10-21 Thread Mauro Carvalho Chehab
Em Fri, 14 Oct 2016 20:22:40 +0200
SF Markus Elfring  escreveu:

> > diff --git a/drivers/media/dvb-core/dmxdev.c 
> > b/drivers/media/dvb-core/dmxdev.c
> > index 7b67e1dd97fd..1e96a6f1b6f0 100644
> > --- a/drivers/media/dvb-core/dmxdev.c
> > +++ b/drivers/media/dvb-core/dmxdev.c
> > @@ -20,6 +20,8 @@
> >   *
> >   */
> >  
> > +#define pr_fmt(fmt) "dmxdev: " fmt
> > +
> >  #include 
> >  #include 
> >  #include   
> 
> How do you think to use an approach like the following there?
> 
> 
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> 
> 
>or eventually
> 
> 
> +#define MY_LOG_PREFIX KBUILD_MODNAME ": "
> +#define pr_fmt(fmt) MY_LOG_PREFIX fmt

we use a lot KBUILD_MODNAME on driver's pr_fmt() macros.

However, in this specific case, it is not a good idea, as this patch
is touching at the DVB core, with is composed by several different
and almost independent parts. So, we want to know what part
of the DVB core is producing such messages.

Regards,
Mauro
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 11/25] [media] dvb-core: use pr_foo() instead of printk()

2016-10-14 Thread SF Markus Elfring
> diff --git a/drivers/media/dvb-core/dmxdev.c b/drivers/media/dvb-core/dmxdev.c
> index 7b67e1dd97fd..1e96a6f1b6f0 100644
> --- a/drivers/media/dvb-core/dmxdev.c
> +++ b/drivers/media/dvb-core/dmxdev.c
> @@ -20,6 +20,8 @@
>   *
>   */
>  
> +#define pr_fmt(fmt) "dmxdev: " fmt
> +
>  #include 
>  #include 
>  #include 

How do you think to use an approach like the following there?


+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt


   or eventually


+#define MY_LOG_PREFIX KBUILD_MODNAME ": "
+#define pr_fmt(fmt) MY_LOG_PREFIX fmt


Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 11/25] [media] dvb-core: use pr_foo() instead of printk()

2016-10-14 Thread Mauro Carvalho Chehab
The dvb-core directly calls printk() without using the modern
printk macros, or using the proper printk levels. Change it
to use pr_foo().

Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/media/dvb-core/dmxdev.c | 24 ++
 drivers/media/dvb-core/dvb_ca_en50221.c | 57 ++-
 drivers/media/dvb-core/dvb_demux.c  | 46 ++
 drivers/media/dvb-core/dvb_frontend.c   | 12 +++--
 drivers/media/dvb-core/dvb_net.c| 82 ++---
 drivers/media/dvb-core/dvbdev.c | 25 ++
 6 files changed, 146 insertions(+), 100 deletions(-)

diff --git a/drivers/media/dvb-core/dmxdev.c b/drivers/media/dvb-core/dmxdev.c
index 7b67e1dd97fd..1e96a6f1b6f0 100644
--- a/drivers/media/dvb-core/dmxdev.c
+++ b/drivers/media/dvb-core/dmxdev.c
@@ -20,6 +20,8 @@
  *
  */
 
+#define pr_fmt(fmt) "dmxdev: " fmt
+
 #include 
 #include 
 #include 
@@ -36,7 +38,11 @@ static int debug;
 module_param(debug, int, 0644);
 MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off).");
 
-#define dprintkif (debug) printk
+#define dprintk(fmt, arg...) do {  \
+   if (debug)  \
+   printk(KERN_DEBUG pr_fmt("%s: " fmt),   \
+   __func__, ##arg);   \
+} while (0)
 
 static int dvb_dmxdev_buffer_write(struct dvb_ringbuffer *buf,
   const u8 *src, size_t len)
@@ -50,7 +56,7 @@ static int dvb_dmxdev_buffer_write(struct dvb_ringbuffer *buf,
 
free = dvb_ringbuffer_free(buf);
if (len > free) {
-   dprintk("dmxdev: buffer overflow\n");
+   dprintk("buffer overflow\n");
return -EOVERFLOW;
}
 
@@ -126,7 +132,7 @@ static int dvb_dvr_open(struct inode *inode, struct file 
*file)
struct dmxdev *dmxdev = dvbdev->priv;
struct dmx_frontend *front;
 
-   dprintk("function : %s\n", __func__);
+   dprintk("%s\n", __func__);
 
if (mutex_lock_interruptible(&dmxdev->mutex))
return -ERESTARTSYS;
@@ -258,7 +264,7 @@ static int dvb_dvr_set_buffer_size(struct dmxdev *dmxdev,
void *newmem;
void *oldmem;
 
-   dprintk("function : %s\n", __func__);
+   dprintk("%s\n", __func__);
 
if (buf->size == size)
return 0;
@@ -367,7 +373,7 @@ static int dvb_dmxdev_section_callback(const u8 *buffer1, 
size_t buffer1_len,
return 0;
}
del_timer(&dmxdevfilter->timer);
-   dprintk("dmxdev: section callback %*ph\n", 6, buffer1);
+   dprintk("section callback %*ph\n", 6, buffer1);
ret = dvb_dmxdev_buffer_write(&dmxdevfilter->buffer, buffer1,
  buffer1_len);
if (ret == buffer1_len) {
@@ -655,7 +661,7 @@ static int dvb_dmxdev_filter_start(struct dmxdev_filter 
*filter)
   secfeed,
   
dvb_dmxdev_section_callback);
if (ret < 0) {
-   printk("DVB (%s): could not alloc feed\n",
+   pr_err("DVB (%s): could not alloc feed\n",
   __func__);
return ret;
}
@@ -663,7 +669,7 @@ static int dvb_dmxdev_filter_start(struct dmxdev_filter 
*filter)
ret = (*secfeed)->set(*secfeed, para->pid, 32768,
  (para->flags & DMX_CHECK_CRC) ? 1 
: 0);
if (ret < 0) {
-   printk("DVB (%s): could not set feed\n",
+   pr_err("DVB (%s): could not set feed\n",
   __func__);
dvb_dmxdev_feed_restart(filter);
return ret;
@@ -844,7 +850,7 @@ static int dvb_dmxdev_filter_set(struct dmxdev *dmxdev,
 struct dmxdev_filter *dmxdevfilter,
 struct dmx_sct_filter_params *params)
 {
-   dprintk("function : %s, PID=0x%04x, flags=%02x, timeout=%d\n",
+   dprintk("%s: PID=0x%04x, flags=%02x, timeout=%d\n",
__func__, params->pid, params->flags, params->timeout);
 
dvb_dmxdev_filter_stop(dmxdevfilter);
@@ -1184,7 +1190,7 @@ static unsigned int dvb_dvr_poll(struct file *file, 
poll_table *wait)
struct dmxdev *dmxdev = dvbdev->priv;
unsigned int mask = 0;
 
-   dprintk("function : %s\n", __func__);
+   dprintk("%s\n", __func__);
 
if (dmxdev->exit)
return POLLERR;
diff --git a/drivers/media/dvb-core/dvb_ca_en50221.c 
b/drivers/media/dvb-core/dvb_ca_en50221.c
index b5b5b195ea7f..262a492e7c08 100644
--- a/drivers/media/dvb-core/dvb_c