From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (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 58D894085D; Tue, 20 Aug 2024 17:28:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724174920; cv=none; b=EhKjBXBkSnE3sqHe8ND5fTa2Iv+U5ZdV57ciOSQGU+QG44Ik79+WEF6g7TUyEiq6PEm+XqnBgut2qQiDNNqOAEdxWyM9foApWFrmtNVUcGM+A8q1TdABQdVbuSg4sFrhgvtSj0LZ9q3AbQ1bNxGh9T5dlfCJm2gxQb5j07vNLmg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724174920; c=relaxed/simple; bh=gxOpFPPyX4vEfDtz0VCkirxZGrDav49zs5925e143/I=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=oAJrqNOlvXLVw2EURpKrsT3bTeTtACMxCFrHllg9BjKgHsj1Nze6IernZcZ3xEpjR3Qedj0PMVC5UHSq5KZE8CeMMhyR53qJGGBYAPVQeamAD/TIGah7S3yAZwsNaY/sDRnVMLhpXp/NeO+zYDDF7/HYhWzIWRThhUdFnBfp2x8= 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=nU+36PWl; arc=none smtp.client-ip=198.175.65.18 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="nU+36PWl" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1724174920; x=1755710920; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=gxOpFPPyX4vEfDtz0VCkirxZGrDav49zs5925e143/I=; b=nU+36PWlLr2yy9b5oNKBlPOT/LX0Ijp7clA0Q1b8yXz3fl0/77P80Bz3 XnHIOp4QTUXfhKd/HpM8zot6Ed0Ij//c+gsyyDRKJ3cDrXwYEZc0m1NCJ 7eGIGDfsikBPmtvtCHptpCMUBy/YE2NwdKxBHr7dQjxwbgFAAmGlgM1hE 2DQD2TcfjTIGdAL8GKaAwfk3YcCEsTLiostydIzqMrXSehhERZL+1Zme5 LUYSA7ZNA4/J4SvXkh8kgH6rtJ4Y6KhxbdaeSVJU4QJtkcc4SAgrezJKI sxntn6dXVHS6gWDLbW9bfI+XLopO8TRb/5MiMQP1nREUJgwujHQEH5u4f g==; X-CSE-ConnectionGUID: +mIpcTNuTNuUXOs04YfrUA== X-CSE-MsgGUID: pPnitQ+8Sh2rLE+VuCLJAQ== X-IronPort-AV: E=McAfee;i="6700,10204,11170"; a="22644744" X-IronPort-AV: E=Sophos;i="6.10,162,1719903600"; d="scan'208";a="22644744" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2024 10:28:08 -0700 X-CSE-ConnectionGUID: M1PnaZKjTxGoD5szJQWUeQ== X-CSE-MsgGUID: o+OJD7p9Riqa+7SQuPBl6w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,162,1719903600"; d="scan'208";a="91523618" Received: from smile.fi.intel.com ([10.237.72.54]) by orviesa002.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2024 10:27:58 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.98) (envelope-from ) id 1sgSeA-0000000HOGh-1rJT; Tue, 20 Aug 2024 20:27:54 +0300 Date: Tue, 20 Aug 2024 20:27:54 +0300 From: Andy Shevchenko To: Stephen Boyd Cc: chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org, patches@lists.linux.dev, devicetree@vger.kernel.org, Douglas Anderson , Pin-yen Lin , Andrzej Hajda , Benson Leung , Conor Dooley , Daniel Vetter , David Airlie , Dmitry Baryshkov , dri-devel@lists.freedesktop.org, Guenter Roeck , Jernej Skrabec , Jonas Karlman , Krzysztof Kozlowski , Laurent Pinchart , Lee Jones , Maarten Lankhorst , Maxime Ripard , Neil Armstrong , Prashant Malani , Robert Foss , Rob Herring , Thomas Zimmermann , Tzung-Bi Shih , Alexandre Belloni , Daniel Scally , Greg Kroah-Hartman , Heikki Krogerus , Ivan Orlov , linux-acpi@vger.kernel.org, linux-usb@vger.kernel.org, Mika Westerberg , "Rafael J . Wysocki" , Sakari Ailus , Vinod Koul Subject: Re: [PATCH v3 05/17] usb: typec: Add device managed typec_switch_register() Message-ID: References: <20240819223834.2049862-1-swboyd@chromium.org> <20240819223834.2049862-6-swboyd@chromium.org> Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo On Tue, Aug 20, 2024 at 10:23:06AM -0700, Stephen Boyd wrote: > Quoting Stephen Boyd (2024-08-20 10:19:48) > > Quoting Andy Shevchenko (2024-08-20 10:16:40) > > > On Tue, Aug 20, 2024 at 10:01:07AM -0700, Stephen Boyd wrote: > > > > Quoting Andy Shevchenko (2024-08-20 03:16:09) > > > > > On Mon, Aug 19, 2024 at 03:38:19PM -0700, Stephen Boyd wrote: ... > > > > > > + ptr = devres_alloc(devm_typec_switch_unregister, sizeof(*ptr), GFP_KERNEL); > > > > > > + if (!ptr) > > > > > > + return ERR_PTR(-ENOMEM); > > > > > > + > > > > > > + switch_dev = typec_switch_register(parent ,desc); > > > > > > (Side note: wrong location of the white space) > > > > Thanks. > > > > > > > > > > > + if (!IS_ERR(switch_dev)) { > > > > > > (Side note: positive conditional is okay) > > > > > > > > > + *ptr = switch_dev; > > > > > > + devres_add(parent, ptr); > > > > > > + } else { > > > > > > + devres_free(ptr); > > > > > > + } > > > > > > > > > > devm_add_action_or_reset() ? > > > > > > > > No. We don't want to call the 'action' devm_typec_switch_unregister() > > > > when it fails because that would unregister a switch that has never been > > > > registered. > > > > > > Hmm... With devm_add_action_or_reset() we first do things and then try to add > > > them to the managed resources. In that case it won't be like you described. > > > > > > What do I miss? > > > > I believe you've missed that this is a wrapper around struct device and > > the error path is different (put_device() vs. device_unregister()). > > Or you're suggesting devm_add_action_or_reset() after registering the > switch? Sorry it wasn't clear to me. Yes, after successful switch registration. -- With Best Regards, Andy Shevchenko