From: Greg KH on
On Mon, Jun 14, 2010 at 09:34:15AM +0300, Henri H�kkinen wrote:
> Cleaned up and fixed coding convention issues as reporteed by
> checkpatch.pl tool on the file `drivers.c'. Added logging macros
> to `comedidev.h'. Replaced "BUG:" printk functions calls with
> BUG_ON macro.
>
> Signed-off-by: Henri H�kkinen <henuxd(a)gmail.com>
> ---
> drivers/staging/comedi/comedidev.h | 54 +++++++++++++++-
> drivers/staging/comedi/drivers.c | 118 +++++++++++++++--------------------
> 2 files changed, 102 insertions(+), 70 deletions(-)
>
> diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h
> index 4eb2b77..5c78564 100644
> --- a/drivers/staging/comedi/comedidev.h
> +++ b/drivers/staging/comedi/comedidev.h
> @@ -43,11 +43,59 @@
>
> #include "comedi.h"
>
> -#define DPRINTK(format, args...) do { \
> - if (comedi_debug) \
> - printk(KERN_DEBUG "comedi: " format , ## args); \
> +#define comedi_printk(level, fmt, args...) \
> + printk(level "comedi: " pr_fmt(fmt), ##args)
> +
> +#define DPRINTK(format, args...) \
> +do { \
> + if (comedi_debug) \
> + comedi_printk(KERN_DEBUG, fmt, ##args); \
> } while (0)
>
> +#define comedi_emerg(fmt, ...) \
> + comedi_printk(KERN_EMERG, fmt, ##__VA_ARGS__)

I'd much rather you use the real dev_printk() versions of this instead
(dev_warn, dev_err, etc.) instead of creating a new macro.

thanks,

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Greg KH on
On Sat, Jun 12, 2010 at 10:30:50PM -0700, Joe Perches wrote:
> On Sat, 2010-06-12 at 22:07 -0700, Joe Perches wrote:
> > 2: Create some comedi logging functions or macros like:
> > comedi_<level>(fmt, arg...) (ie: comedi_info, comedi_err, etc)
> > where "comedi:" is always prefixed and an
> > optional #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> > could be used.
>
> Maybe this is a start:
>
> Signed-off-by: Joe Perches <joe(a)perches.com>
> ---
> drivers/staging/comedi/comedidev.h | 54 ++++++++++++++++++++++++++++++++++--
> 1 files changed, 51 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h
> index 4eb2b77..6c2bdde 100644
> --- a/drivers/staging/comedi/comedidev.h
> +++ b/drivers/staging/comedi/comedidev.h
> @@ -43,11 +43,59 @@
>
> #include "comedi.h"
>
> -#define DPRINTK(format, args...) do { \
> - if (comedi_debug) \
> - printk(KERN_DEBUG "comedi: " format , ## args); \
> +#define comedi_printk(level, fmt, args...) \
> + printk(level "comedi: " pr_fmt(fmt), ##args)
> +
> +#define DPRINTK(format, args...) \
> +do { \
> + if (comedi_debug) \
> + comedi_printk(KERN_DEBUG, fmt, ##args); \
> } while (0)
>
> +#define comedi_emerg(fmt, ...) \
> + comedi_printk(KERN_EMERG, fmt, ##__VA_ARGS__)

I would prefer the conversion of everything over to the dev_printk()
versions instead of creating a new macro for every individual subsystem.
That way you get the advantage of logging everything in the common
format and the dynamic debug functionality as well.

thanks,

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Joe Perches on
On Thu, 2010-06-17 at 15:51 -0700, Greg KH wrote:
> On Sat, Jun 12, 2010 at 10:30:50PM -0700, Joe Perches wrote:
> > On Sat, 2010-06-12 at 22:07 -0700, Joe Perches wrote:
> > > 2: Create some comedi logging functions or macros like:
> > > comedi_<level>(fmt, arg...) (ie: comedi_info, comedi_err, etc)
> > > where "comedi:" is always prefixed and an
> > > optional #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> > > could be used.

> I would prefer the conversion of everything over to the dev_printk()
> versions instead of creating a new macro for every individual subsystem.
> That way you get the advantage of logging everything in the common
> format and the dynamic debug functionality as well.

What I posted has dynamic_debug.

+#elif defined(CONFIG_DYNAMIC_DEBUG)
+/* dynamic_pr_debug() uses pr_fmt() internally so we don't need it here */
+#define comedi_debug(fmt, ...) \
+ dynamic_pr_debug(fmt, ##__VA_ARGS__)

As far as I know, comedi doesn't always take a struct device *.
I believe it's only used when there's a DMA.

In struct comedi_device, there are two struct device *'s.

struct device *class_dev;
....
struct device *hw_dev;


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Greg KH on
On Thu, Jun 17, 2010 at 04:15:58PM -0700, Joe Perches wrote:
> On Thu, 2010-06-17 at 15:51 -0700, Greg KH wrote:
> > On Sat, Jun 12, 2010 at 10:30:50PM -0700, Joe Perches wrote:
> > > On Sat, 2010-06-12 at 22:07 -0700, Joe Perches wrote:
> > > > 2: Create some comedi logging functions or macros like:
> > > > comedi_<level>(fmt, arg...) (ie: comedi_info, comedi_err, etc)
> > > > where "comedi:" is always prefixed and an
> > > > optional #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> > > > could be used.
>
> > I would prefer the conversion of everything over to the dev_printk()
> > versions instead of creating a new macro for every individual subsystem.
> > That way you get the advantage of logging everything in the common
> > format and the dynamic debug functionality as well.
>
> What I posted has dynamic_debug.
>
> +#elif defined(CONFIG_DYNAMIC_DEBUG)
> +/* dynamic_pr_debug() uses pr_fmt() internally so we don't need it here */
> +#define comedi_debug(fmt, ...) \
> + dynamic_pr_debug(fmt, ##__VA_ARGS__)
>
> As far as I know, comedi doesn't always take a struct device *.
> I believe it's only used when there's a DMA.

No, there's a struct device down in the device almost always.

> In struct comedi_device, there are two struct device *'s.
>
> struct device *class_dev;
> ...
> struct device *hw_dev;

hw_dev is what we want to use.

thanks,

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Joe Perches on
On Thu, 2010-06-17 at 16:28 -0700, Greg KH wrote:
> On Thu, Jun 17, 2010 at 04:15:58PM -0700, Joe Perches wrote:
> > On Thu, 2010-06-17 at 15:51 -0700, Greg KH wrote:
> > > On Sat, Jun 12, 2010 at 10:30:50PM -0700, Joe Perches wrote:
> > > > On Sat, 2010-06-12 at 22:07 -0700, Joe Perches wrote:
> > > > > 2: Create some comedi logging functions or macros like:
> > > > > comedi_<level>(fmt, arg...) (ie: comedi_info, comedi_err, etc)
> > > > > where "comedi:" is always prefixed and an
> > > > > optional #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> > > > > could be used.
> >
> > > I would prefer the conversion of everything over to the dev_printk()
> > > versions instead of creating a new macro for every individual subsystem.
> > > That way you get the advantage of logging everything in the common
> > > format and the dynamic debug functionality as well.
> >
> > What I posted has dynamic_debug.
> >
> > +#elif defined(CONFIG_DYNAMIC_DEBUG)
> > +/* dynamic_pr_debug() uses pr_fmt() internally so we don't need it here */
> > +#define comedi_debug(fmt, ...) \
> > + dynamic_pr_debug(fmt, ##__VA_ARGS__)
> >
> > As far as I know, comedi doesn't always take a struct device *.
> > I believe it's only used when there's a DMA.
>
> No, there's a struct device down in the device almost always.
>
> > In struct comedi_device, there are two struct device *'s.
> >
> > struct device *class_dev;
> > ...
> > struct device *hw_dev;
>
> hw_dev is what we want to use.

Perhaps Ian or Frank might clarify if
that's reasonable. It doesn't look like
it to me.

Look at comedi_set_hw_dev.
See how often it's used?


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/