From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jason Gunthorpe Subject: Re: [PATCH v4 2/2] Add "shutdown" to "struct class". Date: Wed, 31 May 2017 16:18:11 -0600 Message-ID: <20170531221811.GA12603@obsidianresearch.com> References: <20170530075419.766mlyxomxrzbxz6@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: tpmdd-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org To: Josh Zimmerman Cc: tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org, jmorris-gx6/JNMH7DfYtjvyW6yDsg@public.gmane.org List-Id: tpmdd-devel@lists.sourceforge.net On Wed, May 31, 2017 at 03:01:13PM -0700, Josh Zimmerman wrote: > >> + if (dev->class && dev->class->shutdown) { > >> + if (initcall_debug) > >> + dev_info(dev, "shutdown\n"); > >> + dev->class->shutdown(dev); > >> + } > >> if (dev->bus && dev->bus->shutdown) { > > I just looked again at this line, which I am suddenly skeptical of. Is there > any reason to run _both_ the class and the bus or driver shutdown > functions? In the code as-is, only the bus or the driver function will > execute. Right now, this patch will change that behavior. I suspect I > should just add the appropriate "else", but I'm not sure if there is > some reason to prefer the behavior as implemented in this version of > the patch. Yes, I think the else should be there. >>From what I could tell, the intent is that the most generic will then call the least generic in the proper order, eg tpm class shutdown full should then call bus and driver shutdown, if they are defined. This allows each step to inject some action both before and after calling the lower level steps, and follows the same pattern used elsewhere. Jason ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot