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

iio: light: Added PM support for Capella CM3232 ambient light sensor driver.

Added Power Management Support.

Signed-off-by: Kevin Tsai <ktsai@capellamicro.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>

authored by

Kevin Tsai and committed by
Jonathan Cameron
1ec28ce6 21bd23ea

+36
+36
drivers/iio/light/cm3232.c
··· 378 378 {} 379 379 }; 380 380 381 + #ifdef CONFIG_PM_SLEEP 382 + static int cm3232_suspend(struct device *dev) 383 + { 384 + struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); 385 + struct cm3232_chip *chip = iio_priv(indio_dev); 386 + struct i2c_client *client = chip->client; 387 + int ret; 388 + 389 + chip->regs_cmd |= CM3232_CMD_ALS_DISABLE; 390 + ret = i2c_smbus_write_byte_data(client, CM3232_REG_ADDR_CMD, 391 + chip->regs_cmd); 392 + 393 + return ret; 394 + } 395 + 396 + static int cm3232_resume(struct device *dev) 397 + { 398 + struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); 399 + struct cm3232_chip *chip = iio_priv(indio_dev); 400 + struct i2c_client *client = chip->client; 401 + int ret; 402 + 403 + chip->regs_cmd &= ~CM3232_CMD_ALS_DISABLE; 404 + ret = i2c_smbus_write_byte_data(client, CM3232_REG_ADDR_CMD, 405 + chip->regs_cmd | CM3232_CMD_ALS_RESET); 406 + 407 + return ret; 408 + } 409 + 410 + static const struct dev_pm_ops cm3232_pm_ops = { 411 + SET_SYSTEM_SLEEP_PM_OPS(cm3232_suspend, cm3232_resume)}; 412 + #endif 413 + 381 414 MODULE_DEVICE_TABLE(i2c, cm3232_id); 382 415 383 416 static const struct of_device_id cm3232_of_match[] = { ··· 423 390 .name = "cm3232", 424 391 .owner = THIS_MODULE, 425 392 .of_match_table = of_match_ptr(cm3232_of_match), 393 + #ifdef CONFIG_PM_SLEEP 394 + .pm = &cm3232_pm_ops, 395 + #endif 426 396 }, 427 397 .id_table = cm3232_id, 428 398 .probe = cm3232_probe,