2023-11-20 12:09:19

by Raag Jadav

[permalink] [raw]
Subject: [PATCH v1 0/6] Support integer types for _UID matching

This series updates the standard ACPI helpers to support _UID matching
for both integer and string types, and uses them in a couple of places.

Raag Jadav (6):
compiler.h: Introduce helpers for identifying array and pointer types
ACPI: bus: update acpi_dev_uid_match() to support multiple types
ACPI: bus: update acpi_dev_hid_uid_match() to support multiple types
ACPI: LPSS: use acpi_dev_uid_match() for matching _UID
efi: dev-path-parser: use acpi_dev_uid_match() for matching _UID
perf: arm_cspmu: drop redundant acpi_dev_uid_to_integer()

drivers/acpi/acpi_lpss.c | 8 +---
drivers/acpi/utils.c | 48 ---------------------
drivers/firmware/efi/dev-path-parser.c | 7 +---
drivers/perf/arm_cspmu/arm_cspmu.c | 4 +-
include/acpi/acpi_bus.h | 58 +++++++++++++++++++++++++-
include/linux/acpi.h | 15 ++-----
include/linux/compiler.h | 5 +++
7 files changed, 70 insertions(+), 75 deletions(-)


base-commit: 5bd262f4820f2d5645d8ff1f251ef8e96715ef84
--
2.17.1


2023-11-20 12:09:27

by Raag Jadav

[permalink] [raw]
Subject: [PATCH v1 3/6] ACPI: bus: update acpi_dev_hid_uid_match() to support multiple types

Now that we have _UID matching support for both integer and string types,
we can support them into acpi_dev_hid_uid_match() helper as well.

Signed-off-by: Raag Jadav <[email protected]>
---
drivers/acpi/utils.c | 29 -----------------------------
include/acpi/acpi_bus.h | 23 ++++++++++++++++++++++-
include/linux/acpi.h | 7 +------
3 files changed, 23 insertions(+), 36 deletions(-)

diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
index fe7e850c6479..03f6de9a0807 100644
--- a/drivers/acpi/utils.c
+++ b/drivers/acpi/utils.c
@@ -824,35 +824,6 @@ bool acpi_check_dsm(acpi_handle handle, const guid_t *guid, u64 rev, u64 funcs)
}
EXPORT_SYMBOL(acpi_check_dsm);

-/**
- * acpi_dev_hid_uid_match - Match device by supplied HID and UID
- * @adev: ACPI device to match.
- * @hid2: Hardware ID of the device.
- * @uid2: Unique ID of the device, pass NULL to not check _UID.
- *
- * Matches HID and UID in @adev with given @hid2 and @uid2. Absence of @uid2
- * will be treated as a match. If user wants to validate @uid2, it should be
- * done before calling this function.
- *
- * Returns:
- * - %true if matches or @uid2 is NULL.
- * - %false otherwise.
- */
-bool acpi_dev_hid_uid_match(struct acpi_device *adev,
- const char *hid2, const char *uid2)
-{
- const char *hid1 = acpi_device_hid(adev);
-
- if (strcmp(hid1, hid2))
- return false;
-
- if (!uid2)
- return true;
-
- return acpi_dev_uid_match(adev, uid2);
-}
-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
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 25b9fabf350f..979a60a512e5 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -857,9 +857,15 @@ static inline bool acpi_device_can_poweroff(struct acpi_device *adev)
adev->power.states[ACPI_STATE_D3_HOT].flags.explicit_set);
}

-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);

+static inline bool acpi_dev_hid_match(struct acpi_device *adev, const char *hid2)
+{
+ const char *hid1 = acpi_device_hid(adev);
+
+ return hid1 && hid2 && !strcmp(hid1, hid2);
+}
+
static inline bool acpi_str_uid_match(struct acpi_device *adev, const char *uid2)
{
const char *uid1 = acpi_device_uid(adev);
@@ -893,6 +899,21 @@ static inline bool acpi_int_uid_match(struct acpi_device *adev, u64 uid2)
const char *: acpi_str_uid_match, \
u64: acpi_int_uid_match)(adev, uid2)

+/**
+ * acpi_dev_hid_uid_match - Match device by supplied HID and UID
+ * @adev: ACPI device to match.
+ * @hid2: Hardware ID of the device.
+ * @uid2: Unique ID of the device, pass 0 or NULL to not check _UID.
+ *
+ * Matches HID and UID in @adev with given @hid2 and @uid2. Absence of @uid2
+ * will be treated as a match. If user wants to validate @uid2, it should be
+ * done before calling this function.
+ *
+ * Returns: %true if matches or @uid2 is 0 or NULL, %false otherwise.
+ */
+#define acpi_dev_hid_uid_match(adev, hid2, uid2) \
+ (acpi_dev_hid_match(adev, hid2) && (!uid2 || acpi_dev_uid_match(adev, uid2)))
+
void acpi_dev_clear_dependencies(struct acpi_device *supplier);
bool acpi_dev_ready_for_enumeration(const struct acpi_device *device);
struct acpi_device *acpi_dev_get_next_consumer_dev(struct acpi_device *supplier,
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 3d7ee8c0b86a..c43ae3bd238d 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -758,6 +758,7 @@ const char *acpi_get_subsystem_id(acpi_handle handle);

/* Get rid of the -Wunused-variable for adev */
#define acpi_dev_uid_match(adev, uid2) (adev && false)
+#define acpi_dev_hid_uid_match(adev, uid2) (adev && false)

#include <acpi/acpi_numa.h>

@@ -775,12 +776,6 @@ static inline bool acpi_dev_present(const char *hid, const char *uid, s64 hrv)

struct acpi_device;

-static inline bool
-acpi_dev_hid_uid_match(struct acpi_device *adev, const char *hid2, const char *uid2)
-{
- return false;
-}
-
static inline int acpi_dev_uid_to_integer(struct acpi_device *adev, u64 *integer)
{
return -ENODEV;
--
2.17.1

2023-11-20 12:09:35

by Raag Jadav

[permalink] [raw]
Subject: [PATCH v1 4/6] ACPI: LPSS: use acpi_dev_uid_match() for matching _UID

Now that we have _UID matching support for integer types, we can use
acpi_dev_uid_match() for it.

Signed-off-by: Raag Jadav <[email protected]>
---
drivers/acpi/acpi_lpss.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
index 875de44961bf..8b80ef7da21f 100644
--- a/drivers/acpi/acpi_lpss.c
+++ b/drivers/acpi/acpi_lpss.c
@@ -167,10 +167,8 @@ static struct pwm_lookup byt_pwm_lookup[] = {

static void byt_pwm_setup(struct lpss_private_data *pdata)
{
- u64 uid;
-
/* Only call pwm_add_table for the first PWM controller */
- if (acpi_dev_uid_to_integer(pdata->adev, &uid) || uid != 1)
+ if (!acpi_dev_uid_match(pdata->adev, 1))
return;

pwm_add_table(byt_pwm_lookup, ARRAY_SIZE(byt_pwm_lookup));
@@ -218,10 +216,8 @@ static struct pwm_lookup bsw_pwm_lookup[] = {

static void bsw_pwm_setup(struct lpss_private_data *pdata)
{
- u64 uid;
-
/* Only call pwm_add_table for the first PWM controller */
- if (acpi_dev_uid_to_integer(pdata->adev, &uid) || uid != 1)
+ if (!acpi_dev_uid_match(pdata->adev, 1))
return;

pwm_add_table(bsw_pwm_lookup, ARRAY_SIZE(bsw_pwm_lookup));
--
2.17.1

2023-11-20 12:09:38

by Raag Jadav

[permalink] [raw]
Subject: [PATCH v1 1/6] compiler.h: Introduce helpers for identifying array and pointer types

Introduce is_array_type() and is_pointer_type() helpers, which compare the
data type of provided argument against the enumeration values defined in
typeclass.h using __builtin_classify_type() function and identify array
and pointer types respectively.

Signed-off-by: Raag Jadav <[email protected]>
---
include/linux/compiler.h | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index bb1339c7057b..b4f656002c0f 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -242,6 +242,11 @@ static inline void *offset_to_ptr(const int *off)
#define is_signed_type(type) (((type)(-1)) < (__force type)1)
#define is_unsigned_type(type) (!is_signed_type(type))

+/* Classify data type based on enum values in typeclass.h */
+#define is_array_type(x) (__builtin_classify_type(x) == 14)
+#define is_pointer_type(x) (__builtin_classify_type(x) == 5)
+#define is_array_or_pointer_type(x) (is_array_type(x) || is_pointer_type(x))
+
/*
* This is needed in functions which generate the stack canary, see
* arch/x86/kernel/smpboot.c::start_secondary() for an example.
--
2.17.1

2023-11-20 12:09:49

by Raag Jadav

[permalink] [raw]
Subject: [PATCH v1 5/6] efi: dev-path-parser: use acpi_dev_uid_match() for matching _UID

Now that we have _UID matching support for integer types, we can use
acpi_dev_uid_match() for it.

Signed-off-by: Raag Jadav <[email protected]>
---
drivers/firmware/efi/dev-path-parser.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/firmware/efi/dev-path-parser.c b/drivers/firmware/efi/dev-path-parser.c
index f80d87c199c3..937be269fee8 100644
--- a/drivers/firmware/efi/dev-path-parser.c
+++ b/drivers/firmware/efi/dev-path-parser.c
@@ -18,8 +18,6 @@ static long __init parse_acpi_path(const struct efi_dev_path *node,
struct acpi_device *adev;
struct device *phys_dev;
char hid[ACPI_ID_LEN];
- u64 uid;
- int ret;

if (node->header.length != 12)
return -EINVAL;
@@ -31,10 +29,9 @@ static long __init parse_acpi_path(const struct efi_dev_path *node,
node->acpi.hid >> 16);

for_each_acpi_dev_match(adev, hid, NULL, -1) {
- ret = acpi_dev_uid_to_integer(adev, &uid);
- if (ret == 0 && node->acpi.uid == uid)
+ if (acpi_dev_uid_match(adev, node->acpi.uid))
break;
- if (ret == -ENODATA && node->acpi.uid == 0)
+ if (!acpi_device_uid(adev) && node->acpi.uid == 0)
break;
}
if (!adev)
--
2.17.1

2023-11-20 12:09:57

by Raag Jadav

[permalink] [raw]
Subject: [PATCH v1 2/6] ACPI: bus: update acpi_dev_uid_match() to support multiple types

According to ACPI specification, a _UID object can evaluate to either
a numeric value or a string. Update acpi_dev_uid_match() helper to
support _UID matching for both integer and string types.

Suggested-by: Andy Shevchenko <[email protected]>
Suggested-by: Mika Westerberg <[email protected]>
Suggested-by: Rafael J. Wysocki <[email protected]>
Signed-off-by: Raag Jadav <[email protected]>
---
drivers/acpi/utils.c | 19 -------------------
include/acpi/acpi_bus.h | 35 ++++++++++++++++++++++++++++++++++-
include/linux/acpi.h | 8 +++-----
3 files changed, 37 insertions(+), 25 deletions(-)

diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
index 28c75242fca9..fe7e850c6479 100644
--- a/drivers/acpi/utils.c
+++ b/drivers/acpi/utils.c
@@ -824,25 +824,6 @@ bool acpi_check_dsm(acpi_handle handle, const guid_t *guid, u64 rev, u64 funcs)
}
EXPORT_SYMBOL(acpi_check_dsm);

-/**
- * acpi_dev_uid_match - Match device by supplied UID
- * @adev: ACPI device to match.
- * @uid2: Unique ID of the device.
- *
- * Matches UID in @adev with given @uid2.
- *
- * Returns:
- * - %true if matches.
- * - %false otherwise.
- */
-bool acpi_dev_uid_match(struct acpi_device *adev, const char *uid2)
-{
- const char *uid1 = acpi_device_uid(adev);
-
- return uid1 && uid2 && !strcmp(uid1, uid2);
-}
-EXPORT_SYMBOL_GPL(acpi_dev_uid_match);
-
/**
* acpi_dev_hid_uid_match - Match device by supplied HID and UID
* @adev: ACPI device to match.
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 989ea623b1c2..25b9fabf350f 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -9,6 +9,7 @@
#ifndef __ACPI_BUS_H__
#define __ACPI_BUS_H__

+#include <linux/compiler.h>
#include <linux/device.h>
#include <linux/property.h>

@@ -856,10 +857,42 @@ static inline bool acpi_device_can_poweroff(struct acpi_device *adev)
adev->power.states[ACPI_STATE_D3_HOT].flags.explicit_set);
}

-bool acpi_dev_uid_match(struct acpi_device *adev, const char *uid2);
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);

+static inline bool acpi_str_uid_match(struct acpi_device *adev, const char *uid2)
+{
+ const char *uid1 = acpi_device_uid(adev);
+
+ return uid1 && uid2 && !strcmp(uid1, uid2);
+}
+
+static inline bool acpi_int_uid_match(struct acpi_device *adev, u64 uid2)
+{
+ u64 uid1;
+
+ return !acpi_dev_uid_to_integer(adev, &uid1) && uid1 == uid2;
+}
+
+/**
+ * acpi_dev_uid_match - Match device by supplied UID
+ * @adev: ACPI device to match.
+ * @uid2: Unique ID of the device.
+ *
+ * Matches UID in @adev with given @uid2.
+ *
+ * Returns: %true if matches, %false otherwise.
+ */
+
+/* Treat uid as a string for pointer and array types, treat as an integer otherwise */
+#define get_uid_type(x) \
+ (__builtin_choose_expr(is_array_or_pointer_type(x), (const char *)0, (u64)0))
+
+#define acpi_dev_uid_match(adev, uid2) \
+ _Generic(get_uid_type(uid2), \
+ const char *: acpi_str_uid_match, \
+ u64: acpi_int_uid_match)(adev, uid2)
+
void acpi_dev_clear_dependencies(struct acpi_device *supplier);
bool acpi_dev_ready_for_enumeration(const struct acpi_device *device);
struct acpi_device *acpi_dev_get_next_consumer_dev(struct acpi_device *supplier,
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 54189e0e5f41..3d7ee8c0b86a 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -756,6 +756,9 @@ const char *acpi_get_subsystem_id(acpi_handle handle);
#define ACPI_HANDLE(dev) (NULL)
#define ACPI_HANDLE_FWNODE(fwnode) (NULL)

+/* Get rid of the -Wunused-variable for adev */
+#define acpi_dev_uid_match(adev, uid2) (adev && false)
+
#include <acpi/acpi_numa.h>

struct fwnode_handle;
@@ -772,11 +775,6 @@ static inline bool acpi_dev_present(const char *hid, const char *uid, s64 hrv)

struct acpi_device;

-static inline bool acpi_dev_uid_match(struct acpi_device *adev, const char *uid2)
-{
- return false;
-}
-
static inline bool
acpi_dev_hid_uid_match(struct acpi_device *adev, const char *hid2, const char *uid2)
{
--
2.17.1

2023-11-20 12:12:16

by Raag Jadav

[permalink] [raw]
Subject: [PATCH v1 6/6] perf: arm_cspmu: drop redundant acpi_dev_uid_to_integer()

Now that we have _UID matching support for integer types, we can use
acpi_dev_hid_uid_match() for it.

Signed-off-by: Raag Jadav <[email protected]>
---
drivers/perf/arm_cspmu/arm_cspmu.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/perf/arm_cspmu/arm_cspmu.c b/drivers/perf/arm_cspmu/arm_cspmu.c
index 42b72042f6b3..9642e703ccd3 100644
--- a/drivers/perf/arm_cspmu/arm_cspmu.c
+++ b/drivers/perf/arm_cspmu/arm_cspmu.c
@@ -1105,7 +1105,6 @@ static int arm_cspmu_request_irq(struct arm_cspmu *cspmu)

static inline int arm_cspmu_find_cpu_container(int cpu, u32 container_uid)
{
- u64 acpi_uid;
struct device *cpu_dev;
struct acpi_device *acpi_dev;

@@ -1115,8 +1114,7 @@ static inline int arm_cspmu_find_cpu_container(int cpu, u32 container_uid)

acpi_dev = ACPI_COMPANION(cpu_dev);
while (acpi_dev) {
- if (acpi_dev_hid_uid_match(acpi_dev, ACPI_PROCESSOR_CONTAINER_HID, NULL) &&
- !acpi_dev_uid_to_integer(acpi_dev, &acpi_uid) && acpi_uid == container_uid)
+ if (acpi_dev_hid_uid_match(acpi_dev, ACPI_PROCESSOR_CONTAINER_HID, container_uid))
return 0;

acpi_dev = acpi_dev_parent(acpi_dev);
--
2.17.1

2023-11-20 16:00:09

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH v1 3/6] ACPI: bus: update acpi_dev_hid_uid_match() to support multiple types

Hi Raag,

kernel test robot noticed the following build warnings:

[auto build test WARNING on 5bd262f4820f2d5645d8ff1f251ef8e96715ef84]

url: https://github.com/intel-lab-lkp/linux/commits/Raag-Jadav/compiler-h-Introduce-helpers-for-identifying-array-and-pointer-types/20231120-201140
base: 5bd262f4820f2d5645d8ff1f251ef8e96715ef84
patch link: https://lore.kernel.org/r/20231120120837.3002-4-raag.jadav%40intel.com
patch subject: [PATCH v1 3/6] ACPI: bus: update acpi_dev_hid_uid_match() to support multiple types
config: x86_64-defconfig (https://download.01.org/0day-ci/archive/20231120/[email protected]/config)
compiler: gcc-11 (Debian 11.3.0-12) 11.3.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231120/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

In file included from include/linux/acpi.h:45,
from drivers/iommu/amd/iommu.c:13:
drivers/iommu/amd/iommu.c: In function 'get_acpihid_device_id':
>> drivers/iommu/amd/iommu.c:103:63: warning: pointer/integer type mismatch in conditional expression
103 | p->uid[0] ? p->uid : NULL)) {
| ^
include/acpi/acpi_bus.h:915:46: note: in definition of macro 'acpi_dev_hid_uid_match'
915 | (acpi_dev_hid_match(adev, hid2) && (!uid2 || acpi_dev_uid_match(adev, uid2)))
| ^~~~


vim +103 drivers/iommu/amd/iommu.c

81cd07b9c92ad4 drivers/iommu/amd_iommu.c Joerg Roedel 2016-07-07 85
15898bbcb48fc8 arch/x86/kernel/amd_iommu.c Joerg Roedel 2009-11-24 86 /****************************************************************************
15898bbcb48fc8 arch/x86/kernel/amd_iommu.c Joerg Roedel 2009-11-24 87 *
15898bbcb48fc8 arch/x86/kernel/amd_iommu.c Joerg Roedel 2009-11-24 88 * Helper functions
15898bbcb48fc8 arch/x86/kernel/amd_iommu.c Joerg Roedel 2009-11-24 89 *
15898bbcb48fc8 arch/x86/kernel/amd_iommu.c Joerg Roedel 2009-11-24 90 ****************************************************************************/
15898bbcb48fc8 arch/x86/kernel/amd_iommu.c Joerg Roedel 2009-11-24 91
2bf9a0a12749b2 drivers/iommu/amd_iommu.c Wan Zongshun 2016-04-01 92 static inline int get_acpihid_device_id(struct device *dev,
2bf9a0a12749b2 drivers/iommu/amd_iommu.c Wan Zongshun 2016-04-01 93 struct acpihid_map_entry **entry)
2bf9a0a12749b2 drivers/iommu/amd_iommu.c Wan Zongshun 2016-04-01 94 {
ae5e6c6439c3d0 drivers/iommu/amd_iommu.c Andy Shevchenko 2019-10-01 95 struct acpi_device *adev = ACPI_COMPANION(dev);
2bf9a0a12749b2 drivers/iommu/amd_iommu.c Wan Zongshun 2016-04-01 96 struct acpihid_map_entry *p;
2bf9a0a12749b2 drivers/iommu/amd_iommu.c Wan Zongshun 2016-04-01 97
ae5e6c6439c3d0 drivers/iommu/amd_iommu.c Andy Shevchenko 2019-10-01 98 if (!adev)
ae5e6c6439c3d0 drivers/iommu/amd_iommu.c Andy Shevchenko 2019-10-01 99 return -ENODEV;
ae5e6c6439c3d0 drivers/iommu/amd_iommu.c Andy Shevchenko 2019-10-01 100
2bf9a0a12749b2 drivers/iommu/amd_iommu.c Wan Zongshun 2016-04-01 101 list_for_each_entry(p, &acpihid_map, list) {
ea90228c7b2ae6 drivers/iommu/amd_iommu.c Raul E Rangel 2020-05-11 102 if (acpi_dev_hid_uid_match(adev, p->hid,
ea90228c7b2ae6 drivers/iommu/amd_iommu.c Raul E Rangel 2020-05-11 @103 p->uid[0] ? p->uid : NULL)) {
2bf9a0a12749b2 drivers/iommu/amd_iommu.c Wan Zongshun 2016-04-01 104 if (entry)
2bf9a0a12749b2 drivers/iommu/amd_iommu.c Wan Zongshun 2016-04-01 105 *entry = p;
2bf9a0a12749b2 drivers/iommu/amd_iommu.c Wan Zongshun 2016-04-01 106 return p->devid;
2bf9a0a12749b2 drivers/iommu/amd_iommu.c Wan Zongshun 2016-04-01 107 }
2bf9a0a12749b2 drivers/iommu/amd_iommu.c Wan Zongshun 2016-04-01 108 }
2bf9a0a12749b2 drivers/iommu/amd_iommu.c Wan Zongshun 2016-04-01 109 return -EINVAL;
2bf9a0a12749b2 drivers/iommu/amd_iommu.c Wan Zongshun 2016-04-01 110 }
2bf9a0a12749b2 drivers/iommu/amd_iommu.c Wan Zongshun 2016-04-01 111

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

2023-11-20 17:59:06

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH v1 3/6] ACPI: bus: update acpi_dev_hid_uid_match() to support multiple types

Hi Raag,

kernel test robot noticed the following build errors:

[auto build test ERROR on 5bd262f4820f2d5645d8ff1f251ef8e96715ef84]

url: https://github.com/intel-lab-lkp/linux/commits/Raag-Jadav/compiler-h-Introduce-helpers-for-identifying-array-and-pointer-types/20231120-201140
base: 5bd262f4820f2d5645d8ff1f251ef8e96715ef84
patch link: https://lore.kernel.org/r/20231120120837.3002-4-raag.jadav%40intel.com
patch subject: [PATCH v1 3/6] ACPI: bus: update acpi_dev_hid_uid_match() to support multiple types
config: openrisc-allmodconfig (https://download.01.org/0day-ci/archive/20231121/[email protected]/config)
compiler: or1k-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231121/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

sound/soc/codecs/rt5645.c: In function 'rt5645_i2c_probe':
>> sound/soc/codecs/rt5645.c:3933:87: error: macro "acpi_dev_hid_uid_match" passed 3 arguments, but takes just 2
3933 | if (acpi_dev_hid_uid_match(ACPI_COMPANION(&i2c->dev), "10EC3270", NULL))
| ^
In file included from include/linux/i2c.h:13,
from sound/soc/codecs/rt5645.c:14:
include/linux/acpi.h:761: note: macro "acpi_dev_hid_uid_match" defined here
761 | #define acpi_dev_hid_uid_match(adev, uid2) (adev && false)
|
>> sound/soc/codecs/rt5645.c:3933:21: error: 'acpi_dev_hid_uid_match' undeclared (first use in this function)
3933 | if (acpi_dev_hid_uid_match(ACPI_COMPANION(&i2c->dev), "10EC3270", NULL))
| ^~~~~~~~~~~~~~~~~~~~~~
sound/soc/codecs/rt5645.c:3933:21: note: each undeclared identifier is reported only once for each function it appears in


vim +/acpi_dev_hid_uid_match +3933 sound/soc/codecs/rt5645.c

48edaa4b4fb6e7 Oder Chiou 2015-06-12 3885
35b88858050025 Stephen Kitt 2022-04-05 3886 static int rt5645_i2c_probe(struct i2c_client *i2c)
1319b2f6a56523 Oder Chiou 2014-04-28 3887 {
452801cabc0a0f Hans de Goede 2021-03-07 3888 struct rt5645_platform_data *pdata = NULL;
78f5605c0329f8 Hans de Goede 2018-01-02 3889 const struct dmi_system_id *dmi_data;
1319b2f6a56523 Oder Chiou 2014-04-28 3890 struct rt5645_priv *rt5645;
9fc114c5d7af6c Koro Chen 2015-07-17 3891 int ret, i;
1319b2f6a56523 Oder Chiou 2014-04-28 3892 unsigned int val;
49abc6cd587348 Bard Liao 2015-11-10 3893 struct regmap *regmap;
1319b2f6a56523 Oder Chiou 2014-04-28 3894
1319b2f6a56523 Oder Chiou 2014-04-28 3895 rt5645 = devm_kzalloc(&i2c->dev, sizeof(struct rt5645_priv),
1319b2f6a56523 Oder Chiou 2014-04-28 3896 GFP_KERNEL);
1319b2f6a56523 Oder Chiou 2014-04-28 3897 if (rt5645 == NULL)
1319b2f6a56523 Oder Chiou 2014-04-28 3898 return -ENOMEM;
1319b2f6a56523 Oder Chiou 2014-04-28 3899
f3fa1bbd836a7d Oder Chiou 2014-09-19 3900 rt5645->i2c = i2c;
1319b2f6a56523 Oder Chiou 2014-04-28 3901 i2c_set_clientdata(i2c, rt5645);
1319b2f6a56523 Oder Chiou 2014-04-28 3902
78f5605c0329f8 Hans de Goede 2018-01-02 3903 dmi_data = dmi_first_match(dmi_platform_data);
78f5605c0329f8 Hans de Goede 2018-01-02 3904 if (dmi_data) {
78f5605c0329f8 Hans de Goede 2018-01-02 3905 dev_info(&i2c->dev, "Detected %s platform\n", dmi_data->ident);
78f5605c0329f8 Hans de Goede 2018-01-02 3906 pdata = dmi_data->driver_data;
78f5605c0329f8 Hans de Goede 2018-01-02 3907 }
78f5605c0329f8 Hans de Goede 2018-01-02 3908
48edaa4b4fb6e7 Oder Chiou 2015-06-12 3909 if (pdata)
1319b2f6a56523 Oder Chiou 2014-04-28 3910 rt5645->pdata = *pdata;
9761c0f65d3a4c Bard Liao 2015-11-30 3911 else if (rt5645_check_dp(&i2c->dev))
48edaa4b4fb6e7 Oder Chiou 2015-06-12 3912 rt5645_parse_dt(rt5645, &i2c->dev);
5954c4a1455c3b Pierre-Louis Bossart 2018-01-11 3913 else
5954c4a1455c3b Pierre-Louis Bossart 2018-01-11 3914 rt5645->pdata = jd_mode3_platform_data;
0b0cefc8fd105f Oder Chiou 2015-06-10 3915
4999b0214b05a0 Takashi Iwai 2017-06-29 3916 if (quirk != -1) {
4999b0214b05a0 Takashi Iwai 2017-06-29 3917 rt5645->pdata.in2_diff = QUIRK_IN2_DIFF(quirk);
4999b0214b05a0 Takashi Iwai 2017-06-29 3918 rt5645->pdata.level_trigger_irq = QUIRK_LEVEL_IRQ(quirk);
4999b0214b05a0 Takashi Iwai 2017-06-29 3919 rt5645->pdata.inv_jd1_1 = QUIRK_INV_JD1_1(quirk);
28c988492cf656 Chris Chiu 2021-01-11 3920 rt5645->pdata.inv_hp_pol = QUIRK_INV_HP_POL(quirk);
4999b0214b05a0 Takashi Iwai 2017-06-29 3921 rt5645->pdata.jd_mode = QUIRK_JD_MODE(quirk);
4999b0214b05a0 Takashi Iwai 2017-06-29 3922 rt5645->pdata.dmic1_data_pin = QUIRK_DMIC1_DATA_PIN(quirk);
4999b0214b05a0 Takashi Iwai 2017-06-29 3923 rt5645->pdata.dmic2_data_pin = QUIRK_DMIC2_DATA_PIN(quirk);
4999b0214b05a0 Takashi Iwai 2017-06-29 3924 }
0b0cefc8fd105f Oder Chiou 2015-06-10 3925
3f004d2dc118e5 Hans de Goede 2021-03-07 3926 if (has_acpi_companion(&i2c->dev)) {
3f004d2dc118e5 Hans de Goede 2021-03-07 3927 if (cht_rt5645_gpios) {
21f603482a6bdc Chris Chiu 2021-01-11 3928 if (devm_acpi_dev_add_driver_gpios(&i2c->dev, cht_rt5645_gpios))
21f603482a6bdc Chris Chiu 2021-01-11 3929 dev_dbg(&i2c->dev, "Failed to add driver gpios\n");
3f004d2dc118e5 Hans de Goede 2021-03-07 3930 }
3f004d2dc118e5 Hans de Goede 2021-03-07 3931
3f004d2dc118e5 Hans de Goede 2021-03-07 3932 /* The ALC3270 package has the headset-mic pin not-connected */
3f004d2dc118e5 Hans de Goede 2021-03-07 @3933 if (acpi_dev_hid_uid_match(ACPI_COMPANION(&i2c->dev), "10EC3270", NULL))
3f004d2dc118e5 Hans de Goede 2021-03-07 3934 rt5645->pdata.no_headset_mic = true;
3f004d2dc118e5 Hans de Goede 2021-03-07 3935 }
21f603482a6bdc Chris Chiu 2021-01-11 3936
25c8888ad65f81 Axel Lin 2015-06-12 3937 rt5645->gpiod_hp_det = devm_gpiod_get_optional(&i2c->dev, "hp-detect",
25c8888ad65f81 Axel Lin 2015-06-12 3938 GPIOD_IN);
0b0cefc8fd105f Oder Chiou 2015-06-10 3939
0b0cefc8fd105f Oder Chiou 2015-06-10 3940 if (IS_ERR(rt5645->gpiod_hp_det)) {
cec55827dde1e8 Pierre-Louis Bossart 2017-02-01 3941 dev_info(&i2c->dev, "failed to initialize gpiod\n");
cec55827dde1e8 Pierre-Louis Bossart 2017-02-01 3942 ret = PTR_ERR(rt5645->gpiod_hp_det);
cec55827dde1e8 Pierre-Louis Bossart 2017-02-01 3943 /*
cec55827dde1e8 Pierre-Louis Bossart 2017-02-01 3944 * Continue if optional gpiod is missing, bail for all other
cec55827dde1e8 Pierre-Louis Bossart 2017-02-01 3945 * errors, including -EPROBE_DEFER
cec55827dde1e8 Pierre-Louis Bossart 2017-02-01 3946 */
cec55827dde1e8 Pierre-Louis Bossart 2017-02-01 3947 if (ret != -ENOENT)
cec55827dde1e8 Pierre-Louis Bossart 2017-02-01 3948 return ret;
78c34fd42e3b0e Fang, Yang A 2015-04-24 3949 }
1319b2f6a56523 Oder Chiou 2014-04-28 3950
9fc114c5d7af6c Koro Chen 2015-07-17 3951 for (i = 0; i < ARRAY_SIZE(rt5645->supplies); i++)
9fc114c5d7af6c Koro Chen 2015-07-17 3952 rt5645->supplies[i].supply = rt5645_supply_names[i];
9fc114c5d7af6c Koro Chen 2015-07-17 3953
9fc114c5d7af6c Koro Chen 2015-07-17 3954 ret = devm_regulator_bulk_get(&i2c->dev,
9fc114c5d7af6c Koro Chen 2015-07-17 3955 ARRAY_SIZE(rt5645->supplies),
9fc114c5d7af6c Koro Chen 2015-07-17 3956 rt5645->supplies);
9fc114c5d7af6c Koro Chen 2015-07-17 3957 if (ret) {
9fc114c5d7af6c Koro Chen 2015-07-17 3958 dev_err(&i2c->dev, "Failed to request supplies: %d\n", ret);
9fc114c5d7af6c Koro Chen 2015-07-17 3959 return ret;
9fc114c5d7af6c Koro Chen 2015-07-17 3960 }
9fc114c5d7af6c Koro Chen 2015-07-17 3961
9fc114c5d7af6c Koro Chen 2015-07-17 3962 ret = regulator_bulk_enable(ARRAY_SIZE(rt5645->supplies),
9fc114c5d7af6c Koro Chen 2015-07-17 3963 rt5645->supplies);
9fc114c5d7af6c Koro Chen 2015-07-17 3964 if (ret) {
9fc114c5d7af6c Koro Chen 2015-07-17 3965 dev_err(&i2c->dev, "Failed to enable supplies: %d\n", ret);
9fc114c5d7af6c Koro Chen 2015-07-17 3966 return ret;
9fc114c5d7af6c Koro Chen 2015-07-17 3967 }
9fc114c5d7af6c Koro Chen 2015-07-17 3968
49abc6cd587348 Bard Liao 2015-11-10 3969 regmap = devm_regmap_init_i2c(i2c, &temp_regmap);
49abc6cd587348 Bard Liao 2015-11-10 3970 if (IS_ERR(regmap)) {
49abc6cd587348 Bard Liao 2015-11-10 3971 ret = PTR_ERR(regmap);
49abc6cd587348 Bard Liao 2015-11-10 3972 dev_err(&i2c->dev, "Failed to allocate temp register map: %d\n",
49abc6cd587348 Bard Liao 2015-11-10 3973 ret);
7883c193d7ae1c Zheyu Ma 2022-05-10 3974 goto err_enable;
49abc6cd587348 Bard Liao 2015-11-10 3975 }
0c279a590fde66 Akshu Agrawal 2017-11-09 3976
0c279a590fde66 Akshu Agrawal 2017-11-09 3977 /*
0c279a590fde66 Akshu Agrawal 2017-11-09 3978 * Read after 400msec, as it is the interval required between
0c279a590fde66 Akshu Agrawal 2017-11-09 3979 * read and power On.
0c279a590fde66 Akshu Agrawal 2017-11-09 3980 */
0c279a590fde66 Akshu Agrawal 2017-11-09 3981 msleep(TIME_TO_POWER_MS);
bf62eec5cdecbe Shuming Fan 2023-07-05 3982 ret = regmap_read(regmap, RT5645_VENDOR_ID2, &val);
bf62eec5cdecbe Shuming Fan 2023-07-05 3983 if (ret < 0) {
bf62eec5cdecbe Shuming Fan 2023-07-05 3984 dev_err(&i2c->dev, "Failed to read: 0x%02X\n, ret = %d", RT5645_VENDOR_ID2, ret);
bf62eec5cdecbe Shuming Fan 2023-07-05 3985 goto err_enable;
bf62eec5cdecbe Shuming Fan 2023-07-05 3986 }
5c4ca99df718f6 Bard Liao 2015-01-21 3987
5c4ca99df718f6 Bard Liao 2015-01-21 3988 switch (val) {
5c4ca99df718f6 Bard Liao 2015-01-21 3989 case RT5645_DEVICE_ID:
49abc6cd587348 Bard Liao 2015-11-10 3990 rt5645->regmap = devm_regmap_init_i2c(i2c, &rt5645_regmap);
5c4ca99df718f6 Bard Liao 2015-01-21 3991 rt5645->codec_type = CODEC_TYPE_RT5645;
5c4ca99df718f6 Bard Liao 2015-01-21 3992 break;
5c4ca99df718f6 Bard Liao 2015-01-21 3993 case RT5650_DEVICE_ID:
49abc6cd587348 Bard Liao 2015-11-10 3994 rt5645->regmap = devm_regmap_init_i2c(i2c, &rt5650_regmap);
5c4ca99df718f6 Bard Liao 2015-01-21 3995 rt5645->codec_type = CODEC_TYPE_RT5650;
5c4ca99df718f6 Bard Liao 2015-01-21 3996 break;
5c4ca99df718f6 Bard Liao 2015-01-21 3997 default:
1319b2f6a56523 Oder Chiou 2014-04-28 3998 dev_err(&i2c->dev,
8f68e80f5f4349 Jarkko Nikula 2015-06-25 3999 "Device with ID register %#x is not rt5645 or rt5650\n",
5c4ca99df718f6 Bard Liao 2015-01-21 4000 val);
9fc114c5d7af6c Koro Chen 2015-07-17 4001 ret = -ENODEV;
9fc114c5d7af6c Koro Chen 2015-07-17 4002 goto err_enable;
d12d6c4ef252dd John Lin 2015-05-12 4003 }
d12d6c4ef252dd John Lin 2015-05-12 4004
49abc6cd587348 Bard Liao 2015-11-10 4005 if (IS_ERR(rt5645->regmap)) {
49abc6cd587348 Bard Liao 2015-11-10 4006 ret = PTR_ERR(rt5645->regmap);
49abc6cd587348 Bard Liao 2015-11-10 4007 dev_err(&i2c->dev, "Failed to allocate register map: %d\n",
49abc6cd587348 Bard Liao 2015-11-10 4008 ret);
7883c193d7ae1c Zheyu Ma 2022-05-10 4009 goto err_enable;
49abc6cd587348 Bard Liao 2015-11-10 4010 }
49abc6cd587348 Bard Liao 2015-11-10 4011
1319b2f6a56523 Oder Chiou 2014-04-28 4012 regmap_write(rt5645->regmap, RT5645_RESET, 0);
1319b2f6a56523 Oder Chiou 2014-04-28 4013
50f510a33c7c90 Bard Liao 2017-10-30 4014 regmap_read(regmap, RT5645_VENDOR_ID, &val);
50f510a33c7c90 Bard Liao 2017-10-30 4015 rt5645->v_id = val & 0xff;
50f510a33c7c90 Bard Liao 2017-10-30 4016
56986b07d17b4a Bard Liao 2017-11-22 4017 regmap_write(rt5645->regmap, RT5645_AD_DA_MIXER, 0x8080);
56986b07d17b4a Bard Liao 2017-11-22 4018
aa98697c7dbd8d Shuming Fan 2023-08-18 4019 ret = regmap_multi_reg_write(rt5645->regmap, init_list,
1319b2f6a56523 Oder Chiou 2014-04-28 4020 ARRAY_SIZE(init_list));
1319b2f6a56523 Oder Chiou 2014-04-28 4021 if (ret != 0)
1319b2f6a56523 Oder Chiou 2014-04-28 4022 dev_warn(&i2c->dev, "Failed to apply regmap patch: %d\n", ret);
1319b2f6a56523 Oder Chiou 2014-04-28 4023
5c4ca99df718f6 Bard Liao 2015-01-21 4024 if (rt5645->codec_type == CODEC_TYPE_RT5650) {
aa98697c7dbd8d Shuming Fan 2023-08-18 4025 ret = regmap_multi_reg_write(rt5645->regmap, rt5650_init_list,
5c4ca99df718f6 Bard Liao 2015-01-21 4026 ARRAY_SIZE(rt5650_init_list));
5c4ca99df718f6 Bard Liao 2015-01-21 4027 if (ret != 0)
5c4ca99df718f6 Bard Liao 2015-01-21 4028 dev_warn(&i2c->dev, "Apply rt5650 patch failed: %d\n",
5c4ca99df718f6 Bard Liao 2015-01-21 4029 ret);
5c4ca99df718f6 Bard Liao 2015-01-21 4030 }
5c4ca99df718f6 Bard Liao 2015-01-21 4031
105e56f1ec335a Bard Liao 2017-06-27 4032 regmap_update_bits(rt5645->regmap, RT5645_CLSD_OUT_CTRL, 0xc0, 0xc0);
105e56f1ec335a Bard Liao 2017-06-27 4033
1319b2f6a56523 Oder Chiou 2014-04-28 4034 if (rt5645->pdata.in2_diff)
1319b2f6a56523 Oder Chiou 2014-04-28 4035 regmap_update_bits(rt5645->regmap, RT5645_IN2_CTRL,
1319b2f6a56523 Oder Chiou 2014-04-28 4036 RT5645_IN_DF2, RT5645_IN_DF2);
1319b2f6a56523 Oder Chiou 2014-04-28 4037
ac4fc3eeb79e06 Bard Liao 2015-05-05 4038 if (rt5645->pdata.dmic1_data_pin || rt5645->pdata.dmic2_data_pin) {
1319b2f6a56523 Oder Chiou 2014-04-28 4039 regmap_update_bits(rt5645->regmap, RT5645_GPIO_CTRL1,
1319b2f6a56523 Oder Chiou 2014-04-28 4040 RT5645_GP2_PIN_MASK, RT5645_GP2_PIN_DMIC1_SCL);
ac4fc3eeb79e06 Bard Liao 2015-05-05 4041 }
1319b2f6a56523 Oder Chiou 2014-04-28 4042 switch (rt5645->pdata.dmic1_data_pin) {
1319b2f6a56523 Oder Chiou 2014-04-28 4043 case RT5645_DMIC_DATA_IN2N:
1319b2f6a56523 Oder Chiou 2014-04-28 4044 regmap_update_bits(rt5645->regmap, RT5645_DMIC_CTRL1,
1319b2f6a56523 Oder Chiou 2014-04-28 4045 RT5645_DMIC_1_DP_MASK, RT5645_DMIC_1_DP_IN2N);
1319b2f6a56523 Oder Chiou 2014-04-28 4046 break;
1319b2f6a56523 Oder Chiou 2014-04-28 4047
1319b2f6a56523 Oder Chiou 2014-04-28 4048 case RT5645_DMIC_DATA_GPIO5:
a094935e4ebdf5 Bard Liao 2015-08-03 4049 regmap_update_bits(rt5645->regmap, RT5645_GPIO_CTRL1,
a094935e4ebdf5 Bard Liao 2015-08-03 4050 RT5645_I2S2_DAC_PIN_MASK, RT5645_I2S2_DAC_PIN_GPIO);
1319b2f6a56523 Oder Chiou 2014-04-28 4051 regmap_update_bits(rt5645->regmap, RT5645_DMIC_CTRL1,
1319b2f6a56523 Oder Chiou 2014-04-28 4052 RT5645_DMIC_1_DP_MASK, RT5645_DMIC_1_DP_GPIO5);
1319b2f6a56523 Oder Chiou 2014-04-28 4053 regmap_update_bits(rt5645->regmap, RT5645_GPIO_CTRL1,
1319b2f6a56523 Oder Chiou 2014-04-28 4054 RT5645_GP5_PIN_MASK, RT5645_GP5_PIN_DMIC1_SDA);
1319b2f6a56523 Oder Chiou 2014-04-28 4055 break;
1319b2f6a56523 Oder Chiou 2014-04-28 4056
1319b2f6a56523 Oder Chiou 2014-04-28 4057 case RT5645_DMIC_DATA_GPIO11:
1319b2f6a56523 Oder Chiou 2014-04-28 4058 regmap_update_bits(rt5645->regmap, RT5645_DMIC_CTRL1,
1319b2f6a56523 Oder Chiou 2014-04-28 4059 RT5645_DMIC_1_DP_MASK, RT5645_DMIC_1_DP_GPIO11);
1319b2f6a56523 Oder Chiou 2014-04-28 4060 regmap_update_bits(rt5645->regmap, RT5645_GPIO_CTRL1,
1319b2f6a56523 Oder Chiou 2014-04-28 4061 RT5645_GP11_PIN_MASK,
1319b2f6a56523 Oder Chiou 2014-04-28 4062 RT5645_GP11_PIN_DMIC1_SDA);
1319b2f6a56523 Oder Chiou 2014-04-28 4063 break;
1319b2f6a56523 Oder Chiou 2014-04-28 4064
1319b2f6a56523 Oder Chiou 2014-04-28 4065 default:
1319b2f6a56523 Oder Chiou 2014-04-28 4066 break;
1319b2f6a56523 Oder Chiou 2014-04-28 4067 }
1319b2f6a56523 Oder Chiou 2014-04-28 4068
1319b2f6a56523 Oder Chiou 2014-04-28 4069 switch (rt5645->pdata.dmic2_data_pin) {
1319b2f6a56523 Oder Chiou 2014-04-28 4070 case RT5645_DMIC_DATA_IN2P:
1319b2f6a56523 Oder Chiou 2014-04-28 4071 regmap_update_bits(rt5645->regmap, RT5645_DMIC_CTRL1,
1319b2f6a56523 Oder Chiou 2014-04-28 4072 RT5645_DMIC_2_DP_MASK, RT5645_DMIC_2_DP_IN2P);
1319b2f6a56523 Oder Chiou 2014-04-28 4073 break;
1319b2f6a56523 Oder Chiou 2014-04-28 4074
1319b2f6a56523 Oder Chiou 2014-04-28 4075 case RT5645_DMIC_DATA_GPIO6:
1319b2f6a56523 Oder Chiou 2014-04-28 4076 regmap_update_bits(rt5645->regmap, RT5645_DMIC_CTRL1,
1319b2f6a56523 Oder Chiou 2014-04-28 4077 RT5645_DMIC_2_DP_MASK, RT5645_DMIC_2_DP_GPIO6);
1319b2f6a56523 Oder Chiou 2014-04-28 4078 regmap_update_bits(rt5645->regmap, RT5645_GPIO_CTRL1,
1319b2f6a56523 Oder Chiou 2014-04-28 4079 RT5645_GP6_PIN_MASK, RT5645_GP6_PIN_DMIC2_SDA);
1319b2f6a56523 Oder Chiou 2014-04-28 4080 break;
1319b2f6a56523 Oder Chiou 2014-04-28 4081
1319b2f6a56523 Oder Chiou 2014-04-28 4082 case RT5645_DMIC_DATA_GPIO10:
1319b2f6a56523 Oder Chiou 2014-04-28 4083 regmap_update_bits(rt5645->regmap, RT5645_DMIC_CTRL1,
1319b2f6a56523 Oder Chiou 2014-04-28 4084 RT5645_DMIC_2_DP_MASK, RT5645_DMIC_2_DP_GPIO10);
1319b2f6a56523 Oder Chiou 2014-04-28 4085 regmap_update_bits(rt5645->regmap, RT5645_GPIO_CTRL1,
1319b2f6a56523 Oder Chiou 2014-04-28 4086 RT5645_GP10_PIN_MASK,
1319b2f6a56523 Oder Chiou 2014-04-28 4087 RT5645_GP10_PIN_DMIC2_SDA);
1319b2f6a56523 Oder Chiou 2014-04-28 4088 break;
1319b2f6a56523 Oder Chiou 2014-04-28 4089
1319b2f6a56523 Oder Chiou 2014-04-28 4090 case RT5645_DMIC_DATA_GPIO12:
1319b2f6a56523 Oder Chiou 2014-04-28 4091 regmap_update_bits(rt5645->regmap, RT5645_DMIC_CTRL1,
53f9b3baa937e0 Axel Lin 2015-04-21 4092 RT5645_DMIC_2_DP_MASK, RT5645_DMIC_2_DP_GPIO12);
1319b2f6a56523 Oder Chiou 2014-04-28 4093 regmap_update_bits(rt5645->regmap, RT5645_GPIO_CTRL1,
1319b2f6a56523 Oder Chiou 2014-04-28 4094 RT5645_GP12_PIN_MASK,
1319b2f6a56523 Oder Chiou 2014-04-28 4095 RT5645_GP12_PIN_DMIC2_SDA);
1319b2f6a56523 Oder Chiou 2014-04-28 4096 break;
1319b2f6a56523 Oder Chiou 2014-04-28 4097
1319b2f6a56523 Oder Chiou 2014-04-28 4098 default:
1319b2f6a56523 Oder Chiou 2014-04-28 4099 break;
1319b2f6a56523 Oder Chiou 2014-04-28 4100 }
1319b2f6a56523 Oder Chiou 2014-04-28 4101
ac4fc3eeb79e06 Bard Liao 2015-05-05 4102 if (rt5645->pdata.jd_mode) {
bb656add19764c Bard Liao 2014-11-05 4103 regmap_update_bits(rt5645->regmap, RT5645_GEN_CTRL3,
ac4fc3eeb79e06 Bard Liao 2015-05-05 4104 RT5645_IRQ_CLK_GATE_CTRL,
ac4fc3eeb79e06 Bard Liao 2015-05-05 4105 RT5645_IRQ_CLK_GATE_CTRL);
bb656add19764c Bard Liao 2014-11-05 4106 regmap_update_bits(rt5645->regmap, RT5645_MICBIAS,
bb656add19764c Bard Liao 2014-11-05 4107 RT5645_IRQ_CLK_INT, RT5645_IRQ_CLK_INT);
2d4e2d02051663 Bard Liao 2014-11-18 4108 regmap_update_bits(rt5645->regmap, RT5645_IRQ_CTRL2,
2d4e2d02051663 Bard Liao 2014-11-18 4109 RT5645_IRQ_JD_1_1_EN, RT5645_IRQ_JD_1_1_EN);
2d4e2d02051663 Bard Liao 2014-11-18 4110 regmap_update_bits(rt5645->regmap, RT5645_GEN_CTRL3,
2d4e2d02051663 Bard Liao 2014-11-18 4111 RT5645_JD_PSV_MODE, RT5645_JD_PSV_MODE);
2d4e2d02051663 Bard Liao 2014-11-18 4112 regmap_update_bits(rt5645->regmap, RT5645_HPO_MIXER,
2d4e2d02051663 Bard Liao 2014-11-18 4113 RT5645_IRQ_PSV_MODE, RT5645_IRQ_PSV_MODE);
2d4e2d02051663 Bard Liao 2014-11-18 4114 regmap_update_bits(rt5645->regmap, RT5645_MICBIAS,
2d4e2d02051663 Bard Liao 2014-11-18 4115 RT5645_MIC2_OVCD_EN, RT5645_MIC2_OVCD_EN);
2d4e2d02051663 Bard Liao 2014-11-18 4116 regmap_update_bits(rt5645->regmap, RT5645_GPIO_CTRL1,
2d4e2d02051663 Bard Liao 2014-11-18 4117 RT5645_GP1_PIN_IRQ, RT5645_GP1_PIN_IRQ);
2d4e2d02051663 Bard Liao 2014-11-18 4118 switch (rt5645->pdata.jd_mode) {
2d4e2d02051663 Bard Liao 2014-11-18 4119 case 1:
2d4e2d02051663 Bard Liao 2014-11-18 4120 regmap_update_bits(rt5645->regmap, RT5645_A_JD_CTRL1,
2d4e2d02051663 Bard Liao 2014-11-18 4121 RT5645_JD1_MODE_MASK,
2d4e2d02051663 Bard Liao 2014-11-18 4122 RT5645_JD1_MODE_0);
2d4e2d02051663 Bard Liao 2014-11-18 4123 break;
2d4e2d02051663 Bard Liao 2014-11-18 4124 case 2:
2d4e2d02051663 Bard Liao 2014-11-18 4125 regmap_update_bits(rt5645->regmap, RT5645_A_JD_CTRL1,
2d4e2d02051663 Bard Liao 2014-11-18 4126 RT5645_JD1_MODE_MASK,
2d4e2d02051663 Bard Liao 2014-11-18 4127 RT5645_JD1_MODE_1);
2d4e2d02051663 Bard Liao 2014-11-18 4128 break;
2d4e2d02051663 Bard Liao 2014-11-18 4129 case 3:
e7cfd867fd9842 Jacob Rasmussen 2019-11-11 4130 case 4:
2d4e2d02051663 Bard Liao 2014-11-18 4131 regmap_update_bits(rt5645->regmap, RT5645_A_JD_CTRL1,
2d4e2d02051663 Bard Liao 2014-11-18 4132 RT5645_JD1_MODE_MASK,
2d4e2d02051663 Bard Liao 2014-11-18 4133 RT5645_JD1_MODE_2);
2d4e2d02051663 Bard Liao 2014-11-18 4134 break;
2d4e2d02051663 Bard Liao 2014-11-18 4135 default:
2d4e2d02051663 Bard Liao 2014-11-18 4136 break;
2d4e2d02051663 Bard Liao 2014-11-18 4137 }
aea086dda2d5df Bard Liao 2017-06-28 4138 if (rt5645->pdata.inv_jd1_1) {
aea086dda2d5df Bard Liao 2017-06-28 4139 regmap_update_bits(rt5645->regmap, RT5645_IRQ_CTRL2,
aea086dda2d5df Bard Liao 2017-06-28 4140 RT5645_JD_1_1_MASK, RT5645_JD_1_1_INV);
aea086dda2d5df Bard Liao 2017-06-28 4141 }
2d4e2d02051663 Bard Liao 2014-11-18 4142 }
2d4e2d02051663 Bard Liao 2014-11-18 4143
02c5c03283c521 Bard Liao 2016-12-27 4144 regmap_update_bits(rt5645->regmap, RT5645_ADDA_CLK1,
02c5c03283c521 Bard Liao 2016-12-27 4145 RT5645_I2S_PD1_MASK, RT5645_I2S_PD1_2);
02c5c03283c521 Bard Liao 2016-12-27 4146
895750228c9d33 Bard Liao 2017-06-28 4147 if (rt5645->pdata.level_trigger_irq) {
7ff6319e7da5c0 Bard Liao 2015-12-30 4148 regmap_update_bits(rt5645->regmap, RT5645_IRQ_CTRL2,
7ff6319e7da5c0 Bard Liao 2015-12-30 4149 RT5645_JD_1_1_MASK, RT5645_JD_1_1_INV);
381437dd0bd590 Bard Liao 2016-05-05 4150 }
7211ec6392c865 Kees Cook 2017-10-25 4151 timer_setup(&rt5645->btn_check_timer, rt5645_btn_check_callback, 0);
7ff6319e7da5c0 Bard Liao 2015-12-30 4152
7ea3470a727738 Nicolas Boichat 2015-06-05 4153 INIT_DELAYED_WORK(&rt5645->jack_detect_work, rt5645_jack_detect_work);
7099ee85e6af56 Oder Chiou 2015-11-05 4154 INIT_DELAYED_WORK(&rt5645->rcclock_work, rt5645_rcclock_work);
7ea3470a727738 Nicolas Boichat 2015-06-05 4155
f3fa1bbd836a7d Oder Chiou 2014-09-19 4156 if (rt5645->i2c->irq) {
f3fa1bbd836a7d Oder Chiou 2014-09-19 4157 ret = request_threaded_irq(rt5645->i2c->irq, NULL, rt5645_irq,
f3fa1bbd836a7d Oder Chiou 2014-09-19 4158 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING
f3fa1bbd836a7d Oder Chiou 2014-09-19 4159 | IRQF_ONESHOT, "rt5645", rt5645);
5168c5476a0723 Koro Chen 2015-07-17 4160 if (ret) {
f3fa1bbd836a7d Oder Chiou 2014-09-19 4161 dev_err(&i2c->dev, "Failed to reguest IRQ: %d\n", ret);
9fc114c5d7af6c Koro Chen 2015-07-17 4162 goto err_enable;
5168c5476a0723 Koro Chen 2015-07-17 4163 }
f3fa1bbd836a7d Oder Chiou 2014-09-19 4164 }
f3fa1bbd836a7d Oder Chiou 2014-09-19 4165
79223bf1909191 Kuninori Morimoto 2018-01-29 4166 ret = devm_snd_soc_register_component(&i2c->dev, &soc_component_dev_rt5645,
1319b2f6a56523 Oder Chiou 2014-04-28 4167 rt5645_dai, ARRAY_SIZE(rt5645_dai));
5168c5476a0723 Koro Chen 2015-07-17 4168 if (ret)
5168c5476a0723 Koro Chen 2015-07-17 4169 goto err_irq;
5168c5476a0723 Koro Chen 2015-07-17 4170
5168c5476a0723 Koro Chen 2015-07-17 4171 return 0;
5168c5476a0723 Koro Chen 2015-07-17 4172
5168c5476a0723 Koro Chen 2015-07-17 4173 err_irq:
5168c5476a0723 Koro Chen 2015-07-17 4174 if (rt5645->i2c->irq)
5168c5476a0723 Koro Chen 2015-07-17 4175 free_irq(rt5645->i2c->irq, rt5645);
9fc114c5d7af6c Koro Chen 2015-07-17 4176 err_enable:
9fc114c5d7af6c Koro Chen 2015-07-17 4177 regulator_bulk_disable(ARRAY_SIZE(rt5645->supplies), rt5645->supplies);
5168c5476a0723 Koro Chen 2015-07-17 4178 return ret;
1319b2f6a56523 Oder Chiou 2014-04-28 4179 }
1319b2f6a56523 Oder Chiou 2014-04-28 4180

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki