From: Greg KH <gregkh@linuxfoundation.org>
To: Constantine Shulyupin <const@MakeLinux.com>
Cc: linux-kernel@vger.kernel.org, celinux-dev@lists.celinuxforum.org,
Tim Bird <tim.bird@am.sony.com>, Baruch Siach <baruch@tkos.co.il>,
Thomas Petazzoni <thomas.petazzoni@free-electrons.com>,
Peter Korsgaard <jacmet@sunsite.dk>,
Ezequiel Garcia <elezegarcia@gmail.com>,
Selim TEMUR <selimtemur@gmail.com>,
Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Subject: Re: [PATCH] LDT - Linux Driver Template
Date: Tue, 13 Nov 2012 11:01:23 -0800 [thread overview]
Message-ID: <20121113190123.GA32271@kroah.com> (raw)
In-Reply-To: <1352832397-1349-1-git-send-email-const@MakeLinux.com>
On Tue, Nov 13, 2012 at 08:46:37PM +0200, Constantine Shulyupin wrote:
> +++ b/samples/ltd/ldt.c
> @@ -0,0 +1,764 @@
> +/*
> + * LDT - Linux Driver Template
> + *
> + * Copyright (C) 2012 Constantine Shulyupin http://www.makelinux.net/
> + *
> + * Dual BSD/GPL License
That makes no sense for Linux-specific kernel code, why would you want
it to be dual licensed? Please fix this.
> + * Device Model (class, device)
Don't use class code in an example, it is slowly going away from the
whole kernel.
> +#define ctracer_cut_path(fn) (fn[0] != '/' ? fn : (strrchr(fn, '/') + 1))
> +#define __file__ ctracer_cut_path(__FILE__)
Why is this needed?
> +/*
> + * print_context prints execution context:
> + * hard interrupt, soft interrupt or scheduled task
> + */
> +
> +#define print_context() \
> + pr_debug("%s:%d %s %s 0x%x\n", __file__, __LINE__, __func__, \
> + (in_irq() ? "harirq" : current->comm), preempt_count());
Ick, no, never do that.
> +#define once(exp) do { \
> + static int _passed; if (!_passed) { exp; }; _passed = 1; } while (0)
We have macros for this already.
> +#define check(a) \
> + (ret = a, ((ret < 0) ? pr_warning("%s:%i %s FAIL\n\t%i=%s\n", \
> + __file__, __LINE__, __func__, ret, #a) : 0), ret)
Why?
> +#define pr_debug_hex(h) pr_debug("%s:%d %s %s = 0x%lX\n", \
> + __file__, __LINE__, __func__, #h, (long int)h)
This is not needed at all, just use the proper printk() attribute.
> +#define pr_debug_dec(d) pr_debug("%s:%d %s %s = %ld\n", \
> + __file__, __LINE__, __func__, #d, (long int)d)
Why?
> +#define pr_err_msg(m) pr_err("%s:%d %s %s\n", __file__, __LINE__, __func__, m)
Again, why?
Please don't create your own debugging macros, otherwise people will
copy them. Use the in-kernel ones, as they are the ones everyone should
use. And never use the __file__ things, that looks horrible when
building a kernel and makes no sense.
> +static char ldt_name[] = KBUILD_MODNAME;
Why not just use the macro itself?
> +static int bufsize = PFN_ALIGN(16 * 1024);
Why align?
> +static void *in_buf;
> +static void *out_buf;
> +static int uart_detected;
> +void *port_ptr;
Not static? I'm guessing you didn't run this through sparse?
> +static int port;
> +module_param(port, int, 0);
> +static int port_size;
> +module_param(port_size, int, 0);
> +
> +static int irq;
> +module_param(irq, int, 0);
> +
> +static int loopback;
> +module_param(loopback, int, 0);
No descriptions? Not good.
I've stopped here, I think this has a bunch more work in order to be a
"correct" example in the kernel source tree.
> +MODULE_LICENSE("Dual BSD/GPL");
Note that modules that touch driver core functions, like this one, can't
really be BSD licensed, sorry.
greg k-h
next prev parent reply other threads:[~2012-11-13 19:01 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-13 18:46 [PATCH] LDT - Linux Driver Template Constantine Shulyupin
2012-11-13 19:01 ` Greg KH [this message]
2012-11-13 22:31 ` Constantine Shulyupin
2012-11-13 23:02 ` Greg KH
2012-11-13 23:19 ` Constantine Shulyupin
2012-11-13 23:32 ` Greg KH
2012-11-13 23:51 ` Constantine Shulyupin
2012-11-14 0:14 ` Constantine Shulyupin
2012-11-14 0:48 ` Greg KH
2012-11-14 0:59 ` [Celinux-dev] " Tim Bird
2012-11-14 3:42 ` Ryan Mallon
2012-11-14 13:04 ` Constantine Shulyupin
2012-11-14 11:13 ` Alan Cox
2012-11-16 9:57 ` Jean-Christophe PLAGNIOL-VILLARD
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20121113190123.GA32271@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=baruch@tkos.co.il \
--cc=celinux-dev@lists.celinuxforum.org \
--cc=const@MakeLinux.com \
--cc=elezegarcia@gmail.com \
--cc=jacmet@sunsite.dk \
--cc=linux-kernel@vger.kernel.org \
--cc=plagnioj@jcrosoft.com \
--cc=selimtemur@gmail.com \
--cc=thomas.petazzoni@free-electrons.com \
--cc=tim.bird@am.sony.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.