devfs
[Top] [All Lists]

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

To: Jon Grimm <jgrimm@xxxxxxxxxx>
Subject: Re: non-DevFS behavior of devfs_register returns NULL; seems backwords
From: Richard Gooch <rgooch@xxxxxxxxxxxxx>
Date: Wed, 24 Jan 2001 12:06:11 +1100
Cc: devfs <devfs@xxxxxxxxxxx>
In-reply-to: <3A6E257E.E522FD37@xxxxxxxxxx>
References: <3A6E257E.E522FD37@xxxxxxxxxx>
Sender: owner-devfs@xxxxxxxxxxx
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>