Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp5936512rwb; Wed, 7 Sep 2022 10:04:28 -0700 (PDT) X-Google-Smtp-Source: AA6agR6dPHPTbSycHQcyxOYOY/IHtbRJoTTSXOP7gXy+OLK52VP4UQlBpx+Qu6csRQN9X41kskds X-Received: by 2002:a17:906:cc13:b0:73d:d22d:63cd with SMTP id ml19-20020a170906cc1300b0073dd22d63cdmr3012974ejb.741.1662570268744; Wed, 07 Sep 2022 10:04:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662570268; cv=none; d=google.com; s=arc-20160816; b=xTyFmWOfeocftL23qla8lMWOxMyc9KgFhTfXjxt6n7LT5/X9NkVyYvBWHNDxKzNydD 6wPjRMxja1T5nvMbB3r+iHIHPXorh3uVhcNTpqjgFhomTay85ByaJi6Zi64E5rTCgg6a /TofFtwfj3zjxRfc79utmssrRB8R6xHzDmaQYLC3/MhZSxSBN0E6hl3Oa+GqVI0Dn4Oy Teh/jxJo6tgZzZ3HpiN1qZM/51y1w1sIoLv8+++HUYKOYD1fWFERtfKGzpLrKG/ol2Za WOMaBW1YlOmevtP3jvAGoJ1DrHvcm2tbub+Niop5Tr5kZAbjlNwxkVtIZUe9uxgR4S32 4ZmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=UmoqdAJH7nv4AvlEILIBNf1YFl1jQ3LL1/HxZNLvFrw=; b=JWC+Y3JUhXiRcHjo0FXAe91wRYWLRsL+5vfe/JU2Vi/dRUvIrO1/5i1TF+zt+mS7oe 8ECHv4zaJa43+TJDXlZ05LJv8RY5QkvN476l0EuGeiiev7vR6n3HxAFlqNrYOpIu9Y9I uDd7TQrhRPHWSNKjPDZeg5iyNM23YvayWrvJZo0fXhGZueJhuWRAa6AoZrEYb88InV8F I8beCb7y857CehSGccRHh5XRNOKMzUR0W2Mf059r6rhsAayAnfSc6ls9j65SiV2NakYu huNCsXiukSc9IAlJ6D9M3yosVYbA2BaoZoMJNZXA0qsuuFF7WhJXL+S+olzya0mmiHe7 T11Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nTNA84VN; 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 y25-20020a170906471900b007416895306fsi10048681ejq.645.2022.09.07.10.04.03; Wed, 07 Sep 2022 10:04:28 -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=nTNA84VN; 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 S229740AbiIGQ40 (ORCPT + 99 others); Wed, 7 Sep 2022 12:56:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230046AbiIGQ4M (ORCPT ); Wed, 7 Sep 2022 12:56:12 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1890663F35; Wed, 7 Sep 2022 09:56:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662569770; x=1694105770; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=m0kanKnTB7upr4A4R2TXWHbPaIPkjlnBprjRvh+trso=; b=nTNA84VNbIqn3CY2Q1anEAPsbrgDlUBcSXjc5RzYGn4xrNv3jJ6L4uQ8 ce0AdEHlcuU3VDrJ8OWOwwrsS4wpe27nQyzmM97sRJ3exgLUqCLMaPBud maW5l3npFXmwnmYF+mqtlSEC/tdMpaJv1v3CByaa7S5rRDrJybRgEQlvj 1bH3ebTk0IKnAxOAUBXblvsheLIrZYld6hedxh0pNsrsd99A78JkWqVwG TiFrjn8os1Qng3RRiqbVUfr3R9tviA4tNLCYp52bmUE30H5uHe1sv9V5X 3AHZcC/2K4aq3Yf4D798WmdD2I+ZVLjS36mPyyJxwuria5quiVDw9Yhbb Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10463"; a="298271986" X-IronPort-AV: E=Sophos;i="5.93,297,1654585200"; d="scan'208";a="298271986" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Sep 2022 09:46:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,297,1654585200"; d="scan'208";a="676278084" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga008.fm.intel.com with ESMTP; 07 Sep 2022 09:45:55 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id CFDC245; Wed, 7 Sep 2022 19:46:11 +0300 (EEST) From: Andy Shevchenko To: "Rafael J. Wysocki" , Andy Shevchenko , Wolfram Sang , Hans de Goede , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org, linux-i2c@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-spi@vger.kernel.org, devel@acpica.org Cc: "Rafael J. Wysocki" , Len Brown , Ard Biesheuvel , Elie Morisse , Nehal Shah , Shyam Sundar S K , Khalil Blaiech , Andy Gross , Bjorn Andersson , Konrad Dybcio , Will Deacon , Mark Rutland , Daniel Mack , Haojian Zhuang , Robert Jarzmik , Mark Brown , Robert Moore , Wolfram Sang Subject: [PATCH v1 1/8] ACPI: utils: Add acpi_dev_uid_to_integer() helper to get _UID as integer Date: Wed, 7 Sep 2022 19:45:59 +0300 Message-Id: <20220907164606.65742-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220907164606.65742-1-andriy.shevchenko@linux.intel.com> References: <20220907164606.65742-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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 Some users interpret _UID only as integer and for them it's easier to have an integer representation of _UID. Add respective helper for that. Signed-off-by: Andy Shevchenko --- drivers/acpi/utils.c | 24 ++++++++++++++++++++++++ include/acpi/acpi_bus.h | 1 + include/linux/acpi.h | 5 +++++ 3 files changed, 30 insertions(+) diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c index 4acd6f7d1395..2ea14648a661 100644 --- a/drivers/acpi/utils.c +++ b/drivers/acpi/utils.c @@ -793,6 +793,30 @@ bool acpi_dev_hid_uid_match(struct acpi_device *adev, } EXPORT_SYMBOL(acpi_dev_hid_uid_match); +/** + * acpi_dev_uid_to_integer - treat ACPI device _UID as integer + * @adev: ACPI device to get _UID from + * @integer: output buffer for integer + * + * Considers _UID as integer and converts it to @integer. + * + * Returns 0 on success, or negative error code otherwise. + */ +int acpi_dev_uid_to_integer(struct acpi_device *adev, u64 *integer) +{ + const char *uid; + + if (!adev) + return -ENODEV; + + uid = acpi_device_uid(adev); + if (!uid) + return -ENODATA; + + return kstrtou64(uid, 0, integer); +} +EXPORT_SYMBOL(acpi_dev_uid_to_integer); + /** * acpi_dev_found - Detect presence of a given ACPI device in the namespace. * @hid: Hardware ID of the device. diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index 42f76f2c2d49..1804d7a70918 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h @@ -739,6 +739,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); +int acpi_dev_uid_to_integer(struct acpi_device *adev, u64 *integer); void acpi_dev_clear_dependencies(struct acpi_device *supplier); bool acpi_dev_ready_for_enumeration(const struct acpi_device *device); diff --git a/include/linux/acpi.h b/include/linux/acpi.h index ed4aa395cc49..619b2b1e4fb4 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -799,6 +799,11 @@ acpi_dev_hid_uid_match(struct acpi_device *adev, const char *hid2, const char *u return false; } +static inline int acpi_dev_uid_to_integer(struct acpi_device *adev, u64 *integer) +{ + return -ENODEV; +} + static inline struct acpi_device * acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv) { -- 2.35.1