[Mjpeg-users] [PATCH 2/4] staging: media: zoran: setup videocodec header for debugging macros

2022-04-25 Thread Ian Cowan
This adds inline functions in the videocodec header file to convert the
videocodec and videocodec_master structs to their respective contained
zoran struct. This will be used to pass the zoran struct to the
zrdev_XXX() macros defined in the zoran header.

In the zoran header, the new include is added to ensure all variables
can be completely defined with the zoran and videocodec includes where
they are located.

Signed-off-by: Ian Cowan 
---
 drivers/staging/media/zoran/videocodec.h | 15 +++
 drivers/staging/media/zoran/zoran.h  |  1 +
 2 files changed, 16 insertions(+)

diff --git a/drivers/staging/media/zoran/videocodec.h 
b/drivers/staging/media/zoran/videocodec.h
index 9dea348fee40..5e6057edd339 100644
--- a/drivers/staging/media/zoran/videocodec.h
+++ b/drivers/staging/media/zoran/videocodec.h
@@ -307,4 +307,19 @@ extern int videocodec_unregister(const struct videocodec 
*);
 
 int videocodec_debugfs_show(struct seq_file *m);
 
+#include "zoran.h"
+static inline struct zoran *videocodec_master_to_zoran(struct 
videocodec_master *master)
+{
+   struct zoran *zr = master->data;
+
+   return zr;
+}
+
+static inline struct zoran *videocodec_to_zoran(struct videocodec *codec)
+{
+   struct videocodec_master *master = codec->master_data;
+
+   return videocodec_master_to_zoran(master);
+}
+
 #endif /*ifndef __LINUX_VIDEOCODEC_H */
diff --git a/drivers/staging/media/zoran/zoran.h 
b/drivers/staging/media/zoran/zoran.h
index 42b86356c022..674658154e88 100644
--- a/drivers/staging/media/zoran/zoran.h
+++ b/drivers/staging/media/zoran/zoran.h
@@ -20,6 +20,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
-- 
2.35.1



___
Mjpeg-users mailing list
Mjpeg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mjpeg-users


[Mjpeg-users] [PATCH 1/4] staging: media: zoran: add logging macros

2022-04-25 Thread Ian Cowan
This adds the zrdev_dbg() (pointing to pci_dbg()), zrdev_err() (pointing
to pci_err()), and zrdev_info() (pointing to pci_info()) macros to the
zoran drivers. These are the preferred method for debugging and this
will allow to extract the device from the zoran struct to make the call.

Signed-off-by: Ian Cowan 
---
 drivers/staging/media/zoran/zoran.h | 13 +
 1 file changed, 13 insertions(+)

diff --git a/drivers/staging/media/zoran/zoran.h 
b/drivers/staging/media/zoran/zoran.h
index 654c95fa5aba..4f7f71d8e93c 100644
--- a/drivers/staging/media/zoran/zoran.h
+++ b/drivers/staging/media/zoran/zoran.h
@@ -19,6 +19,7 @@
 #define _BUZ_H_
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -301,6 +302,18 @@ static inline struct zoran *to_zoran(struct v4l2_device 
*v4l2_dev)
 
 #endif
 
+/**
+ * Debugging macros
+ */
+#define zrdev_dbg(zr, format, args...) \
+   pci_dbg(zr->pci_dev, format, ##args) \
+
+#define zrdev_err(zr, format, args...) \
+   pci_err(zr->pci_dev, format, ##args) \
+
+#define zrdev_info(zr, format, args...) \
+   pci_info(zr->pci_dev, format, ##args) \
+
 int zoran_queue_init(struct zoran *zr, struct vb2_queue *vq, int dir);
 void zoran_queue_exit(struct zoran *zr);
 int zr_set_buf(struct zoran *zr);
-- 
2.35.1



___
Mjpeg-users mailing list
Mjpeg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mjpeg-users


Re: [Mjpeg-users] [PATCH 1/4] staging: media: zoran: add zrdev_dbg() macros

2022-04-25 Thread Ian Cowan
On Sun, Apr 24, 2022 at 09:17:22PM +0200, LABBE Corentin wrote:
> Hello
> 
> Thanks for your patchs, removing dprintk is a good idea.
> Please use pci_xxx() instead of dev_xxx() to be consistent with the rest of 
> the driver.
> The comment title is misleading, zrdev_err is not about debugging. What about 
> Logging macros ?
> 
> Regards
> 

I have made those modifications, and I will resubmit patches 1 and 2
shortly. Those are the only patches that affected by this change; 3 and
4 will not change.

Thanks,
Ian


___
Mjpeg-users mailing list
Mjpeg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mjpeg-users


Re: [Mjpeg-users] [PATCH 1/4] staging: media: zoran: add zrdev_dbg() macros

2022-04-25 Thread LABBE Corentin
Le Sat, Apr 23, 2022 at 01:17:45AM -0400, Ian Cowan a écrit :
> This adds the zrdev_dbg() (pointing to dev_dbg()), zrdev_err() (pointing
> to dev_err()), and zrdev_info() (pointing to dev_info()) macros to the
> zoran drivers. These are the preferred method for debugging and this
> will allow to extract the device from the zoran struct to make the call.
> 
> Signed-off-by: Ian Cowan 
> ---
>  drivers/staging/media/zoran/zoran.h | 13 +
>  1 file changed, 13 insertions(+)
> 
> diff --git a/drivers/staging/media/zoran/zoran.h 
> b/drivers/staging/media/zoran/zoran.h
> index 654c95fa5aba..42b86356c022 100644
> --- a/drivers/staging/media/zoran/zoran.h
> +++ b/drivers/staging/media/zoran/zoran.h
> @@ -19,6 +19,7 @@
>  #define _BUZ_H_
>  
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -301,6 +302,18 @@ static inline struct zoran *to_zoran(struct v4l2_device 
> *v4l2_dev)
>  
>  #endif
>  
> +/**
> + * Debugging macros
> + */
> +#define zrdev_dbg(zr, format, args...) \
> + dev_dbg(&zr->video_dev->dev, format, ##args) \
> +
> +#define zrdev_err(zr, format, args...) \
> + dev_err(&zr->video_dev->dev, format, ##args) \
> +
> +#define zrdev_info(zr, format, args...) \
> + dev_info(&zr->video_dev->dev, format, ##args) \
> +
>  int zoran_queue_init(struct zoran *zr, struct vb2_queue *vq, int dir);
>  void zoran_queue_exit(struct zoran *zr);
>  int zr_set_buf(struct zoran *zr);
> -- 
> 2.35.1
> 

Hello

Thanks for your patchs, removing dprintk is a good idea.
Please use pci_xxx() instead of dev_xxx() to be consistent with the rest of the 
driver.
The comment title is misleading, zrdev_err is not about debugging. What about 
Logging macros ?

Regards


___
Mjpeg-users mailing list
Mjpeg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mjpeg-users


[Mjpeg-users] [PATCH v2 1/4] staging: media: zoran: add logging macros

2022-04-25 Thread Ian Cowan
This adds the zrdev_dbg() (pointing to pci_dbg()), zrdev_err() (pointing
to pci_err()), and zrdev_info() (pointing to pci_info()) macros to the
zoran drivers. These are the preferred method for debugging and this
will allow to extract the device from the zoran struct to make the call.

Signed-off-by: Ian Cowan 
---
 drivers/staging/media/zoran/zoran.h | 13 +
 1 file changed, 13 insertions(+)

diff --git a/drivers/staging/media/zoran/zoran.h 
b/drivers/staging/media/zoran/zoran.h
index 654c95fa5aba..4f7f71d8e93c 100644
--- a/drivers/staging/media/zoran/zoran.h
+++ b/drivers/staging/media/zoran/zoran.h
@@ -19,6 +19,7 @@
 #define _BUZ_H_
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -301,6 +302,18 @@ static inline struct zoran *to_zoran(struct v4l2_device 
*v4l2_dev)
 
 #endif
 
+/**
+ * Debugging macros
+ */
+#define zrdev_dbg(zr, format, args...) \
+   pci_dbg(zr->pci_dev, format, ##args) \
+
+#define zrdev_err(zr, format, args...) \
+   pci_err(zr->pci_dev, format, ##args) \
+
+#define zrdev_info(zr, format, args...) \
+   pci_info(zr->pci_dev, format, ##args) \
+
 int zoran_queue_init(struct zoran *zr, struct vb2_queue *vq, int dir);
 void zoran_queue_exit(struct zoran *zr);
 int zr_set_buf(struct zoran *zr);
-- 
2.35.1



___
Mjpeg-users mailing list
Mjpeg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mjpeg-users


[Mjpeg-users] [PATCH v2 3/4] staging: media: zoran: replace all pr_err() with zrdev_err()

2022-04-25 Thread Ian Cowan
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 
---
 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(-)

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, 

Re: [Mjpeg-users] [PATCH 1/4] staging: media: zoran: add zrdev_dbg() macros

2022-04-25 Thread Greg KH
On Sun, Apr 24, 2022 at 09:22:30PM -0400, Ian Cowan wrote:
> On Sun, Apr 24, 2022 at 09:17:22PM +0200, LABBE Corentin wrote:
> > Hello
> > 
> > Thanks for your patchs, removing dprintk is a good idea.
> > Please use pci_xxx() instead of dev_xxx() to be consistent with the rest of 
> > the driver.
> > The comment title is misleading, zrdev_err is not about debugging. What 
> > about Logging macros ?
> > 
> > Regards
> > 
> 
> I have made those modifications, and I will resubmit patches 1 and 2
> shortly. Those are the only patches that affected by this change; 3 and
> 4 will not change.

You should send a whole new series, properly versioned as the
documentation in the kernel asks you to.  Otherwise it is impossible for
reviewers and maintainers to know what is the "latest" version to
accept.

thanks,

greg k-h


___
Mjpeg-users mailing list
Mjpeg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mjpeg-users


Re: [Mjpeg-users] [PATCH 2/4] staging: media: zoran: setup videocodec header for debugging macros

2022-04-25 Thread Ian Cowan
This adds inline functions in the videocodec header file to convert the
videocodec and videocodec_master structs to their respective contained
zoran struct. This will be used to pass the zoran struct to the
zrdev_XXX() macros defined in the zoran header.

In the zoran header, the new include is added to ensure all variables
can be completely defined with the zoran and videocodec includes where
they are located.

> Slight modification made here so the patch will apply properly from
> the modified patch 1 - sorry about that.

Signed-off-by: Ian Cowan 
---
 drivers/staging/media/zoran/videocodec.h | 15 +++
 drivers/staging/media/zoran/zoran.h  |  1 +
 2 files changed, 16 insertions(+)

diff --git a/drivers/staging/media/zoran/videocodec.h 
b/drivers/staging/media/zoran/videocodec.h
index 9dea348fee40..5e6057edd339 100644
--- a/drivers/staging/media/zoran/videocodec.h
+++ b/drivers/staging/media/zoran/videocodec.h
@@ -307,4 +307,19 @@ extern int videocodec_unregister(const struct videocodec 
*);
 
 int videocodec_debugfs_show(struct seq_file *m);
 
+#include "zoran.h"
+static inline struct zoran *videocodec_master_to_zoran(struct 
videocodec_master *master)
+{
+   struct zoran *zr = master->data;
+
+   return zr;
+}
+
+static inline struct zoran *videocodec_to_zoran(struct videocodec *codec)
+{
+   struct videocodec_master *master = codec->master_data;
+
+   return videocodec_master_to_zoran(master);
+}
+
 #endif /*ifndef __LINUX_VIDEOCODEC_H */
diff --git a/drivers/staging/media/zoran/zoran.h 
b/drivers/staging/media/zoran/zoran.h
index 42b86356c022..674658154e88 100644
--- a/drivers/staging/media/zoran/zoran.h
+++ b/drivers/staging/media/zoran/zoran.h
@@ -20,6 +20,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
-- 
2.35.1



___
Mjpeg-users mailing list
Mjpeg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mjpeg-users


[Mjpeg-users] [PATCH v2 2/4] staging: media: zoran: setup videocodec header for debugging macros

2022-04-25 Thread Ian Cowan
This adds inline functions in the videocodec header file to convert the
videocodec and videocodec_master structs to their respective contained
zoran struct. This will be used to pass the zoran struct to the
zrdev_XXX() macros defined in the zoran header.

In the zoran header, the new include is added to ensure all variables
can be completely defined with the zoran and videocodec includes where
they are located.

Signed-off-by: Ian Cowan 
---
 drivers/staging/media/zoran/videocodec.h | 15 +++
 drivers/staging/media/zoran/zoran.h  |  1 +
 2 files changed, 16 insertions(+)

diff --git a/drivers/staging/media/zoran/videocodec.h 
b/drivers/staging/media/zoran/videocodec.h
index 9dea348fee40..5e6057edd339 100644
--- a/drivers/staging/media/zoran/videocodec.h
+++ b/drivers/staging/media/zoran/videocodec.h
@@ -307,4 +307,19 @@ extern int videocodec_unregister(const struct videocodec 
*);
 
 int videocodec_debugfs_show(struct seq_file *m);
 
+#include "zoran.h"
+static inline struct zoran *videocodec_master_to_zoran(struct 
videocodec_master *master)
+{
+   struct zoran *zr = master->data;
+
+   return zr;
+}
+
+static inline struct zoran *videocodec_to_zoran(struct videocodec *codec)
+{
+   struct videocodec_master *master = codec->master_data;
+
+   return videocodec_master_to_zoran(master);
+}
+
 #endif /*ifndef __LINUX_VIDEOCODEC_H */
diff --git a/drivers/staging/media/zoran/zoran.h 
b/drivers/staging/media/zoran/zoran.h
index 42b86356c022..674658154e88 100644
--- a/drivers/staging/media/zoran/zoran.h
+++ b/drivers/staging/media/zoran/zoran.h
@@ -20,6 +20,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
-- 
2.35.1



___
Mjpeg-users mailing list
Mjpeg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mjpeg-users


[Mjpeg-users] [PATCH v2 4/4] staging: media: zoran: replace dprintk with new debugging macros

2022-04-25 Thread Ian Cowan
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 
---
 drivers/staging/media/zoran/videocodec.c |  55 --
 drivers/staging/media/zoran/zr36016.c|  60 +--
 drivers/staging/media/zoran/zr36050.c| 131 +++
 drivers/staging/media/zoran/zr36060.c|  74 ++---
 4 files changed, 143 insertions(+), 177 deletions(-)

diff --git a/drivers/staging/media/zoran/videocodec.c 
b/drivers/staging/media/zoran/videocodec.c
index cabb291d302c..64ca3efbd3f5 100644
--- a/drivers/staging/media/zoran/videocodec.c
+++ b/drivers/staging/media/zoran/videocodec.c
@@ -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;
@@ -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)
@@ -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;
@@ -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;
@@ -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__);
@@ -141,7 +132,7 @@ 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 {
zrd