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

From: Timur Tabi
Date: Wed Nov 17 2010 - 17:42:56 EST


Greg KH wrote:
> I think you are forgetting that your byte channel devices must be
> "devices" in the system here, right? There is a 'struct bus_id" for
> your bus that these devices live on.

Do you mean "struct bus_type"? I don't have any concept of a "bus" in my
driver. I didn't know I needed to create one, and I'm not sure how, either.

I guess my real problem is that I'm not really sure what I should be doing. I
already have a plain character driver that creates devices for each byte
channel. First I call alloc_chrdev_region() to get a started dev_id. Then I
iterate over the byte channels and call device_create() for each one, with NULL
for the parent. At the end, I call cdev_init() and cdev_add().

Now I'm trying to register these byte channels as tty devices, because I'd like
to use them for the system console, and not just plain character devices. My
plan was to just call tty_register_device() instead of device_create(), so I
don't understand where the "bus" comes in. What bus?

> Then you create a tty device in
> your tty driver that attaches to the byte channel that shows up as a tty
> device on your bus.

Are you saying that when I call tty_register_device(), the third parameter
should be the return value from the previous call to device_create(), like this:

bc->dev_id = MKDEV(MAJOR(dev_id), MINOR(dev_id) + i);
bc->dev = device_create(ehv_bc_class, NULL, bc->dev_id, bc, "bc%u", bc->handle);
tty_register_device(ehv_bc_driver, MINOR(bc->dev_id), bc->dev);

--
Timur Tabi
Linux kernel developer at Freescale

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