mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-06 11:54:14 -04:00
usb: typec: altmodes/displayport: Add pin assignment helper
commit 582836e3cfab4faafbdc93bbec96fce036a08ee1 upstream.
The code to extract a peripheral's currently supported Pin Assignments
is repeated in a couple of locations. Factor it out into a separate
function.
This will also make it easier to add fixes (we only need to update 1
location instead of 2).
Fixes: c1e5c2f0cb8a ("usb: typec: altmodes/displayport: correct pin assignment for UFP receptacles")
Cc: stable@vger.kernel.org
Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Prashant Malani <pmalani@chromium.org>
Reviewed-by: Benson Leung <bleung@chromium.org>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/20230111020546.3384569-1-pmalani@chromium.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
040e0d1281
commit
a1478ef59b
1 changed files with 14 additions and 8 deletions
|
|
@ -407,6 +407,18 @@ static const char * const pin_assignments[] = {
|
|||
[DP_PIN_ASSIGN_F] = "F",
|
||||
};
|
||||
|
||||
/*
|
||||
* Helper function to extract a peripheral's currently supported
|
||||
* Pin Assignments from its DisplayPort alternate mode state.
|
||||
*/
|
||||
static u8 get_current_pin_assignments(struct dp_altmode *dp)
|
||||
{
|
||||
if (DP_CONF_CURRENTLY(dp->data.conf) == DP_CONF_DFP_D)
|
||||
return DP_CAP_UFP_D_PIN_ASSIGN(dp->alt->vdo);
|
||||
else
|
||||
return DP_CAP_DFP_D_PIN_ASSIGN(dp->alt->vdo);
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
pin_assignment_store(struct device *dev, struct device_attribute *attr,
|
||||
const char *buf, size_t size)
|
||||
|
|
@ -433,10 +445,7 @@ pin_assignment_store(struct device *dev, struct device_attribute *attr,
|
|||
goto out_unlock;
|
||||
}
|
||||
|
||||
if (DP_CONF_CURRENTLY(dp->data.conf) == DP_CONF_DFP_D)
|
||||
assignments = DP_CAP_UFP_D_PIN_ASSIGN(dp->alt->vdo);
|
||||
else
|
||||
assignments = DP_CAP_DFP_D_PIN_ASSIGN(dp->alt->vdo);
|
||||
assignments = get_current_pin_assignments(dp);
|
||||
|
||||
if (!(DP_CONF_GET_PIN_ASSIGN(conf) & assignments)) {
|
||||
ret = -EINVAL;
|
||||
|
|
@ -473,10 +482,7 @@ static ssize_t pin_assignment_show(struct device *dev,
|
|||
|
||||
cur = get_count_order(DP_CONF_GET_PIN_ASSIGN(dp->data.conf));
|
||||
|
||||
if (DP_CONF_CURRENTLY(dp->data.conf) == DP_CONF_DFP_D)
|
||||
assignments = DP_CAP_UFP_D_PIN_ASSIGN(dp->alt->vdo);
|
||||
else
|
||||
assignments = DP_CAP_DFP_D_PIN_ASSIGN(dp->alt->vdo);
|
||||
assignments = get_current_pin_assignments(dp);
|
||||
|
||||
for (i = 0; assignments; assignments >>= 1, i++) {
|
||||
if (assignments & 1) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue