devfs
[Top] [All Lists]

Re: non-DevFS behavior of devfs_register returns NULL; seems backwords

To: devfs <devfs@xxxxxxxxxxx>
Subject: Re: non-DevFS behavior of devfs_register returns NULL; seems backwords
From: "Jon Grimm" <jgrimm@xxxxxxxxxx>
Date: Wed, 24 Jan 2001 09:20:53 -0600
Cc: rgooch@xxxxxxxxxxxxx
Importance: Normal
Sender: owner-devfs@xxxxxxxxxxx
On a similar note:  How would one programatically know that
devfs_register_series failed?  I can't very well take any sort of action if
I don't know there is a problem.

I have another module (doesn't actually drive hardware), that if this or
other similar initialization steps were to fail it really would have no
point in continuing and should fail to init/load.

Since devfs_register_series works on a whole series of entries, I'm not
quite sure what could be returned; maybe the parent dir with NULL on error?
maybe an rc?

Regards,
Jon Grimm
jgrimm@xxxxxxxxxx


To:   Jon Grimm/Austin/IBM@IBMUS
cc:   devfs <devfs@xxxxxxxxxxx>
Subject:  Re: non-DevFS behavior of devfs_register returns NULL; seems
      backwords



Jon Grimm writes:
> Hi,
>     Working a new driver and am using the devfs_*  APIs right from the
> start.    I like the inlined compatibility functions that are provided
> when the kernel is not configured to build devfs support, however .....
>
> I noticed that the inlined devfs_register API returns a NULL.
> Unfortunately, this return code matches the error condition of
> devfs_register.   So my error routines kick in on a non-DevFS build.
>
> Could devfs_register ever fail?  I don't see many examples of
> checking the returned handle in other driver source, but I'm try
> hard to check advertised failure behavior.  I could put #ifdef
> CONFIG_DEVFS_FS in my code, but this would seem to defeat the
> purpose of the compatibility macros, as well as, introduce a (minor)
> future maintenance issue if CONFIG_DEVFS_FS goes away with DevFS
> becoming mainstream.

devfs_register() could fail for a number of reasons, including lack of
memory. It should generate a message on error.

> Would there be other side-effects to returning a non-NULL return code.
> Is it worth the trouble?

The devfs API is designed to ignore NULL entry pointers, so it's safe
to call devfs_register() and pass the result to another function. So
don't generate your own message if you get NULL.

                    Regards,

                         Richard....
Permanent: rgooch@xxxxxxxxxxxxx
Current:   rgooch@xxxxxxxxxxxxxxx



<Prev in Thread] Current Thread [Next in Thread>