From: Wei Ni <wni@nvidia.com>
To: Guenter Roeck <linux@roeck-us.net>
Cc: "durgadoss.r@intel.com" <durgadoss.r@intel.com>,
"rui.zhang@intel.com" <rui.zhang@intel.com>,
Matthew Longnecker <MLongnecker@nvidia.com>,
"khali@linux-fr.org" <khali@linux-fr.org>,
"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
"devicetree-discuss@lists.ozlabs.org"
<devicetree-discuss@lists.ozlabs.org>,
"lm-sensors@lm-sensors.org" <lm-sensors@lm-sensors.org>,
Alex Courbot <acourbot@nvidia.com>,
"linux-tegra@vger.kernel.org" <linux-tegra@vger.kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>
Subject: Re: [lm-sensors] [RFC PATCH 3/9] hwmon: (lm90) add support to handle irq
Date: Tue, 19 Feb 2013 18:43:36 +0800 [thread overview]
Message-ID: <51235758.60902@nvidia.com> (raw)
In-Reply-To: <20130219033419.GB25610@roeck-us.net>
On 02/19/2013 11:34 AM, Guenter Roeck wrote:
> On Mon, Feb 18, 2013 at 07:30:25PM +0800, Wei Ni wrote:
>> Add support to handle irq. When the temperature touch the limit value, the
>> driver can handle the interrupt.
>>
>> Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
>> Signed-off-by: Wei Ni <wni@nvidia.com>
>> ---
>> drivers/hwmon/lm90.c | 38 ++++++++++++++++++++++++++++++++++++++
>> 1 file changed, 38 insertions(+)
>>
>> diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
>> index caf01b0..80311ef 100644
>> --- a/drivers/hwmon/lm90.c
>> +++ b/drivers/hwmon/lm90.c
>> @@ -89,6 +89,8 @@
>> #include <linux/err.h>
>> #include <linux/mutex.h>
>> #include <linux/sysfs.h>
>> +#include <linux/interrupt.h>
>> +#include <linux/of_irq.h>
>>
>> /*
>> * Addresses to scan
>> @@ -302,6 +304,7 @@ static const struct lm90_params lm90_params[] = {
>> struct lm90_data {
>> struct device *hwmon_dev;
>> struct mutex update_lock;
>> + struct work_struct irq_work;
>> char valid; /* zero until following fields are valid */
>> unsigned long last_updated; /* in jiffies */
>> int kind;
>> @@ -1418,6 +1421,29 @@ 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 void lm90_irq_work(struct work_struct *work)
>> +{
>> + struct lm90_data *data = container_of(work, struct lm90_data,
>> + irq_work);
>> + struct i2c_client *client = to_i2c_client(data->hwmon_dev->parent);
>> +
>> + lm90_alert(client, 0);
>> +
>> + enable_irq(client->irq);
>> +}
>> +
>> +static irqreturn_t lm90_irq(int irq, void *dev_id)
>> +{
>> + struct lm90_data *data = dev_id;
>> +
>> + disable_irq_nosync(irq);
>> + schedule_work(&data->irq_work);
>> +
>> + return IRQ_HANDLED;
>> +}
>> +
>> static int lm90_probe(struct i2c_client *client,
>> const struct i2c_device_id *id)
>> {
>> @@ -1494,6 +1520,17 @@ static int lm90_probe(struct i2c_client *client,
>> goto exit_remove_files;
>> }
>>
>> + if (client->irq >= 0) {
>> + INIT_WORK(&data->irq_work, lm90_irq_work);
>> + dev_dbg(dev, "lm90 irq: %d\n", client->irq);
>> + err = request_irq(client->irq, lm90_irq, IRQF_TRIGGER_LOW,
>> + "lm90", data);
>
> request_threaded_irq or even better devm_request_threaded_irq would be better here.
yes, it's better to use request_threaded_irq here.
we can set lm90_irq() as interrupt handle, and set lm90_alert() as
thread function.
I will try it on my next version.
>
>> + if (err < 0) {
>> + dev_err(dev, "cannot request interrupt\n");
>> + goto exit_remove_files;
>> + }
>> + }
>> +
>> return 0;
>>
>> exit_remove_files:
>> @@ -1507,6 +1544,7 @@ static int lm90_remove(struct i2c_client *client)
>> {
>> struct lm90_data *data = i2c_get_clientdata(client);
>>
>> + free_irq(client->irq, data);
>> hwmon_device_unregister(data->hwmon_dev);
>> lm90_remove_files(client, data);
>> lm90_restore_conf(client, data);
>> --
>> 1.7.9.5
>>
>>
>> _______________________________________________
>> lm-sensors mailing list
>> lm-sensors@lm-sensors.org
>> http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
>>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-tegra" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
next prev parent reply other threads:[~2013-02-19 10:43 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-18 11:30 [RFC PATCH 0/9] Support for tegra30 thermal Wei Ni
2013-02-18 11:30 ` [RFC PATCH 2/9] hwmon: (lm90) split set&show temp as common codes Wei Ni
2013-02-18 22:29 ` Matthew Longnecker
2013-02-19 9:48 ` Wei Ni
2013-02-19 3:31 ` [lm-sensors] " Guenter Roeck
[not found] ` <20130219033144.GA25610-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2013-02-19 10:00 ` Wei Ni
2013-02-19 22:56 ` Stephen Warren
[not found] ` <51240331.7080604-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2013-02-20 12:31 ` Wei Ni
2013-02-18 11:30 ` [RFC PATCH 4/9] hwmon: (lm90) use macros for the indexes of temp8 and temp11 Wei Ni
2013-02-19 5:39 ` Alex Courbot
[not found] ` <5123100A.9050604-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-02-19 9:58 ` Wei Ni
2013-02-19 23:02 ` Stephen Warren
[not found] ` <51240497.8010909-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2013-02-20 10:29 ` Wei Ni
2013-02-18 11:30 ` [RFC PATCH 7/9] thermal: tegra30: add tegra30 thermal driver Wei Ni
2013-02-19 23:48 ` Stephen Warren
2013-02-20 12:23 ` Wei Ni
2013-02-19 23:56 ` Russell King - ARM Linux
[not found] ` <20130219235629.GU17833-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2013-02-20 12:29 ` Wei Ni
[not found] ` <1361187031-3679-1-git-send-email-wni-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-02-18 11:30 ` [RFC PATCH 1/9] ARM: dt: t30 cardhu: add dt entry for lm90 Wei Ni
[not found] ` <1361187031-3679-2-git-send-email-wni-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-02-19 3:28 ` Alex Courbot
2013-02-19 9:52 ` Wei Ni
[not found] ` <5122F162.9030103-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-02-19 22:48 ` Stephen Warren
2013-02-18 11:30 ` [RFC PATCH 3/9] hwmon: (lm90) add support to handle irq Wei Ni
[not found] ` <1361187031-3679-4-git-send-email-wni-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-02-19 3:34 ` [lm-sensors] " Guenter Roeck
2013-02-19 10:43 ` Wei Ni [this message]
2013-02-19 23:00 ` Stephen Warren
2013-02-20 3:27 ` Alex Courbot
[not found] ` <5124429B.2000404-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-02-20 10:27 ` Wei Ni
2013-02-18 11:30 ` [RFC PATCH 5/9] Thermal: Support using dt node to get sensor Wei Ni
[not found] ` <1361187031-3679-6-git-send-email-wni-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-02-19 23:12 ` Stephen Warren
[not found] ` <512406F0.4080708-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2013-02-20 10:36 ` Wei Ni
2013-02-18 11:30 ` [RFC PATCH 6/9] hwmon: (lm90) Register to the thermal framework Wei Ni
2013-02-19 3:42 ` [lm-sensors] " Guenter Roeck
[not found] ` <20130219034205.GC25610-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2013-02-19 10:47 ` Wei Ni
2013-02-19 5:22 ` Alex Courbot
2013-02-19 10:58 ` Wei Ni
[not found] ` <1361187031-3679-7-git-send-email-wni-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-02-19 23:18 ` Stephen Warren
2013-02-20 10:40 ` Wei Ni
2013-02-18 11:30 ` [RFC PATCH 8/9] ARM: dt: t30 cardhu: add dt entry for thermal driver Wei Ni
2013-02-19 3:42 ` Alex Courbot
2013-02-19 9:56 ` Wei Ni
[not found] ` <1361187031-3679-9-git-send-email-wni-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-02-19 23:28 ` Stephen Warren
2013-02-20 11:53 ` Wei Ni
[not found] ` <5124B934.3020900-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-02-20 17:18 ` Stephen Warren
2013-02-18 11:30 ` [RFC PATCH 9/9] ARM: tegra: defconfig: enable thermal framework Wei Ni
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=51235758.60902@nvidia.com \
--to=wni@nvidia.com \
--cc=MLongnecker@nvidia.com \
--cc=acourbot@nvidia.com \
--cc=devicetree-discuss@lists.ozlabs.org \
--cc=durgadoss.r@intel.com \
--cc=khali@linux-fr.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=lm-sensors@lm-sensors.org \
--cc=rui.zhang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).