Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 249777
b: refs/heads/master
c: bdab100
h: refs/heads/master
i:
  249775: 68dca9b
v: v3
  • Loading branch information
Jonathan Cameron authored and Greg Kroah-Hartman committed May 19, 2011
1 parent 232a125 commit 53424b8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 44 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b26a2188e0464f5962caff62074c91ef1c92056a
refs/heads/master: bdab1001738f4ebf8df21bab8c9da79bd5dd3362
62 changes: 19 additions & 43 deletions trunk/drivers/staging/iio/light/tsl2563.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ struct tsl2563_chip {
struct i2c_client *client;
struct delayed_work poweroff_work;

struct work_struct work_thresh;
s64 event_timestamp;
/* Remember state for suspend and resume functions */
pm_message_t state;

Expand Down Expand Up @@ -677,38 +675,22 @@ static IIO_DEVICE_ATTR(intensity0_both_raw_thresh_falling_value,
tsl2563_write_thresh,
TSL2563_REG_LOWLOW);

static int tsl2563_int_th(struct iio_dev *dev_info,
int index,
s64 timestamp,
int not_test)
static irqreturn_t tsl2563_event_handler(int irq, void *private)
{
struct iio_dev *dev_info = private;
struct tsl2563_chip *chip = iio_priv(dev_info);

chip->event_timestamp = timestamp;
schedule_work(&chip->work_thresh);

return 0;
}

static void tsl2563_int_bh(struct work_struct *work_s)
{
struct tsl2563_chip *chip
= container_of(work_s,
struct tsl2563_chip, work_thresh);
u8 cmd = TSL2563_CMD | TSL2563_CLEARINT;

iio_push_event(iio_priv_to_dev(chip), 0,
iio_push_event(dev_info, 0,
IIO_UNMOD_EVENT_CODE(IIO_EV_CLASS_LIGHT,
0,
IIO_EV_TYPE_THRESH,
IIO_EV_DIR_EITHER),
chip->event_timestamp);
iio_get_time_ns());

/* reenable_irq */
enable_irq(chip->client->irq);
/* clear the interrupt and push the event */
i2c_master_send(chip->client, &cmd, sizeof(cmd));

return IRQ_HANDLED;
}

static ssize_t tsl2563_write_interrupt_config(struct device *dev,
Expand All @@ -718,16 +700,13 @@ static ssize_t tsl2563_write_interrupt_config(struct device *dev,
{
struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct tsl2563_chip *chip = iio_priv(indio_dev);
struct iio_event_attr *this_attr = to_iio_event_attr(attr);
int input, ret = 0;

ret = sscanf(buf, "%d", &input);
if (ret != 1)
return -EINVAL;
mutex_lock(&chip->lock);
if (input && !(chip->intr & 0x30)) {
iio_add_event_to_list(this_attr->listel,
&indio_dev->interrupts[0]->ev_list);
chip->intr &= ~0x30;
chip->intr |= 0x10;
/* ensure the chip is actually on */
Expand All @@ -747,8 +726,6 @@ static ssize_t tsl2563_write_interrupt_config(struct device *dev,
if (!input && (chip->intr & 0x30)) {
chip->intr |= ~0x30;
ret = tsl2563_write(chip->client, TSL2563_REG_INT, chip->intr);
iio_remove_event_from_list(this_attr->listel,
&indio_dev->interrupts[0]->ev_list);
chip->int_enabled = false;
/* now the interrupt is not enabled, we can go to sleep */
schedule_delayed_work(&chip->poweroff_work, 5 * HZ);
Expand Down Expand Up @@ -781,15 +758,14 @@ static ssize_t tsl2563_read_interrupt_config(struct device *dev,

return (ret < 0) ? ret : len;
}

IIO_EVENT_ATTR(intensity0_both_thresh_en,
tsl2563_read_interrupt_config,
tsl2563_write_interrupt_config,
0,
tsl2563_int_th);
static IIO_DEVICE_ATTR(intensity0_both_thresh_en,
S_IRUGO | S_IWUSR,
tsl2563_read_interrupt_config,
tsl2563_write_interrupt_config,
0);

static struct attribute *tsl2563_event_attributes[] = {
&iio_event_attr_intensity0_both_thresh_en.dev_attr.attr,
&iio_dev_attr_intensity0_both_thresh_en.dev_attr.attr,
&iio_dev_attr_intensity0_both_raw_thresh_rising_value.dev_attr.attr,
&iio_dev_attr_intensity0_both_raw_thresh_falling_value.dev_attr.attr,
NULL,
Expand Down Expand Up @@ -820,7 +796,6 @@ static int __devinit tsl2563_probe(struct i2c_client *client,

chip = iio_priv(indio_dev);

INIT_WORK(&chip->work_thresh, tsl2563_int_bh);
i2c_set_clientdata(client, chip);
chip->client = client;

Expand Down Expand Up @@ -865,11 +840,12 @@ static int __devinit tsl2563_probe(struct i2c_client *client,
goto fail1;

if (client->irq) {
ret = iio_register_interrupt_line(client->irq,
indio_dev,
0,
IRQF_TRIGGER_RISING,
client->name);
ret = request_threaded_irq(client->irq,
NULL,
&tsl2563_event_handler,
IRQF_TRIGGER_RISING | IRQF_ONESHOT,
"tsl2563_event",
indio_dev);
if (ret)
goto fail2;
}
Expand All @@ -884,7 +860,7 @@ static int __devinit tsl2563_probe(struct i2c_client *client,
return 0;
fail3:
if (client->irq)
iio_unregister_interrupt_line(indio_dev, 0);
free_irq(client->irq, indio_dev);
fail2:
iio_device_unregister(indio_dev);
fail1:
Expand All @@ -904,7 +880,7 @@ static int tsl2563_remove(struct i2c_client *client)
flush_scheduled_work();
tsl2563_set_power(chip, 0);
if (client->irq)
iio_unregister_interrupt_line(indio_dev, 0);
free_irq(client->irq, indio_dev);
iio_device_unregister(indio_dev);

return 0;
Expand Down

0 comments on commit 53424b8

Please sign in to comment.