Richard,
I do not believe I described my dilema sufficiently. DevFS works
just fine. When I am _not_ building with CONFIG_DEVFS_FS, the
'devfs_fs_kernel.h' defines some inline functions for compatibility. The
inline function for devfs_register returns NULL. So for example:
handle = devfs_register(NULL, "myname", DEVFS_FL_NONE, major, 0,
S_IFCHR|S_IRUGO, &fops, NULL);
if(!handle)
goto err_register;
Building with CONFIG_DEVFS_FS, the code works fine, building without does
not. I think the inline compat. function for devfs_register should return
something non-NULL. Otherwise, it seems to defeat the purpose of having
those compatibility functions.
Thanks for the response. I does seem from your note, that there can be
situations were this routine will fail.
Jon Grimm, (or better known as the goof who did not spellcheck 'backwords')
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
|