Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp818536iog; Mon, 13 Jun 2022 13:44:39 -0700 (PDT) X-Google-Smtp-Source: AGRyM1ukBQ7FYQ1xMV41bZA+yGCNXBoqeKqBkcLoYLZ591Y7E/jCRoCcqC+/fvtwQSJVNFHgzqUn X-Received: by 2002:a05:6402:35d0:b0:42e:1a76:67ae with SMTP id z16-20020a05640235d000b0042e1a7667aemr1801644edc.311.1655153079563; Mon, 13 Jun 2022 13:44:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655153079; cv=none; d=google.com; s=arc-20160816; b=BSzTzcFj7jBCxVTKL+9tLQOdJ/xVdzxEPX/jAsdLVHuON3CHt5YJvSW2hPiiafPsv0 GrsPAkUOwig52YSihhtdDmLMS0olqk5uZYCdJehF1VnoQ7jAcaD3uq9E7wIUCjbvC9B8 xiAt7rAC7x4JZmNGOSsb4QJ6ST85/aub7odwGTjDhgKlsx0LSH0apsmR1iZf5lO0Y9Gi 72UyX+W8skLXA2gXulm/eEAKECVM1rZzSRkFdeh2abmIVIZ0DB3VL9U5I5TfbjH/azX5 i8zkNgQ9uDOQ7+QB7bHNdo/FTeUBJgv+F1ugXudPvKCC1ZTbkdpVxl9Nqe9ILbCON/q0 lcOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=W8flbSXaUZjsRMPA8okirjGr4Rh28cjxj1EpLdcWyGQ=; b=cIC+r9efI+sgakw3wgggiPZoTbYuKfG1M+Vfhd9msb4L10WCI5/iv5OusTkpmAdLzg HxRtZ7SN73OJwxzmyJ+feY8/VqjdocBv5l+tjEbdUyOzJnYJf3EW2EIIzuTxeRKsDDXd JG8hc0/GHiQ6J1LeQ0dA765KUD8lTjqp/W9A8o8yIuMYzqVkrIg+pUoD56yGItEvIwgh FOhEkEo4iCQBbwZsUYdERy99F2QCA2dBXnQ41Ts59J0Z3GkuKjF0ycS+a5sufr/7z28V 9yQdD3xa24XPiKcfRk7Qnv3T58HM8sVtWMUny1hPFxWkNZjv7cST4Gqulkq8V0ZVlH2w 7IZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=acZCmGCy; 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 c14-20020aa7c74e000000b00430f6f56a0dsi8434606eds.265.2022.06.13.13.44.14; Mon, 13 Jun 2022 13:44:39 -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=acZCmGCy; 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 S1351012AbiFMURO (ORCPT + 99 others); Mon, 13 Jun 2022 16:17:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350960AbiFMUQy (ORCPT ); Mon, 13 Jun 2022 16:16:54 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A501737AA; Mon, 13 Jun 2022 11:54:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1655146485; x=1686682485; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=rrteT8J06qadrldMcQRzRLZphFKmersKJgLFFUeBMAw=; b=acZCmGCyIAErSAEvtzRqpmxCogNIu7Kx1odcmKEC80A+F3SCN1890qMk 5jhVe6X8vBNAaCEJyXllB2lrzKQtYbBc187mf/UCcfbq/tWT1kTHoJ6Hs YcouSYYeZdDrK2uPj1e0niTPUdLoFi8PsUA/Ofu00hnzilW6n1Ri6YFuS kShvxtnbZzhD0o1Bz3xaE8kjxMD/4Rob6AzYa4xkkRPqhkCqoDnklsJrR U7XCLh6xBhzz5Dl2fQHhk0xIugkyXQaSpSFyPM9f/vOaQPK2HvbUEmMyg 1u5QKX607sIHXm3a0CgjyYg+vKL+mH0/rpmxsxTB5VQxjWyN7yk3hQKLP Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10377"; a="278412731" X-IronPort-AV: E=Sophos;i="5.91,297,1647327600"; d="scan'208";a="278412731" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jun 2022 11:54:43 -0700 X-IronPort-AV: E=Sophos;i="5.91,297,1647327600"; d="scan'208";a="686212131" Received: from smile.fi.intel.com ([10.237.72.54]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jun 2022 11:54:39 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.95) (envelope-from ) id 1o0pCu-000bIa-OV; Mon, 13 Jun 2022 21:54:36 +0300 Date: Mon, 13 Jun 2022 21:54:36 +0300 From: Andy Shevchenko To: "Rafael J. Wysocki" Cc: Linux ACPI , LKML , Linux PM , Mika Westerberg , Hans de Goede , Sakari Ailus , Henrique de Moraes Holschuh , Mark Gross , ibm-acpi-devel@lists.sourceforge.net, platform-driver-x86@vger.kernel.org Subject: Re: [PATCH v2 12/16] platform/x86/thinkpad_acpi: Use acpi_dev_for_each_child() Message-ID: References: <1843211.tdWV9SEqCh@kreacher> <2653857.mvXUDI8C0e@kreacher> <2091400.OBFZWjSADL@kreacher> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2091400.OBFZWjSADL@kreacher> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,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 On Mon, Jun 13, 2022 at 08:30:19PM +0200, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki > > Instead of walking the list of children of an ACPI device directly, > use acpi_dev_for_each_child() to carry out an action for all of > the given ACPI device's children. > > This will help to eliminate the children list head from struct > acpi_device as it is redundant and it is used in questionable ways > in some places (in particular, locking is needed for walking the > list pointed to it safely, but it is often missing). Reviewed-by: Andy Shevchenko > Signed-off-by: Rafael J. Wysocki > --- > > v1 -> v2: > * Eliminate unnecessary branch (Andy). > > --- > drivers/platform/x86/thinkpad_acpi.c | 53 +++++++++++++++++------------------ > 1 file changed, 27 insertions(+), 26 deletions(-) > > Index: linux-pm/drivers/platform/x86/thinkpad_acpi.c > =================================================================== > --- linux-pm.orig/drivers/platform/x86/thinkpad_acpi.c > +++ linux-pm/drivers/platform/x86/thinkpad_acpi.c > @@ -6841,6 +6841,31 @@ static const struct backlight_ops ibm_ba > > /* --------------------------------------------------------------------- */ > > +static int __init tpacpi_evaluate_bcl(struct acpi_device *adev, void *not_used) > +{ > + struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; > + union acpi_object *obj; > + acpi_status status; > + int rc; > + > + status = acpi_evaluate_object(adev->handle, "_BCL", NULL, &buffer); > + if (ACPI_FAILURE(status)) > + return 0; > + > + obj = buffer.pointer; > + if (!obj || obj->type != ACPI_TYPE_PACKAGE) { > + acpi_handle_info(adev->handle, > + "Unknown _BCL data, please report this to %s\n", > + TPACPI_MAIL); > + rc = 0; > + } else { > + rc = obj->package.count; > + } > + kfree(obj); > + > + return rc; > +} > + > /* > * Call _BCL method of video device. On some ThinkPads this will > * switch the firmware to the ACPI brightness control mode. > @@ -6848,37 +6873,13 @@ static const struct backlight_ops ibm_ba > > static int __init tpacpi_query_bcl_levels(acpi_handle handle) > { > - struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; > - union acpi_object *obj; > - struct acpi_device *device, *child; > - int rc; > + struct acpi_device *device; > > device = acpi_fetch_acpi_dev(handle); > if (!device) > return 0; > > - rc = 0; > - list_for_each_entry(child, &device->children, node) { > - acpi_status status = acpi_evaluate_object(child->handle, "_BCL", > - NULL, &buffer); > - if (ACPI_FAILURE(status)) { > - buffer.length = ACPI_ALLOCATE_BUFFER; > - continue; > - } > - > - obj = (union acpi_object *)buffer.pointer; > - if (!obj || (obj->type != ACPI_TYPE_PACKAGE)) { > - pr_err("Unknown _BCL data, please report this to %s\n", > - TPACPI_MAIL); > - rc = 0; > - } else { > - rc = obj->package.count; > - } > - break; > - } > - > - kfree(buffer.pointer); > - return rc; > + return acpi_dev_for_each_child(device, tpacpi_evaluate_bcl, NULL); > } > > > > > -- With Best Regards, Andy Shevchenko