public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Releasing bus devices?
@ 2015-11-25 16:21 Andy Lutomirski
  2015-11-25 16:37 ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: Andy Lutomirski @ 2015-11-25 16:21 UTC (permalink / raw)
  To: Greg KH, linux-kernel@vger.kernel.org

I'm writing a bus driver, and I'm confused.

If I create a class and class devices, I can set a release method on
the class.  But if I create a bus, there's no bus_type.dev_release.
Am I really supposed to manually set .release on each struct device
that I enumerate?  If so, why?

--Andy

-- 
Andy Lutomirski
AMA Capital Management, LLC

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Releasing bus devices?
  2015-11-25 16:21 Releasing bus devices? Andy Lutomirski
@ 2015-11-25 16:37 ` Greg KH
  2015-11-27 17:27   ` Andy Lutomirski
  0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2015-11-25 16:37 UTC (permalink / raw)
  To: Andy Lutomirski; +Cc: linux-kernel@vger.kernel.org

On Wed, Nov 25, 2015 at 08:21:36AM -0800, Andy Lutomirski wrote:
> I'm writing a bus driver, and I'm confused.

Yeah, writing a new bus is a major pain, I keep meaning to work on the
api every year or so when I have to write a new one, but then I just
suffer through it and never get around to it :(

> If I create a class and class devices, I can set a release method on
> the class.  But if I create a bus, there's no bus_type.dev_release.
> Am I really supposed to manually set .release on each struct device
> that I enumerate?  If so, why?

No, you shouldn't have to do that, the "struct device_type" that is
assigned to your device has a .release callback, that is what will be
called.  Make sure you set that for each device you create for your bus.

hope this helps,

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Releasing bus devices?
  2015-11-25 16:37 ` Greg KH
@ 2015-11-27 17:27   ` Andy Lutomirski
  0 siblings, 0 replies; 3+ messages in thread
From: Andy Lutomirski @ 2015-11-27 17:27 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-kernel@vger.kernel.org

On Wed, Nov 25, 2015 at 8:37 AM, Greg KH <gregkh@linuxfoundation.org> wrote:
> On Wed, Nov 25, 2015 at 08:21:36AM -0800, Andy Lutomirski wrote:
>> I'm writing a bus driver, and I'm confused.
>
> Yeah, writing a new bus is a major pain, I keep meaning to work on the
> api every year or so when I have to write a new one, but then I just
> suffer through it and never get around to it :(
>
>> If I create a class and class devices, I can set a release method on
>> the class.  But if I create a bus, there's no bus_type.dev_release.
>> Am I really supposed to manually set .release on each struct device
>> that I enumerate?  If so, why?
>
> No, you shouldn't have to do that, the "struct device_type" that is
> assigned to your device has a .release callback, that is what will be
> called.  Make sure you set that for each device you create for your bus.
>
> hope this helps,
>

It does, thanks.

One more question: device_destroy seems to be the opposite of
device_create.  But device_destroy does put_device and
device_unregister, and device_unregister also does put_device.  That
suggests that device_create returns a device with *two* references.
How does that happen?

I'm having trouble reconciling this with the fact that device_register
followed immediately by device_unregister appears to release the
device.

Is there some reference counting subtlety I'm missing?

--Andy

-- 
Andy Lutomirski
AMA Capital Management, LLC

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-11-27 17:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-25 16:21 Releasing bus devices? Andy Lutomirski
2015-11-25 16:37 ` Greg KH
2015-11-27 17:27   ` Andy Lutomirski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox