From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4002EC433E0 for ; Tue, 26 May 2020 16:06:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1A8B920787 for ; Tue, 26 May 2020 16:06:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590509200; bh=cvYB3hh7Q76PYz7hliuDbOXInt7xrd58ZtrEs29wRBw=; h=References:In-Reply-To:From:Date:Subject:To:Cc:List-ID:From; b=stJSgfhmqg/LT3ip2P9cDrPxtoHMW/gwBnzRIOzOOX1oeQn3gciS5ztCLuaYdNWB5 oNl+nYt8OqdcY136bpPr/DpdlRJCJg4XXS1dFL0MxY/5bIkV1S4q8d7iLApcWthARw eKFCleA4hUhreYeaTrllFrWx8hpexoXdn8dWV+nU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728301AbgEZQGh convert rfc822-to-8bit (ORCPT ); Tue, 26 May 2020 12:06:37 -0400 Received: from mail-oi1-f196.google.com ([209.85.167.196]:33144 "EHLO mail-oi1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727941AbgEZQGh (ORCPT ); Tue, 26 May 2020 12:06:37 -0400 Received: by mail-oi1-f196.google.com with SMTP id o24so19145577oic.0; Tue, 26 May 2020 09:06:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=c26RmLFN4y9M7Vs7EfSWgMEviKc2MmyIW9oT1wuhozo=; b=ahTd5HarRRGvm0TxkwSK2SVrnG0OUcco+8fAMnDVdXyVzDpMhfdPffs86FREdmZZ2F i278C5j0uC0dIIXuF0ISSBXhrX3Pkb4r0L2POLcr2CXuQEWmVvDesdeSAz6P7OTpfl6I Jnz01ev/ZGFzfGUTUXudCkuonc5b33t/35gex2TDuS/VkilJAJ7lUUSkmEY6Xsly4jue 38IkCaYAYQFMHu6NJPZOEBLrVt66O9lsvCvf8Eo1D8ZAy7UC606LPKldz7YGVTcQ38hn ht276Q2qNdGINWinfkxri9KVBSriSaVhA1DLuxzm+zzyehRBR1uEsDy4lNJRX9a0Rs8D IwFg== X-Gm-Message-State: AOAM531cpSQdEihvTSHocCtgEmZFMZu0LXmevvjUB0A4Szv1at++iYyR TAUqVgg/pzmljk/qtm6FaLGBILgDreWOpyfLkj4= X-Google-Smtp-Source: ABdhPJyiiCLhbG6JtUDbl1Up10+V4yfossUJYh4yAKCjzUPhWyxowp2NgBVmj4+4Sa3zxFepbl+ycVP4MzeV68GD/Vo= X-Received: by 2002:aca:eb56:: with SMTP id j83mr15203344oih.110.1590509195948; Tue, 26 May 2020 09:06:35 -0700 (PDT) MIME-Version: 1.0 References: <20200525182608.1823735-1-kw@linux.com> <20200525182608.1823735-9-kw@linux.com> <20200526063521.GC2578492@kroah.com> <20200526150744.GC75990@rocinante> <20200526152844.GA5809@rowland.harvard.edu> In-Reply-To: <20200526152844.GA5809@rowland.harvard.edu> From: "Rafael J. Wysocki" Date: Tue, 26 May 2020 18:06:24 +0200 Message-ID: Subject: Re: [PATCH 8/8] net/iucv: Use the new device_to_pm() helper to access struct dev_pm_ops To: Alan Stern Cc: "Rafael J. Wysocki" , =?UTF-8?Q?Krzysztof_Wilczy=C5=84ski?= , Greg Kroah-Hartman , Dan Carpenter , "Rafael J. Wysocki" , Len Brown , Kevin Hilman , Ulf Hansson , Pavel Machek , Johan Hovold , Alex Elder , Bjorn Helgaas , "James E.J. Bottomley" , "Martin K. Petersen" , Felipe Balbi , Julian Wiedmann , Karsten Graul , Ursula Braun , Jakub Kicinski , Bjorn Andersson , John Stultz , "David S. Miller" , greybus-dev@lists.linaro.org, netdev , ACPI Devel Maling List , Linux PCI , Linux PM , linux-s390@vger.kernel.org, "open list:TARGET SUBSYSTEM" , "open list:ULTRA-WIDEBAND (UWB) SUBSYSTEM:" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org On Tue, May 26, 2020 at 5:28 PM Alan Stern wrote: > > On Tue, May 26, 2020 at 05:19:07PM +0200, Rafael J. Wysocki wrote: > > On Tue, May 26, 2020 at 5:07 PM Krzysztof WilczyƄski wrote: > > > > > > Hello Greg, > > > > > > [...] > > > > It's "interesting" how using your new helper doesn't actually make the > > > > code smaller. Perhaps it isn't a good helper function? > > > > > > The idea for the helper was inspired by the comment Dan made to Bjorn > > > about Bjorn's change, as per: > > > > > > https://lore.kernel.org/driverdev-devel/20191016135002.GA24678@kadam/ > > > > > > It looked like a good idea to try to reduce the following: > > > > > > dev->driver && dev->driver->pm && dev->driver->pm->prepare > > > > > > Into something more succinct. Albeit, given the feedback from yourself > > > and Rafael, I gather that this helper is not really a good addition. > > > > IMO it could be used for reducing code duplication like you did in the > > PCI code, but not necessarily in the other places where the code in > > question is not exactly duplicated. > > The code could be a little more succinct, although it wouldn't fit every > usage. For example, > > #define pm_do_callback(dev, method) \ > (dev->driver && dev->driver->pm && dev->driver->pm->callback ? \ > dev->driver->pm->callback(dev) : 0) > > Then the usage is something like: > > ret = pm_do_callback(dev, prepare); > > Would this be an overall improvement? It wouldn't cover all of the use cases. For example, PCI does other things in addition to running a callback when it is present. Something like this might be enough though: #define pm_driver_callback_is_present(dev, method) \ (dev->driver && dev->driver->pm && dev->driver->pm->method) #define pm_run_driver_callback(dev, method) \ (pm_driver_callback_is_present(dev, method) ? dev->driver->pm->method(dev) : 0) #define pm_get_driver_callback(dev, method) \ (pm_driver_callback_is_present(dev, method) ? dev->driver->pm->method : NULL) so whoever needs the callback pointer can use pm_get_driver_callback() and whoever only needs to run the callback can use pm_run_driver_callback(). Cheers!