Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1998370rdb; Thu, 7 Dec 2023 15:18:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IGob/JUxeQ/E4TYRe8KuvuwLtiBUDTDGm5iDquudSqE7TssGV0RN9XRmZYXYZP0YfFAP+n6 X-Received: by 2002:a05:6e02:1aa3:b0:35d:6f66:45c6 with SMTP id l3-20020a056e021aa300b0035d6f6645c6mr4965973ilv.13.1701991109921; Thu, 07 Dec 2023 15:18:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701991109; cv=none; d=google.com; s=arc-20160816; b=dlvIx9vdpxxLzOzR8o4l+TpGBzxeBA6gGpIfK2+cXycMGH3xYP+QmQdc1C4TL3Hb6j NG4N8OX3anZY3rikC0v0Fi/j3nOvl39hfFW59JqPE/HYNuXdGn5pwPzq1OSkD459GkvK LUDgSI28hmfwTPk5rxsLPFQRYProPS7YNkS/TKXcxpHc4AMr29VV9GglZOqqQwRMfPWf y+WVPPnt1w1QvLeG9xIr1z8G/eFXEHxRaHscPYfuURrnNcez3OSoW400wZEAvciW8Hpc v0ELjYfAx8Cv5CT7Mni0TCb4o2ZU1//bxDpq0RU/FWXz3llrtF9rfp9BB/u3mFb+BzVj n1Xw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=2qVgIXXI2cMw2ajdOYKgvt4GH6JzHiU0pdSvnaX1mW4=; fh=sbWzcFRy6UGcxKZMLw4wW5WBWtS+/DZ/6JA1SqjGTug=; b=egNU4uWAbzhpTwOnfSxFVqd/xuwEuI5bCa8GVQ3n8X5l+bBJiVSwFLQ1yCMtTXX76B c5OCaaHptgKaSufTHiDFsgUETUnOoOpjWDMJcek3BSonF+50pQmOB1E7/jxd6AgOwTWL XPPpzsaTWwJRgTKuqsYi268EiOd9QOg7CO5A4howD7rdJmudshEWTxxLRUuQ9ya2GcXq 8jmA/4bcg/h6iYarfgQolwzg3qxU/CkaUg9yuIcs9/QcFl0xTXEsRe/J/XJAFES7a5tz DrO/mg7YickHQo1Lp+ipMdCfBXXjAAyNYHyEKSOB7n4Toyp0eUUEFJBlvEFEZZZekshZ GYFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=MV1LYsc0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id y184-20020a638ac1000000b005c6c9524f93si416903pgd.766.2023.12.07.15.18.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 15:18:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=MV1LYsc0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id C6549802572F; Thu, 7 Dec 2023 15:18:28 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232476AbjLGXSS (ORCPT + 99 others); Thu, 7 Dec 2023 18:18:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229671AbjLGXSR (ORCPT ); Thu, 7 Dec 2023 18:18:17 -0500 Received: from mail-lj1-x22c.google.com (mail-lj1-x22c.google.com [IPv6:2a00:1450:4864:20::22c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4AD031710 for ; Thu, 7 Dec 2023 15:18:22 -0800 (PST) Received: by mail-lj1-x22c.google.com with SMTP id 38308e7fff4ca-2c9eca5bbaeso17484971fa.3 for ; Thu, 07 Dec 2023 15:18:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1701991100; x=1702595900; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=2qVgIXXI2cMw2ajdOYKgvt4GH6JzHiU0pdSvnaX1mW4=; b=MV1LYsc0sqYLrqubyZ9BgfYCovQ7NwnwTnHIfEkR7xBQXJNRRSsuyRNhOOpkF3dJLP yyujvvp/NHVZte/5SzZrq1TEIU4DQyh0W0aH6t+o+Bpeq41KrkTrOU0P6T0y+r7PfL5V 5obuwdRjan4mYXCSji+IM6vlDnFtVOar44FXk0rfPmV3Wp9vaOwnHny9ttKqSd+pSrmn Q6ee6/2w8uQ/VcEwY0K/CpfjaLy2ubXnFsFHYJG1Pn5RSjlBzUwevT6q3EiMBkInwL+9 LPWqx75VmSpWeCZZ+ReIVgXTXTIhr0l8CPoqLAaazvQOi0j4FkzqWQoglR8O1voUbZK0 Aj1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701991100; x=1702595900; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2qVgIXXI2cMw2ajdOYKgvt4GH6JzHiU0pdSvnaX1mW4=; b=CG+mAG8ySNTZJwSpCsx1XCOotvsihX9djphA+yztCgL9gb0+bYLv4IPsn2GhwLzPB3 +F1w4KgIgA31zGxdD3Fqb39N/p/eHucleTP/AmUdcYWmGjkQz8lBcO1sIuDQU6N2DBco +FpFvVfSOdGrvSZWXtOcGYlqjDGK2ZLLrBZiDfniHDj8/JZT3KpFdgZvgHJTE3VB3+bT U36ZEVHkT8h05GzAYYuINrM4JJJ4IgZXzlhrs5B3ZNDUn0C38OoitVFh2gsfiFAP6B3S sWJWmlVWDCcS5TsS12FGdj2zlEFVeTfDzHFCRHS+IGAbFKrLU9xF8tFvnBzHS/GFJCW5 +iBQ== X-Gm-Message-State: AOJu0Yy8MkuKf3IEICr15JoUm8SMmNC19F2RDGxSJaf0cdZ5rTy4wroL /Po4gtgVKwewdVA1Poji5Yer9rOAiBCNCOpxfgNA3w== X-Received: by 2002:a2e:3608:0:b0:2c9:f4e4:3206 with SMTP id d8-20020a2e3608000000b002c9f4e43206mr932197lja.38.1701991099990; Thu, 07 Dec 2023 15:18:19 -0800 (PST) MIME-Version: 1.0 References: <14973feb4c0f4ad01a0e5047407c93ce9b9e5463.1701971344.git.marcelo.schmitt1@gmail.com> In-Reply-To: <14973feb4c0f4ad01a0e5047407c93ce9b9e5463.1701971344.git.marcelo.schmitt1@gmail.com> From: David Lechner Date: Thu, 7 Dec 2023 17:18:09 -0600 Message-ID: Subject: Re: [PATCH v3 02/13] iio: adc: ad7091r: Populate device driver data field To: Marcelo Schmitt Cc: apw@canonical.com, joe@perches.com, dwaipayanray1@gmail.com, lukas.bulwahn@gmail.com, paul.cercueil@analog.com, Michael.Hennerich@analog.com, lars@metafoo.de, jic23@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, dan.carpenter@linaro.org, marcelo.schmitt1@gmail.com, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 07 Dec 2023 15:18:29 -0800 (PST) On Thu, Dec 7, 2023 at 12:38=E2=80=AFPM Marcelo Schmitt wrote: > > Set device driver data so it can be retrieved when handling alert > events, avoiding null pointer dereference. > > Fixes: ca69300173b6 ("iio: adc: Add support for AD7091R5 ADC") > Signed-off-by: Marcelo Schmitt > --- > drivers/iio/adc/ad7091r-base.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/iio/adc/ad7091r-base.c b/drivers/iio/adc/ad7091r-bas= e.c > index 8e252cde735b..0f192fbecbd4 100644 > --- a/drivers/iio/adc/ad7091r-base.c > +++ b/drivers/iio/adc/ad7091r-base.c > @@ -232,6 +232,7 @@ int ad7091r_probe(struct device *dev, const char *nam= e, > iio_dev->channels =3D chip_info->channels; > > if (irq) { > + dev_set_drvdata(st->dev, iio_dev); > ret =3D devm_request_threaded_irq(dev, irq, NULL, > ad7091r_event_handler, > IRQF_TRIGGER_FALLING | IRQF_ONESHOT, name= , st); > -- > 2.42.0 > > Instead of introducing a new relationship between iio_dev and st, why not pass iio_dev to devm_request_threaded_irq() instead of st and then use iio_priv() to get st in ad7091r_event_handler? diff --git a/drivers/iio/adc/ad7091r-base.c b/drivers/iio/adc/ad7091r-base.= c index 8e252cde735b..0e5d3d2e9c98 100644 --- a/drivers/iio/adc/ad7091r-base.c +++ b/drivers/iio/adc/ad7091r-base.c @@ -174,8 +174,8 @@ static const struct iio_info ad7091r_info =3D { static irqreturn_t ad7091r_event_handler(int irq, void *private) { - struct ad7091r_state *st =3D (struct ad7091r_state *) private; - struct iio_dev *iio_dev =3D dev_get_drvdata(st->dev); + struct iio_dev *iio_dev =3D private; + struct ad7091r_state *st =3D iio_priv(iio_dev); unsigned int i, read_val; int ret; s64 timestamp =3D iio_get_time_ns(iio_dev); @@ -234,7 +234,7 @@ int ad7091r_probe(struct device *dev, const char *name, if (irq) { ret =3D devm_request_threaded_irq(dev, irq, NULL, ad7091r_event_handler, - IRQF_TRIGGER_FALLING | IRQF_ONESHOT, name, st); + IRQF_TRIGGER_FALLING | IRQF_ONESHOT, name, iio_dev); if (ret) return ret; }