public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* How do I choose an arbitrary minor number for my tty device?
@ 2010-11-17 21:37 Timur Tabi
  2010-11-17 21:51 ` Greg KH
  0 siblings, 1 reply; 49+ messages in thread
From: Timur Tabi @ 2010-11-17 21:37 UTC (permalink / raw)
  To: Arnd Bergmann, Greg Kroah-Hartman, Linux Kernel Mailing List
  Cc: Scott Wood, Stuart Yoder

Arnd and Greg,

I'm working on a TTY driver for a virtual device that we call "byte channels".
This are likes pipes, but they go through an ePAPR hypervisor.

The hypervisor declares byte channels as nodes in a device tree.  Each byte
channel has a unique 32-bit number called a "handle", and this handle is
specified in the node for that device tree.  Applications are expected to scan
the device tree to look for the node they want, and then extract the handle from
that node.

The problem I have is that the handles are, from Linux's perspective, arbitrary
and sparsely assigned.  For example, we could have four byte channels with
handles of 2, 8, 73, and 74.

What I would like is for the minor number for each tty device to be the byte
channel handle.  Or the byte channel could be in the /dev name.  Either way,
applications can figure out which /dev entry to open in order to communicate
with a given byte channel.

Unfortunately, the only way I know how to do this is to create a separate tty
driver instance for each byte channel.  This is because of this code in
tty_register_driver:

	if (!(driver->flags & TTY_DRIVER_DEVPTS_MEM) && driver->num) {
		p = kzalloc(driver->num * 2 * sizeof(void *), GFP_KERNEL);
		if (!p)
			return -ENOMEM;
	}

The 'index' passed to tty_register_device() is added to minor_start to create
the /dev entry, and it's added to name_base to create the name.  If I specify a
very large number for driver->num, then tty_register_driver will create a large
but sparsely-populated array.

Would you be okay with creating a separate driver for each byte channel, or is
there a better way to do what I want?

--
Timur Tabi
Linux kernel developer at Freescale


^ permalink raw reply	[flat|nested] 49+ messages in thread

end of thread, other threads:[~2010-12-02 16:12 UTC | newest]

Thread overview: 49+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-17 21:37 How do I choose an arbitrary minor number for my tty device? Timur Tabi
2010-11-17 21:51 ` Greg KH
2010-11-17 22:10   ` Timur Tabi
2010-11-17 22:19     ` Greg KH
2010-11-17 22:42       ` Timur Tabi
2010-11-18  2:24         ` Greg KH
2010-11-18 15:31           ` Timur Tabi
2010-11-18 15:39             ` Greg KH
2010-11-18 16:03               ` Timur Tabi
2010-11-18 16:33                 ` Greg KH
2010-11-18 16:36                   ` Timur Tabi
2010-11-18 16:51                     ` Greg KH
2010-11-18 16:56                       ` Timur Tabi
2010-11-18 17:18                         ` Greg KH
2010-11-18 17:38                           ` Timur Tabi
2010-11-18 17:58                             ` Greg KH
2010-11-18 19:35                               ` Timur Tabi
2010-11-18 20:02                                 ` Greg KH
2010-11-18 20:06                                   ` Timur Tabi
2010-11-18 20:10                                     ` Greg KH
2010-11-18 20:43                                       ` Timur Tabi
2010-11-18 20:56                                         ` Alan Cox
2010-11-22 16:32                                           ` Timur Tabi
2010-11-22 20:12                                             ` Timur Tabi
2010-11-23 13:56                                             ` Alan Cox
2010-11-23 17:14                                               ` Timur Tabi
2010-11-23 23:03                                                 ` Alan Cox
2010-11-18 20:58                                 ` Alan Cox
2010-11-18 17:21                 ` Scott Wood
2010-11-18 17:42                   ` Timur Tabi
2010-11-18 17:58                     ` Greg KH
2010-11-18 18:13                     ` Scott Wood
2010-11-24 10:23                       ` Michael Ellerman
2010-11-24 18:08                         ` Scott Wood
2010-11-24 18:23                           ` Greg KH
2010-11-24 22:44                             ` Michael Ellerman
2010-11-29 21:44                               ` Greg KH
2010-11-29 21:51                                 ` Timur Tabi
2010-11-29 22:30                                   ` Greg KH
2010-11-29 22:36                                     ` Timur Tabi
2010-11-30  3:29                                       ` Greg KH
2010-11-30  4:15                                         ` Tabi Timur-B04825
2010-11-30 19:33                                         ` Timur Tabi
2010-12-01  1:00                                           ` Greg KH
2010-12-01  9:54                                             ` Kay Sievers
2010-12-02 16:12                                               ` Timur Tabi
2010-11-24 22:46                           ` Michael Ellerman
2010-11-25  4:10                             ` Grant Likely
2010-11-24 18:13                         ` Scott Wood

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox