From nobody Thu Aug 01 22:28:04 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4WZkBD6d5dz5RZYd; Thu, 01 Aug 2024 22:28:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WZkBD2Vkhz4Zk8; Thu, 1 Aug 2024 22:28:04 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1722551284; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=/2LfOhQD81MAfIdK3QYKEB1Lm26267OkFFydeBpdqyk=; b=P7OZ6RXXsxwXH/8M3M2/GsggxKpdh4lu1fgXLNlzG/L2AmdPepHpDPkyYjndsZiWPzHUpk NTq/UvBGsSdnb2cQTan3tL19h+b7rvYW9PmSyOA+srLWA/v+qJCDhv6+++snghuWiRfSg0 KyHN3xYCmW4eOR2a8Mjx6orOyZLyfw3ZjPM6dHxXvP/zq74ZiG9Xz2+epxB6jtlMVFVKp0 1ajwEMqMGJil4gq1ByDhxERfBlYvXy1d5iQ5VvvmzjUh7oT2SZ5yeJ5AgG8ZkWnVij8Mfv KebxsvTq0Ur3C9O8zTJJohYGxrbyZAKxPXUU8lwU1A4+iPAkDBtvDbaUhKIuYg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1722551284; a=rsa-sha256; cv=none; b=ODeRAYqNP3S2nyMkkd/dYelnIE3Djqfrx72bn7bKYE2r/rCFw1oEJEjnBKuJ5Aak2U/XOL sfhu6+yqvDBUp/zAxP6JWkNqCyMX9xHUuU5ZWAA0nf+SDNn+3WO/eqQBSfLYANEVdeM1VL vNha5dQIfEdo55sDWyZY2oCObAcsxGrGVoAGVnd6wAsOgLvazoB9Csg1i7IEyCeuIdgBZ1 FqaM7amGmY3CTu79v4n4MulDlsQ7kmGyKLTiN4zXRTSqCvJZkV1/ckn0vu3aRlMWersKoW dGqT+6FNdmQ7MgSp/utfr04rOYLKcaYH+OtA1LxB18/zP5puVbIoz5NEkiRzVA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1722551284; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=/2LfOhQD81MAfIdK3QYKEB1Lm26267OkFFydeBpdqyk=; b=bJ2uLQv0DmIZbySgjH1/SCcW6Wz9+gC1C+TpX+rc5SJsiF/soPrE+k1D0iv3dJOOGlx9dJ J7FrkpG1XTVaXKBpqGObcy8fF2GFNdJ25UBQMAutxrLCZwQFAUXhNbo4VoKXoLG3Ru7AUi iPBGIkYBGwNYn5kaSGyC/3VX0yOvUxCIA2bR6jTFr079/eFjDoqEt6lhRpNxoYpwpvSHEL pS6uUfPgdrqBh9lvJfhJJRk7GuaOUVtVXAm0U3miEGMeXQf7B4Gxf+XU3Ux8zCqQlhw4zw ZOAAW3KI2jVti9GwgskBuchMsl2klUr/QLiUx4fjGCDv/3sF8nCz7a7Prv0qEg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4WZkBD1wFMz12nw; Thu, 1 Aug 2024 22:28:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 471MS4RX028641; Thu, 1 Aug 2024 22:28:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 471MS4Uw028638; Thu, 1 Aug 2024 22:28:04 GMT (envelope-from git) Date: Thu, 1 Aug 2024 22:28:04 GMT Message-Id: <202408012228.471MS4Uw028638@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: d23c4b1a558f - stable/14 - LinuxKPI: Add acpi_dev_get_first_match_dev and acpi_device_handle List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: d23c4b1a558f14c89022498e5ef82618bf671e94 Auto-Submitted: auto-generated The branch stable/14 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=d23c4b1a558f14c89022498e5ef82618bf671e94 commit d23c4b1a558f14c89022498e5ef82618bf671e94 Author: Vladimir Kondratyev AuthorDate: 2024-07-21 13:09:37 +0000 Commit: Vladimir Kondratyev CommitDate: 2024-08-01 21:15:51 +0000 LinuxKPI: Add acpi_dev_get_first_match_dev and acpi_device_handle acpi_dev_get_first_match_dev returns the first match of ACPI device and acpi_device_handle returns its ACPI handle. Sponsored by: Serenity Cyber Security, LLC MFC after: 1 week Reviewed by: manu Differential Revision: https://reviews.freebsd.org/D45847 (cherry picked from commit 3e90716331cdbdee7465213d389a33f90dad11cf) --- sys/compat/linuxkpi/common/include/acpi/acpi_bus.h | 7 +++++ sys/compat/linuxkpi/common/include/linux/acpi.h | 4 +++ sys/compat/linuxkpi/common/src/linux_acpi.c | 32 ++++++++++++++++++++++ 3 files changed, 43 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/acpi/acpi_bus.h b/sys/compat/linuxkpi/common/include/acpi/acpi_bus.h index f107902a26ad..65bcbe7f1bdd 100644 --- a/sys/compat/linuxkpi/common/include/acpi/acpi_bus.h +++ b/sys/compat/linuxkpi/common/include/acpi/acpi_bus.h @@ -29,6 +29,9 @@ #ifndef _LINUXKPI_ACPI_ACPI_BUS_H_ #define _LINUXKPI_ACPI_ACPI_BUS_H_ +/* Aliase struct acpi_device to device_t */ +#define acpi_device _device + typedef char acpi_device_class[20]; struct acpi_bus_event { @@ -38,6 +41,8 @@ struct acpi_bus_event { }; #define acpi_dev_present(...) lkpi_acpi_dev_present(__VA_ARGS__) +#define acpi_dev_get_first_match_dev(...) \ + lkpi_acpi_dev_get_first_match_dev(__VA_ARGS__) ACPI_HANDLE bsd_acpi_get_handle(device_t bsddev); bool acpi_check_dsm(ACPI_HANDLE handle, const char *uuid, int rev, @@ -50,5 +55,7 @@ int unregister_acpi_notifier(struct notifier_block *nb); uint32_t acpi_target_system_state(void); bool lkpi_acpi_dev_present(const char *hid, const char *uid, int64_t hrv); +struct acpi_device *lkpi_acpi_dev_get_first_match_dev(const char *hid, + const char *uid, int64_t hrv); #endif /* _LINUXKPI_ACPI_ACPI_BUS_H_ */ diff --git a/sys/compat/linuxkpi/common/include/linux/acpi.h b/sys/compat/linuxkpi/common/include/linux/acpi.h index 610aa0784cb9..3e1ec1b20626 100644 --- a/sys/compat/linuxkpi/common/include/linux/acpi.h +++ b/sys/compat/linuxkpi/common/include/linux/acpi.h @@ -39,6 +39,10 @@ #define ACPI_HANDLE(dev) \ ((dev)->bsddev != NULL ? bsd_acpi_get_handle((dev)->bsddev) : NULL) +#define acpi_device_handle(dev) \ + ((dev) != NULL ? bsd_acpi_get_handle(dev) : NULL) +static inline void acpi_dev_put(struct acpi_device *adev) {} +#define acpi_handle_debug(handle, fmt, ...) #endif diff --git a/sys/compat/linuxkpi/common/src/linux_acpi.c b/sys/compat/linuxkpi/common/src/linux_acpi.c index 60ec838e9da7..6a9afb3ddff0 100644 --- a/sys/compat/linuxkpi/common/src/linux_acpi.c +++ b/sys/compat/linuxkpi/common/src/linux_acpi.c @@ -180,6 +180,7 @@ struct acpi_dev_present_ctx { const char *hid; const char *uid; int64_t hrv; + struct acpi_device *dev; }; static ACPI_STATUS @@ -187,6 +188,7 @@ acpi_dev_present_cb(ACPI_HANDLE handle, UINT32 level, void *context, void **result) { ACPI_DEVICE_INFO *devinfo; + struct acpi_device *dev; struct acpi_dev_present_ctx *match = context; bool present = false; UINT32 sta, hrv; @@ -230,6 +232,11 @@ acpi_dev_present_cb(ACPI_HANDLE handle, UINT32 level, void *context, return (AE_OK); } + dev = acpi_get_device(handle); + if (dev == NULL) + return (AE_OK); + match->dev = dev; + return (AE_ERROR); } @@ -249,6 +256,24 @@ lkpi_acpi_dev_present(const char *hid, const char *uid, int64_t hrv) return (rv == AE_ERROR); } +struct acpi_device * +lkpi_acpi_dev_get_first_match_dev(const char *hid, const char *uid, + int64_t hrv) +{ + struct acpi_dev_present_ctx match; + int rv; + + match.hid = hid; + match.uid = uid; + match.hrv = hrv; + match.dev = NULL; + + rv = AcpiWalkNamespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, acpi_dev_present_cb, NULL, &match, NULL); + + return (rv == AE_ERROR ? match.dev : NULL); +} + static void linux_register_acpi_event_handlers(void *arg __unused) { @@ -322,4 +347,11 @@ lkpi_acpi_dev_present(const char *hid, const char *uid, int64_t hrv) return (false); } +struct acpi_device * +lkpi_acpi_dev_get_first_match_dev(const char *hid, const char *uid, + int64_t hrv) +{ + return (NULL); +} + #endif /* !DEV_ACPI */