Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932714AbVLHXXE (ORCPT ); Thu, 8 Dec 2005 18:23:04 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S932713AbVLHXXE (ORCPT ); Thu, 8 Dec 2005 18:23:04 -0500 Received: from caramon.arm.linux.org.uk ([212.18.232.186]:30223 "EHLO caramon.arm.linux.org.uk") by vger.kernel.org with ESMTP id S932714AbVLHXXB (ORCPT ); Thu, 8 Dec 2005 18:23:01 -0500 Date: Thu, 8 Dec 2005 23:22:54 +0000 From: Russell King To: Jean Delvare Cc: Dmitry Torokhov , Greg KH , LKML Subject: Re: [PATCH] Minor change to platform_device_register_simple prototype Message-ID: <20051208232254.GC9357@flint.arm.linux.org.uk> Mail-Followup-To: Jean Delvare , Dmitry Torokhov , Greg KH , LKML References: <20051205202707.GH15201@flint.arm.linux.org.uk> <200512070105.40169.dtor_core@ameritech.net> <20051207180842.GG6793@flint.arm.linux.org.uk> <20051207190352.GI6793@flint.arm.linux.org.uk> <20051207225126.GA648@kroah.com> <20051208215257.78d7c67a.khali@linux-fr.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20051208215257.78d7c67a.khali@linux-fr.org> User-Agent: Mutt/1.4.1i Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1419 Lines: 34 On Thu, Dec 08, 2005 at 09:52:57PM +0100, Jean Delvare wrote: > BTW, doesn't this suggest that the error path in > platform_device_register_simple() is currently broken as well? If > platform_device_add() fails therein, I take it that the resources > previously allocated by platform_device_add_resources() will never be > freed. No. If platform_device_add() fails then you platform_device_put() it with no other action. If it's been added, with the current available interfaces, your only option is to platform_device_unregister() it. So: - error during platform_device_alloc, no additional action necessary - error returned by platform_device_add, you have a structure allocated and initialised, you platform_device_put it. - subsequently you want to get rid of it, platform_device_unregister it, or alternatively platform_device_del + platform_device_put it (where provided.) This is actually a generic driver model rule which can be applied to all driver model interfaces which have the alloc/init, add, del, put, register, unregister methods. -- Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of: 2.6 Serial core - 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/