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=-4.0 required=3.0 tests=BAYES_00,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 C33DEC433B4 for ; Mon, 12 Apr 2021 18:12:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 74C3361358 for ; Mon, 12 Apr 2021 18:12:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239858AbhDLSNK (ORCPT ); Mon, 12 Apr 2021 14:13:10 -0400 Received: from mail-oi1-f177.google.com ([209.85.167.177]:46838 "EHLO mail-oi1-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238145AbhDLSNJ (ORCPT ); Mon, 12 Apr 2021 14:13:09 -0400 Received: by mail-oi1-f177.google.com with SMTP id m13so14300112oiw.13; Mon, 12 Apr 2021 11:12:50 -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; bh=LLRmIGD0mbtrbQWE0Wz075QLFoZ2M2WQQT4khJXSwzs=; b=kUI+/IAv+RCVodrsvsLq++s0fAz4nhefsBuN9M6ujTreL+GvdTO5BRDzy+ONu6rsRW VrR+/oV9dnd7tiBfRJ//aGkl15PEMjXteDXqCEgkjda7dVPqok40jJbBHRRd8ocZ1JUm RG6g5upa+uGI00pId3aTUaAyrPTvwdxCWiMzRPWe0k8aGpqDc/+H+23CV+mVIvbyt+rc PzxvZ8Vw9EBTSf+1pfQ+0+Lg3BpbiCrVeClEYCN/KrL1U2Mu4GCyEoDkDJGq4r6hO57m srhGvtqWZXgQZzkDYQA60KMxGLsJMZA1FP3w4adu8z9KrgG84gT0zfHEAqDRi7jOSD5x e6+g== X-Gm-Message-State: AOAM531hHqWg9rzAhFJkAxDXzXF1ColzzU3kp+hceLmNDN95upoRroLe 4X4xVVvZV020pINBDfClPBKjiXx8T/mUpJl43uyguF9B X-Google-Smtp-Source: ABdhPJxk0RjgumnGUEVHGOg01bTZd8kK1/X40tZnDgvo74P9hdZkOj1C8QiGp+eODzXqdmYVynrW+vck8hBPGp1WvKs= X-Received: by 2002:aca:aa8f:: with SMTP id t137mr315642oie.71.1618251169899; Mon, 12 Apr 2021 11:12:49 -0700 (PDT) MIME-Version: 1.0 References: <20210410134718.1942273-1-andy.shevchenko@gmail.com> In-Reply-To: From: "Rafael J. Wysocki" Date: Mon, 12 Apr 2021 20:12:38 +0200 Message-ID: Subject: Re: [PATCH v1 1/1] ACPI: bus: Introduce acpi_dev_get() and reuse it in ACPI code To: Andy Shevchenko Cc: "Rafael J. Wysocki" , Dwaipayan Ray , "Rafael J. Wysocki" , ACPI Devel Maling List , Linux Kernel Mailing List , "open list:ACPI COMPONENT ARCHITECTURE (ACPICA)" , "Rafael J. Wysocki" , Len Brown , Robert Moore , Erik Kaneda Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org On Mon, Apr 12, 2021 at 8:10 PM Andy Shevchenko wrote: > > On Mon, Apr 12, 2021 at 9:05 PM Rafael J. Wysocki wrote: > > > > On Mon, Apr 12, 2021 at 7:47 PM Andy Shevchenko > > wrote: > > > > > > On Mon, Apr 12, 2021 at 8:32 PM Rafael J. Wysocki wrote: > > > > On Sat, Apr 10, 2021 at 3:47 PM Andy Shevchenko > > > > wrote: > > > > > > ... > > > > > > > > static void get_acpi_device(void *dev) > > > > > { > > > > > - if (dev) > > > > > - get_device(&((struct acpi_device *)dev)->dev); > > > > > + acpi_dev_get(dev); > > > > > > > > I would do > > > > > > > > if (dev) > > > > acpi_dev_get(dev); > > > > > > > > here. > > > > > > Hmm... I don't see a point. acpi_dev_get() guaranteed to perform this check. > > > > > > > > } > > > > > > > > > > > +static inline void acpi_dev_get(struct acpi_device *adev) > > > > > +{ > > > > > + if (adev) > > > > > + get_device(&adev->dev); > > > > > > > > And I would drop the adev check from here (because the code calling it > > > > may be running with wrong assumptions if adev is NULL). Or it should > > > > return adev and the caller should be held responsible for checking it > > > > against NULL (if they care). > > > > > > But this follows the get_device() / put_device() logic. > > > > Not really. get_device() returns a pointer. > > > > > Personally I don't think this is a good idea to deviate. > > > > Well, exactly. :-) > > > > > Note the acpi_bus_get_acpi_device() > > > > This also returns a pointer. > > Is it okay to return a pointer in acpi_dev_get() then? Yes, it is, as I've said already.