Subject: Re: another question about bus_space_map
To: Michael Richardson <mcr@sandelman.ottawa.on.ca>
From: Chris G. Demetriou <cgd@CS.cmu.edu>
List: tech-kern
Date: 02/05/1997 14:50:08
> >>>>> "Chris" == Chris G Demetriou <cgd@CS.cmu.edu> writes:
>     >> I take it that the probe routines should call bus_space_unmap
>     >> on allocated things if they fail to find a card?  What is an
>     >> invalid value for bus_space_handle_t? 0? ~0?
> 
>     Chris> there are no defined valid or invalid values.  the only
>     Chris> indication of 'validity' is the return value from
>     Chris> bus_space_map().
> 
>   The desire is to have a cleanup section that reads:
> 
> notfound:
>   if(some_alloc_handle) bus_space_unmap(iot,some_alloc_handle,...);
>   if(some_other_handle) bus_space_unmap(iot,some_other_handle,...);

Right.  I find it easiest to do something like something like:

	bus_space_handle_t h1, h2, h3;
	int have_h1, have_h2, have_h3;

	have_h1 = have_h2 = have_h3 = 0;

	/*
	 * .
	 * .
	 * .
	 *
	 * allocate handles as you need them, marking the have_h*
	 * variables appropriately.
	 *
	 * .
	 * .
	 * .
	 */

	if (have_h1)
		bus_space_umpa(iot, h1, ...);
	...

	return (return_value);


cgd