From nobody Thu Dec 18 20:36:30 2025 Received: from mail-oi1-f171.google.com (mail-oi1-f171.google.com [209.85.167.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 426601C1AAA for ; Mon, 13 Jan 2025 21:43:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736804609; cv=none; b=m4lFv8JPZsmQMKR+ga0ayT5nSa/+g+j2pKcidU88eDljXjchzgnQSkdTVZOhEc3H5XmViYuJrmhtCvgHKz/K0aSfEU3dJvBZMGu236Z2lG74e0cixQHYylmgPIv/kOJvftf3V8NPyd6kSCuWRkalJUO5jGkDFjHFVwsOS6TmFM4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736804609; c=relaxed/simple; bh=5iT11eG/HgQs3YWkbiQr+0bGcmFtfNDAIhVxz74R5Q0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=lNGmYTyMCc+QSKT64MJIPY3xwbgtYlxHQPUtrgCKRi2I98HOeQnbLSDx/qEqJo5Vhs9kLYFf94P94XYg2AT4ogKWWw9CD4z1MnfpyySBM2W+AHXRiBWhziCa2c026bKG7ItyQ28KRNF73PRGMVK/so02SLQ4eiyTjlXjlCuSw+0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=KR3dIgEh; arc=none smtp.client-ip=209.85.167.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="KR3dIgEh" Received: by mail-oi1-f171.google.com with SMTP id 5614622812f47-3eb7edfa42dso2237744b6e.2 for ; Mon, 13 Jan 2025 13:43:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1736804606; x=1737409406; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=TxRWCgdwbsoP98leMR38NpBPw2TRSdUfugz5uC3OaZw=; b=KR3dIgEhoFs80Y/j/hrxLpUZLqr+KICtn5K95qyiW9F6COoZ5d/Idn8WTKYQAyK1sV zZTUCEhJlBJN5T96F26ZrCY2IjNuER+AWpvD076KR0SOgSOog1AigiHDaASPPk1NcIpV lCG4Ay5hpmtx59RJ3ukznDbiqdS6bSDu26QEKO5YPpB02aRDnlYzRQsIfoWr3kA73HKn nHYAz4wG5p2rp1/uyXxQgTZDs/C9v9TXHFu6atX2h3SVJq9Ft5WWgmvSTJcbHiHmq3go Q70c5laHmMZ8I4iJ5T4Wu36iNedBNsixLeTNvQd6atXGE1icV4kY9bigQ83u+XkkUuKH o/fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736804606; x=1737409406; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TxRWCgdwbsoP98leMR38NpBPw2TRSdUfugz5uC3OaZw=; b=EWMF/BPb7vjzZxMnP6kWZlGs90jaGcm+6WYpRuwkMiJ3RS3qUggVsthRPImDuO98Nt RcBegNvPpRlw3mKbi07OwKpMvlHv0LnwFadwmyL+yQv1ircq9JGnv6TP5tIq5rqfhp+h 8Yv2dxaOjiAoRL3tq49onKHJrbzKvpN1FI0Iaw+gCTvYiylMq/lJ00AKL6BL824OsJos HqOX4TlrZjREwYOSn7mxdxCKCWCGIid9Oe5kmW+euQW0vZC5juNQUb0XIlCyTWz5RJAO GCtchanJRYJjbE+GfxLrJ29QV2l1DBfLzI7kcyXLi/fY0cKTY6mReGfpDWqv9Laj9f9k aZ9Q== X-Forwarded-Encrypted: i=1; AJvYcCUWmZwxy7SBp5tWUzOzU0K7kAi1wufaE6iWSK7eai9X9OjqSssozKtdFsYlr4lfG68zjKsPX9s+sZ1+jv0=@vger.kernel.org X-Gm-Message-State: AOJu0YyIFzz6nd/6KJ3+X3YNFw5in3oFl+PeLq42vQGB/H3H4h53QjT9 zB523XKalPsU2Q5d5M1htp4LDa59Fu+XAU2nWUvkXX0eJHhTUTkfC6lVym5v3aQ= X-Gm-Gg: ASbGncs31Aa+eLQ2KrOfI2DD1MDEW3pkXZUI2FDhyYAIvcMlif5CaJKmFQn8qAqBJ+4 0SnB9XHCKMVQmVrXW11v9QyXMHMZLrKZLu7Io/7qX5YuDkm2weAlKhn9+K+cSg9ve5rqFW39qgb YGxYpt6KbXuv7V4DfmJYzlt3Zk8i1MBdQx4HHxIKZxnh0xXvNn6Zvn1vEldgAcBlQSFIfusAhWL dig4jEXH+1nJ0xfBRx2gBD10er8jrAVEvhON+e3xnBlSH1phTMPZRyeAd3GA5fSLsWEIqpqmkkO BYvb93hEOOm1 X-Google-Smtp-Source: AGHT+IGPRNB8LbJw1tytimz7TILkld4KGNDg40MFGgHC2c1apyw7NF6yt5quUyzlhSfejj3b42ZdCw== X-Received: by 2002:a05:6808:1a1a:b0:3eb:39f5:de8b with SMTP id 5614622812f47-3ef2eda1cf2mr15484912b6e.32.1736804606299; Mon, 13 Jan 2025 13:43:26 -0800 (PST) Received: from [127.0.1.1] (ip98-183-112-25.ok.ok.cox.net. [98.183.112.25]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-5f882624f77sm3606806eaf.7.2025.01.13.13.43.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jan 2025 13:43:24 -0800 (PST) From: David Lechner Date: Mon, 13 Jan 2025 15:43:18 -0600 Subject: [PATCH v4 1/2] iio: adc: ad7173: move fwnode_irq_get_byname() call site Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250113-iio-adc-ad7313-fix-non-const-info-struct-v4-1-b63be3ecac4a@baylibre.com> References: <20250113-iio-adc-ad7313-fix-non-const-info-struct-v4-0-b63be3ecac4a@baylibre.com> In-Reply-To: <20250113-iio-adc-ad7313-fix-non-const-info-struct-v4-0-b63be3ecac4a@baylibre.com> To: Jonathan Cameron , Dumitru Ceclan Cc: Michael Hennerich , Nuno Sa , Michael Walle , Andy Shevchenko , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Guillaume Ranquet , David Lechner X-Mailer: b4 0.14.2 Move the call to fwnode_irq_get_byname() from the driver-specific ad7173_fw_parse_device_config() to the shared ad_sd_init() function. The main reason for this is that we want struct ad_sigma_delta_info to be static const data that describes the actual ADC chip, not the application-specific configuration or any runtime state. Previously, this struct was being used to pass the IRQ number to the shared ad_sd_init() function. Now, this is replaced by a boolean flag that is set at compile time and the ad_sd_init() function handles looking up the IRQ number instead. This also has the added benefit that if any other drivers need to make use of this in the future, they just have to set the flag and the shared code will take care of the rest rather than duplicating the code in each driver. Signed-off-by: David Lechner --- v4 changes: * New patch - replaces "iio: adc: ad7173: remove special handling for irq number" --- drivers/iio/adc/ad7173.c | 7 +------ drivers/iio/adc/ad_sigma_delta.c | 11 ++++++++--- include/linux/iio/adc/ad_sigma_delta.h | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/iio/adc/ad7173.c b/drivers/iio/adc/ad7173.c index 6c4ed10ae580d66287857252ce9a69cfaa45db0b..bb9cddd8c9d33f81df95e5001d6= 2a8ceb684d348 100644 --- a/drivers/iio/adc/ad7173.c +++ b/drivers/iio/adc/ad7173.c @@ -871,6 +871,7 @@ static const struct ad_sigma_delta_info ad7173_sigma_de= lta_info =3D { .disable_one =3D ad7173_disable_one, .set_mode =3D ad7173_set_mode, .has_registers =3D true, + .has_named_irqs =3D true, .addr_shift =3D 0, .read_mask =3D BIT(6), .status_ch_mask =3D GENMASK(3, 0), @@ -1515,12 +1516,6 @@ static int ad7173_fw_parse_device_config(struct iio_= dev *indio_dev) return ret; } =20 - ret =3D fwnode_irq_get_byname(dev_fwnode(dev), "rdy"); - if (ret < 0) - return dev_err_probe(dev, ret, "Interrupt 'rdy' is required\n"); - - st->sigma_delta_info.irq_line =3D ret; - return ad7173_fw_parse_channel_config(indio_dev); } =20 diff --git a/drivers/iio/adc/ad_sigma_delta.c b/drivers/iio/adc/ad_sigma_de= lta.c index d5d81581ab34099cef30ec63944ce1171c80ec14..10e635fc4fa4bf0ecad279962a2= b944153b436be 100644 --- a/drivers/iio/adc/ad_sigma_delta.c +++ b/drivers/iio/adc/ad_sigma_delta.c @@ -801,10 +801,15 @@ int ad_sd_init(struct ad_sigma_delta *sigma_delta, st= ruct iio_dev *indio_dev, =20 spin_lock_init(&sigma_delta->irq_lock); =20 - if (info->irq_line) - sigma_delta->irq_line =3D info->irq_line; - else + if (info->has_named_irqs) { + sigma_delta->irq_line =3D fwnode_irq_get_byname(dev_fwnode(&spi->dev), + "rdy"); + if (sigma_delta->irq_line < 0) + return dev_err_probe(&spi->dev, sigma_delta->irq_line, + "Interrupt 'rdy' is required\n"); + } else { sigma_delta->irq_line =3D spi->irq; + } =20 sigma_delta->rdy_gpiod =3D devm_gpiod_get_optional(&spi->dev, "rdy", GPIO= D_IN); if (IS_ERR(sigma_delta->rdy_gpiod)) diff --git a/include/linux/iio/adc/ad_sigma_delta.h b/include/linux/iio/adc= /ad_sigma_delta.h index 417073c52380f60a1a45a4924f4f556b64832295..f242b285081b8d304ca25ae9533= 7425e5842269a 100644 --- a/include/linux/iio/adc/ad_sigma_delta.h +++ b/include/linux/iio/adc/ad_sigma_delta.h @@ -46,6 +46,7 @@ struct iio_dev; * modify or drop the sample data, it, may be NULL. * @has_registers: true if the device has writable and readable registers,= false * if there is just one read-only sample data shift register. + * @has_named_irqs: Set to true if there is more than one IRQ line. * @addr_shift: Shift of the register address in the communications regist= er. * @read_mask: Mask for the communications register having the read bit se= t. * @status_ch_mask: Mask for the channel number stored in status register. @@ -53,7 +54,6 @@ struct iio_dev; * be used. * @irq_flags: flags for the interrupt used by the triggered buffer * @num_slots: Number of sequencer slots - * @irq_line: IRQ for reading conversions. If 0, spi->irq will be used * @num_resetclks: Number of SPI clk cycles with MOSI=3D1 to reset the chi= p. */ struct ad_sigma_delta_info { @@ -64,13 +64,13 @@ struct ad_sigma_delta_info { int (*disable_one)(struct ad_sigma_delta *, unsigned int chan); int (*postprocess_sample)(struct ad_sigma_delta *, unsigned int raw_sampl= e); bool has_registers; + bool has_named_irqs; unsigned int addr_shift; unsigned int read_mask; unsigned int status_ch_mask; unsigned int data_reg; unsigned long irq_flags; unsigned int num_slots; - int irq_line; unsigned int num_resetclks; }; =20 --=20 2.43.0