mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 17:47:41 +02:00
Counter updates for 7.2
Manual mutex lock logic is replaced by lock guards in intel-qep. Additionally, devm_mutex_init() is now used in ftm-quaddec, interrupt-cnt, and intel-qep to handle mutex cleanup automatically. -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQSNN83d4NIlKPjon7a1SFbKvhIjKwUCah5CrwAKCRC1SFbKvhIj K0X3AQCy8OkON3wzX/rd+5P1er9zxXcxEs0cTN7NUwkiqPEosgEAtIKiEKehqczG CeyORY94TwVnADpCYMXGLpELnb43eQ8= =b4nq -----END PGP SIGNATURE----- Merge tag 'counter-updates-for-7.2' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/wbg/counter into char-misc-next William writes: Counter updates for 7.2 Manual mutex lock logic is replaced by lock guards in intel-qep. Additionally, devm_mutex_init() is now used in ftm-quaddec, interrupt-cnt, and intel-qep to handle mutex cleanup automatically. * tag 'counter-updates-for-7.2' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/wbg/counter: counter: intel-qep: Use devm_mutex_init() counter: interrupt-cnt: use devm_mutex_init() counter: ftm-quaddec: use devm_mutex_init() counter: intel-qep: Replace manual mutex logic with lock guards
This commit is contained in:
commit
099b02d3dd
|
|
@ -292,7 +292,9 @@ static int ftm_quaddec_probe(struct platform_device *pdev)
|
|||
counter->signals = ftm_quaddec_signals;
|
||||
counter->num_signals = ARRAY_SIZE(ftm_quaddec_signals);
|
||||
|
||||
mutex_init(&ftm->ftm_quaddec_mutex);
|
||||
ret = devm_mutex_init(&pdev->dev, &ftm->ftm_quaddec_mutex);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ftm_quaddec_init(ftm);
|
||||
|
||||
|
|
|
|||
|
|
@ -188,25 +188,21 @@ static int intel_qep_ceiling_write(struct counter_device *counter,
|
|||
struct counter_count *count, u64 max)
|
||||
{
|
||||
struct intel_qep *qep = counter_priv(counter);
|
||||
int ret = 0;
|
||||
|
||||
/* Intel QEP ceiling configuration only supports 32-bit values */
|
||||
if (max != (u32)max)
|
||||
return -ERANGE;
|
||||
|
||||
mutex_lock(&qep->lock);
|
||||
if (qep->enabled) {
|
||||
ret = -EBUSY;
|
||||
goto out;
|
||||
}
|
||||
guard(mutex)(&qep->lock);
|
||||
|
||||
if (qep->enabled)
|
||||
return -EBUSY;
|
||||
|
||||
pm_runtime_get_sync(qep->dev);
|
||||
intel_qep_writel(qep, INTEL_QEPMAX, max);
|
||||
pm_runtime_put(qep->dev);
|
||||
|
||||
out:
|
||||
mutex_unlock(&qep->lock);
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int intel_qep_enable_read(struct counter_device *counter,
|
||||
|
|
@ -226,10 +222,11 @@ static int intel_qep_enable_write(struct counter_device *counter,
|
|||
u32 reg;
|
||||
bool changed;
|
||||
|
||||
mutex_lock(&qep->lock);
|
||||
guard(mutex)(&qep->lock);
|
||||
|
||||
changed = val ^ qep->enabled;
|
||||
if (!changed)
|
||||
goto out;
|
||||
return 0;
|
||||
|
||||
pm_runtime_get_sync(qep->dev);
|
||||
reg = intel_qep_readl(qep, INTEL_QEPCON);
|
||||
|
|
@ -246,8 +243,6 @@ static int intel_qep_enable_write(struct counter_device *counter,
|
|||
pm_runtime_put(qep->dev);
|
||||
qep->enabled = val;
|
||||
|
||||
out:
|
||||
mutex_unlock(&qep->lock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -279,7 +274,6 @@ static int intel_qep_spike_filter_ns_write(struct counter_device *counter,
|
|||
struct intel_qep *qep = counter_priv(counter);
|
||||
u32 reg;
|
||||
bool enable;
|
||||
int ret = 0;
|
||||
|
||||
/*
|
||||
* Spike filter length is (MAX_COUNT + 2) clock periods.
|
||||
|
|
@ -300,11 +294,10 @@ static int intel_qep_spike_filter_ns_write(struct counter_device *counter,
|
|||
if (length > INTEL_QEPFLT_MAX_COUNT(length))
|
||||
return -ERANGE;
|
||||
|
||||
mutex_lock(&qep->lock);
|
||||
if (qep->enabled) {
|
||||
ret = -EBUSY;
|
||||
goto out;
|
||||
}
|
||||
guard(mutex)(&qep->lock);
|
||||
|
||||
if (qep->enabled)
|
||||
return -EBUSY;
|
||||
|
||||
pm_runtime_get_sync(qep->dev);
|
||||
reg = intel_qep_readl(qep, INTEL_QEPCON);
|
||||
|
|
@ -316,9 +309,7 @@ static int intel_qep_spike_filter_ns_write(struct counter_device *counter,
|
|||
intel_qep_writel(qep, INTEL_QEPCON, reg);
|
||||
pm_runtime_put(qep->dev);
|
||||
|
||||
out:
|
||||
mutex_unlock(&qep->lock);
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int intel_qep_preset_enable_read(struct counter_device *counter,
|
||||
|
|
@ -342,13 +333,11 @@ static int intel_qep_preset_enable_write(struct counter_device *counter,
|
|||
{
|
||||
struct intel_qep *qep = counter_priv(counter);
|
||||
u32 reg;
|
||||
int ret = 0;
|
||||
|
||||
mutex_lock(&qep->lock);
|
||||
if (qep->enabled) {
|
||||
ret = -EBUSY;
|
||||
goto out;
|
||||
}
|
||||
guard(mutex)(&qep->lock);
|
||||
|
||||
if (qep->enabled)
|
||||
return -EBUSY;
|
||||
|
||||
pm_runtime_get_sync(qep->dev);
|
||||
reg = intel_qep_readl(qep, INTEL_QEPCON);
|
||||
|
|
@ -360,10 +349,7 @@ static int intel_qep_preset_enable_write(struct counter_device *counter,
|
|||
intel_qep_writel(qep, INTEL_QEPCON, reg);
|
||||
pm_runtime_put(qep->dev);
|
||||
|
||||
out:
|
||||
mutex_unlock(&qep->lock);
|
||||
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct counter_comp intel_qep_count_ext[] = {
|
||||
|
|
@ -414,7 +400,9 @@ static int intel_qep_probe(struct pci_dev *pci, const struct pci_device_id *id)
|
|||
|
||||
qep->dev = dev;
|
||||
qep->regs = regs;
|
||||
mutex_init(&qep->lock);
|
||||
ret = devm_mutex_init(dev, &qep->lock);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
intel_qep_init(qep);
|
||||
pci_set_drvdata(pci, qep);
|
||||
|
|
|
|||
|
|
@ -233,7 +233,9 @@ static int interrupt_cnt_probe(struct platform_device *pdev)
|
|||
if (ret)
|
||||
return ret;
|
||||
|
||||
mutex_init(&priv->lock);
|
||||
ret = devm_mutex_init(dev, &priv->lock);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = devm_counter_add(dev, counter);
|
||||
if (ret < 0)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user