public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Lee Jones <lee@kernel.org>
To: Milo Spadacini <milo.spadacini@gmail.com>
Cc: heiko@sntech.de, linux-rockchip@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] driver: mfd: admit rk805 driver registration without interrupt support
Date: Thu, 25 May 2023 12:00:26 +0100	[thread overview]
Message-ID: <20230525110026.GG9691@google.com> (raw)
In-Reply-To: <20230525070011.23761-1-milo.spadacini@gmail.com>

Do you mean "Omit"?

On Thu, 25 May 2023, Milo Spadacini wrote:

> rk805 use interrupt only for "rk808-rtc" and "rk805-pwrkey" drivers.

RK805 only uses interrupts for ...

> On custom board these drivers could be not used and the irq gpio

"boards"
"IRQ GPIQs"

> could be not connected.

"are not connected"

> Force the usage of a not used gpio, that could be floating, could cause
> spurious interrupt.

Please rephrase this.  I can't quite make it out to make suggestions.

> Signed-off-by: Milo Spadacini <milo.spadacini@gmail.com>
> ---
>  drivers/mfd/rk808.c | 39 +++++++++++++++++++++++++++------------
>  1 file changed, 27 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
> index e00da7c7e3b1..ae33be90b312 100644
> --- a/drivers/mfd/rk808.c
> +++ b/drivers/mfd/rk808.c
> @@ -643,6 +643,7 @@ MODULE_DEVICE_TABLE(of, rk808_of_match);
>  static int rk808_probe(struct i2c_client *client,
>  		       const struct i2c_device_id *id)
>  {
> +	struct irq_domain * rk808_irq_domain = NULL;

Drop the ' ' after the '*'.

>  	struct device_node *np = client->dev.of_node;
>  	struct rk808 *rk808;
>  	const struct rk808_reg_data *pre_init_reg;
> @@ -692,7 +693,11 @@ static int rk808_probe(struct i2c_client *client,
>  		pre_init_reg = rk805_pre_init_reg;
>  		nr_pre_init_regs = ARRAY_SIZE(rk805_pre_init_reg);
>  		cells = rk805s;
> -		nr_cells = ARRAY_SIZE(rk805s);
> +		if (client->irq)
> +			nr_cells = ARRAY_SIZE(rk805s);
> +		else
> +			nr_cells = ARRAY_SIZE(rk805s) - 2;

What's 2?  Please define it.

Does this rely on the ordering of rk805s?  Seems fragile.

> +
>  		break;
>  	case RK808_ID:
>  		rk808->regmap_cfg = &rk808_regmap_config;
> @@ -734,19 +739,28 @@ static int rk808_probe(struct i2c_client *client,
>  		return PTR_ERR(rk808->regmap);
>  	}
>  
> -	if (!client->irq) {
> +	if (client->irq) {
> +
> +		ret = regmap_add_irq_chip(rk808->regmap, client->irq,
> +					  IRQF_ONESHOT, -1,
> +					  rk808->regmap_irq_chip, &rk808->irq_data);
> +		if (ret) {
> +			dev_err(&client->dev, "Failed to add irq_chip %d\n", ret);
> +			return ret;
> +		}
> +
> +		rk808_irq_domain = regmap_irq_get_domain(rk808->irq_data);
> +	}
> +	else if (rk808->variant == RK805_ID)

else goes on the line above.
> +	{
> +		dev_warn(&client->dev, "Skip interrupt support, no core IRQ\n");
> +	}
> +	else
> +	{
>  		dev_err(&client->dev, "No interrupt support, no core IRQ\n");
>  		return -EINVAL;
>  	}
>  
> -	ret = regmap_add_irq_chip(rk808->regmap, client->irq,
> -				  IRQF_ONESHOT, -1,
> -				  rk808->regmap_irq_chip, &rk808->irq_data);
> -	if (ret) {
> -		dev_err(&client->dev, "Failed to add irq_chip %d\n", ret);
> -		return ret;
> -	}
> -
>  	for (i = 0; i < nr_pre_init_regs; i++) {
>  		ret = regmap_update_bits(rk808->regmap,
>  					pre_init_reg[i].addr,
> @@ -762,7 +776,7 @@ static int rk808_probe(struct i2c_client *client,
>  
>  	ret = devm_mfd_add_devices(&client->dev, PLATFORM_DEVID_NONE,
>  			      cells, nr_cells, NULL, 0,
> -			      regmap_irq_get_domain(rk808->irq_data));
> +			      rk808_irq_domain);
>  	if (ret) {
>  		dev_err(&client->dev, "failed to add MFD devices %d\n", ret);
>  		goto err_irq;
> @@ -796,7 +810,8 @@ static void rk808_remove(struct i2c_client *client)
>  {
>  	struct rk808 *rk808 = i2c_get_clientdata(client);
>  
> -	regmap_del_irq_chip(client->irq, rk808->irq_data);
> +	if (client->irq)
> +		regmap_del_irq_chip(client->irq, rk808->irq_data);
>  
>  	/**
>  	 * pm_power_off may points to a function from another module.
> -- 
> 2.34.1
> 

-- 
Lee Jones [李琼斯]

  reply	other threads:[~2023-05-25 11:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-25  7:00 [PATCH] driver: mfd: admit rk805 driver registration without interrupt support Milo Spadacini
2023-05-25 11:00 ` Lee Jones [this message]
2023-05-26  0:00 ` Sebastian Reichel

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=20230525110026.GG9691@google.com \
    --to=lee@kernel.org \
    --cc=heiko@sntech.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=milo.spadacini@gmail.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