[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20181016062721.GA882@kroah.com>
Date: Tue, 16 Oct 2018 08:27:21 +0200
From: Greg KH <gregkh@...uxfoundation.org>
To: Roman Kiryanov <rkir@...gle.com>
Cc: linux-kernel@...r.kernel.org, Todd Kjos <tkjos@...gle.com>
Subject: Re: [PATCH v3 06/15] platform: goldfish: pipe: Move memory
allocation from probe to init
On Mon, Oct 15, 2018 at 12:06:12PM -0700, Roman Kiryanov wrote:
> > > probe does not know what memory to allocate. We have several versions
> > > of the driver (with different init) and different versions allocate
> > > different state.
> >
> > I only see one driver here.
>
> It will be added in "PATCH v3 15/15". There will be two init functions
> allocating different states.
I think we are getting our terms confused here.
"init" usually means module_init(), is that what you are referring to
here?
probe means when your bus-specific driver's probe function is called
because the kernel recognizes your hardware as being present.
At module_init time, you should do nothing except register your bus
specific driver.
At probe time, allocate memory all you want, that is the correct point
in time to do it.
So yes, if you have two separate drivers, you will have two separate
init functions, but both of them should just register the bus specific
driver.
> > Why does probe not know what to allocate? That is exactly when the
> > device is bound to the driver, you have _way_ more information than you
> > do at init time.
>
> We have two versions of the driver. Probe asks for the version and
> calls the init function for this version.
> I don't want probe to know everything about all versions.
Why would your probe function know, or care, about versions? That's up
to the driver core. How is your probe function learning about the
"version" to use here?
> > > >, not init time as what
> > > > happens if the hardware is not present yet your driver is loaded?
> > >
> > > init will have to rollback what it allocated.
> >
> > But those resources it will sit there wasted until unload happens. And
> > unload _never_ happens on a system unless you are a developer working on
> > the module.
>
> If probe fails I expect the kernel to release all resources. Is this
> not the case?
You have to clean up after your probe function failing before you return
from it.
thanks,
greg k-h
Powered by blists - more mailing lists