Re: Convert urb to skbuff

2010-11-30 Thread Greg KH
On Mon, Nov 29, 2010 at 05:43:13PM +0530, Bond wrote:
> On Mon, Nov 29, 2010 at 5:17 PM, sugnan prabhu  
> wrote:
> >
> > Hello,
> >       I am trying to write a kernel module which is the combination of the
> > usb driver and a network driver, now whenever the data is recieved by the
> > usb driver it will be in struct urb, but the data that is required by the
> > net driver is sk_buff, now how do i convert a urb to sk_buff,
> My reply is not a direct answer of your question but it might help you
> to understand.
> In USB driver the read and write is done via making calls to file
> operations which are same for character drivers.
> I.e. the USB end points is some thing you need to understand.
> For a USB driver the device will be reading and writing to the endpoints.
> Hence you need to have  char driver which can create all this for you.

Bond, no, that is totally and completely wrong.

Sugnan, just take the buffer passed back to you from your urb and put it
into a sk_buff.  Look at the existing usb network drivers for examples.

good luck,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: and there's a routine for *sorting* a kernel linked list as well

2010-11-21 Thread Greg KH
On Sun, Nov 21, 2010 at 02:23:18AM -0500, Robert P. J. Day wrote:
> 
>   what started off as just some nonchalant poking around in kernel
> data structures has become moderately educational.  i had no idea that
> there is support for *sorting* the nodes of a kernel LL in
> :
> 
> 
> void list_sort(void *priv, struct list_head *head,
>int (*cmp)(void *priv, struct list_head *a,
>   struct list_head *b));
> 
> 
>   doesn't seem to be a lot of folks using that:

It's very new.  The drm code needed it, so they took it from the xfs
code and made it common code.

>   i wonder how much kernel code manually sorts a linked list, not
> realizing that there's kernel library support for that.

Hopefully none other, if you find some please feel free to convert it to
use the core code.

thanks,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: CONFIG_DEBUG_FS and -ENODEV

2010-11-21 Thread Greg KH
On Sun, Nov 21, 2010 at 03:59:07PM +0300, Vasiliy Kulikov wrote:
> Hi all,
> 
> 
> In include/linux/debugfs.h there is a comment:
> 
> /* 
>  * We do not return NULL from these functions if CONFIG_DEBUG_FS is not 
> enabled
>  * so users have a chance to detect if there was a real error or not.  We 
> don't
>  * want to duplicate the design decision mistakes of procfs and devfs again.
>  */
> 
> If CONFIG_DEBUG_FS is not enabled then all debugfs functions return
> -ENODEV.  However, implementations doesn't check return codes with
> IS_ERR(), but with (ret == NULL).  Is this done exactly to "spoof"
> drivers and make them think that there is a debugfs?  Then the full
> cycle of debugfs will be dummy.
> 
> AFAIU, this is done to make drivers differ e.g. OOM situations (this is
> critical one) and no debugfs (not critical).  Is it correct?

Yes.

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: Pointers for porting a network driver

2010-11-11 Thread Greg KH

A: No.
Q: Should I include quotations after my reply?

http://daringfireball.net/2007/07/on_top

On Fri, Nov 12, 2010 at 01:05:22AM +0530, Ans_linux wrote:
> Hi Greg,
> 
> Thanks for the response.
> 
> I don't really know why the driver left out from mainline kernel. I am
> planning to merge it once I port it to latest kernel.

Have a pointer to the code right now?

> BTW anybody documents which can help me in porting driver. I am bit new
> to Linux kernel development.

Again, look at the kernel git tree to find the exact changes that have
happened during the years since the code was last touched.  You will
not find an exact document other than that.

good luck,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: Pointers for porting a network driver

2010-11-11 Thread Greg KH
On Thu, Nov 11, 2010 at 12:30:35PM +0530, Ans_linux wrote:
> Hello guys,
> 
> I have custom network device driver working fine with 2.6.20.1 kernel.  I am
> planning to port the driver to Linux-2.6.36 or higher.

Why isn't this driver in the main kernel tree?  If it is merged then you
would not have to do this work.  Please get it merged so you will not
have to do this again in the future.

> It will be great if somebody can help me with pointers to network API
> changes ,data structure changes ,and other stuffs which I need to take care
> while porting.

All of the changes are provided in the kernel git tree with the changes
provided there.

Just use that and you should be fine.

good luck,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: Why to not mark struct pci_driver

2010-11-02 Thread Greg KH
On Tue, Nov 02, 2010 at 05:50:33PM +0530, Bond wrote:
> http://lxr.linux.no/#linux+v2.6.36/Documentation/PCI/pci.txt#L197
> What is meant by marking strcut pci_driver as the above link says not
> to mark it.

Don't mark it as __init or __exit or with any other attribute.  See the
text above the bullet for what the different bullet points are for.

thanks,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: where is usb driver file system

2010-11-01 Thread Greg KH
On Mon, Nov 01, 2010 at 11:23:22PM +0530, Tapas Mishra wrote:
> On Mon, Nov 1, 2010 at 7:26 PM, Greg KH  wrote:
> >
> > It's no longer mounted at /proc/bus/usb as it's not needed there
> > anymore.
> >
> > But if you want to, you can mount it anywhere you want:
> > ? ? ? ?mount -t usbfs none /home/foo/usbfs
> >
> > What do you want to do with it?
> >
> Nothing just learning to write drivers for USB and Network Drivers.

You don't need to use usbfs for that, so don't worry about it.

thanks,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: where is usb driver file system

2010-11-01 Thread Greg KH
On Mon, Nov 01, 2010 at 07:11:52PM +0530, Tapas Mishra wrote:
> I checked this link
> http://www.linux-usb.org/USB-guide/x173.html
> excerpts from above page
>  "The USB device filesystem is a dynamically generated filesystem,
> similar to the /proc filesystem. This filesystem can be mounted just
> about anywhere, however it is customarily mounted on /proc/bus/usb,
> whi"
> 
> and went to see /proc/bus
> but the directories were not there as they have mentioned.
> Can some one point me to right direction.

It's no longer mounted at /proc/bus/usb as it's not needed there
anymore.

But if you want to, you can mount it anywhere you want:
mount -t usbfs none /home/foo/usbfs

What do you want to do with it?

thanks,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: looking for corrections/enhancements/omissions for LKD3

2010-11-01 Thread Greg KH
On Mon, Nov 01, 2010 at 11:52:25AM +0700, Mulyadi Santosa wrote:
> Hi Greg...
> 
> On Mon, Nov 1, 2010 at 10:21, Greg KH  wrote:
> > On Sun, Oct 31, 2010 at 08:18:52AM -0400, Robert P. J. Day wrote:
> >> > Also, I saw XIP in ext2 filesystem. Quite neat..but again, why?
> >>
> >> ? hmmm ... not sure, i'll look into that.
> >
> > So you can run Linux on a system with very limited amount of ram and
> > your code running in rom or flash.
> 
> 
> Make senses to me...thanks for the explanation greg. Anyway, why ext3
> doesn't have similar feature?

Maybe because no one created it yet?

thanks,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: looking for corrections/enhancements/omissions for LKD3

2010-11-01 Thread Greg KH
On Sun, Oct 31, 2010 at 08:18:52AM -0400, Robert P. J. Day wrote:
> > Also, I saw XIP in ext2 filesystem. Quite neat..but again, why?
> 
>   hmmm ... not sure, i'll look into that.

So you can run Linux on a system with very limited amount of ram and
your code running in rom or flash.

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: USB driver (hello usb driver)

2010-10-25 Thread Greg KH
On Mon, Oct 25, 2010 at 08:57:49PM +0530, Bond wrote:
> On Sun, Oct 24, 2010 at 9:24 PM, Greg KH  wrote:
> >
> > Yes, look at the hid driver blacklist.
> >
> >> so that it checks my driver and if it doesn't find it, then pass it to
> >> the usbhid?
> >
> > If your driver is loaded first, yes, you can do that.
> >
> > You can unbind the device from the hid driver by hand through sysfs and
> > then load your driver for testing.
> >
> Okay, i found my device in /dev/bus/usb/devices/usb6/6-1. When I nano
> idVendor, i see the correct vendor, and when i nano idProduct, i see
> the correct product. So it's definately there, but I think the problem
> is that usbhid is catching it before my module does. how would i
> unload the device and test like you stated?

Use the unbind file in sysfs for the usb hid driver to unbind the device
from the driver.

good luck,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: creating a device special file

2010-10-24 Thread Greg KH
On Sun, Oct 24, 2010 at 05:06:31PM +0200, fabio de francesco wrote:
> I meant to do that from a device driver, not from user space!

Userspace is the thing that is creating that device link in the first
place through udev.  So that is how you need to change this, write a
udev rule.

thanks,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: USB driver (hello usb driver)

2010-10-24 Thread Greg KH
On Sun, Oct 24, 2010 at 09:55:17AM +0530, Bond wrote:
> On Fri, Oct 22, 2010 at 6:01 AM, Greg KH  wrote:
> > On Wed, Oct 20, 2010 at 10:49:33PM +0530, Bond wrote:
> >> ?So, I got it to recognize the driver in the kernel, but it refuses to
> >> probe. No matter that vendor/product id combination I use for any of
> >> the devices I've tested.
> >
> > Are you using device ids of existing devices that already have drivers
> > bound to them? ?If so, don't do that :)
> >
> 
> IT's a game pad so it might be bound to the joystick service?

You can see if it is, look in sysfs, or in /sys/kernel/usb/devices

>  is there a way to "supercede" the usbhid driver?

Yes, look at the hid driver blacklist.

> so that it checks my driver and if it doesn't find it, then pass it to
> the usbhid?

If your driver is loaded first, yes, you can do that.

You can unbind the device from the hid driver by hand through sysfs and
then load your driver for testing.

good luck,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: USB driver (hello usb driver)

2010-10-21 Thread Greg KH
On Wed, Oct 20, 2010 at 10:49:33PM +0530, Bond wrote:
>  So, I got it to recognize the driver in the kernel, but it refuses to
> probe. No matter that vendor/product id combination I use for any of
> the devices I've tested.

Are you using device ids of existing devices that already have drivers
bound to them?  If so, don't do that :)

good luck,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: Laptop extras for unsupported laptop brand

2010-10-11 Thread Greg KH
On Mon, Oct 11, 2010 at 10:47:09AM +0300, Ali Polatel wrote:
> On Sun, 10 Oct 2010 23:43:24 +0700, Mulyadi Santosa 
>  wrote:
> > Hi Ali...
> > 
> > On Sun, Oct 10, 2010 at 23:09, Ali Polatel  wrote:
> > > Well xbacklight doesn't work at all on this box:
> > > $> xbacklight
> > > No outputs have backlight property
> > 
> > Great :(
> > 
> > Well, perhaps the first thing you need to do is see the complete
> > output of "lshw" and then discuss it with people like Greg Kroah
> > Hartman. Fortunately, he's in kernelnewbies too :)
> 
> Adding Greg to CC.
> Greg, can you help me add support for this laptop? at least pointers
> about where to start will help greatly.

What laptop are you referring to here?

And unless you have the specs from the manufacturer, or can do a lot of
reverse engineering of the hardware using kvm or vmware, you are going
to have a hard time writing a new driver for it.

good luck,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: Submitting a USB device driver to 2.6 kernel

2010-10-09 Thread Greg KH
On Thu, Oct 07, 2010 at 05:50:03PM -0400, Tek Xtc wrote:
> I have developed a USB driver and tested it with my USB devices.

Great, what type of device/driver have you written?

> I want to submit the file to the kernel source. How do I do this?

Read Documenation/SubmittingPatches and send the patch to the
linux-...@vger.kernel.org list and cc: the Linux USB maintainer (i.e.
me.)

thanks,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: where is usb_interface defined

2010-09-19 Thread Greg KH
On Sun, Sep 19, 2010 at 11:21:17AM +0530, Bond wrote:
> On Sun, Sep 19, 2010 at 3:52 AM, Greg KH  wrote:
> 
> >
> > Also note the age of that presentation, a much newer version can be
> > found on github, along with the code examples.
> >
> Can you give me a link I am new to all these things I was searching to
> write device drivers found your USB driver code
> started understanding that with what ever information I had.

http://github.com/gregkh/kernel-tutorial


--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: where is usb_interface defined

2010-09-18 Thread Greg KH
On Sun, Sep 19, 2010 at 02:23:54AM +0530, Bond wrote:
> On Sun, Sep 19, 2010 at 12:35 AM, Greg KH  wrote:
> 
> > I suggest you use a tool like 'grep', 'ack', 'cgvg', 'ctags', or
> > 'cscope' for future questions like this.  They are all good at finding
> >
> I have used csope but what to search that I am not clear.

I am not clear as to what you are asking, please be specific.

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: where is usb_interface defined

2010-09-18 Thread Greg KH
On Sun, Sep 19, 2010 at 02:35:32AM +0530, Bond wrote:
> On Sun, Sep 19, 2010 at 2:23 AM, Bond  wrote:
> 
> >
> >
> > On Sun, Sep 19, 2010 at 12:35 AM, Greg KH  wrote:
> >
> >> I suggest you use a tool like 'grep', 'ack', 'cgvg', 'ctags', or
> >> 'cscope' for future questions like this.  They are all good at finding
> >>
> > I have used csope but what to search that I am not clear.
> >
> For example on that page
> you used a function dev_info
> http://www.kroah.com/linux/talks/ols_2005_driver_tutorial/mgp00010.html
> I used cscope and got at least 28 lines
> not sure if
> struct dev_info {
> mdk_rdev_t  *rdev;
> sector_tend_sector;
> };
> is the structure you are pointing to.

dev_info() is a function, and the code uses it like that, why would you
be searching for a structure?

> I have read your book LDD first 5 chapters and still reading more.
> Is this dev in your presentation same as described in your book.

What "dev"?

Also note the age of that presentation, a much newer version can be
found on github, along with the code examples.

good luck,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: where is usb_interface defined

2010-09-18 Thread Greg KH
On Wed, Sep 15, 2010 at 08:56:28AM +0530, Bond wrote:
> I am trying my hands at usb driver
> http://www.kroah.com/linux/talks/ols_2005_driver_tutorial/mgp00010.html
> can some one point me where is struct usb_interface defined.

include/linux/usb.h in the kernel source tree.

> I have going through a lot of lines but I could not find it.

I suggest you use a tool like 'grep', 'ack', 'cgvg', 'ctags', or
'cscope' for future questions like this.  They are all good at finding
where things are in large bodies of code.

good luck,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: Concurrent accesses to sysfs

2010-09-06 Thread Greg KH
On Mon, Sep 06, 2010 at 09:23:06AM +0200, Christophe Aeschlimann wrote:
> On 04.09.2010 02:58, Greg KH wrote:
> > On Tue, Aug 24, 2010 at 11:52:07AM +0200, Christophe Aeschlimann wrote:
> >> Hi,
> >>
> >> I'm implementing a user-space API that will give access to
> >> custom hardware features through sysfs. This library is here
> >> to hide the sysfs specifics.
> > 
> > Ick, don't.
> > 
> > What's wrong with the existing sysfs interfaces we have today, open(),
> > read(), close()?
> > 
> > And what type of hardware features are you wanting to export through
> > sysfs?  Why sysfs?
> 
> Well we have to offer a board-support-package to a customer. When I told
> them about sysfs to access LEDS / GPIOS they told me they wanted some layer 
> above that so they can just call a "switch_led_on" function and they 
> wouldn't have to know the way sysfs works. E.G. Know the sysfs path name,
> attributes names and values to write to the attributes to control the device.

{sigh}  Ok, then write a tiny shell script that does this :)

> >> I would like to know if something special must be done in
> >> this library to assure concurrent accesses.
> >>
> >> Here is an example :
> >>
> >> I want the users of my library to be able to switch-on/-off a LED using
> >> a simple function like the following :
> >>
> >> platform_led_on(0); //switches on led '0'
> >> platform_led_off(0); //switches on led '0'
> >>
> >> This led is declared in my platform_data in the board init file as a
> >> gpio_led and can be seen in sysfs under /sys/class/leds/led0
> >>
> >> the platform_led_on/off(0) functions will :
> >>
> >> - build the sysfs path to the led0 based on the argument (0)
> >> - open the brightness file in the sysfs path
> >> - write to the brightness file a value != 0 to switch the led on or 0 to 
> >> switch it off
> >> - close the brightness file
> >> - return
> >>
> >> Now what will happen if a thread tries to switch on the led while another
> >> thread tries to switch it off ?
> > 
> > Who ever writes to the file first will cause their action to happen,
> > followed by the action of the second process/thread.
> 
> What happens with the open() on sysfs pseudo files ?

The file descriptor is returned, what exactly are you worried about
here?

> Can the file be opened twice ? 

Yes, multiple times, try it.

> Or does it requires a close first ?

Nope.

> > If you need locking, do it in your library, but again, this really looks
> > like overkill, why do you need to do all of this?
> 
> Because it's a customer request :)

What type of "locking" are they asking for?

> Is it possible to do the locking with the open() or flock() ? Or should I use 
> pthread mutex ?

open() isn't going to work.

flock() might, haven't tried it though.

a mutex would, if you are controling all access through your library.

But that's really overkill here, right?

> > Oh, and you have looked at libudev, right?
> 
> No I wasn't aware of that lib but I guess :
> 
> udev_device_get_sysattr_value ()
> 
> does the open/read/close for me in a thread-safe way ?

Again, what does "thread-safe" mean here?

The above call opens the file and reads the value and then closes the
file and returns the value to your program.  If someone else went in and
wrote to the file right after reading to it, your read will be stale.

Which is the same thing that would happen with your mutex lock as well,
right?  You aren't going to ever be able to conclusivly say, "Here is
the value, no one else has changed it."

So again, I think you are over thinking this a lot.  Just wrap up the
libudev call if you want, or just point your customer at libudev if they
are writing their own programs.

Or just write a simple shell script :)

good luck,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: Concurrent accesses to sysfs

2010-09-03 Thread Greg KH
On Tue, Aug 24, 2010 at 11:52:07AM +0200, Christophe Aeschlimann wrote:
> Hi,
> 
> I'm implementing a user-space API that will give access to 
> custom hardware features through sysfs. This library is here
> to hide the sysfs specifics.

Ick, don't.

What's wrong with the existing sysfs interfaces we have today, open(),
read(), close()?

And what type of hardware features are you wanting to export through
sysfs?  Why sysfs?

> This library must support multi-threaded accesses.

sysfs handles that just fine.

> I would like to know if something special must be done in
> this library to assure concurrent accesses.
> 
> Here is an example :
> 
> I want the users of my library to be able to switch-on/-off a LED using
> a simple function like the following :
> 
> platform_led_on(0); //switches on led '0'
> platform_led_off(0); //switches on led '0'
> 
> This led is declared in my platform_data in the board init file as a 
> gpio_led and can be seen in sysfs under /sys/class/leds/led0
> 
> the platform_led_on/off(0) functions will :
> 
> - build the sysfs path to the led0 based on the argument (0)
> - open the brightness file in the sysfs path
> - write to the brightness file a value != 0 to switch the led on or 0 to 
> switch it off
> - close the brightness file
> - return
> 
> Now what will happen if a thread tries to switch on the led while another
> thread tries to switch it off ?

Who ever writes to the file first will cause their action to happen,
followed by the action of the second process/thread.

If you need locking, do it in your library, but again, this really looks
like overkill, why do you need to do all of this?

Oh, and you have looked at libudev, right?

thanks,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: Crash on reducing the kernel mem.

2010-09-03 Thread Greg KH
On Fri, Sep 03, 2010 at 12:04:09PM +0530, Prabhu Chawandi wrote:
> Hi all,
> 
>  I am using MIPS processor, with 256 MB RAM. currently I am using 128
> M for drivers and 128 M for Kernel. I tried to allocate more memory
> for Drivers,
> surprisingly I got crash when I reduced kernel memory to 110 M. My
> debugging took me to USB controller, which was not reset in
> bootloader.
> 
> I am not having any clue, why it didnt crash with 128 M ? How reducing
> memory  for kernel bringing it up ?

Perhaps your drivers really needed that much memory.  How are you
"splitting" memory up between drivers and the kernel when the drivers
and kernel all share the same memory areas?

good luck,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: how to add anther file format interpreter to the kernel?

2010-07-09 Thread Greg KH
On Sat, Jul 10, 2010 at 10:11:45AM +0800, Hei Xia wrote:
>  How does wine do it?

The misc interpreter, which is there for whatever you can think of.

good luck,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: how to add anther file format interpreter to the kernel?

2010-07-09 Thread Greg KH
On Fri, Jul 09, 2010 at 03:07:53PM +0800, Hei Xia wrote:
>Hi.
>I want to add anther file format interpreter to the kernel.

Why?  You can do this from userspace today, right?  It shouldn't need to
be in the kernel.

thanks,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: quilt & patch management

2010-07-05 Thread Greg KH
On Fri, Jul 02, 2010 at 05:34:55PM +0530, Onkar Mahajan wrote:
> Please help me with some detailed tutorial on
> Quit utility.

Did you read the quilt documentation?  If so, what specifically are you
having questions about?

thanks,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: simulate a PCI hotplug event?

2010-07-05 Thread Greg KH
On Fri, Jul 02, 2010 at 01:41:45PM -0400, Robert P. J. Day wrote:
> 
>   i'm starting to design a course in how to write a PCI driver, and i
> was looking for kernel support to simulate hotplugging PCI devices,
> and ran across drivers/pci/hotplug/fakephp.c, but that seems to refer
> to a "legacy" feature.  is there a more current feature that lets me
> do this?  thanks.

Nope, that should be good enough, does it not work for you?

But note, that just lets you remove the pci device virtually (not for
real, don't go yanking the device after doing that.)  It doesn't let you
add it back in, you need to reboot to get the device back.

Hm, or was the "rescan the bus" code ever added to fakephp?  I know
there was patches for it floating around, but I can't remember if I ever
merged them or not, sorry.

thanks,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: Which version a patch is added

2010-06-30 Thread Greg KH
On Tue, Jun 29, 2010 at 09:21:34AM +0200, Bjorge Solli wrote:
> Hi, I would like to have a kernel with a specific patch in to my fedora
> 12 machine, but don't know when this patch was included in the kernel.
> How can I figure this out? I only have this info:
> 
> http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=patch;h=462d60577a997aa87c935ae4521bd303733a9f2b

Try:
git describe --contains 462d60577a997aa87c935ae4521bd303733a9f2b

that will show you the release that the git commit id was first in.

hope this helps,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: How to port linux drivers ftom devfs to udev.

2010-06-28 Thread Greg KH
On Mon, Jun 28, 2010 at 10:40:33AM -0700, StephanT wrote:
> 
> 
> >> Your Subject is very generic. 
> 
> Well, my subject says I am looking for a migration/port guide. If you
> have such document I will be very grateful to get a pointer on it.

Again, it all depends on the code.  Some interfaces have changed
radically from the past 8 years, while others, not much at all.

Care to post it?

thanks,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: How to port linux drivers ftom devfs to udev.

2010-06-24 Thread Greg KH
On Thu, Jun 24, 2010 at 02:54:18PM -0700, StephanT wrote:
> 
> > > > You shouldn't need to do anything other than the "normal" 2.4 to  2.6 
> > > > porting.  
> 
> > > I don't know what this "normal" implies.  Hence my question.
> > I don't know what problems you are having, hence my  question :)
> 
> Yet is clearly stated in the subject line.

Specifics please.  Error messages?  Lines you are having problems with?

Your Subject is very generic.  Depending on your code, you might just
have to delete a single line and that's it.  Or you might have to create
a whole class and/or bus subsystem and add devices to it.  It all
depends on your code.

> ---
> 
> > Ok, feel  free to ask questions.
> 
> Here it is: Besides the pointer Arun already sent me do you know of another
> guide "How to port linux drivers from 2.4 to 2.6." ?  

It all depends on the code and what you are doing.  You are trying to
get a simple summary for updating some unknown code, to a codebase that
has evolved by many hundreds of thousands of changes, contributed by
many thousands of different people, for over 8 years.  That's pretty
hard to guess at :)

> > But your drivers can get merged, there's no reason  to keep them out of
> > the tree anymore, we'll take anything :)
> 
> Knowing that:
> 
> 1. If we migrate to 2.6.xx we are going to stay with this 2.6.xx for the next
> 10 years as we stuck to 2.4.18 for the last 10. This is one shot action. We
> just cannot afford to keep up to date with linux kernel.

Then get it in the kernel tree and they will be updated automatically as
stuff changes.

> 2. The drivers have no practical interest for anyone as they are targeted to
> embedded H/W.

Ah, so you are thinking you are unique and special, just like everyone
else, right?

Hint, there's not many "unique" things out there, odds are your code is
useful to others, or perhaps, it could be merged with existing drivers.

> 3. The merge process is not free for us - we'll have to invest an undetermined
> amount of man-hours.

Sure, and again, I, and many others, are willing to help out with this
for free.

> Give me one good reason we would be interested having our stuff in the tree.

See above, and the many other places this is documented in much more
detail.

> ---
> 
> > > For cases like ours would be very, very useful if you, guys would update 
> > > and print LDD V4. 
> 
> > The  wheels on this are slowly moving, but it will be a long time.
> 
> Could you, please give a rough estimate ? And I reiterate the affirmation
> I made above.

Nope, sorry, I can not give any specifics at this time, they are just
too unknown.

Again, just post your code please.  Many more questions can be answered
then.

thanks,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: How to port linux drivers ftom devfs to udev.

2010-06-24 Thread Greg KH
On Wed, Jun 23, 2010 at 03:54:56PM -0700, StephanT wrote:
> 
> 
> >What type of "devfs  driver"?
> character 
> 
> > You shouldn't need to do anything other than the "normal" 2.4 to  2.6 
> > porting.  
> I don't know what this "normal" implies. Hence my question.

I don't know what problems you are having, hence my question :)

> > Do you have a pointer to the driver you need to have ported?
> No. If there is interest I can make them public.

Please do.

> > People will do this work for you, have you seen the linuxdriverproject.org 
> > site?
> No I haven't seen this site. This would be very nice :-) , but I don't think 
> is
> doable.
> 
> Short story: We are using linux 2.4.18 on SH4 architecture. Very specific H/W
> and very different from PC. Linux is used as configuration manager and user
> interface (web). All linux drivers are simple char drivers - mainly to get 
> access 
> to FPGA and DSP. Most of them provide a "mmap" interface to user applications.
> The original port was done by Montavista. They should have made it public
> years ago.

Yeah, we all know about how well Montavista does when it comes to hiding
source, they are wonderful at that :(

> We are looking what would cost to migrate to 2.6. Boss asked for an effort 
> estimation and I had to start from some point. The pointer I got from Arun 
> cleared the way for me to get some numbers. Most of the migration cost is 
> not in driver port but in how we are going to handle a mixed installed
> base.
> 
> Related the the "Linux Driver Project". This is a very nice and generous idea 
> !
> Not for us - unfortunately. Our work is driven by a schedule. Very tight! We 
> do
> not have spare H/W and we are not so rich to pay a person to do interface 
> work.
> It is cheaper to do the work by ourselves and we need to learn to be able to
> maintain/modify/enhance.

Ok, feel free to ask questions.

But your drivers can get merged, there's no reason to keep them out of
the tree anymore, we'll take anything :)

> For cases like ours would be very, very useful if you, guys would update and
> print LDD V4. I can guarantee we will buy at least five copies.

The wheels on this are slowly moving, but it will be a long time.

So, feel free to post the code and we can see how hard it would be to
get it up and working on the latest 2.6 kernel?  If it's just a char
device, it shouldnt' be very hard.

thanks,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: How to port linux drivers ftom devfs to udev.

2010-06-21 Thread Greg KH
On Thu, Jun 10, 2010 at 01:27:05PM -0700, StephanT wrote:
> Hello,
> 
> Is there any User Guide, Tutorial, FAQ, example which explains how to
> port a 2.4 devfs driver to a 2.6 udev one.

What type of "devfs driver"?

You shouldn't need to do anything other than the "normal" 2.4 to 2.6
porting.  Do you have a pointer to the driver you need to have ported?
People will do this work for you, have you seen the
linuxdriverproject.org site?

thanks,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: Read block level storage via kernel modules

2010-04-25 Thread Greg KH
On Sun, Apr 25, 2010 at 08:08:12AM +0530, Naval wrote:
> Thank you very much for replying, I really appreciate your help.
> 
> >Like the one in the kernel already?
> 
> Yes. But i am really unable to figure out how kernel does that.

Read the source to the driver in the kernel that does exactly this
already (hint, it's in drivers/block/nbd.c) and you will see how this
works.

> The request will be received by a server program (user space program) and
> then it has to somehow delegate the request to kernel (i think writing a
> module and a system call myself?). The kernel would access the block device
> and return the data which server would pass to the client which initiated
> the request.

That's much like iscsi as others have pointed out.  If you wish to
reimplement something already done, then look at how those groups did
it, the code is all open.

> >That is because it does not accept html email.  Please fix your client
> and resend.
> 
> Sorry, but I have no idea about such clients. Can you please name one?

Your email client (what you use to send email with).  If it's gmail, go
change the settings on it.

good luck,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: Read block level storage via kernel modules

2010-04-24 Thread Greg KH
On Sun, Apr 25, 2010 at 01:34:01AM +0530, Naval wrote:
> Sir,
> 
>  My intent is to implement a block level storage protocol over network for
> learning purpose, almost the same way SCSI works. Requests will be generated
> by initiator and sent to target (both userspace program) which makes call to
> kernel module and returns the data using TCP protocol to initiator.

Like the one in the kernel already?

> P.S.: 1. Mailing to linux-ker...@vger.kernel.org results in mail delivery
> failure

That is because it does not accept html email.  Please fix your client
and resend.

good luck,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: Best way to communicate to a device.

2010-03-08 Thread Greg KH
On Mon, Mar 08, 2010 at 09:19:27PM +0530, Himanshu Chauhan wrote:
> Hi,
> 
> I have been looking for the best ways user land application can talk to 
> drivers.
> I need a ioctl kind of mechanism. I believe new IOCTL cann't be added to 
> kernel
> without prior permissions (static allocations?). If this is the case what is
> the best way user land application can talk to a driver?

It all depends on what type of driver, and what your communication goals
are (small ammounts of data, high data rates, binary data, etc.)

In short, we need more details.

thanks,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: USB detection

2010-02-14 Thread Greg KH
On Sun, Feb 14, 2010 at 08:05:00AM +0530, Anoop wrote:
> Hi Greg,
> 
> Thanks for reply.
> 
> On Sat, Feb 13, 2010 at 10:02 PM, Greg KH  wrote:
> > On Wed, Feb 10, 2010 at 09:46:42PM +0530, Anoop wrote:
> >> Hi List,
> >>
> >> My system has two USB ports. And I want to know, what is the way to
> >> find, to which USB port the device is plugged in. Moreover what type
> >> of device is it. Can I figure this out from kspace?
> >
> > You want to determine this from another kernel module? ?What is the
> > problem you are trying to solve here?
> My target has two USB ports. I want to write a user space application
> through which I want to provide a interface to user, from where he can
> mount/unmount the device. Also depending upon the device plugged in, I
> want to provide services to the user.

Then you do not need to detect this from within the kernel as you
originally asked, just use udev to notify you of changes here.  Just
like HAL does this already today.

hope this helps,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: USB detection

2010-02-13 Thread Greg KH
On Wed, Feb 10, 2010 at 09:46:42PM +0530, Anoop wrote:
> Hi List,
> 
> My system has two USB ports. And I want to know, what is the way to
> find, to which USB port the device is plugged in. Moreover what type
> of device is it. Can I figure this out from kspace?

You want to determine this from another kernel module?  What is the
problem you are trying to solve here?

thanks,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: Sysfs Device Attributes: Subdirectory under subdirectory

2010-01-30 Thread Greg KH
On Sat, Jan 30, 2010 at 07:24:27PM +0530, Himanshu Chauhan wrote:
> Sorry, I am not quite able to digest this :( 
> Do the USB ports on a system have representation in sysfs?

Um, you can look to see if they do, right?  :)

Hint, no they do not.

> If they do, does each port has a subdirectory of its own?

Nope.

> When I say VHCI ports, I am refering to same kind of USB ports that we
> have on a system to which USB devices can connect. The difference
> being the devices attached on VHCI ports are over IP.

Ah, that's what vhci is, sorry, forgot about usb-ip.

Then you are just fine, use the usb code and you should not have to add
any new support for stuff like this.

With USB, you have a representation in sysfs for the devices that are
attached to the USB bus, which then shows the actual port the device is
connected to.

> The following is the output of "/sys/devices/platform/vhci_hcd/status" file.
> 
> prt sta spd bus dev socket   local_busid
> 000 004 000 000 000  0-0
> 001 004 000 000 000  0-0
> 002 004 000 000 000  0-0
> 003 004 000 000 000  0-0
> 004 004 000 000 000  0-0
> 005 004 000 000 000  0-0
> 006 004 000 000 000  0-0
> 007 004 000 000 000  0-0

That's wrong :)

You should move that to debugfs if you need to watch the status of
things.

> As you can see, I am trying to divide this output in a way that I can
> group sta, spd, bus, dev, socket, local_busid as files under ports[N]
> directory under /sys/devices/platform/vhci_hcd/status

I don't think you need this except for debugging stuff, so put it in
debugfs instead, like the other usb files in debugfs for host
controllers.

> I think ports cannot be taken as "devices" and have their representation
> in sysfs. But I believe they can very well be put under vhci_hcd
> directory as /sys/devices/platform/vhci_hcd/status/port[N]/

Why, who needs to know this information?  "regular" users?

thanks,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: Sysfs Device Attributes: Subdirectory under subdirectory

2010-01-29 Thread Greg KH
On Fri, Jan 29, 2010 at 09:41:21AM +0530, Himanshu Chauhan wrote:
> On Thu, Jan 28, 2010 at 01:11:36PM -0800, Greg KH wrote:
> > On Fri, Jan 29, 2010 at 12:12:31AM +0530, Himanshu Chauhan wrote:
> > > Dear all,
> > > 
> > > I want to create subdirectory under subdirectory in sysfs
> > > for a device.
> > 
> > Ick, don't.
> > 
> > > For example, if vhci_hcd is my device I want
> > > the following hierarchy:
> > > 
> > > vhci_hcd
> > > |
> > > +--> status
> > >|
> > >+--->0
> > >||
> > >|+--> status
> > >||
> > >|+--> speed
> > >||
> > >|+--> device id
> > >||
> > >|+--> socket
> > >||
> > >|+--> busid
> > > 
> > > 
> > > 
> > >|
> > >+--->N
> > > |
> > > +--> status
> > > |
> > > +--> speed
> > > |
> > > +--> device id
> > > |
> > > +--> socket
> > > |
> > > +--> busid
> > 
> > No, you really do not want this.  Why do you feel that you would want to
> > create something that does not fit into the current driver/device model
> > of the kernel?
> > 
> > In short, what specifically are you trying to convey here?
> 
> There are 8 ports exported by VHCI.

What is 'vhci'?

What do you do with a "port"?

> So I want to group the attributes of each port together. 0 to N are
> the port numbers.  All attributes of port zero will be under 0 and all
> attributes of port 1 will be under 1 and so on.

So then make each "port" a device on your bus.  Then the topology
automatically happens for you, no need to mess with "raw" kobjects at
all (which you shouldn't be doing in the first place.)

Can devices be plugged into ports?

> > > So, how do I create subdirectories 0 to N under
> > > status? I created attribute groups from 0 to N,
> > > how do I attach it to status and then in turn,
> > > status to vhci_hcd?
> > 
> > What does these 0-N subdirectories represent?
> > 
> > What does 'status' represent?  Why would status have subdirectories?
> 
> status under VHCI should rather be port_status. So hierarcy would be
> VHCI_HCD->port_status->port_number[0-8]->

Why put the port number below the status?

> > And why in that subdirectory would you have another file called status?
> Status is the status of the port if its connected to the stub on the server.
> 
> If this is not good, what would be the best layout?


HCD->port[N]->attributes

where you have a bus for your HCD, and then port[N] are devices attached
to that bus.

Sound reasonable?

thanks,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: Sysfs Device Attributes: Subdirectory under subdirectory

2010-01-28 Thread Greg KH
On Fri, Jan 29, 2010 at 12:12:31AM +0530, Himanshu Chauhan wrote:
> Dear all,
> 
> I want to create subdirectory under subdirectory in sysfs
> for a device.

Ick, don't.

> For example, if vhci_hcd is my device I want
> the following hierarchy:
> 
> vhci_hcd
> |
> +--> status
>|
>+--->0
>||
>|+--> status
>||
>|+--> speed
>||
>|+--> device id
>||
>|+--> socket
>||
>|+--> busid
> 
> 
> 
>|
>+--->N
> |
> +--> status
> |
> +--> speed
> |
> +--> device id
> |
> +--> socket
> |
> +--> busid

No, you really do not want this.  Why do you feel that you would want to
create something that does not fit into the current driver/device model
of the kernel?

In short, what specifically are you trying to convey here?

> So, how do I create subdirectories 0 to N under
> status? I created attribute groups from 0 to N,
> how do I attach it to status and then in turn,
> status to vhci_hcd?

What does these 0-N subdirectories represent?

What does 'status' represent?  Why would status have subdirectories?

And why in that subdirectory would you have another file called status?

totally confused,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: automatic driver loading functionality in Linux

2010-01-27 Thread Greg KH
On Wed, Jan 27, 2010 at 10:58:59AM +0530, Joel Fernandes wrote:
> Hi Greg.
> 
> > What you want to look at is the modules.alias file. ?That is what makes
> > things so simple, it creates a mapping from a device/product id to the
> > actual module.
> 
> I get the idea now, thanks. So when a device is connected, a modalias
> is generated with the vendor/productid and then modprobe can match
> this against the modalias file to load the module in.

Exactly.

> Does udev do the same thing when it has to autoload a module?

udev just passes this modalias on to modprobe directly, this is how
modprobe sees the alias in the first place.  modprobe is not called
directly by anything else.

hope this helps,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: automatic driver loading functionality in Linux

2010-01-26 Thread Greg KH
On Tue, Jan 26, 2010 at 08:42:20PM +0200, Ozan T??rky??lmaz wrote:
> 26.01.2010 17:42, Greg KH yazm:
>> On Sun, Jan 24, 2010 at 10:49:24AM +0530, Joel Fernandes wrote:
>>> Hi Peter,
>>>
>>> Thanks for your message.
>>> Actually I'm interested in how modprobe autoloads modules based on the
>>> modalias files in sysfs. I read this in Greg KH's great book - Linux Kernel
>>> in a Nutshell and I've been wondering how the modules would get loaded if
>>> they had to be loaded in the first place to have the device->module list to
>>> exist.
>>
>> modprobe is "smart" and knows what modules support what devices based on
>> the cache it creates when you run 'depmod' when a new kernel is
>> installed.
>>
>
> is it possible to get that information (what module determines what
> driver) from modprobe.

Not that I know of, look at the alias file that depmod creates, that
holds the information you need.

Hope this helps,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: automatic driver loading functionality in Linux

2010-01-26 Thread Greg KH
On Tue, Jan 26, 2010 at 11:17:27PM +0530, Joel Fernandes wrote:
> > modprobe is "smart" and knows what modules support what devices based on
> > the cache it creates when you run 'depmod' when a new kernel is
> > installed.
> >
> > That information is found in the drivers themselves.
> >
> > See the modprobe code for details if you wish to know the exact
> > mechanisms involved, it's pretty easy code to understand.
> 
> Hi Greg, Thanks a lot :)
> 
> I just went through the depmod code and it seems that the tables are
> stored in the 'modinfo' section of the ELF object, and depmod extracts
> this and dumps it to a map file. And then udev would do a match with
> this map file whenever a new device is detected and load the required
> module using modprobe. Do you think my analysis is correct?

Close, I don't think the map files are used anymore, and are only around
for backward compatibility.

What you want to look at is the modules.alias file.  That is what makes
things so simple, it creates a mapping from a device/product id to the
actual module.

So then you can do something as simple as:
modprobe 
and modprobe will look at the alias file, and match things up.

For example, when I plug a usb flash device in, I get:
MODALIAS=usb:v154Bp6545d0200dc00dsc00dp00ic08isc06ip50
so you can do:
modprobe usb:v154Bp6545d0200dc00dsc00dp00ic08isc06ip50
looking at the module.alias file, it will match with the usb-storage
module, and load that.

Or it should, I just tried that out and it didn't quite work out, I'm
probably forgetting a step here, but I think you get the general idea.

Hope this helps,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: automatic driver loading functionality in Linux

2010-01-26 Thread Greg KH
On Sun, Jan 24, 2010 at 10:49:24AM +0530, Joel Fernandes wrote:
> Hi Peter,
> 
> Thanks for your message.
> Actually I'm interested in how modprobe autoloads modules based on the
> modalias files in sysfs. I read this in Greg KH's great book - Linux Kernel
> in a Nutshell and I've been wondering how the modules would get loaded if
> they had to be loaded in the first place to have the device->module list to
> exist.

modprobe is "smart" and knows what modules support what devices based on
the cache it creates when you run 'depmod' when a new kernel is
installed.

That information is found in the drivers themselves.

See the modprobe code for details if you wish to know the exact
mechanisms involved, it's pretty easy code to understand.

hope this helps,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: Small patches for Linux kernel

2010-01-26 Thread Greg KH
On Tue, Jan 26, 2010 at 12:41:46PM +0530, Himanshu Chauhan wrote:
> Hi All,
> 
> Where should I send small patches? Patches which address small
> compilation warnings etc. Linux kernel mailing list receives a 
> lot of heavy weight patches and small patches get lost. Which
> is the best place to send, then? Is Kernel Janitor mailing
> list alive?

Use 'scripts/getmaintainer.pl' to determine this, that is what it is
there for.

hope this helps,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: detecting usb host controller type/speed from a gadget driver

2010-01-26 Thread Greg KH
On Sat, Jan 23, 2010 at 12:42:32PM +0530, Arun S wrote:
> Hi,
> From a usb gadget driver, is it possible to detect whether or not a
> usb 1.1/2.0 HOST CONTROLLER? is managing the usb device during
> runtime? I want to use different endpoint descriptors based on this
> info during the setting up of interfaces.

The USB spec does not allow this, sorry.  Please read the documentation
at usb.org for more details.

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: sysfs_ops show vector: size of buffer not required?

2010-01-26 Thread Greg KH
On Tue, Jan 26, 2010 at 12:01:27PM +0530, Himanshu Chauhan wrote:
> On Mon, Jan 25, 2010 at 08:36:46PM -0800, Greg KH wrote:
> > On Sun, Jan 24, 2010 at 01:11:18PM +0530, Himanshu Chauhan wrote:
> > > Hi All,
> > > 
> > > The sysfs_ops's show vector doesn't have a size of the
> > > buffer given to the vector, while store on the other hand
> > > has. What is the rationale behind it?
> > 
> > If you need to check the size, you are doing something wrong.
> > 
> > Seriously, that is the reason.  A sysfs file should be a single value,
> > which will never overflow the buffer.
> > 
> I was talking in context of usb/ip's show_status. It writes a lot of data
> into this buffer.

Then it needs to be fixed.  Again, it must be, one value per file, that
is the sysfs rule.

> Which seems to over flow the buffer. But anyways, I will check if it
> can be reduced or at least be splitted into differnt device
> attributes.

That would be great.

> BTW, Greg, Did you take a look at other patches I had sent? Are are worth or
> I need rework?

They are in my "to-apply" queue that I will be flushing out in the next
few days.

thanks,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: sysfs_ops show vector: size of buffer not required?

2010-01-25 Thread Greg KH
On Sun, Jan 24, 2010 at 01:11:18PM +0530, Himanshu Chauhan wrote:
> Hi All,
> 
> The sysfs_ops's show vector doesn't have a size of the
> buffer given to the vector, while store on the other hand
> has. What is the rationale behind it?

If you need to check the size, you are doing something wrong.

Seriously, that is the reason.  A sysfs file should be a single value,
which will never overflow the buffer.

> I see most of the implementations doing strcpy in the
> show vectors. Ill behaved driver might overwrite the
> given buffer when size is not known. Should this be addressed
> by providing the buffer size along with the buffer pointer?

Nope.

Again, a single value only, it easily fits into the buffer size.

thanks,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: Blacklisting in-kernel drivers

2010-01-23 Thread Greg KH
On Wed, Jan 20, 2010 at 01:54:08PM +0100, luca ellero wrote:
> Hi everybody,
> I'm writing a driver that use a USB mouse as a minimal keyboard (binding 
> mouse buttons to some useful keys: Enter, Tab, ESC or others).
> The problem is the USB mouse driver (integrated into the kernel) takes over 
> the mouse device and so my driver is never bind to it.
> Now, I know how to blacklist a driver if it was a module, but I wonder if 
> there is some easy way to do the same with a "compiled in" driver without 
> recompiling the kernel.

The hid driver has a quirks file you can write to which will keep it
from binding to your device.

You can also unbind a driver from a device by hand through the 'unbind'
file in sysfs in the driver's directory.

In the end, just send a patch to the hid maintainer to add your device
to the quirk list so it doesn't bind to it so you don't have to do this.

good luck,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: browsing the kernel source with ctags?

2010-01-20 Thread Greg KH
On Wed, Jan 20, 2010 at 02:23:04PM -0800, Tony Miller wrote:
> Yeah you're right... ^_^
> 
> I guess ideally, I'd want to find out *which* definition of
> do_gettimeofday() is being used for the function call I'm looking at. Maybe
> cscope would help with that.
> 
> I tried
>make tags
> 
> and then tried to look up do_gettimeofday() again, and I got directed to
> include/linux/time.h, which has the function prototype, which is helpful. It
> would still be even nicer to see the function body, perhaps another tool
> could help with that.

Use cscope, it knows the difference between prototypes and where the
function is defined.

good luck,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: Kernel Build fail on Ubuntu

2010-01-19 Thread Greg KH
On Wed, Jan 20, 2010 at 01:09:30PM +0800, Crossover Lonely wrote:
> Just use mkinitramfs to create kernel image.
> For debian/ubuntu system, mkinitramfs works; while for
> fedora/redhat/slse/opensuse, mkinitrd works.

Use 'make install', it will call the correct thing.  See the 'make help'
documentation for this type of thing.

good luck,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: browsing the kernel source with ctags?

2010-01-19 Thread Greg KH
On Tue, Jan 19, 2010 at 07:13:59PM -0800, Tony Miller wrote:
> Is it possible to browse the kernel source with ctags? I used
> exuberant-ctags to generate a tags file for my kernel sources, but it
> doesn't really work as you expect. If you try to jump to the definition of a
> function it will often not jump to the right location, for example I tried
> to jump to the definition of do_gettimeofday() and i ended up in
> arch/alpha/kernel/time.c.

That is the right place for it :)

The issue is that you are searching all of the different architectures,
how is ctags supposed to know you don't want the alpha definition, but
really the ia64 definition of the function?

You should try to trim the files you are using, the kernel has a build
option for this:
make tags
or if you use cscope:
make cscope

Hope this helps,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: Why the linux does not allow the access to a file in the device driver?

2010-01-14 Thread Greg KH
On Thu, Jan 14, 2010 at 05:48:21PM -0800, Daniel (Youngwhan) Song wrote:
> Hi,
> 
> Could somebody help me to understand the reason why the linux kernel does
> not allow the access to a file in the device driver? For example, for
> debugging purpose, if a device driver want to log some data in a file by
> using open/write/read method like in user application, how a driver can
> access to a file in a specific filesystem? Any comment or docs or web pages
> would be appreciated.

Please read the documentation at kernelnewbies.org for why this is so.

good luck,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: Clear screen from the kernel

2010-01-13 Thread Greg KH
On Wed, Jan 13, 2010 at 07:05:32PM -0300, Diego Woitasen wrote:
> Hi,
>  I want to clear the console before a printk() call. Is there a
> funcion in the kernel API to do it?

No, printk() goes to the kernel log, not the screen.  Yes, it might also
be copied to the console at different times, but it is not a generic
thing.

good luck,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: anyone use "sparse" for static code analysis?

2010-01-08 Thread Greg KH
On Tue, Jan 05, 2010 at 11:06:40AM -0500, Robert P. J. Day wrote:
> 
>   just curious ... i've never taken a close at sparse.  is anyone
> using it for code analysis outside of the linux kernel?

Yes.

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: question about __v annotation

2010-01-05 Thread Greg KH
On Tue, Jan 05, 2010 at 11:00:37PM +0800, Pei Lin wrote:
> i only can think about the reason why not use the inline is that it is
> support by C99 but not support by C89 ANSI C.

No, the Linux kernel supports inline functions, no one builds the kernel
with a C89-only complier, thankfully.

thanks,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: question about __v annotation

2010-01-05 Thread Greg KH
On Tue, Jan 05, 2010 at 12:42:03PM +0100, Bernd Petrovitsch wrote:
> So which is better (in the kernel and for this functions, macros or
> whatever they really maybe!)?
> a) #define readb(c) ((__u8)__raw_readb(__mem_pci(c)))
>which is more a rephrase of the above
> b) static inline __u8 readb(const void *c) { return 
> __raw_readb(__mem_pci(c)); }
> Caveat emptor: Not compile-tested.

Neither is best, use the proper __iomem marking for the memory space,
and use the built-in kernel functions to read and write data to io
space, they are there for a reason, don't try to roll your own.

thanks,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: question about __v annotation

2010-01-05 Thread Greg KH
On Mon, Jan 04, 2010 at 03:32:07PM -0800, Bruce Blinn wrote:
> > -Original Message-
> > From: kernelnewbies-bou...@nl.linux.org 
> > [mailto:kernelnewbies-bou...@nl.linux.org] On Behalf Of Greg KH
> > Sent: Sunday, January 03, 2010 1:27 PM
> > To: Shawn
> > Cc: kernelnewbies@nl.linux.org
> > Subject: Re: question about __v annotation
> > 
> > 
> > On Sat, Jan 02, 2010 at 09:10:08PM +0800, Shawn wrote:
> > > hello guys,
> > >  I got a newbie confused when I was looking into the source code of 
> > > s3c2440's RTC driver.I dont know what is __v excatly 
> > means.anyone can 
> > > tell?thanks anyway!
> > > 
> > > #define readb(c) ({ __u8  __v = __raw_readb(__mem_pci(c)); __v; })
> > 
> > __v is an variable that the macro creates and then returns 
> > the value of.
> > 
> > Don't code like this, it's horrible :)
> > 
> 
> Could you be more specific with what you find wrong with this. The reason I
> ask is there is code like this all over the kernel.

Like what specifically?

Wrapping up a function call in a macro just because someone doesn't want
to type the whole thing out?  That's the horrible thing.

Returning a temporary variable isn't a big deal, but an inline function
is better to use as you will get the proper type safety.

thanks,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: question about __v annotation

2010-01-04 Thread Greg KH
On Sat, Jan 02, 2010 at 09:10:08PM +0800, Shawn wrote:
> hello guys,
>  I got a newbie confused when I was looking into the source code of
> s3c2440's RTC driver.I dont know what is __v excatly means.anyone can
> tell?thanks anyway!
> 
> #define readb(c) ({ __u8  __v = __raw_readb(__mem_pci(c)); __v; })

__v is an variable that the macro creates and then returns the value of.

Don't code like this, it's horrible :)

thanks,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: Probe method vs attach method.

2009-12-15 Thread Greg KH
On Tue, Dec 15, 2009 at 12:04:33PM -0600, LKomz Komz wrote:
> Thanks Pei and Greg. I got it to compile without errors and working by
> moving to the new method.
> One issue though is:-
> 
> Would it be possible to run a usermode driver to access an i2c device when I
> am not exercising the kernel mode driver (i.e without rmmode - ing the
> driver)? (Basically it boils down to can drivers of two nature - i.e kernel
> mode and user mode , access the same part one after the other without any
> problem?)

Without any problem, maybe, but you are taking big chances on doing
that, as they both don't know about the other.

It is generally preferred to only have one controller of the hardware,
be it in the kernel, or in userspace.

So please pick just one.

good luck,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: How to send SCSI command from kernel thread.

2009-12-14 Thread Greg KH
On Mon, Dec 14, 2009 at 05:34:05PM +0530, hari krishnan wrote:
> Hi All,
> 
> I need to send SCSI command asynchronously(Don't want to block my thread)
> and it should be non-GPL API.

That's rather rude of you to assume that you can override the kernel
license by your own one.  If you don't want to use Linux, you don't have
to, but please, if you do use Linux, abide by the license of it.

To do otherwise is to somehow claim that your tiny needs are more
important than the many thousands of other developers.

thanks,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: Problems while adding sysfs support to older device driver

2009-12-14 Thread Greg KH
On Mon, Dec 14, 2009 at 11:34:09AM +0100, Bjoern Hinrichs wrote:
> Reading my mail again I see that I was unclear about what I was trying to do, 
> sorry.
> 
> I want a device node (e.g. /dev/titan) to be generated automatically for my 
> device. I was expecting udev to do so using a default name, but it is not.
> Because of that I started comparing uevents with other drivers and saw that 
> they are seeing additional uevents, therefore I thought that that my mistake 
> was there.

Ah, to do that you need to pass a device major:minor to the function you
used to create your struct device in the kernel.

But usually that is done already by the class-specific code that your
device uses to talk to the rest of the kernel (input, misc, network,
etc.)

What type of device is this?  And have you properly hooked it up to the
class for it?

If it is its "own" class, then you need to create your own device to
have it show up properly.  Use device_create() to do this.

Hope this helps,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: kbuild - two obj's from one source

2009-12-10 Thread Greg KH
On Fri, Dec 11, 2009 at 01:33:08PM +1300, Michal Ludvig wrote:
> On 12/10/2009 06:11 PM, Greg KH wrote:
> > On Thu, Dec 10, 2009 at 01:45:30PM +1300, Michal Ludvig wrote:
> >> Hi,
> >>
> >> is it somehow possible to generate two separate kernel modules from one
> >> source file?
> >>
> >> What I want is roughly:
> >> mymodule-type1.ko compiled from: mymodule.c -D_TYPE_1
> >> and
> >> mymodule-type2.ko compiled from: mymodule.c -D_TYPE_2
> > [..]
> > You can't do it directly.
> > 
> > You can do it by a trick of having the .c file included from another .c
> > file.
> > 
> > But I really don't recommend doing it, please figure out how to handle
> > both code types together in the same module, as the same time, that's
> > the only way the code would be acceptable to the kernel community.
> 
> Thanks Greg. I have factored the type1/type2 backends out to two
> separate source files and link the two kernel modules from a common
> frontend and one of the backends. The Makefile now looks much cleaner too.

See, the limitations of the build service are there for a reason, it
forces you to write cleaner code :)

Glad it's now working,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: Problems while adding sysfs support to older device driver

2009-12-09 Thread Greg KH
On Mon, Dec 07, 2009 at 10:54:36AM +0100, Bjoern Hinrichs wrote:
> Hi,
> 
> I'm running into some walls here while trying to add sysfs support to an 
> older 
> device driver for a PCI framegrabber device.
> 
> I started by adding a
> 
> ---
> static struct pci_driver titan_driver = {
>   .name = DRV_NAME,
>   .id_table = titan_pci_tbl,
>   .probe = titan_probe,
>   .remove = titan_remove,
> };
> ---
> 
> and calls to pci_register_driver / pci_unregister_driver. As expected the 
> driver shows up under /sys/bus/pci/drivers and claims the right device:
> 
> ---
> $ ls -la /sys/bus/pci/drivers/titan/
> total 0
> drwxr-xr-x  2 root root0 2009-11-30 09:14 .
> drwxr-xr-x 13 root root0 2009-11-30 09:14 ..
> lrwxrwxrwx  1 root root0 2009-11-30 09:14 :00:0b.0 -> 
> ../../../../devices/pci:00/:00:0b.0
> --w---  1 root root 4096 2009-11-30 09:14 bind
> lrwxrwxrwx  1 root root0 2009-11-30 09:14 module -> 
> ../../../../module/titan
> --w---  1 root root 4096 2009-11-30 09:14 new_id
> --w---  1 root root 4096 2009-11-30 09:14 remove_id
> --w---  1 root root 4096 2009-11-30 09:14 uevent
> --w---  1 root root 4096 2009-11-30 09:14 unbind
> ---
> 
> Now I want device files to be automatically generated, but it seems as if I'm 
> missing someting here. udevadm tells me I'm getting the following uevents:
> 
> ---
> KERNEL[1259568653.205951] add  /module/titan (module)
> UDEV_LOG=3   
> ACTION=add   
> DEVPATH=/module/titan
> SUBSYSTEM=module 
> SEQNUM=682   
> 
> KERNEL[1259568653.206472] add  /bus/pci/drivers/titan (drivers)
> UDEV_LOG=3 
> ACTION=add 
> DEVPATH=/bus/pci/drivers/titan 
> SUBSYSTEM=drivers  
> SEQNUM=683
> 
> UDEV  [1259568653.215901] add  /module/titan (module)
> UDEV_LOG=3
> ACTION=add
> DEVPATH=/module/titan
> SUBSYSTEM=module
> SEQNUM=682
> 
> UDEV  [1259568653.236102] add  /bus/pci/drivers/titan (drivers)
> UDEV_LOG=3
> ACTION=add
> DEVPATH=/bus/pci/drivers/titan
> SUBSYSTEM=drivers
> SEQNUM=683
> 
> 
> KERNEL[1259568653.205951] add  /module/titan (module)
> UDEV_LOG=3
> ACTION=add
> DEVPATH=/module/titan
> SUBSYSTEM=module
> SEQNUM=682
> ---
> 
> This looks to me as if I'm missing some uevents here. I guess there's 
> something I should be doing in .probe, but I'm neither sure whether that's 
> correct nor what it is.
> (Of course I can still add device files using mknod, but that'd be kinda .. 
> boring.)
> 
> Someone willing to give me a hint?

That all looks correct, what specifically is wrong here?  You don't get
a uevent for adding a sysfs file, only when you add a struct device (or
kobject) to sysfs.

What type of sysfs file are you adding to your driver?  What do you want
to export to userspace?  You do know the rules about sysfs files, right?

thanks,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: kbuild - two obj's from one source

2009-12-09 Thread Greg KH
On Thu, Dec 10, 2009 at 01:45:30PM +1300, Michal Ludvig wrote:
> Hi,
> 
> is it somehow possible to generate two separate kernel modules from one
> source file?
> 
> What I want is roughly:
> mymodule-type1.ko compiled from: mymodule.c -D_TYPE_1
> and
> mymodule-type2.ko compiled from: mymodule.c -D_TYPE_2
> 
> obj-m += mymodule-type1.o
> obj-m += mymodule-type2.o
> CFLAGS_mymodule-type1.o = -D_TYPE_1
> CFLAGS_mymodule-type2.o = -D_TYPE_2
> 
> and mymodule.c symlinked to mymodule-type1.c and mymodule-type2.c
> Now I'd like to get rid of the symlinks.
> 
> I've gone through the kbuild docs but can't find how to do that. Any ideas?

You can't do it directly.

You can do it by a trick of having the .c file included from another .c
file.

But I really don't recommend doing it, please figure out how to handle
both code types together in the same module, as the same time, that's
the only way the code would be acceptable to the kernel community.

good luck,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: Probe method vs attach method.

2009-12-09 Thread Greg KH
On Wed, Dec 09, 2009 at 10:40:05AM -0600, LKomz Komz wrote:
> Are there any documentation on what the changes in the i2c modules are going
> from 2.6.22 to 2.6.31.

Yes, you have the exact number of specific changes that have happened
between those two kernel versions, in the kernel source code itself.
Please use that to determine what has changed, no other type of
documentation would be as complete :)

Also note, that between those two versions, a few hundred thousand
kernel changes have happened, which is not insubstancial.

Good luck,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: keyboard

2009-12-06 Thread Greg KH
On Sat, Dec 05, 2009 at 04:57:59PM -0500, Herlin R. Matos Lastres wrote:
> Hi,
> I need manage the keyboard, for example read the data comming from 
> keyboard.

Which keyboard?  Lots of them can be plugged in at once and they can be
of different types (bluetooth, usb, virtual, serial, ps/2, etc.)

And read it from where, within the kernel or from userspace?

And finally, why do you need to do this?  What is the problem you are
trying to solve?

thanks,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: Probe method vs attach method.

2009-12-04 Thread Greg KH
On Fri, Dec 04, 2009 at 02:29:36PM -0600, LKomz Komz wrote:
> Thanks Greg for the reply!
> 
> I have an i2c driver written using the attach method for binding. It opens
> the device and reads the registers etc.
> 
> The following document talks about another binding method.
> http://www.kernel.org/doc/Documentation/i2c/upgrading-clients
> 
> Could you clarify that whether the new binding method is the way to go for
> i2c devices.

Yes, why would the document lie?

> Do I have to rewrite the current driver to make it compatible with
> future kernel versions.?

Yes.

The best thing for you to do is get it into the main kernel tree, then
it will remain compatible with future kernel versions as the API changes
over time.

thanks,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: Probe method vs attach method.

2009-12-03 Thread Greg KH
On Wed, Dec 02, 2009 at 03:51:19PM -0600, LKomz Komz wrote:
> Hello all,
> 
> Could you help me understand the latest trends in Kernel mode drivers.
> I hear that there are two methods by which the driver attaches itself to the
> kernel:
> 1)Probe method and
> 2)Attach method.
> 
> I have a driver written using the attach method. Is the kernel driver
> community moving towards probe method?

It depends on the type of driver you are writing.

What type of driver are you thinking of?

And do you have an example of what you think the differences are?  As
the maintainer of the kernel's driver core, I really don't understand
what you are getting at, and I think I should :)

thanks,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: Up to date driver-model docs?

2009-11-29 Thread Greg KH
On Sat, Nov 28, 2009 at 12:04:44AM +, Philip Downer wrote:
> Is there any up to date documentation of the driver-model? I've found that 
> device.h is different to the docs in Documentation/driver-model/driver.txt 
> and was going to post here when I found the following thread[1] from 2004. 
> It's
> referring to different files to driver.txt but I'm assuming that everything 
> is out of date as unfortunately nothing seems to have
> come from the old thread and I can't find any correct documentation.

Have you looked at the kerneldoc for the driver core?

> My immediate issue is that as per the docs, I wanted to use the supposed 
> list structure in struct device_driver to get a list of all the devices 
> attached to the driver, so if anyone can help me with that then I'd be 
> grateful.

Why would you need this?  What problem are you trying to solve?

thanks,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: DMA issue with USB devices

2009-11-23 Thread Greg KH
On Mon, Nov 23, 2009 at 02:35:02PM -0600, Asim wrote:
> Thank you for the response. I was referring to security issues due to
> an incorrect DMA from a bad/malicious device.

If you have such a device, it can do bad things :)

> I guess I will now be looking at whether devices come with their own
> controller and how abundant they are.

USB devices?  They do not.

good luck,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: DMA issue with USB devices

2009-11-22 Thread Greg KH
On Wed, Nov 18, 2009 at 04:07:56PM -0600, Asim wrote:
> Hi,
> 
> I realize there is an issue with PCI devices due to the possibilities
> of  a bad DMA due to a bad driver/device.

What specific issue are you referring to?

> Does this problem manifest to USB drivers as well or does the usb core
> ensure that the DMA addresses are always mapped correctly? Can anyone
> point me to the code file where this is being done.

USB host controllers are PCI devices on most systems, so the issue
should be the same, right?  On their own, USB drivers do not do DMA.

thanks,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: MTP Class driver

2009-11-11 Thread Greg KH

A: No.
Q: Should I include quotations after my reply?

http://daringfireball.net/2007/07/on_top

On Wed, Nov 11, 2009 at 05:43:36PM +0530, Satheesh Kumar wrote:
> may be i am not clear with my doubts..
> 
> 1. i am writing a new USB class driver for MTP devices.  But when i plug-in
> the device it is atomatically recognised with mass storage module taking the
> interface information.  But the string descriptor defined as MTP, so how i
> can lead my class driver to probe the device before usb_stroage module
> picks.

You can't, what you need to do is modify the usb_storage module to not
bind to these types of devices, and then your driver will always be
properly loaded.

Do you have a pointer to the source for your driver code somewhere?

> 2. How USB plugin event in class driver can be passed to userspace.  So that
> my MTp library application can understand asynchronoously that device been
> pluged in.  Example if i connect iPod in Linux system it gets recognised by
> rhytom box application immediately.  How come rythmbox able to know that a
> media player device pluged in.

It listens to HAL or libudev events, depending on the version of the
distro (HAL is being removed from the system right now, so don't write
new code depending on it please.)

Nothing new needs to be done in your driver at all, the kernel
infrastructure and udev do this kind of notification for you
automatically.

Hope this helps,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: MTP Class driver

2009-11-10 Thread Greg KH
On Wed, Nov 04, 2009 at 03:49:15PM +0530, Satheesh Kumar wrote:
> Hello,
> 
> I am writing MTP class driver for Cowon Mp3 player. The device has MTP as
> well as mass storage class support. Although i registered MTP class driver
> with relevant vendor id and product id, the same info is also available with
> Mass storage class(MSD) driver, hence on plug-in, by default device detected
> as MSD class, not  as MTP class. How do i override MSD class registration
> with my MTP class driver ?

You send a patch to the linux-...@vger.kernel.org mailing list that
adds the ability to not match a MTP device such as your own.

Do you have a pointer to your driver anywhere?

thanks,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: Communication device interrupts to user space via real time signals

2009-11-10 Thread Greg KH
On Tue, Nov 03, 2009 at 05:14:50PM +0200, Jason Nymble wrote:
>
> On 03 Nov 2009, at 4:47 PM, Greg KH wrote:
>
>> We have laser welding robots using the UIO code just fine.  Same goes
>> for robots cutting wood at 3 meters a second, so I think the latency of
>> UIO is not an issue :)
>
> Now you've gone and piqued my curiosity :)  Are there any publicly 
> available links or papers or anything to the above-mentioned projects?

They were displayed at an industrial conference in Hannover last year,
you might try poking around on the OSADL web page for more information.

Hope this helps,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: Communication device interrupts to user space via real time signals

2009-11-03 Thread Greg KH
On Tue, Nov 03, 2009 at 06:13:37PM +0530,  wrote:
> Hi List
> 
> I am having doubt whether UIO supports asynchronous notification or not. The
> Documentaionsays
> u have to block on read system call to get the event.
> 
> I think the interrupt implementation in user space needs asynchronous
> events. right?
> 
> In case of RT signals, I am not sure whether the latency will be bearable or
> not. And by default queuing capacity of RT signals is 1024. You may have to
> override that, in ur case, depending upon ur hardware.

We have laser welding robots using the UIO code just fine.  Same goes
for robots cutting wood at 3 meters a second, so I think the latency of
UIO is not an issue :)

good luck,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: Communication device interrupts to user space via real time signals

2009-10-31 Thread Greg KH
On Sat, Oct 31, 2009 at 01:24:48PM +0530, Devesh Sharma wrote:
> Hello Greg, Thanks for your reply, currently our development is using
> some older 2.6 version,
> where I think the support for UIO is not present. Therefore, I am
> looking this as an alternative solution.

Then backport the UIO core to your kernel and write a UIO driver.  That
way your driver can be accepted into the main kernel tree and you will
not end up writing code that will be obsolete from the very beginning :)

good luck,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: Communication device interrupts to user space via real time signals

2009-10-30 Thread Greg KH
On Fri, Oct 30, 2009 at 02:37:36PM +0530, Devesh Sharma wrote:
> Hello list,
> 
> I have a physical device for which I am implementing a kernel bypass
> library in user space,
> I want to handle certain device specific interrupts from the user
> space with reliability (Any interrupts is not dropped or missed).
> How efficient and reliable is the Linux Real Time Signal handling
> framework for this purpose?

Use the UIO kernel interface for this, that's the best way to handle it.

good luck,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: Mobile OS

2009-10-13 Thread Greg KH
On Tue, Oct 13, 2009 at 08:09:50PM +0200, Michael Blizek wrote:
> Legally, you can call it open source. But what I am saying is that it is not
> open source in the way people expect it:

Um, there is no difference, sorry.

> - Devices are crippled locked down so.

That is a manufacturer decision, not a limitation of the software
itself.  I have a device that is not locked down, as do thousands of
others.

> - Large parts are not GPL/copyleft, but Apache license. The goal is most
>   likely to empower proprierary vendors to do what they like.

Apache license is "open source", sorry if you don't like that.

> - It is lead mostly by a single company and some who followed, not by a
>   community.

That has nothing to do with "open source" or not.

> - Lots of applications are proprierary. You cannot run the usual Linux
>   applications, as long as they are not completely rewritten.

That has nothing to do with the core and infrastructure being open or
not.  You can freely write closed source applications on Linux, and lots
of people do (Oracle, SAP, etc.)

The fact that you feel a "normal" Linux application can not run, again,
has nothing to do with calling the system "not open source".

> - There is a real comminity effort called openmoko. 

openmoko is great, but it has nothing to do with Android and its
license.

> > availableunless u run commercial applications like Oracle on it???
> > nothing to say then :-)..
> 
> No, but does having a BSD kernel make Apple's "OS X" open source?

No one makes that mistake.  Android is open, sorry if you don't like
that.

Now I do have lots of complaints about how Android is turning out, but
again, the license has nothing to do with that, I am very happy to see a
totally different userspace running on top of a Linux kernel.  It shows
how flexable the Linux kernel can be and makes you think twice about
what you want to call a "Linux" system :)

thanks,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: linux developer conference reg.

2009-10-04 Thread Greg KH
On Fri, Oct 02, 2009 at 01:30:27PM -0400, Anand Arumugam wrote:
> hi all,
> 
> has anyone attended any newbie linux developer conference? esp is there
> anything like that for kernel newbies? a conference where seasoned
> programmers who want to contribute to linux can learn something and get
> started with their work? can you please pass on such information? thanks a
> lot.

The Linux Plumbers Conference or linux.conf.au are both very good,
technical conferences where new kernel developers can learn a lot.
Heck, I learn a lot at both of these conferences, so they are by no
means only limited to "newbies" :)

good luck,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: facing a problem with irq handler,please help me

2009-10-02 Thread Greg KH

A: No.
Q: Should I include quotations after my reply?

http://daringfireball.net/2007/07/on_top

On Fri, Oct 02, 2009 at 01:00:36PM +0530, Harinderjit Singh Sandhu wrote:
> i want to know which statement is turning it off.

The problem is that you are _not_ turning it off, and you need to.  Add
that logic to the interrupt handler and you should be fine.

As for _how_ to turn it off, well, that's a hardware specific thing that
you need to know in order to write the interrupt handler.

hope this helps,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: facing a problem with irq handler,please help me

2009-10-01 Thread Greg KH
On Thu, Oct 01, 2009 at 09:11:30PM +0530, Harinderjit Singh Sandhu wrote:
> i was trying to figure out how the interrupts are handled . can you suggest
> me a reading to have proper knowledge of this ,so that i don't trouble
> people with such problems

Look at a driver with a real interrupt handler?  It's not like we don't
have a few thousand examples in the kernel already :)

good luck,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: facing a problem with irq handler,please help me

2009-10-01 Thread Greg KH
On Thu, Oct 01, 2009 at 08:55:27PM +0530, Harinderjit Singh Sandhu wrote:
> this is the code for the small module that i wrote

The problem is in your interrupt handler:

> // interrupt handler
> irqreturn_t interrupt_handler (int irqn, void *dev)
> {
> 
> printk("Press a key  ");
> 
> 
> return IRQ_HANDLED;
> 
> 
> }

You aren't really handling the interrupt by turning it off in the
hardware.  So the kernel sees an interrupt storm for your device and
shuts it off to save the system from going crazy.

What are you trying to do with this sample module?

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: facing a problem with request _irq qnd enable_irq

2009-10-01 Thread Greg KH
On Thu, Oct 01, 2009 at 11:54:55AM +0530, Harinderjit Singh Sandhu wrote:
> ---
> int ret;
> printk("initializing module\n");
> //free_irq(7,NULL);
> i = register_chrdev (SKELETON_MAJOR, SKELETON_NAME, &skeleton_fops);
> if (i != 0) return - EIO;
> //disable_irq(7);
> ret = request_irq (7, interrupt_handler,0,SKELETON_NAME ,NULL);
> printk("ret=%d\n",ret);
> //enable_irq(7);
> if(ret>=0){
> enable_irq(7);
> //outb_p(0x10, BASEPORT + 2);
> }
> else
> {
> printk("Not Working \n");
> }
> //printk("Generating interrupt \n");
> 
> outb(0, BASEPORT);
> outb(255, BASEPORT);
> outb(0, BASEPORT);
> printk("Interrupt generated. You should see the handler-message\n");
> 
> -
> when i insmod the module of which this is apart.
> 
> 
> i get the following output
> 
> [ 1291.259646] initializing module
> [ 1291.259672] ret=0
> [ 1291.259679] [ cut here ]
> [ 1291.259682] WARNING: at
> /build/buildd/linux-2.6.28/kernel/irq/manage.c:225 __enable_irq+0x30/0x70()
> [ 1291.259685] Unbalanced enable for IRQ 7
> [ 1291.259687] Modules linked in: skeleton(+) hid_bright usbhid rfkill_input
> i915 drm binfmt_misc ppdev bridge stp bnep lp parport arc4 ecb snd_hda_intel
> snd_pcm_oss snd_mixer_oss snd_pcm pcmcia snd_seq_dummy b43 snd_seq_oss
> snd_seq_midi snd_rawmidi mac80211 snd_seq_midi_event cfg80211 iTCO_wdt
> iTCO_vendor_support snd_seq snd_timer snd_seq_device yenta_socket
> rsrc_nonstatic ricoh_mmc sdhci_pci sdhci snd pcmcia_core led_class intel_agp
> agpgart soundcore snd_page_alloc pcspkr input_polldev serio_raw uvcvideo
> compat_ioctl32 videodev v4l1_compat video output ohci1394 ieee1394 8139too
> 8139cp mii ssb fbcon tileblit font bitblit softcursor
> [ 1291.259751] Pid: 4400, comm: insmod Not tainted 2.6.28-11-generic
> #42-Ubuntu
> [ 1291.259754] Call Trace:
> [ 1291.259760]  [] warn_slowpath+0x60/0x80
> [ 1291.259765]  [] ? register_handler_proc+0x119/0x130
> [ 1291.259773]  [] ? vsnprintf+0x378/0x5c0
> [ 1291.259778]  [] ? release_console_sem+0x1c9/0x200
> [ 1291.259782]  [] __enable_irq+0x30/0x70
> [ 1291.259786]  [] enable_irq+0x3c/0x60
> [ 1291.259790]  [] ? skeleton_init_module+0x0/0x96 [skeleton]
> [ 1291.259795]  [] skeleton_init_module+0x78/0x96 [skeleton]
> [ 1291.259802]  [] _stext+0x2e/0x170
> [ 1291.259807]  [] ? sysfs_addrm_finish+0x15/0xf0
> [ 1291.259811]  [] ? sysfs_add_one+0x13/0x50
> [ 1291.259814]  [] ? sysfs_addrm_start+0x3f/0xa0
> [ 1291.259820]  [] ? __vunmap+0x9c/0xe0
> [ 1291.259823]  [] ? __vunmap+0x9c/0xe0
> [ 1291.259832]  [] ? vfree+0x21/0x30
> [ 1291.259837]  [] ? load_module+0x103a/0x1040
> [ 1291.259848]  [] sys_init_module+0x88/0x1b0
> [ 1291.259853]  [] ? sys_close+0x7a/0xc0
> [ 1291.259857]  [] sysenter_do_call+0x12/0x2f
> [ 1291.259865]  [] ? relay_hotcpu_callback+0x6d/0xbd
> [ 1291.259868] ---[ end trace cddcbfa519faa2fe ]---
> [ 1291.259870] Interrupt generated. You should see the handler-message
> 
> and the message in the handler doesnt appear.
> i am unable to get what is the problem and how can this be solved.
> 
> please help me out

Your irq handler is not working properly, please post the code for that.

Also, please follow the kernel coding style rules if you wish to have
other people review your code, otherwise it is very difficult for us to
do so.

good luck,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: Paid Kernel Development

2009-09-24 Thread Greg KH
On Thu, Sep 24, 2009 at 02:36:56PM +0530, debian developer wrote:
> Hi Greg,
> 
> I've submitted quite a few trivial kernel patches previously.
> I liked your idea of free device driver development too. Good luck to
> you with that.
> 
> I want to ask you if there is any place or forum which co-ordinates
> corporates to sponsor work on Linux kernel development. For example,
> I work as a software developer and would love to work on Linux full-time.
> 
> But, It is not really easy for me to do it without some financial support.
> Whom do I approach in this situation? Where do I ask for financial support to
> work on Linux?

There are lots of jobs offered for Linux kernel developers, why not
apply for one of them?

> It is great that people are ready to work for free, but if some
> company which has requested a free device driver wants to hire
> someone, how do we know of it?

I do not know of a centralized location for this type of thing, sorry.

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: PCI Issues

2009-09-14 Thread Greg KH
On Tue, Sep 15, 2009 at 09:19:52AM +0800, Pei Lin wrote:
> 2009/9/15 Greg KH :
> > On Sun, Sep 13, 2009 at 05:12:11PM +0300, Mena Soliko wrote:
> >> Hello,
> >> 1. Can several drivers can handle the same PCI device?
> >
> > Officially, No.  Unofficially, there are ways to do this, but you have
> > to be _very_ careful.
> >
> > What type of PCI device do you want to control?  Is there already a
> > driver bound to it?
> >
> >> 2. How can I know which driver currently handles my PCI devices? (lsmod 
> >> show
> >> few drivers that can show a few candidate but I want to know the actual
> >> driver that register to that PCI).
> >
> > lspci -k
> >
> hi, grep,

The name is "Greg" :)

> what is your lspci's version? and in my fc8 ,lspci version
> is 2.2.6 which has no parameter about -k.

fc8 is very old, please use a newer version.  I'm running 3.1.4 here.

> So lspci just can tell me a not very clear info about pci device if
> there is no device driver attach it.

Not true, use a newer lspci version.

Or just use the proper symlink in sysfs, it will tell you if a driver is
bound to a device, which is what lspci uses.

good luck,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: DEVFS permissions

2009-09-14 Thread Greg KH
On Mon, Sep 14, 2009 at 08:38:48AM -0400, Shankar Ganesh wrote:
> Hi ,
> 
> When we create a node under devfs ,

There is no such thing as devfs anymore.

> 
> hwcdev_class = class_create(THIS_MODULE, DRVNAME);
> device_create(hwcdev_class, NULL, MKDEV(dev_major, 0), dev,
> DEVNAME);
> 
>  the  node is created with default permission of 600 (root=rw, others nil) ,
> 
> crw   root root252  , 
> 
> How do i make permission setting automatically while creating node ? (i need
> 666 and don't want to execute chmod 666 /dev/mydev )

Create a udev rule to provide the proper permission for this device.

thanks,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: PCI Issues

2009-09-14 Thread Greg KH
On Sun, Sep 13, 2009 at 05:12:11PM +0300, Mena Soliko wrote:
> Hello,
> 1. Can several drivers can handle the same PCI device?

Officially, No.  Unofficially, there are ways to do this, but you have
to be _very_ careful.

What type of PCI device do you want to control?  Is there already a
driver bound to it?

> 2. How can I know which driver currently handles my PCI devices? (lsmod show
> few drivers that can show a few candidate but I want to know the actual
> driver that register to that PCI).

lspci -k


thanks,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: Why there is no realloc in kernel?

2009-09-11 Thread Greg KH
On Sat, Sep 12, 2009 at 04:24:25AM +0530, vinit dhatrak wrote:
> Hi Greg,
> 
> Can you point us to it in lxr or something?

Look for krealloc().

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: Why there is no realloc in kernel?

2009-09-11 Thread Greg KH
On Wed, Sep 09, 2009 at 05:13:56PM +0530, Leonidas . wrote:
> Why there is no realloc in kernel?

I see it there, don't you?

> Any specific reason?

Nope, because it is there...

thanks,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: USB Doubt

2009-09-05 Thread Greg KH
On Sat, Sep 05, 2009 at 11:54:45PM +0530, Niamathullah sharief wrote:
> Hi friends,
>  I want to know about USB devices. I mean,From where the device is searching
> for driver when we insert the device into USB port?

Please read the USB chapter in the book, Linux Device Drivers, Third
Edition, free online.  It describes all of this.

good luck,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: error in sysfs node create

2009-08-18 Thread Greg KH
On Tue, Aug 18, 2009 at 10:43:31AM +0530, Shankar Ganesh wrote:
> Hi Friends ,
> 
> When the driver try to  create node under sysfs during boot-up , i am
> getting following error.
> sysfs: duplicate filename '254:0' can not be created . Can you help me out
> to resolve this error ?

Don't create duplicate nodes :)

The problem here is that you are registering a major/minor pair that is
already registered in the kernel.  Fix that up and you should be good.

Do you have a pointer to your code anywhere?

thanks,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: tiny tty driver in ldd3

2009-08-16 Thread Greg KH
On Thu, Aug 13, 2009 at 12:57:49PM -0700, srinivasramana wrote:
> 
> Hi All,
> 
> 1. I am using the tiny tty driver written by Greg long back. Looks like its
> too old and hence some compilation issues. Once i resolve that, its giving
> BUG on add_timer(i tried in 2.6.28 & 2.6.30).
> 2. I have two applications one reads and one which calls an ioctl on the
> same device node. the read app blocks once i start. In the ioctl from second
> app, i am using tty_flip_buffer_push() to write data to tty core so that the
> first app unblocks.
> But i am surprised to see that the data is written back to the tty device
> using write call. 
> 
> can anybody help me on this? How do i have first read app get the data?

Can you post the driver that you now have, and the error you are
getting?

thanks,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: LDD3 examples advice

2009-08-10 Thread Greg KH
On Mon, Aug 10, 2009 at 08:38:50AM -0400, Robert P. J. Day wrote:
> On Sat, 8 Aug 2009, Greg KH wrote:
> 
> > ... LDD3 is one of the top selling Linux books for the publisher.
> > It's a matter of time and figuring out the best way to produce the
> > next volume of the book in a manner that is not going to cause it to
> > go instantly out of date like the previous version did.
> >
> > Just publishing a new version in dead-tree form would not make much
> > sense anymore as the rate of change in the kernel is increasing so
> > fast that it doesn't make any sense.
> 
>   at the risk of saying something idiotic, why *should* LDD4 be out of
> date almost the instant it hits the shelves?  if the underlying kernel
> code is really changing that quickly to olsolete the book, that
> strikes me as a *really* bad sign of kernel instability.

Sorry, but have you read Documentation/stable_api_nonsense.txt before?

If not, please do so, it will answer this question for you.

Also note, the rate of change for the kernel has _increased_
dramatically over the past few years, so that anything that is written
down goes out of date faster than it used to in the past.  That's just a
side affect (or is it effect?) of our rapid development model.

>   note:  i'm not talking about the obvious *new* features that are
> being added constantly to the kernel.  obviously, that's going to
> happen.  but is it really true that you can't even write a book on
> *basic* kernel device drivers without seeing it out of date that
> quickly?  i thought the whole point of the kernel API was that it
> remain relatively stable for *developers*, regardless of what might
> happen internally.

No, not at all, please read the above file for why.

>   anyone should be able to see that a published book on device drivers
> will probably become *incomplete* fairly quickly.  but is that really
> the same as saying that it's going to become *wrong*?

If you consider examples that do not build anymore due to compiler
warnings and errors "wrong", then yes, that is the case.

thanks,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: LDD3 examples advice

2009-08-08 Thread Greg KH
On Sun, Aug 09, 2009 at 03:38:16AM +0530, debian developer wrote:
> On Fri, Aug 7, 2009 at 11:44 PM, Greg KH wrote:
> > On Fri, Aug 07, 2009 at 02:07:32PM +0530, Anuz Pratap Singh Tomar wrote:
> >> Yeah LDD3 is outdated now, atleast huge amount of code is not usable as is,
> >> and for beginner, it may be difficult to figure out.
> >> I donno when LDD4 will be out, but if authors could re-write changed stuff,
> >> somewhere online, it would be great.
> >
> > We have no current plans to update LDD3 to LDD4, at the moment.  We are
> > all swamped with other work, and discussions with the publisher as to a
> > possible change in format kind of stopped due to lack of energy with
> > everyone involved (due to other work responsibilities.)
> >
> 
> Just wanted to know if this was the effect of open sourcing(kind of) the book.
> May be the revenues werenot significant enough for the publisher to push for
> an update?

No, not at all, LDD3 is one of the top selling Linux books for the
publisher.  It's a matter of time and figuring out the best way to
produce the next volume of the book in a manner that is not going to
cause it to go instantly out of date like the previous version did.

Just publishing a new version in dead-tree form would not make much
sense anymore as the rate of change in the kernel is increasing so fast
that it doesn't make any sense.

So we need to figure out how to do it differently.  We have a number of
ideas how to accomplish this, but it takes some time to work out all of
the details.

We'll let everyone know when we have something we can announce.

thanks,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: How to configure usb as console

2009-08-07 Thread Greg KH
On Tue, Aug 04, 2009 at 05:35:20PM -0700, Bizhan Gholikhamseh (bgholikh) wrote:
> Hi All,
> How could I redirect serial output through USB devices so to act as
> console?

Read the serial console documentation and use ttyUSB0 or some other
device node for the configuration.

Note, kernel oops messages do not show up in usb consoles, because
interrupts are needed to get usb messages out.  So it has a limited
benifit for development.

good luck,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: LDD3 examples advice

2009-08-07 Thread Greg KH
On Fri, Aug 07, 2009 at 11:14:54AM -0700, Greg KH wrote:
> On Fri, Aug 07, 2009 at 02:07:32PM +0530, Anuz Pratap Singh Tomar wrote:
> > Yeah LDD3 is outdated now, atleast huge amount of code is not usable as is,
> > and for beginner, it may be difficult to figure out.
> > I donno when LDD4 will be out, but if authors could re-write changed stuff,
> > somewhere online, it would be great.
> 
> We have no current plans to update LDD3 to LDD4, at the moment.

Ok, I take this back, we are now back to discussing this, so there are
plans, just no dates.

sorry for the noise,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: LDD3 examples advice

2009-08-07 Thread Greg KH
On Fri, Aug 07, 2009 at 02:07:32PM +0530, Anuz Pratap Singh Tomar wrote:
> Yeah LDD3 is outdated now, atleast huge amount of code is not usable as is,
> and for beginner, it may be difficult to figure out.
> I donno when LDD4 will be out, but if authors could re-write changed stuff,
> somewhere online, it would be great.

We have no current plans to update LDD3 to LDD4, at the moment.  We are
all swamped with other work, and discussions with the publisher as to a
possible change in format kind of stopped due to lack of energy with
everyone involved (due to other work responsibilities.)

sorry,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: how to list the current HZ value?

2009-08-03 Thread Greg KH
On Tue, Aug 04, 2009 at 09:42:41AM +0800, Pei Lin wrote:
> 2009/8/2 Greg KH :
> > On Sat, Aug 01, 2009 at 03:36:21PM -0400, Robert P. J. Day wrote:
> >> On Sat, 1 Aug 2009, Greg KH wrote:
> >>
> >> > On Fri, Jul 31, 2009 at 11:23:15AM +0700, Mulyadi Santosa wrote:
> >> > > On Fri, Jul 31, 2009 at 6:52 AM, Karel Zak wrote:
> >> > > It seems that user space sees HZ as 100, while in fact my current
> >> > > running kernel is compiled with HZ=300. What do you think about it? Or
> >> > > is there something wrong with my conclusion?
> >> >
> >> > The following C program should properly show you the kernel HZ.
> >> >
> >> > thanks,
> >> >
> >> > greg k-h
> >> >
> >> > --
> >> >
> >> > #include 
> >> > #include 
> >> > #include 
> >> >
> >> > int main()
> >> > {
> >> > struct timespec res;
> >> > double resolution;
> >> >
> >> > printf("UserHZ   %ld\n", sysconf(_SC_CLK_TCK));
> >> >
> >> > clock_getres(CLOCK_REALTIME, &res);
> >> > resolution = res.tv_sec + (((double)res.tv_nsec)/1.0e9);
> >> >
> >> > printf("SystemHZ %ld\n", (unsigned long)(1/resolution + 0.5));
> >> > return 0;
> >> > }
> >>
> >>   i already knew about sysconf.  so i'm going to assume there's no
> >> simpler way to get the current HZ (either command line or /proc
> >> based).
> >
> > But the point is, from userspace's point of view, the kernel HZ value
> > means NOTHING.  See the above program that shows what the resolution
> > that userspace can use is.  That is what userspace cares about, and what
> > the kernel provides.  Internal HZ values of what the kernel might use
> > for scheduling means _nothing_.
> >
> but some applications or drivers especially for stream media i think
> they need this parameter to get a balance for performance.
> refer to the link: http://lwn.net/Articles/145973/
> i think people need it to configure their kernel.

Look at the code I provided, it gives you the value you need to care
about.

> > So if you do provide it to userspace in a proc file, what then? What is
> > userspace going to do with such a value?  It should never depend on it,
> > because it doesn't matter to it.
> >
> how do we change the kernel HZ parameter except reconfiguration kernel
> and rebuild kernel?

That is the only way.

But again, it should not be an issue at all, except for some very
special server loads which wants a low HZ value.

Do you have a special workload that needs a specific HZ value to achieve
its results?

thanks,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: how to list the current HZ value?

2009-08-01 Thread Greg KH
On Sat, Aug 01, 2009 at 03:36:21PM -0400, Robert P. J. Day wrote:
> On Sat, 1 Aug 2009, Greg KH wrote:
> 
> > On Fri, Jul 31, 2009 at 11:23:15AM +0700, Mulyadi Santosa wrote:
> > > On Fri, Jul 31, 2009 at 6:52 AM, Karel Zak wrote:
> > > It seems that user space sees HZ as 100, while in fact my current
> > > running kernel is compiled with HZ=300. What do you think about it? Or
> > > is there something wrong with my conclusion?
> >
> > The following C program should properly show you the kernel HZ.
> >
> > thanks,
> >
> > greg k-h
> >
> > --
> >
> > #include 
> > #include 
> > #include 
> >
> > int main()
> > {
> > struct timespec res;
> > double resolution;
> >
> > printf("UserHZ   %ld\n", sysconf(_SC_CLK_TCK));
> >
> > clock_getres(CLOCK_REALTIME, &res);
> > resolution = res.tv_sec + (((double)res.tv_nsec)/1.0e9);
> >
> > printf("SystemHZ %ld\n", (unsigned long)(1/resolution + 0.5));
> > return 0;
> > }
> 
>   i already knew about sysconf.  so i'm going to assume there's no
> simpler way to get the current HZ (either command line or /proc
> based).

But the point is, from userspace's point of view, the kernel HZ value
means NOTHING.  See the above program that shows what the resolution
that userspace can use is.  That is what userspace cares about, and what
the kernel provides.  Internal HZ values of what the kernel might use
for scheduling means _nothing_.

So if you do provide it to userspace in a proc file, what then? What is
userspace going to do with such a value?  It should never depend on it,
because it doesn't matter to it.

thanks,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



  1   2   3   >