From nobody Sun Jul 21 13:14:52 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 4WRkR11qclz5RVJd; Sun, 21 Jul 2024 13:14:53 +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 4WRkR10MKsz4S3w; Sun, 21 Jul 2024 13:14:53 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1721567693; 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=CrQ8u5CvrOVmQ05DrLyJLlp2QWSPnFvZTe4hPOj+KJ8=; b=paXEWMNwyYlqjDLVPVTzyrM54IzITXavo1NJmZLRTkaYlbq2SoZxiCJPGpipCyaUvasKHw 4Wr20I+f3rIMS3cx/AXVc3W2a2OnzMuUiksrGxjxKP5sI8wT0nL8pQNWwghknMZ6c2+ohN 2379ZYU5hvJTCsxISpu0KaZ3BPMQLsrpsxLmDDaK86x2LHL5dBJkOxBLlukJBzzIAVi7Cu jWo9IgV6pAO5rM3z9iK5MtbRXgKhw1rZ6DScXwVtlNFaXyLmLcSuGgJu7/xy0zKDf6+CK1 /nItZn3qGhHfLhdqadB/uPnAoe0xQ8fAzlcWO3ldtf0O9XF92+UQMgrjK4H2zw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1721567693; a=rsa-sha256; cv=none; b=smAl4ssFMpXEnLvEHJTItcUVyJ1fmzmm7GGMLyMA3zX2fAT5njNfyBLFRQQ+6GaFWvDNJb xprM7+1dxR0BSLom1QVR3pWYslUUG9f9YQchvkG38RlQFbBIqlKSop3CTvww3vZJZxTkPB 7Jq4QM1KeCaSDCGDXvld/PerUQ9ij9q4TeE5FIkh9B6PfWjddhf8SSnYvDwii2HS8t9AIM iUNP21GDdXXFCFGHHORKE/SlH0F+d9re1BJS3so/pzjFHGaZx467xxPz5sphGIke9Puw4K /Y1ynYUDFcK6WvzgwLuHUKEm45OgOpQHsIDzbPkJMyGJw2JWKb+qr98zZi4ZQw== 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=1721567693; 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=CrQ8u5CvrOVmQ05DrLyJLlp2QWSPnFvZTe4hPOj+KJ8=; b=dAlye5Ql+O4c8ClyoBJ7DJcbPayak0oGi/AcFQIN4Iz1RYSRMJVuNfNHGGY3VWswWUAm0F T9bY+6A2Mty6rMyykoKyJmiOucD23Km7To7UlZiZHFPPRnAXfwq/tEfkeMP3ObWuXpsiEa GVykoeeN8N3tkUO512qYq+oSKxs6ZCEmEoPnD04oDVv7poZ30Q3fMT7i+z609xvI3D+H0i gOX08zApAWAok1YbNJFVjZUU3LJ5xuDJiP50AdXP04Bzv3AY89oRVY3qZ2elUhWnUAQ6wi EEDfPG5yEUJbsOccrg0Ot/F/ZX63us2L2GIMYNC08v9NN0UlNrJ9ZCIr21HEYw== 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 4WRkR06lpxz11Zh; Sun, 21 Jul 2024 13:14:52 +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 46LDEqQe023204; Sun, 21 Jul 2024 13:14:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 46LDEqmx023201; Sun, 21 Jul 2024 13:14:52 GMT (envelope-from git) Date: Sun, 21 Jul 2024 13:14:52 GMT Message-Id: <202407211314.46LDEqmx023201@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Vladimir Kondratyev Subject: git: 3e90716331cd - main - 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/main X-Git-Reftype: branch X-Git-Commit: 3e90716331cdbdee7465213d389a33f90dad11cf Auto-Submitted: auto-generated The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=3e90716331cdbdee7465213d389a33f90dad11cf commit 3e90716331cdbdee7465213d389a33f90dad11cf Author: Vladimir Kondratyev AuthorDate: 2024-07-21 13:09:37 +0000 Commit: Vladimir Kondratyev CommitDate: 2024-07-21 13:09:37 +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 --- 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 */