Re: [PATCH v3 3/4] thunderbolt: Require nhi->ops be valid
From: Mika Westerberg
Date: Fri May 15 2026 - 02:31:54 EST
On Wed, May 13, 2026 at 06:23:34PM +0200, Konrad Dybcio wrote:
> From: Konrad Dybcio <konrad.dybcio@xxxxxxxxxxxxxxxx>
>
> Because of how fundamental ops->init_interrupts() is, it no longer
> makes sense to consider cases where nhi->ops is NULL.
>
> Drop some boilerplate around it and add a single sanity-check in
> nhi_probe() instead.
>
> Signed-off-by: Konrad Dybcio <konrad.dybcio@xxxxxxxxxxxxxxxx>
> ---
> drivers/thunderbolt/nhi.c | 32 ++++++++++++++++++--------------
> drivers/thunderbolt/switch.c | 6 +++---
> 2 files changed, 21 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/thunderbolt/nhi.c b/drivers/thunderbolt/nhi.c
> index 740c10ee852b..2a8d1b3716c0 100644
> --- a/drivers/thunderbolt/nhi.c
> +++ b/drivers/thunderbolt/nhi.c
> @@ -559,7 +559,7 @@ static struct tb_ring *tb_ring_alloc(struct tb_nhi *nhi, u32 hop, int size,
> if (!ring->descriptors)
> goto err_free_ring;
>
> - if (nhi->ops && nhi->ops->request_ring_irq) {
> + if (nhi->ops->request_ring_irq) {
I wonder if it makes this more readable if we wrap these like:
if (nhi_request_ring_irq(nhi)) {
> if (nhi->ops->request_ring_irq(ring, flags & RING_FLAG_NO_SUSPEND))
> goto err_free_descs;
> }