netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Petr Machata <petrm@nvidia.com>
Cc: "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	netdev@vger.kernel.org, Vadim Pasternak <vadimp@nvidia.com>,
	Ido Schimmel <idosch@nvidia.com>,
	mlxsw@nvidia.com, Jiri Pirko <jiri@nvidia.com>
Subject: Re: [PATCH net-next 4/8] mlxsw: i2c: Add support for system interrupt handling
Date: Mon, 22 Aug 2022 03:48:39 +0200	[thread overview]
Message-ID: <YwLgdxKwsBONjgZf@lunn.ch> (raw)
In-Reply-To: <96b0d90c1ed9fa5ca2b3ba5e3ba572155ad01b87.1661093502.git.petrm@nvidia.com>

> +static void mlxsw_i2c_work_handler(struct work_struct *work)
> +{
> +	struct mlxsw_i2c *mlxsw_i2c;
> +
> +	mlxsw_i2c = container_of(work, struct mlxsw_i2c, irq_work);
> +	mlxsw_core_irq_event_handlers_call(mlxsw_i2c->core);
> +}
> +
> +static irqreturn_t mlxsw_i2c_irq_handler(int irq, void *dev)
> +{
> +	struct mlxsw_i2c *mlxsw_i2c = dev;
> +
> +	mlxsw_core_schedule_work(&mlxsw_i2c->irq_work);
> +
> +	/* Interrupt handler shares IRQ line with 'main' interrupt handler.
> +	 * Return here IRQ_NONE, while main handler will return IRQ_HANDLED.
> +	 */
> +	return IRQ_NONE;
> +}
> +
> +static int mlxsw_i2c_irq_init(struct mlxsw_i2c *mlxsw_i2c, u8 addr)
> +{
> +	int err;
> +
> +	/* Initialize interrupt handler if system hotplug driver is reachable,
> +	 * otherwise interrupt line is not enabled and interrupts will not be
> +	 * raised to CPU. Also request_irq() call will be not valid.
> +	 */
> +	if (!IS_REACHABLE(CONFIG_MLXREG_HOTPLUG))
> +		return 0;
> +
> +	/* Set default interrupt line. */
> +	if (mlxsw_i2c->pdata && mlxsw_i2c->pdata->irq)
> +		mlxsw_i2c->irq = mlxsw_i2c->pdata->irq;
> +	else if (addr == MLXSW_FAST_I2C_SLAVE)
> +		mlxsw_i2c->irq = MLXSW_I2C_DEFAULT_IRQ;
> +
> +	if (!mlxsw_i2c->irq)
> +		return 0;
> +
> +	INIT_WORK(&mlxsw_i2c->irq_work, mlxsw_i2c_work_handler);
> +	err = request_irq(mlxsw_i2c->irq, mlxsw_i2c_irq_handler,
> +			  IRQF_TRIGGER_FALLING | IRQF_SHARED, "mlxsw-i2c",
> +			  mlxsw_i2c);

I think you can make this simpler by using a request_threaded_irq()

  Andrew

  reply	other threads:[~2022-08-22  1:48 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-21 16:20 [PATCH net-next 0/8] mlxsw: Introduce modular system support by minimal driver Petr Machata
2022-08-21 16:20 ` [PATCH net-next 1/8] mlxsw: core_linecards: Separate line card init and fini flow Petr Machata
2022-08-21 16:20 ` [PATCH net-next 2/8] mlxsw: core: Add registration APIs for system event handler Petr Machata
2022-08-21 16:20 ` [PATCH net-next 3/8] mlxsw: core_linecards: Register a " Petr Machata
2022-08-21 16:20 ` [PATCH net-next 4/8] mlxsw: i2c: Add support for system interrupt handling Petr Machata
2022-08-22  1:48   ` Andrew Lunn [this message]
2022-08-22 11:53     ` Vadim Pasternak
2022-08-21 16:20 ` [PATCH net-next 5/8] mlxsw: minimal: Extend APIs with slot index for modular system support Petr Machata
2022-08-21 16:20 ` [PATCH net-next 6/8] mlxsw: minimal: Move ports allocation to separate routine Petr Machata
2022-08-21 16:20 ` [PATCH net-next 7/8] mlxsw: minimal: Extend module to port mapping with slot index Petr Machata
2022-08-21 16:20 ` [PATCH net-next 8/8] mlxsw: minimal: Extend to support line card dynamic operations Petr Machata
2022-08-24  0:40 ` [PATCH net-next 0/8] mlxsw: Introduce modular system support by minimal driver patchwork-bot+netdevbpf

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=YwLgdxKwsBONjgZf@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=idosch@nvidia.com \
    --cc=jiri@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=mlxsw@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=petrm@nvidia.com \
    --cc=vadimp@nvidia.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;
as well as URLs for NNTP newsgroup(s).