Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions drivers/dpll/dpll_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ void dpll_init_pin(struct dpll_pin **pin, enum dpll_pin_type type,
(*pin)->type = type;
(*pin)->priv = priv;
(*pin)->id = id;
refcount_set(&((*pin)->ref_count), 0);
if (name)
snprintf((*pin)->name, PIN_NAME_LENGTH, "%s", name);
else
Expand Down Expand Up @@ -241,7 +242,7 @@ int dpll_pin_register(struct dpll_device *dpll, struct dpll_pin *pin)
mutex_lock(&dpll->lock);
ret = pin_register(&dpll->pins, pin);
if (!ret) {
pin->ref_count++;
refcount_inc(&pin->ref_count);
change_pin_count(dpll, pin, true);
xa_set_mark(&dpll->pins, dpll->id, DPLL_REGISTERED);
}
Expand Down Expand Up @@ -287,9 +288,7 @@ int dpll_pin_deregister(struct dpll_device *dpll, struct dpll_pin *pin)
mutex_unlock(&dpll->lock);

if (!ret) {
mutex_lock(&pin->lock);
pin->ref_count--;
mutex_unlock(&pin->lock);
refcount_dec(&pin->ref_count);
dpll_notify_pin_deregister(dpll->id, pin->id);
}

Expand All @@ -311,7 +310,7 @@ void dpll_pin_free(struct dpll_device *dpll, struct dpll_pin *pin)
if (!pin_found)
return;

if (pin->ref_count)
if (refcount_read(&pin->ref_count) != 0)
return;

xa_destroy(&pin->muxed_pins);
Expand All @@ -333,7 +332,7 @@ void dpll_muxed_pin_free(struct dpll_pin *parent_pin, struct dpll_pin *pin)
if (!pin_found)
return;

if (pin->ref_count)
if (refcount_read(&pin->ref_count) != 0)
return;

xa_destroy(&pin->muxed_pins);
Expand All @@ -348,9 +347,7 @@ int dpll_muxed_pin_register(struct dpll_pin *parent_pin, struct dpll_pin *pin)
ret = pin_register(&parent_pin->muxed_pins, pin);

if (!ret) {
mutex_lock(&pin->lock);
pin->ref_count++;
mutex_unlock(&pin->lock);
refcount_inc(&pin->ref_count);
dpll_notify_muxed_pin_register(parent_pin, pin->id);
}

Expand All @@ -370,9 +367,7 @@ int dpll_muxed_pin_deregister(struct dpll_pin *parent_pin, struct dpll_pin *pin)
mutex_unlock(&parent_pin->lock);

if (!ret) {
mutex_lock(&pin->lock);
pin->ref_count--;
mutex_unlock(&pin->lock);
refcount_dec(&pin->ref_count);
dpll_notify_muxed_pin_deregister(parent_pin, pin->id);
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/dpll/dpll_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
struct dpll_pin {
int id;
enum dpll_pin_type type;
int ref_count;
refcount_t ref_count;
struct dpll_pin_ops *ops;
struct mutex lock;
void *priv;
Expand Down
8 changes: 4 additions & 4 deletions drivers/dpll/dpll_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ static int __dpll_cmd_dump_sources(struct dpll_device *dpll,
}
ret = 0;
}
if (pin->ops->get_prio) {
prio = pin->ops->get_prio(pin, dpll);
if (dpll->ops->get_prio) {
prio = dpll->ops->get_prio(dpll, pin);
if (nla_put_u32(msg, DPLLA_SOURCE_PIN_PRIO, prio)) {
nla_nest_cancel(msg, src_attr);
ret = -EMSGSIZE;
Expand Down Expand Up @@ -393,10 +393,10 @@ static int dpll_genl_cmd_set_source_prio(struct sk_buff *skb, struct genl_info *

mutex_lock(&dpll->lock);
pin = dpll_pin_get_by_id(dpll, src_id);
if (!pin || !pin->ops || !pin->ops->set_prio)
if (!dpll->ops || !dpll->ops->set_prio)
ret = -EOPNOTSUPP;
else
ret = pin->ops->set_prio(pin, dpll, prio);
ret = dpll->ops->set_prio(dpll, pin, prio);
mutex_unlock(&dpll->lock);

if (!ret)
Expand Down
14 changes: 7 additions & 7 deletions drivers/net/ethernet/intel/ice/ice_synce.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,13 +361,13 @@ static int ice_synce_get_src_select_supported(struct dpll_device *dpll, int mode
/**
* ice_synce_get_source_prio
* @dpll: registered dpll pointer
* @id: source index
* @pin: dpll pin object
*
* dpll subsystem callback.
* Get source priority value.
* Return: source priority value
*/
static int ice_synce_get_source_prio(struct dpll_pin *pin, struct dpll_device *dpll)
static int ice_synce_get_source_prio(struct dpll_device *dpll, struct dpll_pin *pin)
{
struct ice_pf *pf = dpll_priv(dpll);
u8 idx = (u8)pin_id(pin);
Expand All @@ -389,7 +389,7 @@ static int ice_synce_get_source_prio(struct dpll_pin *pin, struct dpll_device *d
/**
* ice_synce_set_source_prio
* @dpll: registered dpll pointer
* @id: source index
* @pin: dpll pin object
* @prio: expected priority value
*
* dpll subsystem callback.
Expand All @@ -398,8 +398,8 @@ static int ice_synce_get_source_prio(struct dpll_pin *pin, struct dpll_device *d
* * 0 - success
* * negative - failure
*/
static int ice_synce_set_source_prio(struct dpll_pin *pin,
struct dpll_device *dpll, int prio)
static int ice_synce_set_source_prio(struct dpll_device *dpll,
struct dpll_pin *pin, int prio)
{
struct ice_pf *pf = dpll_priv(dpll);
u8 idx, priov = (u8)prio;
Expand Down Expand Up @@ -435,8 +435,6 @@ static struct dpll_pin_ops ice_synce_source_ops = {
.get_type = ice_synce_get_source_type,
.set_type = ice_synce_set_source_type,
.is_type_supported = ice_synce_get_source_supported,
.get_prio = ice_synce_get_source_prio,
.set_prio = ice_synce_set_source_prio,
};

static struct dpll_pin_ops ice_synce_output_ops = {
Expand All @@ -450,6 +448,8 @@ static struct dpll_device_ops ice_synce_dpll_ops = {
.get_lock_status = ice_synce_get_lock_status,
.get_source_select_mode = ice_synce_get_source_select_mode,
.get_source_select_mode_supported = ice_synce_get_src_select_supported,
.get_prio = ice_synce_get_source_prio,
.set_prio = ice_synce_set_source_prio,
};

/**
Expand Down
4 changes: 2 additions & 2 deletions include/linux/dpll.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ struct dpll_device_ops {
int (*get_source_supported)(struct dpll_device *dpll, int sma, int type);
int (*get_output_type)(struct dpll_device *dpll, int sma);
int (*get_output_supported)(struct dpll_device, int sma, int type);
int (*get_prio)(struct dpll_device *dpll, struct dpll_pin *pin);
int (*set_prio)(struct dpll_device *dpll, struct dpll_pin *pin, int prio);
};

struct dpll_pin_ops {
Expand All @@ -30,8 +32,6 @@ struct dpll_pin_ops {
int (*set_type)(struct dpll_pin *pin, int type);
int (*set_source)(struct dpll_pin *pin, struct dpll_device *dpll, int id);
int (*set_flags)(struct dpll_pin *pin, struct dpll_device *dpll, int flags);
int (*get_prio)(struct dpll_pin *pin, struct dpll_device *dpll);
int (*set_prio)(struct dpll_pin *pin, struct dpll_device *dpll, int prio);
};

enum dpll_pin_type {
Expand Down