mirror of
https://github.com/torvalds/linux.git
synced 2025-12-01 07:26:02 +07:00
pwm: twl-led: Drop driver local locking
The pwm core already serializes .apply(). twl6030's .request() and .free() are also already serialized against .apply() because there is only a single PWM. So the mutex doesn't add any additional protection and can be dropped. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com> Link: https://lore.kernel.org/r/c1c7f646190f7cb2fe43b10959aa8dade80cb79e.1750788649.git.u.kleine-koenig@baylibre.com Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
This commit is contained in:
committed by
Uwe Kleine-König
parent
dce0df8ac1
commit
2c06a21789
@@ -61,10 +61,6 @@
|
|||||||
#define TWL6040_LED_MODE_OFF 0x02
|
#define TWL6040_LED_MODE_OFF 0x02
|
||||||
#define TWL6040_LED_MODE_MASK 0x03
|
#define TWL6040_LED_MODE_MASK 0x03
|
||||||
|
|
||||||
struct twl_pwmled_chip {
|
|
||||||
struct mutex mutex;
|
|
||||||
};
|
|
||||||
|
|
||||||
static inline struct twl_pwmled_chip *to_twl(struct pwm_chip *chip)
|
static inline struct twl_pwmled_chip *to_twl(struct pwm_chip *chip)
|
||||||
{
|
{
|
||||||
return pwmchip_get_drvdata(chip);
|
return pwmchip_get_drvdata(chip);
|
||||||
@@ -106,15 +102,13 @@ static int twl4030_pwmled_config(struct pwm_chip *chip, struct pwm_device *pwm,
|
|||||||
|
|
||||||
static int twl4030_pwmled_enable(struct pwm_chip *chip, struct pwm_device *pwm)
|
static int twl4030_pwmled_enable(struct pwm_chip *chip, struct pwm_device *pwm)
|
||||||
{
|
{
|
||||||
struct twl_pwmled_chip *twl = to_twl(chip);
|
|
||||||
int ret;
|
int ret;
|
||||||
u8 val;
|
u8 val;
|
||||||
|
|
||||||
mutex_lock(&twl->mutex);
|
|
||||||
ret = twl_i2c_read_u8(TWL4030_MODULE_LED, &val, TWL4030_LEDEN_REG);
|
ret = twl_i2c_read_u8(TWL4030_MODULE_LED, &val, TWL4030_LEDEN_REG);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(pwmchip_parent(chip), "%s: Failed to read LEDEN\n", pwm->label);
|
dev_err(pwmchip_parent(chip), "%s: Failed to read LEDEN\n", pwm->label);
|
||||||
goto out;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
val |= TWL4030_LED_TOGGLE(pwm->hwpwm, TWL4030_LED_PINS);
|
val |= TWL4030_LED_TOGGLE(pwm->hwpwm, TWL4030_LED_PINS);
|
||||||
@@ -123,23 +117,19 @@ static int twl4030_pwmled_enable(struct pwm_chip *chip, struct pwm_device *pwm)
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
dev_err(pwmchip_parent(chip), "%s: Failed to enable PWM\n", pwm->label);
|
dev_err(pwmchip_parent(chip), "%s: Failed to enable PWM\n", pwm->label);
|
||||||
|
|
||||||
out:
|
|
||||||
mutex_unlock(&twl->mutex);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void twl4030_pwmled_disable(struct pwm_chip *chip,
|
static void twl4030_pwmled_disable(struct pwm_chip *chip,
|
||||||
struct pwm_device *pwm)
|
struct pwm_device *pwm)
|
||||||
{
|
{
|
||||||
struct twl_pwmled_chip *twl = to_twl(chip);
|
|
||||||
int ret;
|
int ret;
|
||||||
u8 val;
|
u8 val;
|
||||||
|
|
||||||
mutex_lock(&twl->mutex);
|
|
||||||
ret = twl_i2c_read_u8(TWL4030_MODULE_LED, &val, TWL4030_LEDEN_REG);
|
ret = twl_i2c_read_u8(TWL4030_MODULE_LED, &val, TWL4030_LEDEN_REG);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(pwmchip_parent(chip), "%s: Failed to read LEDEN\n", pwm->label);
|
dev_err(pwmchip_parent(chip), "%s: Failed to read LEDEN\n", pwm->label);
|
||||||
goto out;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
val &= ~TWL4030_LED_TOGGLE(pwm->hwpwm, TWL4030_LED_PINS);
|
val &= ~TWL4030_LED_TOGGLE(pwm->hwpwm, TWL4030_LED_PINS);
|
||||||
@@ -147,9 +137,6 @@ static void twl4030_pwmled_disable(struct pwm_chip *chip,
|
|||||||
ret = twl_i2c_write_u8(TWL4030_MODULE_LED, val, TWL4030_LEDEN_REG);
|
ret = twl_i2c_write_u8(TWL4030_MODULE_LED, val, TWL4030_LEDEN_REG);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
dev_err(pwmchip_parent(chip), "%s: Failed to disable PWM\n", pwm->label);
|
dev_err(pwmchip_parent(chip), "%s: Failed to disable PWM\n", pwm->label);
|
||||||
|
|
||||||
out:
|
|
||||||
mutex_unlock(&twl->mutex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int twl4030_pwmled_apply(struct pwm_chip *chip, struct pwm_device *pwm,
|
static int twl4030_pwmled_apply(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||||
@@ -209,16 +196,14 @@ static int twl6030_pwmled_config(struct pwm_chip *chip, struct pwm_device *pwm,
|
|||||||
|
|
||||||
static int twl6030_pwmled_enable(struct pwm_chip *chip, struct pwm_device *pwm)
|
static int twl6030_pwmled_enable(struct pwm_chip *chip, struct pwm_device *pwm)
|
||||||
{
|
{
|
||||||
struct twl_pwmled_chip *twl = to_twl(chip);
|
|
||||||
int ret;
|
int ret;
|
||||||
u8 val;
|
u8 val;
|
||||||
|
|
||||||
mutex_lock(&twl->mutex);
|
|
||||||
ret = twl_i2c_read_u8(TWL6030_MODULE_ID1, &val, TWL6030_LED_PWM_CTRL2);
|
ret = twl_i2c_read_u8(TWL6030_MODULE_ID1, &val, TWL6030_LED_PWM_CTRL2);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(pwmchip_parent(chip), "%s: Failed to read PWM_CTRL2\n",
|
dev_err(pwmchip_parent(chip), "%s: Failed to read PWM_CTRL2\n",
|
||||||
pwm->label);
|
pwm->label);
|
||||||
goto out;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
val &= ~TWL6040_LED_MODE_MASK;
|
val &= ~TWL6040_LED_MODE_MASK;
|
||||||
@@ -228,24 +213,20 @@ static int twl6030_pwmled_enable(struct pwm_chip *chip, struct pwm_device *pwm)
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
dev_err(pwmchip_parent(chip), "%s: Failed to enable PWM\n", pwm->label);
|
dev_err(pwmchip_parent(chip), "%s: Failed to enable PWM\n", pwm->label);
|
||||||
|
|
||||||
out:
|
|
||||||
mutex_unlock(&twl->mutex);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void twl6030_pwmled_disable(struct pwm_chip *chip,
|
static void twl6030_pwmled_disable(struct pwm_chip *chip,
|
||||||
struct pwm_device *pwm)
|
struct pwm_device *pwm)
|
||||||
{
|
{
|
||||||
struct twl_pwmled_chip *twl = to_twl(chip);
|
|
||||||
int ret;
|
int ret;
|
||||||
u8 val;
|
u8 val;
|
||||||
|
|
||||||
mutex_lock(&twl->mutex);
|
|
||||||
ret = twl_i2c_read_u8(TWL6030_MODULE_ID1, &val, TWL6030_LED_PWM_CTRL2);
|
ret = twl_i2c_read_u8(TWL6030_MODULE_ID1, &val, TWL6030_LED_PWM_CTRL2);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(pwmchip_parent(chip), "%s: Failed to read PWM_CTRL2\n",
|
dev_err(pwmchip_parent(chip), "%s: Failed to read PWM_CTRL2\n",
|
||||||
pwm->label);
|
pwm->label);
|
||||||
goto out;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
val &= ~TWL6040_LED_MODE_MASK;
|
val &= ~TWL6040_LED_MODE_MASK;
|
||||||
@@ -254,9 +235,6 @@ static void twl6030_pwmled_disable(struct pwm_chip *chip,
|
|||||||
ret = twl_i2c_write_u8(TWL6030_MODULE_ID1, val, TWL6030_LED_PWM_CTRL2);
|
ret = twl_i2c_write_u8(TWL6030_MODULE_ID1, val, TWL6030_LED_PWM_CTRL2);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
dev_err(pwmchip_parent(chip), "%s: Failed to disable PWM\n", pwm->label);
|
dev_err(pwmchip_parent(chip), "%s: Failed to disable PWM\n", pwm->label);
|
||||||
|
|
||||||
out:
|
|
||||||
mutex_unlock(&twl->mutex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int twl6030_pwmled_apply(struct pwm_chip *chip, struct pwm_device *pwm,
|
static int twl6030_pwmled_apply(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||||
@@ -287,16 +265,14 @@ static int twl6030_pwmled_apply(struct pwm_chip *chip, struct pwm_device *pwm,
|
|||||||
|
|
||||||
static int twl6030_pwmled_request(struct pwm_chip *chip, struct pwm_device *pwm)
|
static int twl6030_pwmled_request(struct pwm_chip *chip, struct pwm_device *pwm)
|
||||||
{
|
{
|
||||||
struct twl_pwmled_chip *twl = to_twl(chip);
|
|
||||||
int ret;
|
int ret;
|
||||||
u8 val;
|
u8 val;
|
||||||
|
|
||||||
mutex_lock(&twl->mutex);
|
|
||||||
ret = twl_i2c_read_u8(TWL6030_MODULE_ID1, &val, TWL6030_LED_PWM_CTRL2);
|
ret = twl_i2c_read_u8(TWL6030_MODULE_ID1, &val, TWL6030_LED_PWM_CTRL2);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(pwmchip_parent(chip), "%s: Failed to read PWM_CTRL2\n",
|
dev_err(pwmchip_parent(chip), "%s: Failed to read PWM_CTRL2\n",
|
||||||
pwm->label);
|
pwm->label);
|
||||||
goto out;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
val &= ~TWL6040_LED_MODE_MASK;
|
val &= ~TWL6040_LED_MODE_MASK;
|
||||||
@@ -306,23 +282,19 @@ static int twl6030_pwmled_request(struct pwm_chip *chip, struct pwm_device *pwm)
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
dev_err(pwmchip_parent(chip), "%s: Failed to request PWM\n", pwm->label);
|
dev_err(pwmchip_parent(chip), "%s: Failed to request PWM\n", pwm->label);
|
||||||
|
|
||||||
out:
|
|
||||||
mutex_unlock(&twl->mutex);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void twl6030_pwmled_free(struct pwm_chip *chip, struct pwm_device *pwm)
|
static void twl6030_pwmled_free(struct pwm_chip *chip, struct pwm_device *pwm)
|
||||||
{
|
{
|
||||||
struct twl_pwmled_chip *twl = to_twl(chip);
|
|
||||||
int ret;
|
int ret;
|
||||||
u8 val;
|
u8 val;
|
||||||
|
|
||||||
mutex_lock(&twl->mutex);
|
|
||||||
ret = twl_i2c_read_u8(TWL6030_MODULE_ID1, &val, TWL6030_LED_PWM_CTRL2);
|
ret = twl_i2c_read_u8(TWL6030_MODULE_ID1, &val, TWL6030_LED_PWM_CTRL2);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(pwmchip_parent(chip), "%s: Failed to read PWM_CTRL2\n",
|
dev_err(pwmchip_parent(chip), "%s: Failed to read PWM_CTRL2\n",
|
||||||
pwm->label);
|
pwm->label);
|
||||||
goto out;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
val &= ~TWL6040_LED_MODE_MASK;
|
val &= ~TWL6040_LED_MODE_MASK;
|
||||||
@@ -331,9 +303,6 @@ static void twl6030_pwmled_free(struct pwm_chip *chip, struct pwm_device *pwm)
|
|||||||
ret = twl_i2c_write_u8(TWL6030_MODULE_ID1, val, TWL6030_LED_PWM_CTRL2);
|
ret = twl_i2c_write_u8(TWL6030_MODULE_ID1, val, TWL6030_LED_PWM_CTRL2);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
dev_err(pwmchip_parent(chip), "%s: Failed to free PWM\n", pwm->label);
|
dev_err(pwmchip_parent(chip), "%s: Failed to free PWM\n", pwm->label);
|
||||||
|
|
||||||
out:
|
|
||||||
mutex_unlock(&twl->mutex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct pwm_ops twl6030_pwmled_ops = {
|
static const struct pwm_ops twl6030_pwmled_ops = {
|
||||||
@@ -345,7 +314,6 @@ static const struct pwm_ops twl6030_pwmled_ops = {
|
|||||||
static int twl_pwmled_probe(struct platform_device *pdev)
|
static int twl_pwmled_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct pwm_chip *chip;
|
struct pwm_chip *chip;
|
||||||
struct twl_pwmled_chip *twl;
|
|
||||||
unsigned int npwm;
|
unsigned int npwm;
|
||||||
const struct pwm_ops *ops;
|
const struct pwm_ops *ops;
|
||||||
|
|
||||||
@@ -357,15 +325,12 @@ static int twl_pwmled_probe(struct platform_device *pdev)
|
|||||||
npwm = 1;
|
npwm = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
chip = devm_pwmchip_alloc(&pdev->dev, npwm, sizeof(*twl));
|
chip = devm_pwmchip_alloc(&pdev->dev, npwm, 0);
|
||||||
if (IS_ERR(chip))
|
if (IS_ERR(chip))
|
||||||
return PTR_ERR(chip);
|
return PTR_ERR(chip);
|
||||||
twl = to_twl(chip);
|
|
||||||
|
|
||||||
chip->ops = ops;
|
chip->ops = ops;
|
||||||
|
|
||||||
mutex_init(&twl->mutex);
|
|
||||||
|
|
||||||
return devm_pwmchip_add(&pdev->dev, chip);
|
return devm_pwmchip_add(&pdev->dev, chip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user