linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mike Murphy <mamurph@cs.clemson.edu>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org,
	linux-usb@vger.kernel.org, greg@kroah.com, oliver@neukum.org,
	fweisbec@gmail.com, torvalds@linux-foundation.org
Subject: Re: PATCH [1/3] drivers/input/xpad.c: Improve Xbox 360 wireless support and add sysfs interface
Date: Mon, 2 Mar 2009 17:27:41 -0500	[thread overview]
Message-ID: <5aa163d00903021427v4088e29alac4350f9006d5a35@mail.gmail.com> (raw)
In-Reply-To: <20090302140014.47b60178.akpm@linux-foundation.org>

On Mon, Mar 2, 2009 at 5:00 PM, Andrew Morton <akpm@linux-foundation.org> wrote:
>
> Yup, there's lots of crappy code in the tree, and it is regrettable
> that maintainers continue to go ahead and merge that crappy code.
>
> There's no easy fix for this - you need to be aware of what is right
> and what is wrong, but you cannot look at existing code to determine
> this :(

Part of the problem is that this is the first driver I've really
worked on to any extent... and all my formal kernel hacking training
was on FreeBSD, not Linux. Given the speed at which kernel development
moves, lack of good docs on how best to do development, etc., one
simply has to jump into the process and hope for the best. That's
awfully hard to do when kernel hacking isn't your full-time
occupation....

For example, my dissertation is on virtualization of grid computing
systems. I'm doing this driver development simply because I need the
driver for my own use... and perhaps one of our affiliated research
groups can use it. In my own research, I use Linux exclusively, but
all the work I do is at such a high level in userspace that I write
all my code in Python. I've taught C programming before and have done
a ton of low-level development in a C dialect for sensor networks
(nesC for TinyOS), so I'm comfortable with it. Even so, the kernel has
its own internal types (hence my unneeded typecasts), and it's not
always clear what type belongs where.

>
> If the code which you're modifying is known (by you) to be wrong then
> there are two schools of thought.  Some people do like to "match the
> existing code".  I disagree with that.  The code's wrong dammit - we
> might as well make the new code "right".  If that results in
> inconsistent-looking code, well, so be it.  We shouldn't have merged
> the wrong code in the first place.
>
>

Agreed on the code being correct, but there always arises that
question about what constitutes "correct" in any given context
(provably dumb things, like dividing by zero, excepted). For example,
I broke the xpad driver into two pieces to make it easier to
understand. When I go to compile it, the #include "xpad.h" in xpad.c
literally causes the preprocessor to dump the contents of xpad.h into
xpad.c, before handing the result off to the compiler for conversion
to assembly. So the system doesn't really care what goes in which
file... that distinction is left to the humans, who have to establish
some kind of convention. But where is that convention documented?

I could make the argument, for example, that the table of different
Xbox devices and their properties should really go in the header file,
even though it generates an array. That table constitutes metadata
that the driver uses to map device ids to products, so from a software
engineering perspective, it is more of a configuration than an
executable segment. On the other hand, the only piece that really
cares about that data is the driver itself... userspace really only
cares about what type of device is actually connected. So from that
perspective, it belongs in the C file. But then, whose userspace code
is really going to include xpad.h? Circles are fun....

And perhaps this is why we academics tend not to write operating
systems that find their way into widespread use... instead ruminating
on "nicer" designs (perhaps with a microkernel, *cough*) over more
practical solutions :).

Mike
-- 
Mike Murphy
Ph.D. Candidate and NSF Graduate Research Fellow
Clemson University School of Computing
120 McAdams Hall
Clemson, SC 29634-0974 USA
Tel: +1 864.656.2838   Fax: +1 864.656.0145
http://cirg.cs.clemson.edu/~mamurph
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2009-03-02 22:27 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-01  4:53 PATCH [1/3] drivers/input/xpad.c: Improve Xbox 360 wireless support and add sysfs interface Mike Murphy
     [not found] ` <5aa163d00902282053h38b0febbyb37fc30855fdc985-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-03-02 21:04   ` Andrew Morton
2009-03-02 21:18     ` Greg KH
     [not found]       ` <20090302211820.GA21489-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
2009-03-02 21:35         ` Andrew Morton
     [not found]           ` <20090302133551.1266f725.akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
2009-03-02 21:59             ` Greg KH
2009-03-02 21:59           ` Mike Murphy
     [not found]             ` <5aa163d00903021359x3a4693f5tbb7f1e3fec4d88b8-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-03-02 22:39               ` Greg KH
2009-03-02 23:04                 ` Mike Murphy
     [not found]                   ` <5aa163d00903021504l1965ecdi3423a43134de10d0-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-03-02 23:13                     ` Greg KH
2009-03-02 21:46     ` Mike Murphy
2009-03-02 22:00       ` Andrew Morton
2009-03-02 22:27         ` Mike Murphy [this message]
2009-03-03  2:47     ` Mike Murphy
2009-03-03  3:09       ` Mike Murphy
     [not found]       ` <5aa163d00903021847n525e8704jd332610c45e4675a-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-03-03  3:12         ` Linus Torvalds
     [not found]           ` <alpine.LFD.2.00.0903021902460.3111-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2009-03-03  4:16             ` Mike Murphy
     [not found]               ` <5aa163d00903022016s14b7ad32qfbaf82a07b9e0921-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-03-03  4:20                 ` Mike Murphy

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=5aa163d00903021427v4088e29alac4350f9006d5a35@mail.gmail.com \
    --to=mamurph@cs.clemson.edu \
    --cc=akpm@linux-foundation.org \
    --cc=fweisbec@gmail.com \
    --cc=greg@kroah.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=oliver@neukum.org \
    --cc=torvalds@linux-foundation.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).