summaryrefslogtreecommitdiff
path: root/include/linux/apple-gmux.h
diff options
context:
space:
mode:
authorOrlando Chamberlain <orlandoch.dev@gmail.com>2023-03-03 14:28:41 +0300
committerHans de Goede <hdegoede@redhat.com>2023-03-16 13:02:00 +0300
commit96ec2d9868c4afd3cea17f4ee18b84ccc1cde20f (patch)
tree0f105e09ab0416e161c7256c5a9954d133ec97ba /include/linux/apple-gmux.h
parent90caf1dfe9efb727874bcafd30fefb0807cb7670 (diff)
downloadlinux-96ec2d9868c4afd3cea17f4ee18b84ccc1cde20f.tar.xz
platform/x86: apple-gmux: refactor gmux types
Add apple_gmux_config struct containing operations and data specific to each mux type. This is in preparation for adding a third, MMIO based, gmux type. Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Orlando Chamberlain <orlandoch.dev@gmail.com> Link: https://lore.kernel.org/r/20230303112842.3094-3-orlandoch.dev@gmail.com Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'include/linux/apple-gmux.h')
-rw-r--r--include/linux/apple-gmux.h18
1 files changed, 12 insertions, 6 deletions
diff --git a/include/linux/apple-gmux.h b/include/linux/apple-gmux.h
index 1f68b49bcd68..147dc1c52e08 100644
--- a/include/linux/apple-gmux.h
+++ b/include/linux/apple-gmux.h
@@ -36,6 +36,11 @@
#define GMUX_MIN_IO_LEN (GMUX_PORT_BRIGHTNESS + 4)
+enum apple_gmux_type {
+ APPLE_GMUX_TYPE_PIO,
+ APPLE_GMUX_TYPE_INDEXED,
+};
+
#if IS_ENABLED(CONFIG_APPLE_GMUX)
static inline bool apple_gmux_is_indexed(unsigned long iostart)
{
@@ -65,13 +70,13 @@ static inline bool apple_gmux_is_indexed(unsigned long iostart)
* Return: %true if a supported gmux ACPI device is detected and the kernel
* was configured with CONFIG_APPLE_GMUX, %false otherwise.
*/
-static inline bool apple_gmux_detect(struct pnp_dev *pnp_dev, bool *indexed_ret)
+static inline bool apple_gmux_detect(struct pnp_dev *pnp_dev, enum apple_gmux_type *type_ret)
{
u8 ver_major, ver_minor, ver_release;
struct device *dev = NULL;
struct acpi_device *adev;
struct resource *res;
- bool indexed = false;
+ enum apple_gmux_type type = APPLE_GMUX_TYPE_PIO;
bool ret = false;
if (!pnp_dev) {
@@ -99,13 +104,14 @@ static inline bool apple_gmux_detect(struct pnp_dev *pnp_dev, bool *indexed_ret)
ver_minor = inb(res->start + GMUX_PORT_VERSION_MINOR);
ver_release = inb(res->start + GMUX_PORT_VERSION_RELEASE);
if (ver_major == 0xff && ver_minor == 0xff && ver_release == 0xff) {
- indexed = apple_gmux_is_indexed(res->start);
- if (!indexed)
+ if (apple_gmux_is_indexed(res->start))
+ type = APPLE_GMUX_TYPE_INDEXED;
+ else
goto out;
}
- if (indexed_ret)
- *indexed_ret = indexed;
+ if (type_ret)
+ *type_ret = type;
ret = true;
out: