Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp4840826pxb; Mon, 28 Mar 2022 04:24:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJziHDtxoLKt0pfuFABVYIGxpLIQfqwR6Ow/jV62OMQWiKZyRgUFLHCKeeZc7N++HN2SeHkz X-Received: by 2002:a17:907:3d8c:b0:6df:4bdc:a282 with SMTP id he12-20020a1709073d8c00b006df4bdca282mr27172139ejc.464.1648466669793; Mon, 28 Mar 2022 04:24:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648466669; cv=none; d=google.com; s=arc-20160816; b=N+xs+YwTsWDkUV00Kqp9qUarvUMJ8ujHmduib2/46RmTY/13QVr5/23MXb8cdcDPiU XsYVGoBb6bPUnguOT2zrf/2igAepS+w0nrmlge9zbuh1HrD5nDtfGiuu+ff7Fmoi+BTi 0spiTmyc75ikOcWQSA2IPjz58mABUlRzabt80D2UVJjR9b8pFvfst4XUKB8/ipMAJks/ n5sCaXtpCmqY1YorNytcCfeSXZDmxHyqKPJsQ7KAzaecHqNUI6/0ODtd3jWOylZvSelA 932SvMIMqKhgtX4EkCB5h/hQIBM1qaWYeSREpk2di4+Da/T0+MNXX9G6YsiLyKFBaRe1 AQCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=K+ifjE/qGf9OdzW9CXScyEVA4D7+TBQTvmlA4M8f9xI=; b=fLBGuwySEjoZD53ZDc3Pl1YB0liP1AOtYuyICJF0CLOKDhCGSXVGS5/eHjjeMVetCd G4ezUDAFj7f4q8hUqsc4mxBM0GpQT1gr0MQCMdDrjL84h3yyXYssYhBd1ejJDehrEN/E n1tKT5J47yVxjDBrow9Ih+3J0roUOFW0K3MyZWCX9mJY0P2OWHS/0oAeSOpBYYE6sh98 DqTdIthsNowLeJo7z9gO6MTE5oEciwUXhBhClGY5MvNhzC9SkdHXnYmX0eX/PfaiN/un wxOfKGMalt4n5ValMPDgnDUBFB1v7rPGmpv6j3ZcNigV9adH2eF1qiZp3P6AS3/ZX3Ja TpUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=dUjn4iX2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u10-20020a1709060eca00b006df76385e6esi13294520eji.782.2022.03.28.04.23.45; Mon, 28 Mar 2022 04:24:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=dUjn4iX2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239210AbiC1IQv (ORCPT + 99 others); Mon, 28 Mar 2022 04:16:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239205AbiC1IQu (ORCPT ); Mon, 28 Mar 2022 04:16:50 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA5281275D; Mon, 28 Mar 2022 01:15:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1648455310; x=1679991310; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=+ly0OGq6gM5noH+O4k+peHcygWjXe0wzX2kxggo7hiU=; b=dUjn4iX2mLQQC+MSHoL1yNLV5Y3IWk1vaFSnm1eiSqSqDWf8t8q2ZLGk oTP/IMegaP1HNcNgh8bkpSdM0qbx6kyqIWypLxMMZ7Au0pZ67HsRy6Afz lPrABQSbTEHmV/kooRHG5NmAPm9/0o+oVogBFZ+rxRP1aZbnxewQ7S60C tSpp8bcyNaFrOIGYadIlD4RB0TD0kFUGN7Krzd00yCzjY+CmeWO3Iq/VL L8TDy2sIxF1yUFjqoLNI0yCnQLII08eqirDL4oAW/N5HDXZ8h8NV+6C/V 7HuG+cPAx/PW30iQsf1l0sH6yOCtdlFjCVUlN4zH2uKWteWCl51UmZUAc A==; X-IronPort-AV: E=McAfee;i="6200,9189,10299"; a="241095115" X-IronPort-AV: E=Sophos;i="5.90,216,1643702400"; d="scan'208";a="241095115" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2022 01:15:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,216,1643702400"; d="scan'208";a="694285824" Received: from kuha.fi.intel.com ([10.237.72.185]) by fmsmga001.fm.intel.com with SMTP; 28 Mar 2022 01:15:05 -0700 Received: by kuha.fi.intel.com (sSMTP sendmail emulation); Mon, 28 Mar 2022 11:15:05 +0300 Date: Mon, 28 Mar 2022 11:15:05 +0300 From: Heikki Krogerus To: Lukas Wunner Cc: "Rafael J. Wysocki" , Felipe Balbi , Andy Shevchenko , Sakari Ailus , linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, linux-acpi@vger.kernel.org Subject: Re: [PATCHv2 1/3] software node: Power management operations for software nodes Message-ID: References: <20201029105941.63410-1-heikki.krogerus@linux.intel.com> <20201029105941.63410-2-heikki.krogerus@linux.intel.com> <20220325164255.GA12710@wunner.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220325164255.GA12710@wunner.de> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Lukas, On Fri, Mar 25, 2022 at 05:42:55PM +0100, Lukas Wunner wrote: > Hi Heikki, > > saw this linked in your WSR and felt compelled to reply... ;) > > On Thu, Oct 29, 2020 at 01:59:39PM +0300, Heikki Krogerus wrote: > > +static int software_node_runtime_suspend(struct device *dev) > > +{ > > + struct swnode_pm_domain *domain = to_swnode_pm_domain(dev->pm_domain); > > + struct swnode *swnode = dev_to_swnode(dev); > > + int ret; > > + > > + if (domain->primary && domain->primary->ops.runtime_suspend) > > + ret = domain->primary->ops.runtime_suspend(dev); > > + else if (dev->type && dev->type->pm && dev->type->pm->runtime_suspend) > > + ret = dev->type->pm->runtime_suspend(dev); > > + else if (dev->class && dev->class->pm && dev->class->pm->runtime_suspend) > > + ret = dev->class->pm->runtime_suspend(dev); > > + else if (dev->bus && dev->bus->pm && dev->bus->pm->runtime_suspend) > > + ret = dev->bus->pm->runtime_suspend(dev); > > + else > > + ret = pm_generic_runtime_suspend(dev); > > This if/else ladder seems to be duplicated for every single PM callback > in this patch. > > Code size can be reduced significantly if you use offsetof() to determine > the offset of the given callback in struct pm_ops, then pass that offset > to a helper which contains the above-quoted if/else ladder and retrieves > the callback. Finally invoke the callback you've just retrieved. I think Sakari already suggested that. I'll improve this part in the next version. thanks, -- heikki