[KJ] [RFC] request_region() error handling fixes

Badari Pulavarty pbadari at us.ibm.com
Thu Sep 28 08:04:12 PDT 2006


> > > If you don't like all these goto's :
> > >
> > > > +       if (!request_region(0x20,0x20,"pic1")) {
> > > > +               printk(KERN_WARNING"chrp_init: pic1 request region failed\n");
> > > > +               return;
> > > > +       }
> > > > +       if (!request_region(0xa0,0x20,"pic2")) {
> > > > +               printk(KERN_WARNING"chrp_init: pic2 request region failed\n");
> > > > +               goto out5;
> > > > +       }
> > > > +       if (!request_region(0x00,0x20,"dma1")) {
> > > > +               printk(KERN_WARNING"chrp_init: dma1 request region failed\n");
> > > > +               goto out4;
> > > > +       }
> > > > +       if (!request_region(0x40,0x20,"timer")) {
> > > > +               printk(KERN_WARNING"chrp_init: timer1 request region failed\n");
> > > > +               goto out3;
> > > > +       }
> > > > +       if (!request_region(0x80,0x10,"dma page reg")) {
> > > > +               printk(KERN_WARNING"chrp_init: dma page request region failed\n");
> > > > +               goto out2;
> > > > +       }
> > > > +       if (!request_region(0xc0,0x20,"dma2")) {
> > > > +               printk(KERN_WARNING"chrp_init: dma2 request region failed\n");
> > > > +               goto out1;
> > > > +       }
> >

I see lot of places where we try acquire multiple regions, so all these
places need to handle errors and release already acquired ones properly.
I am just wondering, if we are better off introducing/requesting a new
interface like request_regions() and release_regions() which iterates
over a vector of requests and handles them properly ?

Thanks,
Badari




More information about the Kernel-janitors mailing list