mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-21 06:50:25 +00:00
staging:iio:light:tsl2563 remove old style event registration.
Untested. Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
parent
b26a2188e0
commit
bdab100173
1 changed files with 19 additions and 43 deletions
|
@ -117,8 +117,6 @@ struct tsl2563_chip {
|
||||||
struct i2c_client *client;
|
struct i2c_client *client;
|
||||||
struct delayed_work poweroff_work;
|
struct delayed_work poweroff_work;
|
||||||
|
|
||||||
struct work_struct work_thresh;
|
|
||||||
s64 event_timestamp;
|
|
||||||
/* Remember state for suspend and resume functions */
|
/* Remember state for suspend and resume functions */
|
||||||
pm_message_t state;
|
pm_message_t state;
|
||||||
|
|
||||||
|
@ -677,38 +675,22 @@ static IIO_DEVICE_ATTR(intensity0_both_raw_thresh_falling_value,
|
||||||
tsl2563_write_thresh,
|
tsl2563_write_thresh,
|
||||||
TSL2563_REG_LOWLOW);
|
TSL2563_REG_LOWLOW);
|
||||||
|
|
||||||
static int tsl2563_int_th(struct iio_dev *dev_info,
|
static irqreturn_t tsl2563_event_handler(int irq, void *private)
|
||||||
int index,
|
|
||||||
s64 timestamp,
|
|
||||||
int not_test)
|
|
||||||
{
|
{
|
||||||
|
struct iio_dev *dev_info = private;
|
||||||
struct tsl2563_chip *chip = iio_priv(dev_info);
|
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;
|
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,
|
IIO_UNMOD_EVENT_CODE(IIO_EV_CLASS_LIGHT,
|
||||||
0,
|
0,
|
||||||
IIO_EV_TYPE_THRESH,
|
IIO_EV_TYPE_THRESH,
|
||||||
IIO_EV_DIR_EITHER),
|
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 */
|
/* clear the interrupt and push the event */
|
||||||
i2c_master_send(chip->client, &cmd, sizeof(cmd));
|
i2c_master_send(chip->client, &cmd, sizeof(cmd));
|
||||||
|
return IRQ_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t tsl2563_write_interrupt_config(struct device *dev,
|
static ssize_t tsl2563_write_interrupt_config(struct device *dev,
|
||||||
|
@ -718,7 +700,6 @@ static ssize_t tsl2563_write_interrupt_config(struct device *dev,
|
||||||
{
|
{
|
||||||
struct iio_dev *indio_dev = dev_get_drvdata(dev);
|
struct iio_dev *indio_dev = dev_get_drvdata(dev);
|
||||||
struct tsl2563_chip *chip = iio_priv(indio_dev);
|
struct tsl2563_chip *chip = iio_priv(indio_dev);
|
||||||
struct iio_event_attr *this_attr = to_iio_event_attr(attr);
|
|
||||||
int input, ret = 0;
|
int input, ret = 0;
|
||||||
|
|
||||||
ret = sscanf(buf, "%d", &input);
|
ret = sscanf(buf, "%d", &input);
|
||||||
|
@ -726,8 +707,6 @@ static ssize_t tsl2563_write_interrupt_config(struct device *dev,
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
mutex_lock(&chip->lock);
|
mutex_lock(&chip->lock);
|
||||||
if (input && !(chip->intr & 0x30)) {
|
if (input && !(chip->intr & 0x30)) {
|
||||||
iio_add_event_to_list(this_attr->listel,
|
|
||||||
&indio_dev->interrupts[0]->ev_list);
|
|
||||||
chip->intr &= ~0x30;
|
chip->intr &= ~0x30;
|
||||||
chip->intr |= 0x10;
|
chip->intr |= 0x10;
|
||||||
/* ensure the chip is actually on */
|
/* ensure the chip is actually on */
|
||||||
|
@ -747,8 +726,6 @@ static ssize_t tsl2563_write_interrupt_config(struct device *dev,
|
||||||
if (!input && (chip->intr & 0x30)) {
|
if (!input && (chip->intr & 0x30)) {
|
||||||
chip->intr |= ~0x30;
|
chip->intr |= ~0x30;
|
||||||
ret = tsl2563_write(chip->client, TSL2563_REG_INT, chip->intr);
|
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;
|
chip->int_enabled = false;
|
||||||
/* now the interrupt is not enabled, we can go to sleep */
|
/* now the interrupt is not enabled, we can go to sleep */
|
||||||
schedule_delayed_work(&chip->poweroff_work, 5 * HZ);
|
schedule_delayed_work(&chip->poweroff_work, 5 * HZ);
|
||||||
|
@ -781,15 +758,14 @@ error_ret:
|
||||||
|
|
||||||
return (ret < 0) ? ret : len;
|
return (ret < 0) ? ret : len;
|
||||||
}
|
}
|
||||||
|
static IIO_DEVICE_ATTR(intensity0_both_thresh_en,
|
||||||
IIO_EVENT_ATTR(intensity0_both_thresh_en,
|
S_IRUGO | S_IWUSR,
|
||||||
tsl2563_read_interrupt_config,
|
tsl2563_read_interrupt_config,
|
||||||
tsl2563_write_interrupt_config,
|
tsl2563_write_interrupt_config,
|
||||||
0,
|
0);
|
||||||
tsl2563_int_th);
|
|
||||||
|
|
||||||
static struct attribute *tsl2563_event_attributes[] = {
|
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_rising_value.dev_attr.attr,
|
||||||
&iio_dev_attr_intensity0_both_raw_thresh_falling_value.dev_attr.attr,
|
&iio_dev_attr_intensity0_both_raw_thresh_falling_value.dev_attr.attr,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -820,7 +796,6 @@ static int __devinit tsl2563_probe(struct i2c_client *client,
|
||||||
|
|
||||||
chip = iio_priv(indio_dev);
|
chip = iio_priv(indio_dev);
|
||||||
|
|
||||||
INIT_WORK(&chip->work_thresh, tsl2563_int_bh);
|
|
||||||
i2c_set_clientdata(client, chip);
|
i2c_set_clientdata(client, chip);
|
||||||
chip->client = client;
|
chip->client = client;
|
||||||
|
|
||||||
|
@ -865,11 +840,12 @@ static int __devinit tsl2563_probe(struct i2c_client *client,
|
||||||
goto fail1;
|
goto fail1;
|
||||||
|
|
||||||
if (client->irq) {
|
if (client->irq) {
|
||||||
ret = iio_register_interrupt_line(client->irq,
|
ret = request_threaded_irq(client->irq,
|
||||||
indio_dev,
|
NULL,
|
||||||
0,
|
&tsl2563_event_handler,
|
||||||
IRQF_TRIGGER_RISING,
|
IRQF_TRIGGER_RISING | IRQF_ONESHOT,
|
||||||
client->name);
|
"tsl2563_event",
|
||||||
|
indio_dev);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto fail2;
|
goto fail2;
|
||||||
}
|
}
|
||||||
|
@ -884,7 +860,7 @@ static int __devinit tsl2563_probe(struct i2c_client *client,
|
||||||
return 0;
|
return 0;
|
||||||
fail3:
|
fail3:
|
||||||
if (client->irq)
|
if (client->irq)
|
||||||
iio_unregister_interrupt_line(indio_dev, 0);
|
free_irq(client->irq, indio_dev);
|
||||||
fail2:
|
fail2:
|
||||||
iio_device_unregister(indio_dev);
|
iio_device_unregister(indio_dev);
|
||||||
fail1:
|
fail1:
|
||||||
|
@ -904,7 +880,7 @@ static int tsl2563_remove(struct i2c_client *client)
|
||||||
flush_scheduled_work();
|
flush_scheduled_work();
|
||||||
tsl2563_set_power(chip, 0);
|
tsl2563_set_power(chip, 0);
|
||||||
if (client->irq)
|
if (client->irq)
|
||||||
iio_unregister_interrupt_line(indio_dev, 0);
|
free_irq(client->irq, indio_dev);
|
||||||
iio_device_unregister(indio_dev);
|
iio_device_unregister(indio_dev);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue