Re: How do I choose an arbitrary minor number for my tty device?

From: Greg KH
Date: Wed Nov 17 2010 - 16:59:09 EST


On Wed, Nov 17, 2010 at 03:37:31PM -0600, Timur Tabi wrote:
> 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.

What is ePAPR?

> 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.

Why would you need this mapping? Just do a first-come-first serve
assignment of tty minor devices like all other subsystems do (usb,
serial, acm, etc.)

sysfs will show the representation between your ePAPR device "handle"
and the tty device minor just fine, as it does today for those other
types of devices.

Bonus being that udev will create a persistant device id for your tty
device based on that handle so you can just open that if you want to, no
need to get the kernel involved in sparse minor mappings at all.

Hope this helps,

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/