From patchwork Thu Jul 4 07:57:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Ni X-Patchwork-Id: 256814 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 90A662C0091 for ; Thu, 4 Jul 2013 17:58:25 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756441Ab3GDH6Y (ORCPT ); Thu, 4 Jul 2013 03:58:24 -0400 Received: from hqemgate04.nvidia.com ([216.228.121.35]:6048 "EHLO hqemgate04.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755420Ab3GDH6X (ORCPT ); Thu, 4 Jul 2013 03:58:23 -0400 Received: from hqnvupgp07.nvidia.com (Not Verified[216.228.121.13]) by hqemgate04.nvidia.com id ; Thu, 04 Jul 2013 00:58:30 -0700 Received: from hqemhub02.nvidia.com ([172.20.12.94]) by hqnvupgp07.nvidia.com (PGP Universal service); Thu, 04 Jul 2013 00:59:19 -0700 X-PGP-Universal: processed; by hqnvupgp07.nvidia.com on Thu, 04 Jul 2013 00:59:19 -0700 Received: from hkemhub01.nvidia.com (10.18.67.12) by hqemhub02.nvidia.com (172.20.150.31) with Microsoft SMTP Server (TLS) id 8.3.298.1; Thu, 4 Jul 2013 00:58:12 -0700 Received: from niwei-ubuntu.nvidia.com (10.18.67.5) by hkemhub01.nvidia.com (10.18.67.12) with Microsoft SMTP Server id 8.3.298.1; Thu, 4 Jul 2013 15:58:11 +0800 From: Wei Ni To: , , CC: , , , , , Wei Ni Subject: [PATCH 2/3] hwmon: (lm90) add support to handle irq Date: Thu, 4 Jul 2013 15:57:49 +0800 Message-ID: <1372924670-16355-3-git-send-email-wni@nvidia.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1372924670-16355-1-git-send-email-wni@nvidia.com> References: <1372924670-16355-1-git-send-email-wni@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 Sender: linux-tegra-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org Add support to handle irq. When the temperature touch the limit value, the driver can handle the interrupt. Signed-off-by: Wei Ni --- drivers/hwmon/lm90.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c index 2cb7f8e..fce9dfa 100644 --- a/drivers/hwmon/lm90.c +++ b/drivers/hwmon/lm90.c @@ -89,6 +89,7 @@ #include #include #include +#include /* * Addresses to scan @@ -1423,6 +1424,18 @@ static void lm90_init_client(struct i2c_client *client) i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1, config); } +static void lm90_alert(struct i2c_client *client, unsigned int flag); + +static irqreturn_t lm90_irq_thread(int irq, void *dev_id) +{ + struct lm90_data *data = dev_id; + struct i2c_client *client = to_i2c_client(data->hwmon_dev->parent); + + lm90_alert(client, 0); + + return IRQ_HANDLED; +} + static int lm90_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -1499,6 +1512,18 @@ static int lm90_probe(struct i2c_client *client, goto exit_remove_files; } + if (client->irq >= 0) { + dev_dbg(dev, "lm90 irq: %d\n", client->irq); + err = devm_request_threaded_irq(dev, client->irq, + NULL, lm90_irq_thread, + IRQF_TRIGGER_LOW | IRQF_ONESHOT, + "lm90", data); + if (err < 0) { + dev_err(dev, "cannot request interrupt\n"); + goto exit_remove_files; + } + } + return 0; exit_remove_files: