From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B3B9236AF2; Sun, 21 Jan 2024 12:28:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.9 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705840141; cv=none; b=QuqH/gGRaKnGIrOk7EyfXSgKUWd/p/CEZ6DMUkuKvPBzg+/y5j2drjAUoAHqd3zzKK9Ae+kwyVqV1tWgbTySxDwA5UB+buByvwDcMd04h0uXlqmj/8a3Q59xfe/bB744lGIj2WDbJtbU13bMwlPCl9dusGTN2mbLCQcuBkYx7lA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705840141; c=relaxed/simple; bh=Y6ol/RDZQ2ez7fxRFYvFa1Ns5wBcgPZcyyD8Gbgkfo0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=tRyoZs8lf7pveVgo+iymDRGcvd+zSQSN4InMUzuMGgoYTDHVIBqBLsplULzS5rdrSKRTnPJQ58FJl0B+YdTQI7SfK9LVjGP1VluNxJzGR8m/YuyAXV6neB72eWQOjjMsQQc/pFc34HQp1sQTNPVKwXnKs8QnzIC2MPhOx2ixSx8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=BuBTEzBx; arc=none smtp.client-ip=192.198.163.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="BuBTEzBx" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1705840140; x=1737376140; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=Y6ol/RDZQ2ez7fxRFYvFa1Ns5wBcgPZcyyD8Gbgkfo0=; b=BuBTEzBxA6YzjUFGpG8WjOg7P6aTgt6L4pJFeLNkGUlJ62XXNqfYYWMH SJ8RSFMiwtEQ9iRQz0pIuhQZyse/cU/8IJ7Ruj+auXSS9BLqnjAloEtfQ bIMt3QXF7eBa+idh1KJcYFGN39LGGqx+ZqNlxle2kEsJ4oWI4nr3dfVJD XIRORjDcUhhdyEsr4L0xpaukvv5W4E8B58W7jbXzqhD2CAfePrgQIAGnp +SmarRtNvt0KpQDlnBzBrA/NpTCXqqTFqN3hoiXBoHi45QFUCfgeqVmoD J/V2Oka5/OzYc5kV0lDMtlvYwLLISEOOCs27/XUTcgae6w5B4qdYuldh6 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10959"; a="7785771" X-IronPort-AV: E=Sophos;i="6.05,209,1701158400"; d="scan'208";a="7785771" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jan 2024 04:28:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10959"; a="958501216" X-IronPort-AV: E=Sophos;i="6.05,209,1701158400"; d="scan'208";a="958501216" Received: from smile.fi.intel.com ([10.237.72.54]) by orsmga005.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jan 2024 04:28:52 -0800 Received: from andy by smile.fi.intel.com with local (Exim 4.97) (envelope-from ) id 1rRWwS-0000000FcGE-0aPg; Sun, 21 Jan 2024 14:28:48 +0200 Date: Sun, 21 Jan 2024 14:28:47 +0200 From: Andy Shevchenko To: Jonathan Cameron Cc: linux-iio@vger.kernel.org, "Rafael J . Wysocki" , Len Brown , linux-acpi@vger.kernel.org, Greg Kroah-Hartman , Daniel Scally , Heikki Krogerus , Sakari Ailus , Nuno =?iso-8859-1?Q?S=E1?= , Cosmin Tanislav , Mihail Chindris , Rasmus Villemoes , Tomislav Denis , Marek Vasut , Olivier Moysan , Fabrice Gasnier , Lad Prabhakar , Dmitry Baryshkov , Marijn Suijten , Marius Cristea , Ibrahim Tilki , Jonathan Cameron Subject: Re: [PATCH 01/13] device property: Add cleanup.h based fwnode_handle_put() scope based cleanup. Message-ID: References: <20240114172009.179893-1-jic23@kernel.org> <20240114172009.179893-2-jic23@kernel.org> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240114172009.179893-2-jic23@kernel.org> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo On Sun, Jan 14, 2024 at 05:19:57PM +0000, Jonathan Cameron wrote: > From: Jonathan Cameron > > This allows the following > > struct fwnode_handle *child __free(kfree) = NULL; > > device_for_each_child_node(dev, child) { > if (false) > return -EINVAL; > } > > without the fwnode_handle_put() call which tends to complicate early > exits from such loops and lead to resource leak bugs. > > Can also be used where the fwnode_handle was obtained from a call > such as fwnode_find_reference() as it will safely do nothing if > IS_ERR() is true. ... > struct fwnode_handle *fwnode_handle_get(struct fwnode_handle *fwnode); > void fwnode_handle_put(struct fwnode_handle *fwnode); I would add a blank line here > +DEFINE_FREE(fwnode_handle, struct fwnode_handle *, > + if (!IS_ERR_OR_NULL(_T)) fwnode_handle_put(_T)) > > int fwnode_irq_get(const struct fwnode_handle *fwnode, unsigned int index); > int fwnode_irq_get_byname(const struct fwnode_handle *fwnode, const char *name); With the above, Reviewed-by: Andy Shevchenko -- With Best Regards, Andy Shevchenko