From nobody Mon Jun 8 08:29:04 2026 Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) (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 78E983403F8 for ; Wed, 3 Jun 2026 09:03:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780477422; cv=none; b=iaI9f8HNqBBCvS1kcCafRWJCY/D9R0O2t+NVlIb4H2EJRR/sf96oSKU904J/XLFbDZNhSJn/6gx7OKlOyCrjTi38hEWVAjRWCrs4iLkoa/EYcJfSRokBriNEGFo5Ym6ImMdsTna8g56oloHpyhxP1hmVyFihDDuzXHy/jp0suyk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780477422; c=relaxed/simple; bh=vtlyrLm0TvkUPo2wg/R/JazT+XqsbQ1jNn4MsZdjIzU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=a2FAOqI9OKulvoEtkfcf6k1oo7jcqtHkli4yVZot3bH0uqW9MVeJo1i3Iuu+oIrZzTIYxtyJLQteitP4YVhxrctvSjnBTTTKRW69bXk0zRSbvY7hzklkjmjYMxYZ1tqXs+15C7z1p2/fJZTtxgW4pRYeTpOuhDb1YzitIMjAYP0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=AxJf6Nvo; arc=none smtp.client-ip=209.85.167.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="AxJf6Nvo" Received: by mail-lf1-f44.google.com with SMTP id 2adb3069b0e04-5aa64cbb08fso370445e87.3 for ; Wed, 03 Jun 2026 02:03:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780477419; x=1781082219; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=uh1b+mJpQbr3+CkGJCunycJWNSs6fDOpmRP1WL4Ja5Y=; b=AxJf6NvojgvXOWh88CUPWSopJrxJ8Yd16nHn4mivRGtFNYWlHknCGLawKQlvJUyv9z Ttzr/QmQNIssw9WA3EVV0KRqqTQTWOQ8qNWMYPqq+o/eYxOaYauup7S44uo0i0hW62Rx n5vhiBYlW5QdUJDKfRE2IMunPudaDZT5I3o7kfmFZx/nHGYrW6QhewlHTkkYFNpVou6x osecQ664QOJYPi7uSxYXEL2/qSoo+RVXEAfjzyaeiYDdHI0bOpvUhjRuen3P4xRcCRbN e0daOHxPwJ2LymGsvp0/wZZSJYXvx/3My2pZmeBEylHpWHi48RHZ3OtcqjF1hHRQxx1Y 9QjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780477419; x=1781082219; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=uh1b+mJpQbr3+CkGJCunycJWNSs6fDOpmRP1WL4Ja5Y=; b=sUe9xnHNo/3/ufbA9buxpVtHIxe87B3zoR7u2IsoiXnNXiPfSfJTTEnLW4d2czTXrT a9Jd9o1dzmzunF/xCNKIo3hqLTkqn2dW/OMnQkECpdsO86q7qgmW1smVP9KyZNE+zH8S hAenEkfBbsayGjBpVUne12gxcApwWSnnub6+SzkEvQn09tUo9bldGn7x69C/HBki/Er7 QaPMlNUrMiWylIUlrM3zzfIaB+Vu1P6hxnldgvqLdyPWtkNSExQwYkOBytJpd42ujs19 R7rxxSuYj+rglZdP2N0XnD+6cI5FOGklR7+5+fJJ3qrBPp3k9360Wh548yuPIngq/Qug jg+Q== X-Forwarded-Encrypted: i=1; AFNElJ+UxwXA5iPaL9ghdRDFO9Y5ug/s4ykzneFR5oeXBEnXhwlS1W8VxsXoioZUxjrZdpHIC9/rHG7wrMeV4kc=@vger.kernel.org X-Gm-Message-State: AOJu0YxpPMreWu07elEgJmVYjZ/XH0CLFduPVih2aOW92syBIObrWpgw ZTxm0TsQ3l2d3T7CT0/jRw6XEhWNuSB67oZbgYJtfP95JBtJt5tShnDC X-Gm-Gg: Acq92OGtkLIfPtuTKP2VPSRRegank6HTWuh+SUqWvzEmCKwu4L3uCecdpE62f9/Pua6 qFaQ9CuJfvuekbXiExoHN/SRAmtzXAqlhFjFoqYngMeGPYtfElZSEEiepr0WVTxTz4OuvGNQoH2 5enaELlzJ5Hz26L0aL78Xz6loeYd0I+6C5uLIgy0sGnoXDYdd/4iDY/3s8eSvydIMU/o4gcdkKj 40tjZMOAfv4meXMUZrqmUxJssFKt8qtaEmV8zVroO3a/7+Oqy/u+3OB4J/D/MUYN2OQGg+L3ioN A1hUDQxr9UKS0pkjXREkgGBinC7YIROr/9gyIxuucJsc/xMGmmNzNFmB/A64mUKXfLN0ov+8OK0 G17jppZUXZrIIRs4EXsWmpI/bOz/7UnxgH6MNcNFGQ+3HmwwELYstnSTBXC0MYSRNPybydP3ooo V4ahb9/JNe5lGv2I6in9U1l+x7cL4k8f3BEmN+Yd3wBPv+6A== X-Received: by 2002:a05:6512:3d19:b0:5aa:6232:576c with SMTP id 2adb3069b0e04-5aa7bf48994mr353921e87.6.1780477417014; Wed, 03 Jun 2026 02:03:37 -0700 (PDT) Received: from localhost ([5.124.46.112]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5aa7b9862fesm517686e87.57.2026.06.03.02.03.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2026 02:03:36 -0700 (PDT) From: Taha Narimani To: jic23@kernel.org, lars@metafoo.de, Michael.Hennerich@analog.com, gregkh@linuxfoundation.org Cc: dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org, linux-iio@vger.kernel.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Taha Narimani Subject: [PATCH v2] staging: iio: adc: ad7816: Use devm_gpiod_get_optional() for busy GPIO Date: Wed, 3 Jun 2026 12:33:33 +0000 Message-ID: <20260603123333.5608-1-tahanarimani3443@gmail.com> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The driver currently utilizes devm_gpiod_get() for the 'busy' line, which makes the GPIO mandatory. However, the busy pin is hardware-optional depending on the specific board configuration. Switch to devm_gpiod_get_optional() to allow boards that do not have this pin wired up to still probe the driver successfully, and remove the redundant conditional chip-ID check since the optional API handles missing descriptors gracefully. Signed-off-by: Taha Narimani --- Changes in v2: - Fixed trailing whitespace and missing newline at the end of the file. - Converted the file format to Unix (LF) to remove carriage returns. - Removed the explicit chip-ID check around the busy pin logic. - Improved the commit message to provide clear architectural justificatio= n. drivers/staging/iio/adc/ad7816.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/staging/iio/adc/ad7816.c b/drivers/staging/iio/adc/ad7= 816.c index 0eac484..039b34d 100644 --- a/drivers/staging/iio/adc/ad7816.c +++ b/drivers/staging/iio/adc/ad7816.c @@ -84,7 +84,7 @@ static int ad7816_spi_read(struct ad7816_chip_info *chip,= u16 *data) gpiod_set_value(chip->convert_pin, 1); } =20 - if (chip->id =3D=3D ID_AD7817) { + if (chip->busy_pin) { while (gpiod_get_value(chip->busy_pin)) cpu_relax(); } @@ -380,15 +380,14 @@ static int ad7816_probe(struct spi_device *spi_dev) ret); return ret; } - if (chip->id =3D=3D ID_AD7817) { - chip->busy_pin =3D devm_gpiod_get(&spi_dev->dev, "busy", - GPIOD_IN); - if (IS_ERR(chip->busy_pin)) { - ret =3D PTR_ERR(chip->busy_pin); - dev_err(&spi_dev->dev, "Failed to request busy GPIO: %d\n", - ret); - return ret; - } + + chip->busy_pin =3D devm_gpiod_get_optional(&spi_dev->dev, "busy", + GPIOD_IN); + if (IS_ERR(chip->busy_pin)) { + ret =3D PTR_ERR(chip->busy_pin); + dev_err(&spi_dev->dev, "Failed to request busy GPIO: %d\n", + ret); + return ret; } =20 indio_dev->name =3D spi_get_device_id(spi_dev)->name; --=20 2.53.0