[PATCH] driver: mfd: admit rk805 driver registration without interrupt support

Lee Jones lee at kernel.org
Thu May 25 04:00:26 PDT 2023


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 at 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 [李琼斯]



More information about the Linux-rockchip mailing list