Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1791146imu; Sat, 8 Dec 2018 07:18:18 -0800 (PST) X-Google-Smtp-Source: AFSGD/UYs4AvAubSw0DA1+uJFWvfzvSms8aiv47qJZir9fgNJIH17zza2Wpg/prpa9kI/C5yda9E X-Received: by 2002:a62:9fd9:: with SMTP id v86mr6136087pfk.191.1544282298257; Sat, 08 Dec 2018 07:18:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544282298; cv=none; d=google.com; s=arc-20160816; b=MPHwgTCynmNmG96CZHaxSMevBDjSQmx8IZjCcquFm1k/Z0eyP/fC+Y6FHr9z8NeaqR jiMXvX9alNrxv2GtudMKSjdgUv9rKe2OccucxfFVJ+38Cbc+w5mo47HdG9gJGlBbhVJ4 xUHo3Ns5BnAsTd/TiR3mMnHZA8UmAQcm6jQyGEkNhoFl1KmSJxM0HoDvttthLNPxG+Vr 1U6MXVueYHEnlBOOmXI4rzoFDXa+uRToSblQVAgNugJTKdlQKVLLu51QX8tGXKqH92Qu rdEqEgQCtG85fW+WB/Oz+l8D+MrP0gXtkhazF7ySoUCjCwkLyQwC6HnA/nbFxRfSDgNk +DmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:to:from:dkim-signature; bh=nWcKVpbCtOeHHfzBkxr54dLK7pg5obwuEhza0JXpwy4=; b=NAR0n2Z2sSQTegx7TlbOs34CcP70cOLPg+DIK4Y7fbo11ZP34sdQqBejQHZg89rK0m ZBK/d5eP97Qfb9SXsLzzSuznXcSwHq2FJSnVchw7snJ2Wx/vimD2T7FGn3elNNrwS56s zr73GH+8FLZivQKAvQDcs7CF2/XeV5fxMskF4vzigrzeus03cu3SGszUJrw1mzgOaCIw 0UpmZROcKCJdHyyfnMTybf3JbsqHuICDq38m9FyujBNEwoq+p5nNrY86licdP0T+Qvc7 sxPbBkjG9M38g3GLIRQB5rIb4hLkcfdH1PoUfvfFSKE/XpTmlCKMXOPzXqNHWylo6ywC KAcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=PUk9+P0H; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b26si5341303pgl.539.2018.12.08.07.17.46; Sat, 08 Dec 2018 07:18:18 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=PUk9+P0H; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726189AbeLHPQt (ORCPT + 99 others); Sat, 8 Dec 2018 10:16:49 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:42782 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726147AbeLHPQs (ORCPT ); Sat, 8 Dec 2018 10:16:48 -0500 Received: by mail-pl1-f196.google.com with SMTP id y1so3177587plp.9; Sat, 08 Dec 2018 07:16:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=nWcKVpbCtOeHHfzBkxr54dLK7pg5obwuEhza0JXpwy4=; b=PUk9+P0Hb2yaJ9Bxan1LfCT5xVEvAuf8XylcuDAOPytX6nICbix9bg8tHAcKMvI3yl w78d0j8Vvtufi+yEhHx1eZrvvyLnsKp4eVvx+fOk/AUasHo3u8zbJ2ZecUXiweStHlIs aKlRNGWo01nI+PT9CtKsUGGG1mXywVQYpTGcEIiPlW1v+w1WKPkUtbjCIqwt1dZJ37w0 wZUPGCGQk2lZZzQTSKxwA7uG+Hg7oZP6yGXbqVwMCKAp9I+Go85UnEzyiMu7kDm8k2JV LZa+k9tsDX8VeFZXM01zoA9z6FpDmg2qNP7/0D22K5qDv0FhUZ7q7ZtcnYVMHHgWsRE/ ieew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=nWcKVpbCtOeHHfzBkxr54dLK7pg5obwuEhza0JXpwy4=; b=aAUP89ntCVj2SwT3Xqlo0IYQh8gOJR5p759WR0jTopUm3W3T0VoPp9BYR9rYmhYvI8 1zwTmQg5SvNRT+LI+dVrr6B8h2SiJ3WLJs0mRxY9romKRpk3r8/HjLfF71PXsuel5Zoe xmslzXgq5iQpCFB2VVAjFdDQXpbL3N6J2bOBlRaDJRaYvDVcjAJhgq9m1pPvKuRas6+E ErdfIlrLOmPJ+OFMC6Zi0O8/m33gb0+yatDEZVRWvP7HSUk5lFknZfn2N1S6b0qlvuuJ PyDSKrzkvQzIv+UnNK1wq9/2aHeGldAIThU5cyT3cNbedSussc+qe8RIJDlHtMVSL8Tf mQuw== X-Gm-Message-State: AA+aEWac/JgVVcwBfVbNN+bE58ITbRnGQknBCwknDdten4OvdNO95eKO 4uYayPat60hqzqerWjKPVZnMUadV X-Received: by 2002:a17:902:704b:: with SMTP id h11mr6056475plt.157.1544282207770; Sat, 08 Dec 2018 07:16:47 -0800 (PST) Received: from localhost.localdomain ([103.212.140.153]) by smtp.gmail.com with ESMTPSA id e23sm9774091pfh.68.2018.12.08.07.16.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 08 Dec 2018 07:16:47 -0800 (PST) From: Shreeya Patel To: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org, knaack.h@gmx.de, pmeerw@pmeerw.net, gregkh@linuxfoundation.org, linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, shreeya.patel23498@gmail.com Subject: [PATCH v3 1/3] Staging: iio: adt7316: Use device tree data to assign irq_type Date: Sat, 8 Dec 2018 20:46:36 +0530 Message-Id: <20181208151638.8759-2-shreeya.patel23498@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181208151638.8759-1-shreeya.patel23498@gmail.com> References: <20181208151638.8759-1-shreeya.patel23498@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ADT7316 driver no more uses platform data and hence use device tree data instead of platform data for assigning irq_type field. Switch case figures out the type of irq and if it's the default case then assign the default value to the irq_type i.e. irq_type = IRQF_TRIGGER_LOW All this is implemented in a new function called adt7316_setup_irq. Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index 9c72538baf9e..86b2c3d53588 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -1807,6 +1807,29 @@ static irqreturn_t adt7316_event_handler(int irq, void *private) return IRQ_HANDLED; } +static int adt7316_setup_irq(struct device *dev, int irq) +{ + int irq_type; + + irq_type = irqd_get_trigger_type(irq_get_irq_data(irq)); + + switch (irq_type) { + case IRQF_TRIGGER_HIGH: + case IRQF_TRIGGER_RISING: + break; + case IRQF_TRIGGER_LOW: + case IRQF_TRIGGER_FALLING: + break; + default: + dev_info(dev, "mode %d unsupported, using IRQF_TRIGGER_LOW\n", + irq_type); + irq_type = IRQF_TRIGGER_LOW; + break; + } + + return irq_type; +} + /* * Show mask of enabled interrupts in Hex. */ @@ -2101,8 +2124,7 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, { struct adt7316_chip_info *chip; struct iio_dev *indio_dev; - unsigned short *adt7316_platform_data = dev->platform_data; - int irq_type = IRQF_TRIGGER_LOW; + int irq_type; int ret = 0; indio_dev = devm_iio_device_alloc(dev, sizeof(*chip)); @@ -2146,8 +2168,7 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, indio_dev->modes = INDIO_DIRECT_MODE; if (chip->bus.irq > 0) { - if (adt7316_platform_data[0]) - irq_type = adt7316_platform_data[0]; + irq_type = adt7316_setup_irq(dev, chip->bus.irq); ret = devm_request_threaded_irq(dev, chip->bus.irq, NULL, -- 2.17.1