Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1597672pxb; Mon, 22 Feb 2021 06:17:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJxV/PdMIPKpR0f3wRWRygvnpGrrmc0kdvfa5odbNqfwhWu3IWwelB1oMR6oXUsx2qovpZv1 X-Received: by 2002:a17:906:ca58:: with SMTP id jx24mr18253447ejb.482.1614003464611; Mon, 22 Feb 2021 06:17:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614003464; cv=none; d=google.com; s=arc-20160816; b=eLsZBGXkRi6Vm4w+9dBwR8PEJZU/++m3dPPnqvLFxwyQ/hSrQNdaMLltnYa1RWQmFh SLRwCY85h30Qux+GaBmP0P0KnYPyTewJKJuBcSqyg5Io9HSl59Ckg4CL1t7dQojI31+c meicnZnkAMxfZLJOV2FE2in3p/Vb4Jzf78aF4KtovqquWCECCcKtnZkvVriHPQGF2yue ksJMoD6kuwTzLeOxpo3KAcLuMdRoZagvF9PK1VMCfi0d5vs0yI4YNiDvnlMb5qWIuhFQ KMIyZrJa+haxUBVeRZnVD2sUA541snjP7Pejod7O1bj4bRN8QCon6LZFHVRlYoJFZIXf LZQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=2vjozFVKQtbd9R8z6ePqX0QDJApxB9ca8f7RZkFJnhg=; b=sBMHIFBCAVl7Trl5sWAZwcgk192k95syu9wXUTT/fdVUsQ+YQyXP8CpkyyR+fuoAWd Dhz03y2YU3hjX6C0XHNyomZ14P4ELxsIGnpLYMQQoXTbwTQcPzWVk9IlXGzZbFDtGUEA WyJ+Wwwh69UJqXDo2EVjnfhlfSokagp48Ty7E+2881CrCv8FBZXwgdjFnZmjITWi8Ayc nq4v5zJXhUubD7L+SMa8T2WzLgnsSHM4OWwQQqvt771i+DgyDcZrDTVkd1kHD8jYsXHe GyzvDCinN24ulH4RzWr7jFpHJhlOhsU4bv8v+1ASJOcv6d4Q9RNCrObaSS7EqqKhtWI8 cTxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Hi9GAjgr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i23si12638428ejj.317.2021.02.22.06.17.21; Mon, 22 Feb 2021 06:17:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Hi9GAjgr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231466AbhBVOQl (ORCPT + 99 others); Mon, 22 Feb 2021 09:16:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232052AbhBVNnm (ORCPT ); Mon, 22 Feb 2021 08:43:42 -0500 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3815C061794; Mon, 22 Feb 2021 05:41:37 -0800 (PST) Received: by mail-pf1-x42c.google.com with SMTP id z5so3413047pfe.3; Mon, 22 Feb 2021 05:41:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=2vjozFVKQtbd9R8z6ePqX0QDJApxB9ca8f7RZkFJnhg=; b=Hi9GAjgrttZNmbGX5K+2Kqqbg6M2du1eGsAq53n8CmzY5H1DnRMVhUv7cxcbhdG/KT 6/uEjAsKYBtKHhjm9vAFCLvMsyzB2o2ZBNKPdj/wjzUhs/LukobtRL19TG3faPg2fhTA OrqKhFLw4if0HUzBja40r88q7kd42qHzs9VBaLb+FuNxV+lKOFjtI+KId3+Y9nT4eobz 6C305sht8qnXNIS7qpR9vvPezT5AGl32MyAVUOdfA8RLXE3Q6D/5JRfRxWqujtb58cvB tTLiiHKQ6ghlMyGZ0zdhc/+uH/2JnIbTp/uytRxw82KF64mfONjlnM2TXTc5+9hdrMN/ 0XQA== 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=2vjozFVKQtbd9R8z6ePqX0QDJApxB9ca8f7RZkFJnhg=; b=DYWKdsFvrYQpmNEaZnOaGw/7rB/XRWRB8+ERqExF4PP8Dx0Gl5ivHWWa6iLSD1RCDb MNX30b8HYoZX6BgsCIBdS5wJRdvG0AXrC6n1Sm6y4ZgoI9yAiEAsWow0umnYgx62PuvD vn0n7aVAmFQtoBLhJQLtOoe7IGTt2rL4CVGOoj4fU1KM84rdHyTywKyFmAecNLEnDBJA STBIdzEK92kFxSwb4+BJB/SPE6FMN1DVNudy08aGZQtj654tspvFJzasIyjFNNPbDrQe fuNW6BASO6Phthva5jnaOXe3rRTRE4Vs+Uh2RH8bT0IPuvEGwiAJB542kUZ2XYM8eIBO npbA== X-Gm-Message-State: AOAM533NCZM9FmXhGT+zi3f5p98pqm/NIoOSVJxVRGu9XrXQtW40OJpg +iFmRUXLZJNVtTr/Hab+C666F9fak0hNbcSZz9g= X-Received: by 2002:a63:2643:: with SMTP id m64mr12349805pgm.4.1614001297293; Mon, 22 Feb 2021 05:41:37 -0800 (PST) MIME-Version: 1.0 References: <20210222130735.1313443-1-djrscally@gmail.com> <20210222130735.1313443-3-djrscally@gmail.com> In-Reply-To: <20210222130735.1313443-3-djrscally@gmail.com> From: Andy Shevchenko Date: Mon, 22 Feb 2021 15:41:21 +0200 Message-ID: Subject: Re: [PATCH v3 2/6] ACPI: scan: Add function to fetch dependent of acpi device To: Daniel Scally , Andy Shevchenko Cc: Tomasz Figa , Sakari Ailus , Rajmohan Mani , "Rafael J. Wysocki" , Len Brown , Mika Westerberg , Linus Walleij , Bartosz Golaszewski , Wolfram Sang , Lee Jones , kieran.bingham+renesas@ideasonboard.com, Laurent Pinchart , Hans de Goede , Mark Gross , Maximilian Luz , Robert Moore , Erik Kaneda , me@fabwu.ch, Linux Kernel Mailing List , ACPI Devel Maling List , "open list:GPIO SUBSYSTEM" , linux-i2c , Platform Driver , devel@acpica.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 22, 2021 at 3:11 PM Daniel Scally wrote: > > In some ACPI tables we encounter, devices use the _DEP method to assert > a dependence on other ACPI devices as opposed to the OpRegions that the > specification intends. We need to be able to find those devices "from" > the dependee, so add a callback and a wrapper to walk over the > acpi_dep_list and return the dependent ACPI device. > Reviewed-by: Andy Shevchenko Nit-picks below as usual :-) > Signed-off-by: Daniel Scally > --- > Changes in v3: > - Switched from a standalone function to a callback passed to > acpi_walk_dep_device_list(). > > drivers/acpi/scan.c | 34 ++++++++++++++++++++++++++++++++++ > include/acpi/acpi_bus.h | 1 + > 2 files changed, 35 insertions(+) > > diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c > index c9e4190316ef..55626925261c 100644 > --- a/drivers/acpi/scan.c > +++ b/drivers/acpi/scan.c > @@ -2093,6 +2093,21 @@ static void acpi_bus_attach(struct acpi_device *device, bool first_pass) > device->handler->hotplug.notify_online(device); > } > > +static int __acpi_dev_get_dependent_dev(struct acpi_dep_data *dep, void *data) > +{ > + struct acpi_device *adev; > + int ret; > + > + ret = acpi_bus_get_device(dep->consumer, &adev); > + if (ret) > + /* If we don't find an adev then we want to continue parsing */ > + return 0; > + > + *(struct acpi_device **)data = adev; Hmm... I'm wondering if *(void **data) = adev; will compile and work. But on second thought the current code is more specific and explicit, which is good. > + > + return 1; > +} > + > static int __acpi_dev_flag_dependency_met(struct acpi_dep_data *dep, > void *data) > { > @@ -2145,6 +2160,25 @@ void acpi_dev_flag_dependency_met(acpi_handle handle) > } > EXPORT_SYMBOL_GPL(acpi_dev_flag_dependency_met); > > +/** > + * acpi_dev_get_dependent_dev - Return ACPI device dependent on @adev > + * @adev: Pointer to the dependee device > + * > + * Returns the first &struct acpi_device which declares itself dependent on > + * @adev via the _DEP buffer, parsed from the acpi_dep_list. > + */ > +struct acpi_device * > +acpi_dev_get_dependent_dev(struct acpi_device *supplier) I believe it will be okay to have it on one line > +{ > + struct acpi_device *adev = NULL; > + acpi_walk_dep_device_list(supplier->handle, > + __acpi_dev_get_dependent_dev, &adev); Ditto. > + return adev; > +} > +EXPORT_SYMBOL_GPL(acpi_dev_get_dependent_dev); > + > /** > * acpi_bus_scan - Add ACPI device node objects in a given namespace scope. > * @handle: Root of the namespace scope to scan. > diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h > index 91172af3a04d..5b14a9ae4ed5 100644 > --- a/include/acpi/acpi_bus.h > +++ b/include/acpi/acpi_bus.h > @@ -690,6 +690,7 @@ static inline bool acpi_device_can_poweroff(struct acpi_device *adev) > bool acpi_dev_hid_uid_match(struct acpi_device *adev, const char *hid2, const char *uid2); > > void acpi_dev_flag_dependency_met(acpi_handle handle); > +struct acpi_device *acpi_dev_get_dependent_dev(struct acpi_device *supplier); > struct acpi_device * > acpi_dev_get_next_match_dev(struct acpi_device *adev, const char *hid, const char *uid, s64 hrv); > struct acpi_device * > -- > 2.25.1 > -- With Best Regards, Andy Shevchenko