Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

iio: light: vcnl4000: replace mutex_init() with devm_mutex_init()

Replace mutex_init() used across the driver with its device-managed
counterpart, so all assigned mutexes get destroyed.

Reviewed-by: David Lechner <dlechner@baylibre.com>
Signed-off-by: Erikas Bitovtas <xerikasxx@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Erikas Bitovtas and committed by
Jonathan Cameron
177fa06d 1c9cb535

+14 -3
+14 -3
drivers/iio/light/vcnl4000.c
··· 356 356 357 357 static int vcnl4200_init(struct vcnl4000_data *data) 358 358 { 359 + struct i2c_client *client = data->client; 360 + struct device *dev = &client->dev; 359 361 int ret, id; 360 362 u16 regval; 361 363 ··· 402 400 } 403 401 data->al_scale = data->chip_spec->ulux_step; 404 402 data->ps_scale = 16; 405 - mutex_init(&data->vcnl4200_al.lock); 406 - mutex_init(&data->vcnl4200_ps.lock); 403 + 404 + ret = devm_mutex_init(dev, &data->vcnl4200_al.lock); 405 + if (ret) 406 + return ret; 407 + 408 + ret = devm_mutex_init(dev, &data->vcnl4200_ps.lock); 409 + if (ret) 410 + return ret; 407 411 408 412 /* Use 16 bits proximity sensor readings */ 409 413 ret = i2c_smbus_read_word_data(data->client, VCNL4200_PS_CONF1); ··· 1987 1979 static int vcnl4000_probe(struct i2c_client *client) 1988 1980 { 1989 1981 const struct i2c_device_id *id = i2c_client_get_device_id(client); 1982 + struct device *dev = &client->dev; 1990 1983 struct vcnl4000_data *data; 1991 1984 struct iio_dev *indio_dev; 1992 1985 int ret; ··· 2002 1993 data->id = id->driver_data; 2003 1994 data->chip_spec = &vcnl4000_chip_spec_cfg[data->id]; 2004 1995 2005 - mutex_init(&data->vcnl4000_lock); 1996 + ret = devm_mutex_init(dev, &data->vcnl4000_lock); 1997 + if (ret) 1998 + return ret; 2006 1999 2007 2000 ret = data->chip_spec->init(data); 2008 2001 if (ret < 0)