~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to drivers/staging/iio/trigger/iio-trig-periodic-rtc.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
72
72
        return ret;
73
73
}
74
74
 
75
 
static IIO_TRIGGER_NAME_ATTR;
76
75
static DEVICE_ATTR(frequency, S_IRUGO | S_IWUSR,
77
76
            iio_trig_periodic_read_freq,
78
77
            iio_trig_periodic_write_freq);
79
78
 
80
79
static struct attribute *iio_trig_prtc_attrs[] = {
81
80
        &dev_attr_frequency.attr,
82
 
        &dev_attr_name.attr,
83
81
        NULL,
84
82
};
 
83
 
85
84
static const struct attribute_group iio_trig_prtc_attr_group = {
86
85
        .attrs = iio_trig_prtc_attrs,
87
86
};
88
87
 
 
88
static const struct attribute_group *iio_trig_prtc_attr_groups[] = {
 
89
        &iio_trig_prtc_attr_group,
 
90
        NULL
 
91
};
 
92
 
89
93
static void iio_prtc_trigger_poll(void *private_data)
90
94
{
91
95
        /* Timestamp is not provided currently */
103
107
        for (i = 0;; i++) {
104
108
                if (pdata[i] == NULL)
105
109
                        break;
106
 
                trig = iio_allocate_trigger();
 
110
                trig = iio_allocate_trigger("periodic%s", pdata[i]);
107
111
                if (!trig) {
108
112
                        ret = -ENOMEM;
109
113
                        goto error_free_completed_registrations;
118
122
                trig->private_data = trig_info;
119
123
                trig->owner = THIS_MODULE;
120
124
                trig->set_trigger_state = &iio_trig_periodic_rtc_set_state;
121
 
                trig->name = kasprintf(GFP_KERNEL, "periodic%s", pdata[i]);
122
 
                if (trig->name == NULL) {
123
 
                        ret = -ENOMEM;
124
 
                        goto error_free_trig_info;
125
 
                }
126
 
 
127
125
                /* RTC access */
128
126
                trig_info->rtc
129
127
                        = rtc_class_open(pdata[i]);
130
128
                if (trig_info->rtc == NULL) {
131
129
                        ret = -EINVAL;
132
 
                        goto error_free_name;
 
130
                        goto error_free_trig_info;
133
131
                }
134
132
                trig_info->task.func = iio_prtc_trigger_poll;
135
133
                trig_info->task.private_data = trig;
136
134
                ret = rtc_irq_register(trig_info->rtc, &trig_info->task);
137
135
                if (ret)
138
136
                        goto error_close_rtc;
139
 
                trig->control_attrs = &iio_trig_prtc_attr_group;
 
137
                trig->dev.groups = iio_trig_prtc_attr_groups;
140
138
                ret = iio_trigger_register(trig);
141
139
                if (ret)
142
140
                        goto error_unregister_rtc_irq;
146
144
        rtc_irq_unregister(trig_info->rtc, &trig_info->task);
147
145
error_close_rtc:
148
146
        rtc_class_close(trig_info->rtc);
149
 
error_free_name:
150
 
        kfree(trig->name);
151
147
error_free_trig_info:
152
148
        kfree(trig_info);
153
149
error_put_trigger_and_remove_from_list:
161
157
                trig_info = trig->private_data;
162
158
                rtc_irq_unregister(trig_info->rtc, &trig_info->task);
163
159
                rtc_class_close(trig_info->rtc);
164
 
                kfree(trig->name);
165
160
                kfree(trig_info);
166
161
                iio_trigger_unregister(trig);
167
162
        }
180
175
                trig_info = trig->private_data;
181
176
                rtc_irq_unregister(trig_info->rtc, &trig_info->task);
182
177
                rtc_class_close(trig_info->rtc);
183
 
                kfree(trig->name);
184
178
                kfree(trig_info);
185
179
                iio_trigger_unregister(trig);
186
180
        }