mirror of
https://github.com/torvalds/linux.git
synced 2024-11-26 06:02:05 +00:00
Merge branches 'ib-leds-mips-sound-6.10' and 'ib-leds-locking-6.10' into ibs-for-leds-merged
This commit is contained in:
commit
66f7d2ceae
@ -283,7 +283,10 @@ static int an30259a_probe(struct i2c_client *client)
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
mutex_init(&chip->mutex);
|
||||
err = devm_mutex_init(&client->dev, &chip->mutex);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
chip->client = client;
|
||||
i2c_set_clientdata(client, chip);
|
||||
|
||||
@ -317,17 +320,9 @@ static int an30259a_probe(struct i2c_client *client)
|
||||
return 0;
|
||||
|
||||
exit:
|
||||
mutex_destroy(&chip->mutex);
|
||||
return err;
|
||||
}
|
||||
|
||||
static void an30259a_remove(struct i2c_client *client)
|
||||
{
|
||||
struct an30259a *chip = i2c_get_clientdata(client);
|
||||
|
||||
mutex_destroy(&chip->mutex);
|
||||
}
|
||||
|
||||
static const struct of_device_id an30259a_match_table[] = {
|
||||
{ .compatible = "panasonic,an30259a", },
|
||||
{ /* sentinel */ },
|
||||
@ -347,7 +342,6 @@ static struct i2c_driver an30259a_driver = {
|
||||
.of_match_table = an30259a_match_table,
|
||||
},
|
||||
.probe = an30259a_probe,
|
||||
.remove = an30259a_remove,
|
||||
.id_table = an30259a_id,
|
||||
};
|
||||
|
||||
|
@ -530,6 +530,16 @@ static const struct regmap_config aw200xx_regmap_config = {
|
||||
.disable_locking = true,
|
||||
};
|
||||
|
||||
static void aw200xx_chip_reset_action(void *data)
|
||||
{
|
||||
aw200xx_chip_reset(data);
|
||||
}
|
||||
|
||||
static void aw200xx_disable_action(void *data)
|
||||
{
|
||||
aw200xx_disable(data);
|
||||
}
|
||||
|
||||
static int aw200xx_probe(struct i2c_client *client)
|
||||
{
|
||||
const struct aw200xx_chipdef *cdef;
|
||||
@ -568,11 +578,17 @@ static int aw200xx_probe(struct i2c_client *client)
|
||||
|
||||
aw200xx_enable(chip);
|
||||
|
||||
ret = devm_add_action(&client->dev, aw200xx_disable_action, chip);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = aw200xx_chip_check(chip);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
mutex_init(&chip->mutex);
|
||||
ret = devm_mutex_init(&client->dev, &chip->mutex);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
/* Need a lock now since after call aw200xx_probe_fw, sysfs nodes created */
|
||||
mutex_lock(&chip->mutex);
|
||||
@ -581,6 +597,10 @@ static int aw200xx_probe(struct i2c_client *client)
|
||||
if (ret)
|
||||
goto out_unlock;
|
||||
|
||||
ret = devm_add_action(&client->dev, aw200xx_chip_reset_action, chip);
|
||||
if (ret)
|
||||
goto out_unlock;
|
||||
|
||||
ret = aw200xx_probe_fw(&client->dev, chip);
|
||||
if (ret)
|
||||
goto out_unlock;
|
||||
@ -595,15 +615,6 @@ out_unlock:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void aw200xx_remove(struct i2c_client *client)
|
||||
{
|
||||
struct aw200xx *chip = i2c_get_clientdata(client);
|
||||
|
||||
aw200xx_chip_reset(chip);
|
||||
aw200xx_disable(chip);
|
||||
mutex_destroy(&chip->mutex);
|
||||
}
|
||||
|
||||
static const struct aw200xx_chipdef aw20036_cdef = {
|
||||
.channels = 36,
|
||||
.display_size_rows_max = 3,
|
||||
@ -652,7 +663,6 @@ static struct i2c_driver aw200xx_driver = {
|
||||
.of_match_table = aw200xx_match_table,
|
||||
},
|
||||
.probe = aw200xx_probe,
|
||||
.remove = aw200xx_remove,
|
||||
.id_table = aw200xx_id,
|
||||
};
|
||||
module_i2c_driver(aw200xx_driver);
|
||||
|
@ -320,6 +320,11 @@ static int aw2013_probe_dt(struct aw2013 *chip)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void aw2013_chip_disable_action(void *data)
|
||||
{
|
||||
aw2013_chip_disable(data);
|
||||
}
|
||||
|
||||
static const struct regmap_config aw2013_regmap_config = {
|
||||
.reg_bits = 8,
|
||||
.val_bits = 8,
|
||||
@ -336,7 +341,10 @@ static int aw2013_probe(struct i2c_client *client)
|
||||
if (!chip)
|
||||
return -ENOMEM;
|
||||
|
||||
mutex_init(&chip->mutex);
|
||||
ret = devm_mutex_init(&client->dev, &chip->mutex);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
mutex_lock(&chip->mutex);
|
||||
|
||||
chip->client = client;
|
||||
@ -384,6 +392,10 @@ static int aw2013_probe(struct i2c_client *client)
|
||||
goto error_reg;
|
||||
}
|
||||
|
||||
ret = devm_add_action(&client->dev, aw2013_chip_disable_action, chip);
|
||||
if (ret)
|
||||
goto error_reg;
|
||||
|
||||
ret = aw2013_probe_dt(chip);
|
||||
if (ret < 0)
|
||||
goto error_reg;
|
||||
@ -406,19 +418,9 @@ error_reg:
|
||||
|
||||
error:
|
||||
mutex_unlock(&chip->mutex);
|
||||
mutex_destroy(&chip->mutex);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void aw2013_remove(struct i2c_client *client)
|
||||
{
|
||||
struct aw2013 *chip = i2c_get_clientdata(client);
|
||||
|
||||
aw2013_chip_disable(chip);
|
||||
|
||||
mutex_destroy(&chip->mutex);
|
||||
}
|
||||
|
||||
static const struct of_device_id aw2013_match_table[] = {
|
||||
{ .compatible = "awinic,aw2013", },
|
||||
{ /* sentinel */ },
|
||||
@ -432,7 +434,6 @@ static struct i2c_driver aw2013_driver = {
|
||||
.of_match_table = aw2013_match_table,
|
||||
},
|
||||
.probe = aw2013_probe,
|
||||
.remove = aw2013_remove,
|
||||
};
|
||||
|
||||
module_i2c_driver(aw2013_driver);
|
||||
|
@ -542,6 +542,13 @@ static int lm3532_parse_als(struct lm3532_data *priv)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void gpio_set_low_action(void *data)
|
||||
{
|
||||
struct lm3532_data *priv = data;
|
||||
|
||||
gpiod_direction_output(priv->enable_gpio, 0);
|
||||
}
|
||||
|
||||
static int lm3532_parse_node(struct lm3532_data *priv)
|
||||
{
|
||||
struct fwnode_handle *child = NULL;
|
||||
@ -556,6 +563,12 @@ static int lm3532_parse_node(struct lm3532_data *priv)
|
||||
if (IS_ERR(priv->enable_gpio))
|
||||
priv->enable_gpio = NULL;
|
||||
|
||||
if (priv->enable_gpio) {
|
||||
ret = devm_add_action(&priv->client->dev, gpio_set_low_action, priv);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
priv->regulator = devm_regulator_get(&priv->client->dev, "vin");
|
||||
if (IS_ERR(priv->regulator))
|
||||
priv->regulator = NULL;
|
||||
@ -691,7 +704,10 @@ static int lm3532_probe(struct i2c_client *client)
|
||||
return ret;
|
||||
}
|
||||
|
||||
mutex_init(&drvdata->lock);
|
||||
ret = devm_mutex_init(&client->dev, &drvdata->lock);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
i2c_set_clientdata(client, drvdata);
|
||||
|
||||
ret = lm3532_parse_node(drvdata);
|
||||
@ -703,16 +719,6 @@ static int lm3532_probe(struct i2c_client *client)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void lm3532_remove(struct i2c_client *client)
|
||||
{
|
||||
struct lm3532_data *drvdata = i2c_get_clientdata(client);
|
||||
|
||||
mutex_destroy(&drvdata->lock);
|
||||
|
||||
if (drvdata->enable_gpio)
|
||||
gpiod_direction_output(drvdata->enable_gpio, 0);
|
||||
}
|
||||
|
||||
static const struct of_device_id of_lm3532_leds_match[] = {
|
||||
{ .compatible = "ti,lm3532", },
|
||||
{},
|
||||
@ -727,7 +733,6 @@ MODULE_DEVICE_TABLE(i2c, lm3532_id);
|
||||
|
||||
static struct i2c_driver lm3532_i2c_driver = {
|
||||
.probe = lm3532_probe,
|
||||
.remove = lm3532_remove,
|
||||
.id_table = lm3532_id,
|
||||
.driver = {
|
||||
.name = LM3532_NAME,
|
||||
|
@ -207,6 +207,13 @@ static const struct regmap_config lp3952_regmap = {
|
||||
.cache_type = REGCACHE_MAPLE,
|
||||
};
|
||||
|
||||
static void gpio_set_low_action(void *data)
|
||||
{
|
||||
struct lp3952_led_array *priv = data;
|
||||
|
||||
gpiod_set_value(priv->enable_gpio, 0);
|
||||
}
|
||||
|
||||
static int lp3952_probe(struct i2c_client *client)
|
||||
{
|
||||
int status;
|
||||
@ -226,6 +233,10 @@ static int lp3952_probe(struct i2c_client *client)
|
||||
return status;
|
||||
}
|
||||
|
||||
status = devm_add_action(&client->dev, gpio_set_low_action, priv);
|
||||
if (status)
|
||||
return status;
|
||||
|
||||
priv->regmap = devm_regmap_init_i2c(client, &lp3952_regmap);
|
||||
if (IS_ERR(priv->regmap)) {
|
||||
int err = PTR_ERR(priv->regmap);
|
||||
@ -254,15 +265,6 @@ static int lp3952_probe(struct i2c_client *client)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void lp3952_remove(struct i2c_client *client)
|
||||
{
|
||||
struct lp3952_led_array *priv;
|
||||
|
||||
priv = i2c_get_clientdata(client);
|
||||
lp3952_on_off(priv, LP3952_LED_ALL, false);
|
||||
gpiod_set_value(priv->enable_gpio, 0);
|
||||
}
|
||||
|
||||
static const struct i2c_device_id lp3952_id[] = {
|
||||
{LP3952_NAME, 0},
|
||||
{}
|
||||
@ -274,7 +276,6 @@ static struct i2c_driver lp3952_i2c_driver = {
|
||||
.name = LP3952_NAME,
|
||||
},
|
||||
.probe = lp3952_probe,
|
||||
.remove = lp3952_remove,
|
||||
.id_table = lp3952_id,
|
||||
};
|
||||
|
||||
|
@ -256,6 +256,7 @@ static int mlxreg_led_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct mlxreg_core_platform_data *led_pdata;
|
||||
struct mlxreg_led_priv_data *priv;
|
||||
int err;
|
||||
|
||||
led_pdata = dev_get_platdata(&pdev->dev);
|
||||
if (!led_pdata) {
|
||||
@ -267,26 +268,21 @@ static int mlxreg_led_probe(struct platform_device *pdev)
|
||||
if (!priv)
|
||||
return -ENOMEM;
|
||||
|
||||
mutex_init(&priv->access_lock);
|
||||
err = devm_mutex_init(&pdev->dev, &priv->access_lock);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
priv->pdev = pdev;
|
||||
priv->pdata = led_pdata;
|
||||
|
||||
return mlxreg_led_config(priv);
|
||||
}
|
||||
|
||||
static void mlxreg_led_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct mlxreg_led_priv_data *priv = dev_get_drvdata(&pdev->dev);
|
||||
|
||||
mutex_destroy(&priv->access_lock);
|
||||
}
|
||||
|
||||
static struct platform_driver mlxreg_led_driver = {
|
||||
.driver = {
|
||||
.name = "leds-mlxreg",
|
||||
},
|
||||
.probe = mlxreg_led_probe,
|
||||
.remove_new = mlxreg_led_remove,
|
||||
};
|
||||
|
||||
module_platform_driver(mlxreg_led_driver);
|
||||
|
@ -118,6 +118,15 @@ static struct nic78bx_led nic78bx_leds[] = {
|
||||
}
|
||||
};
|
||||
|
||||
static void lock_led_reg_action(void *data)
|
||||
{
|
||||
struct nic78bx_led_data *led_data = data;
|
||||
|
||||
/* Lock LED register */
|
||||
outb(NIC78BX_LOCK_VALUE,
|
||||
led_data->io_base + NIC78BX_LOCK_REG_OFFSET);
|
||||
}
|
||||
|
||||
static int nic78bx_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct device *dev = &pdev->dev;
|
||||
@ -152,6 +161,10 @@ static int nic78bx_probe(struct platform_device *pdev)
|
||||
led_data->io_base = io_rc->start;
|
||||
spin_lock_init(&led_data->lock);
|
||||
|
||||
ret = devm_add_action(dev, lock_led_reg_action, led_data);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(nic78bx_leds); i++) {
|
||||
nic78bx_leds[i].data = led_data;
|
||||
|
||||
@ -167,15 +180,6 @@ static int nic78bx_probe(struct platform_device *pdev)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void nic78bx_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct nic78bx_led_data *led_data = platform_get_drvdata(pdev);
|
||||
|
||||
/* Lock LED register */
|
||||
outb(NIC78BX_LOCK_VALUE,
|
||||
led_data->io_base + NIC78BX_LOCK_REG_OFFSET);
|
||||
}
|
||||
|
||||
static const struct acpi_device_id led_device_ids[] = {
|
||||
{"NIC78B3", 0},
|
||||
{"", 0},
|
||||
@ -184,7 +188,6 @@ MODULE_DEVICE_TABLE(acpi, led_device_ids);
|
||||
|
||||
static struct platform_driver led_driver = {
|
||||
.probe = nic78bx_probe,
|
||||
.remove_new = nic78bx_remove,
|
||||
.driver = {
|
||||
.name = KBUILD_MODNAME,
|
||||
.acpi_match_table = ACPI_PTR(led_device_ids),
|
||||
|
@ -22,6 +22,8 @@
|
||||
#include <linux/cleanup.h>
|
||||
#include <linux/mutex_types.h>
|
||||
|
||||
struct device;
|
||||
|
||||
#ifdef CONFIG_DEBUG_LOCK_ALLOC
|
||||
# define __DEP_MAP_MUTEX_INITIALIZER(lockname) \
|
||||
, .dep_map = { \
|
||||
@ -117,6 +119,31 @@ do { \
|
||||
} while (0)
|
||||
#endif /* CONFIG_PREEMPT_RT */
|
||||
|
||||
#ifdef CONFIG_DEBUG_MUTEXES
|
||||
|
||||
int __devm_mutex_init(struct device *dev, struct mutex *lock);
|
||||
|
||||
#else
|
||||
|
||||
static inline int __devm_mutex_init(struct device *dev, struct mutex *lock)
|
||||
{
|
||||
/*
|
||||
* When CONFIG_DEBUG_MUTEXES is off mutex_destroy() is just a nop so
|
||||
* no really need to register it in the devm subsystem.
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#define devm_mutex_init(dev, mutex) \
|
||||
({ \
|
||||
typeof(mutex) mutex_ = (mutex); \
|
||||
\
|
||||
mutex_init(mutex_); \
|
||||
__devm_mutex_init(dev, mutex_); \
|
||||
})
|
||||
|
||||
/*
|
||||
* See kernel/locking/mutex.c for detailed documentation of these APIs.
|
||||
* Also see Documentation/locking/mutex-design.rst.
|
||||
|
@ -12,6 +12,7 @@
|
||||
*/
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/export.h>
|
||||
#include <linux/poison.h>
|
||||
#include <linux/sched.h>
|
||||
@ -89,6 +90,17 @@ void debug_mutex_init(struct mutex *lock, const char *name,
|
||||
lock->magic = lock;
|
||||
}
|
||||
|
||||
static void devm_mutex_release(void *res)
|
||||
{
|
||||
mutex_destroy(res);
|
||||
}
|
||||
|
||||
int __devm_mutex_init(struct device *dev, struct mutex *lock)
|
||||
{
|
||||
return devm_add_action_or_reset(dev, devm_mutex_release, lock);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(__devm_mutex_init);
|
||||
|
||||
/***
|
||||
* mutex_destroy - mark a mutex unusable
|
||||
* @lock: the mutex to be destroyed
|
||||
|
Loading…
Reference in New Issue
Block a user