Re: Does register_chrdev function make device file under /dev ?

2014-03-12 Thread Valdis . Kletnieks
On Tue, 11 Mar 2014 08:01:26 -, Kim Chan said:

 To my understanding, device file is needed when a user program wants to
 access the device and we don't need to generate the device file for us to use
 the device in kernel. Is my understanding correct?

Right.  You don't need to generate the device file because you shouldn't be
accessing the device in a file-like manner from inside the kernel.

 I am trying to open a shell on my LCD (is it going to be tty2

That's userspace, not kernel access.


pgp1FTlZNga7b.pgp
Description: PGP signature
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


RE: Does register_chrdev function make device file under /dev ?

2014-03-11 Thread Kim Chan

Yeah, I know mknod command. I just wanted to know if the register_chrdev makes 
the file or not.
To my understanding, device file is needed when a user program wants to access 
the device and we don't need to generate the device file for us to use the 
device in kernel. Is my understanding correct?

For example, busybox (a user program) starts shell on tty2-4 by default. (as 
the assumed default inittab below)
tty2::askfirst:-/bin/sh
tty3::askfirst:-/bin/sh
tty4::askfirst:-/bin/sh
I have had some mknod commands before in /etc/init.d/rcS to make tty2~tty4 
device files, but when I remove them for test, I can see busybox (almost sure 
it's coming from busybox) complaining that it cannot find the tty2~tty4 device 
files.

I am trying to open a shell on my LCD (is it going to be tty2 ? I don't know) 
and I'm not sure if I have to make vcs1 vcs2 vcs3 files. And I don't know how 
to switch to LCD shell. during the boot, the texts come out on the LCD but I 
cannot see the texts (printf) from busybox. and cannot see the shell on LCD. 
When I press the keyboad, it looks like it's connected to tty1(I can see using 
prints on uart window). Can anybody tell me some direction?

From : Kernel bu.ker...@gmail.com
Sent : 2014-03-11 14:44:09 ( +09:00 )
To : Kim Chan c...@etri.re.kr
Cc : kernelnewbies@kernelnewbies.org kernelnewbies@kernelnewbies.org
Subject : Re: Does register_chrdev function make device file under /dev ?



On Mar 10, 2014, at 10:25 PM, 김찬 c...@etri.re.krmailto:c...@etri.re.kr 
wrote:

Hi,

This should be a basic question.
Does the regisetr_chrdev function make the device file under /dev directory?
I am running linux on our embedded system and inside vcs_init, register_chrdev 
is called as below.

int __init vcs_init(void)
{
unsigned int i;
if (register_chrdev(VCS_MAJOR, vcs, vcs_fops))
panic(unable to get major %d for vcs device, VCS_MAJOR);

I can see the function is returning ok but I don't see any vcs* file under /dev.
Does it only register the device on /sys or /proc directory and not under /dev?
Thanks in advance.

Chan


You have to create a device file using 'mknod'

Ex: mknod -m 666 /dev/vcs c major no minor no


___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.orgmailto:Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Does register_chrdev function make device file under /dev ?

2014-03-11 Thread Mandeep Sandhu
On Tue, Mar 11, 2014 at 1:31 PM, Kim Chan c...@etri.re.kr wrote:

 Yeah, I know mknod command. I just wanted to know if the register_chrdev
 makes the file or not.

It doesn't. Also note that this is the old way of registering a char
device. New code should use cdev_add() etc.

 To my understanding, device file is needed when a user program wants to
 access the device and we don't need to generate the device file for us to
 use the device in kernel. Is my understanding correct?

Yes, device nodes are needed for userspace code to access a device
(the good ol devices are also files Unix paradigm! :)).

I'm not sure how an in-kernel access will work (maybe via directly
getting the corresponding cdec structure).


 For example, busybox (a user program) starts shell on tty2-4 by default. (as
 the assumed default inittab below)
 tty2::askfirst:-/bin/sh
 tty3::askfirst:-/bin/sh
 tty4::askfirst:-/bin/sh
 I have had some mknod commands before in /etc/init.d/rcS to make tty2~tty4
 device files, but when I remove them for test, I can see busybox (almost
 sure it's coming from busybox) complaining that it cannot find the tty2~tty4
 device files.

Correct. You will have to create those nodes manually.


 I am trying to open a shell on my LCD (is it going to be tty2 ? I don't
 know) and I'm not sure if I have to make vcs1 vcs2 vcs3 files. And I don't
 know how to switch to LCD shell. during the boot, the texts come out on the
 LCD but I cannot see the texts (printf) from busybox. and cannot see the
 shell on LCD. When I press the keyboad, it looks like it's connected to
 tty1(I can see using prints on uart window). Can anybody tell me some
 direction?

I think you need to point getty or a shell to the correct tty before
you can see o/p on the screen. Do you know which device file you're
supposed to create for the LCD? If so, just use that in your inittab.
Something like:

::askfirst:-/bin/sh

HTH,
-mandeep


 
 From : Kernel bu.ker...@gmail.com
 Sent : 2014-03-11 14:44:09 ( +09:00 )
 To : Kim Chan c...@etri.re.kr
 Cc : kernelnewbies@kernelnewbies.org kernelnewbies@kernelnewbies.org
 Subject : Re: Does register_chrdev function make device file under /dev ?



 On Mar 10, 2014, at 10:25 PM, 김찬 c...@etri.re.kr wrote:

 Hi,

 This should be a basic question.
 Does the regisetr_chrdev function make the device file under /dev directory?
 I am running linux on our embedded system and inside vcs_init,
 register_chrdev is called as below.

 int __init vcs_init(void)
 {
 unsigned int i;
 if (register_chrdev(VCS_MAJOR, vcs, vcs_fops))
 panic(unable to get major %d for vcs device, VCS_MAJOR);

 I can see the function is returning ok but I don't see any vcs* file under
 /dev.
 Does it only register the device on /sys or /proc directory and not under
 /dev?
 Thanks in advance.

 Chan



 You have to create a device file using 'mknod'

 Ex: mknod -m 666 /dev/vcs c major no minor no


 ___
 Kernelnewbies mailing list
 Kernelnewbies@kernelnewbies.org
 http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


 ___
 Kernelnewbies mailing list
 Kernelnewbies@kernelnewbies.org
 http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


RE: Does register_chrdev function make device file under /dev ?

2014-03-11 Thread 김찬
Hi, Mandeep, Thanks for clearing some things for me.

For accessing the device in kernel code, I think maybe we can use the /proc or 
/sys file system.
(I remember seeing people saying something like that.. correct me if I'm wrong)

 I think you need to point getty or a shell to the correct tty before you
 can see o/p on the screen. Do you know which device file you're supposed
 to create for the LCD? If so, just use that in your inittab.
 Something like:
 
 ::askfirst:-/bin/sh

The problem is, after the final sys_execve() which executes /sbin/init of the 
ramdisk, I cannot see any shell coming up so I cannot use getty command.
Using some prints on separate uart print routine, I can see from the kbd_event 
function the key value is going to current vc which is using tty1. The key 
value is then handed to put_queue function where the character is somehow 
copied to tty buffer. Flush_to_ldisc is scheduled for it and it will probably 
get passed on to the virtual console.
Added to this, there is a notifier_call_chain and the notifier block is 
registered by vcs_poll_data_get function which I don't know weather is 
necessary or not. So one of my questions is  if vcs is necessary for my case. 
(I guess not. There is no other notifier blocks registered)

I gathered without inittab (I don't use inittab which should be ok for most 
cases) the assumed default inittab
tty2::askfirst:-/bin/sh
tty3::askfirst:-/bin/sh 
tty4::askfirst:-/bin/sh 
is being applied by the busybox so there maybe 3 shells on tty2,tty3, and tty4 
running somewhere.
But even if there are shells running I don't know how to switch to those ttys.
I tried using Ctrl-Alt F2 (or F3, F4) using the USB keyboard to switch to 
tty2,3,4 to see if any shell comes up on the LCD but couldn't see it.
I tried using inittab with no avail before.

I hope somebody could point me on what should be checked. Any hint will be 
appreciated.
Regards,
Chan

 -Original Message-
 From: Mandeep Sandhu [mailto:mandeepsandhu@gmail.com]
 Sent: Tuesday, March 11, 2014 6:01 PM
 To: Chan Kim
 Cc: Kernel; kernelnewbies@kernelnewbies.org
 Subject: Re: Does register_chrdev function make device file under /dev ?
 
 On Tue, Mar 11, 2014 at 1:31 PM, Kim Chan c...@etri.re.kr wrote:
 
  Yeah, I know mknod command. I just wanted to know if the
  register_chrdev makes the file or not.
 
 It doesn't. Also note that this is the old way of registering a char
 device. New code should use cdev_add() etc.
 
  To my understanding, device file is needed when a user program wants
  to access the device and we don't need to generate the device file for
  us to use the device in kernel. Is my understanding correct?
 
 Yes, device nodes are needed for userspace code to access a device (the
 good ol devices are also files Unix paradigm! :)).
 
 I'm not sure how an in-kernel access will work (maybe via directly getting
 the corresponding cdec structure).
 
 
  For example, busybox (a user program) starts shell on tty2-4 by
  default. (as the assumed default inittab below)
  tty2::askfirst:-/bin/sh tty3::askfirst:-/bin/sh
  tty4::askfirst:-/bin/sh I have had some mknod commands before in
  /etc/init.d/rcS to make tty2~tty4 device files, but when I remove them
  for test, I can see busybox (almost sure it's coming from busybox)
  complaining that it cannot find the tty2~tty4 device files.
 
 Correct. You will have to create those nodes manually.
 
 
  I am trying to open a shell on my LCD (is it going to be tty2 ? I
  don't
  know) and I'm not sure if I have to make vcs1 vcs2 vcs3 files. And I
  don't know how to switch to LCD shell. during the boot, the texts come
  out on the LCD but I cannot see the texts (printf) from busybox. and
  cannot see the shell on LCD. When I press the keyboad, it looks like
  it's connected to tty1(I can see using prints on uart window). Can
  anybody tell me some direction?
 
 I think you need to point getty or a shell to the correct tty before you
 can see o/p on the screen. Do you know which device file you're supposed
 to create for the LCD? If so, just use that in your inittab.
 Something like:
 
 ::askfirst:-/bin/sh
 
 HTH,
 -mandeep
 
 
  
  From : Kernel bu.ker...@gmail.com
  Sent : 2014-03-11 14:44:09 ( +09:00 )
  To : Kim Chan c...@etri.re.kr
  Cc : kernelnewbies@kernelnewbies.org kernelnewbies@kernelnewbies.org
  Subject : Re: Does register_chrdev function make device file under /dev ?
 
 
 
  On Mar 10, 2014, at 10:25 PM, 김찬 c...@etri.re.kr wrote:
 
  Hi,
 
  This should be a basic question.
  Does the regisetr_chrdev function make the device file under /dev
 directory?
  I am running linux on our embedded system and inside vcs_init,
  register_chrdev is called as below.
 
  int __init vcs_init(void)
  {
  unsigned int i;
  if (register_chrdev(VCS_MAJOR, vcs, vcs_fops))
  panic(unable to get major %d for vcs device,
  VCS_MAJOR);
 
  I can see the function is returning ok but I don't

Re: Does register_chrdev function make device file under /dev ?

2014-03-10 Thread Kernel


 On Mar 10, 2014, at 10:25 PM, 김찬 c...@etri.re.kr wrote:
 
 Hi,
  
 This should be a basic question.
 Does the regisetr_chrdev function make the device file under /dev directory?
 I am running linux on our embedded system and inside vcs_init, 
 register_chrdev is called as below.
  
 int __init vcs_init(void)
 {
 unsigned int i;
 if (register_chrdev(VCS_MAJOR, vcs, vcs_fops))
 panic(unable to get major %d for vcs device, VCS_MAJOR);
  
 I can see the function is returning ok but I don't see any vcs* file under 
 /dev.
 Does it only register the device on /sys or /proc directory and not under 
 /dev?
 Thanks in advance.
  
 Chan
  

You have to create a device file using 'mknod'

Ex: mknod -m 666 /dev/vcs c major no minor no


 ___
 Kernelnewbies mailing list
 Kernelnewbies@kernelnewbies.org
 http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies