linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "linux-os \(Dick Johnson\)" <linux-os@analogic.com>
To: "Aritz Bastida" <aritzbastida@gmail.com>
Cc: "Greg KH" <greg@kroah.com>, <linux-kernel@vger.kernel.org>
Subject: Re: Right way to configure a driver? (sysfs, ioctl, proc, configfs,....)
Date: Wed, 1 Feb 2006 10:11:11 -0500	[thread overview]
Message-ID: <Pine.LNX.4.61.0602010959580.16044@chaos.analogic.com> (raw)
In-Reply-To: <7d40d7190602010619g20be73c5k@mail.gmail.com>


On Wed, 1 Feb 2006, Aritz Bastida wrote:

> Hi!
>
>> At the risk of the obvious....
>>
>>         struct meminfo meminfo;
>>          ioctl(fd, UPDATE_PARAMS, &meminfo);
>>
>> ... and define UPDATE_PARAMS and other function codes to start
>> above those normally used by kernel stuff so that `strace` doesn't
>> make up stories.
>>
>> This is what the ioctl() interface is for. Inside the kernel
>> you can use spinlocks (after you got the data from user-space)
>> to make the operations atomicc.
>>
>
> Well, actually that's more or less what I had done before, and it
> worked. I had a group of ioctl commands for configuring my device. The
> command number was based on an unusded "magic number", as I was told
> when reading Linux Device Drivers 3rd:
>
> #define SCULL_IOCSQUANTUM _IOW(SCULL_IOC_MAGIC,  1, int)
> #define SCULL_IOCSQSET        _IOW(SCULL_IOC_MAGIC,  2, int)
>

This is not good. If you change your kernel, you would have to
recompile your applications as well. The ioctl() command value
needs to be a constant that doesn't change when kernel headers
change.

> This actually works, but it doesnt seem to be "ellegant" code for new
> drivers in 2.6. Or at least that's what it says in LDD3, since the
> ioctls are system wide, unstructured, and so on.
>

Ioctls() contain a unique file-descriptor that means it's for your
device only, not something "system wide". I noticed some bugs with
some kernel version where all ioctls seemed to be treated the same
like a function meant for my device could actually do something
to a terminal. If this still exists, it's a bug. I don't know
if these bugs still exist.

> That's why I was asking for a more ellegant and cleaner configuration
> method. It seems that the new filesystem "configfs" is perfect for
> that, but I would like to know if netlink sockets can also be used for
> that purpose (as I'm writing a kind of network device).
>

Well ellegant isn't necessarily better, just different. The writers
of sysfs want you to use their interface, the writers of xxxfs
want you to use their interface,... etc. Ioctls are forever.
They will exist as long as there is a kernel. Even network
manipulating things like ethtool, ifconfig, and route use
ioctls.

> Thank you anyway
> Regards
>
> Aritz
>

Cheers,
Dick Johnson
Penguin : Linux version 2.6.13.4 on an i686 machine (5589.66 BogoMips).
Warning : 98.36% of all statistics are fiction.
_
To unsubscribe


****************************************************************
The information transmitted in this message is confidential and may be privileged.  Any review, retransmission, dissemination, or other use of this information by persons or entities other than the intended recipient is prohibited.  If you are not the intended recipient, please notify Analogic Corporation immediately - by replying to this message or by sending an email to DeliveryErrors@analogic.com - and destroy all copies of this information, including any attachments, without reading or disclosing them.

Thank you.

      reply	other threads:[~2006-02-01 15:11 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-26 20:06 Right way to configure a driver? (sysfs, ioctl, proc, configfs,....) Aritz Bastida
2006-01-27  5:01 ` Greg KH
2006-01-27 10:30   ` Aritz Bastida
     [not found]     ` <69304d110601270834q5fa8a078m63a7168aa7e288d1@mail.gmail.com>
2006-01-30 11:23       ` Aritz Bastida
2006-01-30 21:39         ` Greg KH
2006-02-01 14:54           ` Jan Engelhardt
2006-02-01 15:11             ` Greg KH
2006-02-01 15:44               ` Aritz Bastida
2006-02-01 16:17                 ` Jan Engelhardt
2006-02-02  6:31               ` Neil Brown
2006-01-30 21:41     ` Greg KH
2006-02-01 13:37       ` Aritz Bastida
2006-02-01 13:53         ` linux-os (Dick Johnson)
2006-02-01 14:19           ` Aritz Bastida
2006-02-01 15:11             ` linux-os (Dick Johnson) [this message]

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=Pine.LNX.4.61.0602010959580.16044@chaos.analogic.com \
    --to=linux-os@analogic.com \
    --cc=aritzbastida@gmail.com \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.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).