Subject: Re: CFR: The Auto-Generation Block/Character Device Switch Tables
To: MAEKAWA Masahide <>
From: Bill Studenmund <>
List: tech-kern
Date: 05/13/2002 09:56:59
On Mon, 13 May 2002, MAEKAWA Masahide wrote:

> Bill Studenmund <> wrote:
> >
> >True. And that can be an advantage.
> After my changes, all device interfaces is still global.
> If really want to call them directly, do it.

After thinking about it, just making the devsw public would be enough.

> >I think it needs to be "magiced" up. We have a lot of devices, and to
> >require every one of them to call devsw_attach(), when we can instead
> >autogen a config file that has the relevant info, seems wasteful.
> devsw_{attach,detach} is used only in the LKM framework now.
> I don't know the future.

Ok, that wasn't clear. Just wanting to make sure. :-)

> >See my suggested change to devsw_attach() below. This question is exacly
> >why I suggested it. :-)
> How about this?
> int devsw_attach(const char *devname, const struct bdevsw *bdev, int *bmajor,
>                  const struct cdevsw *cdev, int *cmajor);
> void devsw_detach(const struct bdevsw *bdev, const struce cdevsw *cdev);
> const struct bdevsw *bdevsw_lookup(dev_t dev);
> const struct cdevsw *cdevsw_lookup(dev_t dev);
> int bdevsw_lookup_major(const struct bdevsw *bdev);
> int cdevsw_lookup_major(const struct cdevsw *cdev);
> (should remove '_lookup'?)

I think the one _lookup that took character or block as a parameter was
fine, but this is fine too. I think the lookup functionality needs to be
there some way, so you need to keep some sort of interface.

> name <-> majors
> Get rid of devnametobdevmaj, chrtoblktabl and chrtoblk().
> struct devsw_conv {
>         const char *d_name;
>         int d_bmajor;
>         int d_cmajor;
> };
> const char *devsw_conv_blk2name(int);
> int devsw_conv_name2blk(const char *, char *, size_t);
> dev_t devsw_conv_chr2blk(dev_t);
> dev_t devsw_conv_blk2chr(dev_t);
> The intial conversion table is generated by config(8).

Good good.

> (should remove '_conv'?)


Take care,