Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755131AbbK0R1c (ORCPT ); Fri, 27 Nov 2015 12:27:32 -0500 Received: from mail-ob0-f170.google.com ([209.85.214.170]:36376 "EHLO mail-ob0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754809AbbK0R13 (ORCPT ); Fri, 27 Nov 2015 12:27:29 -0500 MIME-Version: 1.0 In-Reply-To: <20151125163707.GA5363@kroah.com> References: <20151125163707.GA5363@kroah.com> From: Andy Lutomirski Date: Fri, 27 Nov 2015 09:27:09 -0800 Message-ID: Subject: Re: Releasing bus devices? To: Greg KH Cc: "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1677 Lines: 44 On Wed, Nov 25, 2015 at 8:37 AM, Greg KH 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/