From: Greg KH <gregkh@linuxfoundation.org>
To: Gairuboina Sirisha <sirisha.gairuboina@ltts.com>
Cc: linux-kernel@vger.kernel.org, lee@kernel.org, arnd@arndb.de
Subject: Re: [PATCH v1 3/3] drivers: misc: Add support for TPS65224 pfsm driver
Date: Fri, 27 Oct 2023 09:05:40 +0200 [thread overview]
Message-ID: <2023102749-submerge-aptitude-f05b@gregkh> (raw)
In-Reply-To: <20231026133226.290040-4-sirisha.gairuboina@Ltts.com>
On Thu, Oct 26, 2023 at 07:02:26PM +0530, Gairuboina Sirisha wrote:
> From: Gairuboina Sirisha <sirisha.gairuboina@ltts.com>
>
> Added support for pmic nvm set FSM_I2C_TRIGGER functions driver,
> state control driver, Makefile and Kconfig
>
> Signed-off-by: Gairuboina Sirisha <sirisha.gairuboina@ltts.com>
> ---
> drivers/misc/Kconfig | 12 ++
> drivers/misc/Makefile | 1 +
> drivers/misc/tps65224-pfsm.c | 290 +++++++++++++++++++++++++++++
> include/uapi/linux/tps65224_pfsm.h | 36 ++++
> 4 files changed, 339 insertions(+)
> create mode 100644 drivers/misc/tps65224-pfsm.c
> create mode 100644 include/uapi/linux/tps65224_pfsm.h
>
> diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
> index cadd4a820c03..6d12404b0fa6 100644
> --- a/drivers/misc/Kconfig
> +++ b/drivers/misc/Kconfig
> @@ -562,6 +562,18 @@ config TPS6594_PFSM
> This driver can also be built as a module. If so, the module
> will be called tps6594-pfsm.
>
> +config TPS65224_PFSM
> + tristate "TI TPS65224 Pre-configurable Finite State Machine support"
> + depends on MFD_TPS65224
> + default MFD_TPS65224
> + help
> + Support PFSM (Pre-configurable Finite State Machine) on TPS65224 PMIC devices.
> + These devices integrate a finite state machine engine, which manages the state
> + of the device during operating state transition.
Please wrap your lines a bit better, like the rest of the file has.
> --- /dev/null
> +++ b/drivers/misc/tps65224-pfsm.c
> @@ -0,0 +1,290 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * PFSM (Pre-configurable Finite State Machine) driver for TI TPS65224 PMIC
> + *
> + * Copyright (C) 2015 Texas Instruments Incorporated - https://www.ti.com/
Again, 2015?
> +static long tps65224_pfsm_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
> +{
> + struct tps65224_pfsm *pfsm = TPS65224_FILE_TO_PFSM(f);
> + struct pmic_state_opt state_opt;
> + void __user *argp = (void __user *)arg;
> + int ret = -ENOIOCTLCMD;
> +
> + switch (cmd) {
> + case PMIC_GOTO_STANDBY:
> + /* Force trigger */
> + ret = regmap_write_bits(pfsm->regmap, TPS65224_REG_FSM_I2C_TRIGGERS,
> + TPS65224_BIT_TRIGGER_I2C(0), TPS65224_BIT_TRIGGER_I2C(0));
> + break;
> + case PMIC_UPDATE_PGM:
> + /* Force trigger */
> + ret = regmap_write_bits(pfsm->regmap, TPS65224_REG_FSM_I2C_TRIGGERS,
> + TPS65224_BIT_TRIGGER_I2C(3), TPS65224_BIT_TRIGGER_I2C(3));
> + break;
> + case PMIC_SET_ACTIVE_STATE:
> + /* Modify NSLEEP1-2 bits */
> + ret = regmap_set_bits(pfsm->regmap, TPS65224_REG_FSM_NSLEEP_TRIGGERS,
> + TPS65224_BIT_NSLEEP1B | TPS65224_BIT_NSLEEP2B);
> + break;
> + case PMIC_SET_MCU_ONLY_STATE:
> + if (copy_from_user(&state_opt, argp, sizeof(state_opt)))
> + return -EFAULT;
> +
> + /* Configure retention triggers */
> + ret = tps65224_pfsm_configure_ret_trig(pfsm->regmap, state_opt.gpio_retention,
> + state_opt.ddr_retention);
No error checking of userspace values at all? That's brave.
> + if (ret)
> + return ret;
> +
> + /* Modify NSLEEP1-2 bits */
> + ret = regmap_clear_bits(pfsm->regmap, TPS65224_REG_FSM_NSLEEP_TRIGGERS,
> + TPS65224_BIT_NSLEEP1B);
> + if (ret)
> + return ret;
> +
> + ret = regmap_set_bits(pfsm->regmap, TPS65224_REG_FSM_NSLEEP_TRIGGERS,
> + TPS65224_BIT_NSLEEP2B);
> + break;
> + case PMIC_SET_RETENTION_STATE:
> + if (copy_from_user(&state_opt, argp, sizeof(state_opt)))
> + return -EFAULT;
Again, no checking of valid values?
> +
> + /* Configure wake-up destination */
> + if (state_opt.mcu_only_startup_dest)
> + ret = regmap_write_bits(pfsm->regmap, TPS65224_REG_CONFIG_2,
> + TPS65224_BIT_STARTUP_INT,
> + TPS65224_STARTUP_DEST_MCU_ONLY);
> + else
> + ret = regmap_write_bits(pfsm->regmap, TPS65224_REG_CONFIG_2,
> + TPS65224_BIT_STARTUP_INT,
> + TPS65224_STARTUP_DEST_ACTIVE);
> + if (ret)
> + return ret;
> +
> + /* Configure retention triggers */
> + ret = tps65224_pfsm_configure_ret_trig(pfsm->regmap, state_opt.gpio_retention,
> + state_opt.ddr_retention);
> + if (ret)
> + return ret;
> +
> + /* Modify NSLEEP1-2 bits */
> + ret = regmap_clear_bits(pfsm->regmap, TPS65224_REG_FSM_NSLEEP_TRIGGERS,
> + TPS65224_BIT_NSLEEP2B);
> + break;
> + }
> +
> + return ret;
> +}
Where is the example userspace code that uses these custom ioctls?
Where are they documented? How do we know what they should be doing?
thanks,
greg k-h
next prev parent reply other threads:[~2023-10-27 7:05 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-26 13:32 [PATCH v1 0/3] TPS65224 PMIC driver Gairuboina Sirisha
2023-10-26 13:32 ` [PATCH v1 1/3] drivers: mfd: Add support for TPS65224 Gairuboina Sirisha
2023-10-27 7:02 ` Greg KH
2023-11-07 11:40 ` Gairuboina Sirisha
2023-10-26 13:32 ` [PATCH v1 2/3] drivers: mfd: Add support for TPS65224 i2c driver Gairuboina Sirisha
2023-10-27 7:02 ` Greg KH
2023-11-07 11:42 ` Gairuboina Sirisha
2023-10-27 8:08 ` Krzysztof Kozlowski
2023-11-07 11:50 ` Gairuboina Sirisha
2023-10-26 13:32 ` [PATCH v1 3/3] drivers: misc: Add support for TPS65224 pfsm driver Gairuboina Sirisha
2023-10-27 7:05 ` Greg KH [this message]
2023-11-07 11:44 ` Gairuboina Sirisha
2023-10-27 8:05 ` Krzysztof Kozlowski
2023-11-07 11:48 ` Gairuboina Sirisha
2023-11-03 8:52 ` [PATCH v1 0/3] TPS65224 PMIC driver Julien Panis
2023-11-07 11:37 ` Gairuboina Sirisha
2023-11-08 9:19 ` Julien Panis
2023-11-09 16:22 ` Shree Ramamoorthy
2023-11-10 4:26 ` Greg KH
2023-11-10 20:07 ` [EXTERNAL] " Shree Ramamoorthy
2023-11-17 11:05 ` Lee Jones
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2023102749-submerge-aptitude-f05b@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=arnd@arndb.de \
--cc=lee@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sirisha.gairuboina@ltts.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox