linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
To: hdegoede@redhat.com, markgross@kernel.org
Cc: platform-driver-x86@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
	Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>,
	"Rafael J . Wysocki" <rafael.j.wysocki@intel.com>
Subject: [PATCH 6/7] platform/x86/intel/tpmi: ADD tpmi external interface for tpmi feature drivers
Date: Wed,  1 Feb 2023 17:07:37 -0800	[thread overview]
Message-ID: <20230202010738.2186174-7-srinivas.pandruvada@linux.intel.com> (raw)
In-Reply-To: <20230202010738.2186174-1-srinivas.pandruvada@linux.intel.com>

Add interface to get resources and platform data. This will avoid code
duplication. These interfaces includes:
- Get resource count
- Get resource at an index

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/platform/x86/intel/tpmi.c | 22 ++++++++++++++++++++++
 include/linux/intel_tpmi.h        |  2 ++
 2 files changed, 24 insertions(+)

diff --git a/drivers/platform/x86/intel/tpmi.c b/drivers/platform/x86/intel/tpmi.c
index e612da579b29..c60733261c89 100644
--- a/drivers/platform/x86/intel/tpmi.c
+++ b/drivers/platform/x86/intel/tpmi.c
@@ -153,6 +153,28 @@ struct intel_tpmi_plat_info *tpmi_get_platform_data(struct auxiliary_device *aux
 }
 EXPORT_SYMBOL_NS_GPL(tpmi_get_platform_data, INTEL_TPMI);
 
+int tpmi_get_resource_count(struct auxiliary_device *auxdev)
+{
+	struct intel_vsec_device *vsec_dev = auxdev_to_ivdev(auxdev);
+
+	if (vsec_dev)
+		return vsec_dev->num_resources;
+
+	return 0;
+}
+EXPORT_SYMBOL_NS_GPL(tpmi_get_resource_count, INTEL_TPMI);
+
+struct resource *tpmi_get_resource_at_index(struct auxiliary_device *auxdev, int index)
+{
+	struct intel_vsec_device *vsec_dev = auxdev_to_ivdev(auxdev);
+
+	if (vsec_dev && index < vsec_dev->num_resources)
+		return &vsec_dev->resource[index];
+
+	return NULL;
+}
+EXPORT_SYMBOL_NS_GPL(tpmi_get_resource_at_index, INTEL_TPMI);
+
 static const char *intel_tpmi_name(enum intel_tpmi_id id)
 {
 	switch (id) {
diff --git a/include/linux/intel_tpmi.h b/include/linux/intel_tpmi.h
index 5b665320ecb4..f505788c05da 100644
--- a/include/linux/intel_tpmi.h
+++ b/include/linux/intel_tpmi.h
@@ -24,5 +24,7 @@ struct intel_tpmi_plat_info {
 };
 
 struct intel_tpmi_plat_info *tpmi_get_platform_data(struct auxiliary_device *auxdev);
+struct resource *tpmi_get_resource_at_index(struct auxiliary_device *auxdev, int index);
+int tpmi_get_resource_count(struct auxiliary_device *auxdev);
 
 #endif
-- 
2.31.1


  parent reply	other threads:[~2023-02-02  1:09 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-02  1:07 [PATCH 0/7] Add TPMI support Srinivas Pandruvada
2023-02-02  1:07 ` [PATCH 1/7] platform/x86/intel/vsec: Add TPMI ID Srinivas Pandruvada
2023-02-02  1:07 ` [PATCH 2/7] platform/x86/intel/vsec: Enhance and Export intel_vsec_add_aux() Srinivas Pandruvada
2023-02-02  1:07 ` [PATCH 3/7] platform/x86/intel/vsec: Support private data Srinivas Pandruvada
2023-02-02  1:07 ` [PATCH 4/7] platform/x86/intel: Intel TPMI enumeration driver Srinivas Pandruvada
2023-02-02  1:07 ` [PATCH 5/7] platform/x86/intel/tpmi: Process CPU package mapping Srinivas Pandruvada
2023-02-02  1:07 ` Srinivas Pandruvada [this message]
2023-02-02  1:07 ` [PATCH 7/7] MAINTAINERS: Add entry for TPMI driver Srinivas Pandruvada
2023-02-06 12:50   ` Hans de Goede
2023-02-06 12:49 ` [PATCH 0/7] Add TPMI support Hans de Goede
2023-02-06 12:55   ` Hans de Goede
2023-02-06 13:29     ` srinivas pandruvada
2023-02-10  8:04   ` srinivas pandruvada
2023-02-10 14:24     ` Hans de Goede

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230202010738.2186174-7-srinivas.pandruvada@linux.intel.com \
    --to=srinivas.pandruvada@linux.intel.com \
    --cc=hdegoede@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=markgross@kernel.org \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=rafael.j.wysocki@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).