~ubuntu-branches/ubuntu/gutsy/linux-source-2.6.22/gutsy-updates

« back to all changes in this revision

Viewing changes to debian/binary-custom.d/lpia/patchset/0002-thermals-ext-sysfs_class.patch

  • Committer: Bazaar Package Importer
  • Author(s): Tim Gardner, Amit Kucheria, Kees Cook, Tim Gardner, Upstream Kernel Changes
  • Date: 2008-01-28 13:46:21 UTC
  • Revision ID: james.westby@ubuntu.com-20080128134621-2g3o1x6zrnf4gf81
Tags: 2.6.22-14.51
[Amit Kucheria]

* Poulsbo: Mass update of all patches from moblin repo
* Update config.lpia to reflect new patches
* [sata_sil][sata->ide-bridg] failed to set xfermode
  - LP: #153096
* Poulsbo: remove extra patch

[Kees Cook]

* fix NFSv4 client mount regression
  - LP: #164231

[Tim Gardner]

* Support of new AMD PowerNow! (family 0x11 and beyond)
  - LP: #185649

[Upstream Kernel Changes]

* minixfs: limit minixfs printks on corrupted dir i_size (CVE-2006-6058)
* [JFFS2] Fix ACL vs. mode handling. (CVE-2007-4849)
* [IEEE80211]: avoid integer underflow for runt rx frames (CVE-2007-4997)
* [TCP]: Make sure write_queue_from does not begin with NULL ptr
  (CVE-2007-5501)
* wait_task_stopped: Check p->exit_state instead of TASK_TRACED
  (CVE-2007-5500)
* fix DLM regression
* CVE-2008-0001: Use access mode instead of open flags to determine
  needed permissions
* hrtimers: avoid overflow for large relative timeouts (CVE-2007-5966)
* isdn: avoid copying overly-long strings (CVE-2007-6063)
* I4L: fix isdn_ioctl memory overrun vulnerability (CVE-2007-6151)
* vfs: coredumping fix (CVE-2007-6206)
* tmpfs: restore missing clear_highpage (CVE-2007-6417)
* [UBUNTU] fs/dlm: Fix regression introduced with last security fix.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
From: Sujith Thomas <sujith.thomas@intel.com>
 
2
 
 
3
Generic fan & memory controller sysfs class driver.
 
4
Fan: Expose state & max_state to /sys/class/fan/<FAN0>
 
5
ACPI fan driver will register to this class driver.
 
6
memory_controller : Expose state & max_state to
 
7
/sys/class/memory_controller/<MEM0>
 
8
 
 
9
Signed-off-by: Sujith Thomas <sujith.thomas@intel.com>
 
10
---
 
11
 
 
12
 drivers/Kconfig                      |    2 
 
13
 drivers/Makefile                     |    1 
 
14
 drivers/sysfsclass/Kconfig        |   30 +++++
 
15
 drivers/sysfsclass/Makefile       |    7 +
 
16
 drivers/sysfsclass/fan_sysfs.c    |  200 ++++++++++++++++++++++++++++++++++++++
 
17
 drivers/sysfsclass/memory_sysfs.c |  199 +++++++++++++++++++++++++++++++++++++
 
18
 include/linux/fan.h               |   66 ++++++++++++
 
19
 include/linux/memory_controller.h |   75 ++++++++++++++
 
20
 8 files changed, 580 insertions(+)
 
21
 
 
22
Index: linux-2.6.22/drivers/Kconfig
 
23
===================================================================
 
24
--- linux-2.6.22.orig/drivers/Kconfig
 
25
+++ linux-2.6.22/drivers/Kconfig
 
26
@@ -12,6 +12,8 @@ source "drivers/parport/Kconfig"
 
27
 
 
28
 source "drivers/pnp/Kconfig"
 
29
 
 
30
+source "drivers/sysfsclass/Kconfig"
 
31
+
 
32
 source "drivers/block/Kconfig"
 
33
 
 
34
 # misc before ide - BLK_DEV_SGIIOC4 depends on SGI_IOC4
 
35
Index: linux-2.6.22/drivers/Makefile
 
36
===================================================================
 
37
--- linux-2.6.22.orig/drivers/Makefile
 
38
+++ linux-2.6.22/drivers/Makefile
 
39
@@ -9,6 +9,7 @@ obj-$(CONFIG_PCI)               += pci/
 
40
 obj-$(CONFIG_PARISC)           += parisc/
 
41
 obj-$(CONFIG_RAPIDIO)          += rapidio/
 
42
 obj-y                          += video/
 
43
+obj-$(CONFIG_SYSFS_DEV_CLASS)  += sysfsclass/
 
44
 obj-$(CONFIG_ACPI)             += acpi/
 
45
 # PnP must come after ACPI since it will eventually need to check if acpi
 
46
 # was used and do nothing if so
 
47
Index: linux-2.6.22/drivers/sysfsclass/Kconfig
 
48
===================================================================
 
49
--- /dev/null
 
50
+++ linux-2.6.22/drivers/sysfsclass/Kconfig
 
51
@@ -0,0 +1,30 @@
 
52
+
 
53
+menu "Sysfs device class support"
 
54
+
 
55
+config SYSFS_DEV_CLASS
 
56
+       bool "Sysfs device class support"
 
57
+       default y
 
58
+       help
 
59
+         Say Y to enable sysfs class driver support for the below devices.
 
60
+
 
61
+config FAN_SYSFS
 
62
+       tristate "Fan class in sysfs"
 
63
+       default y
 
64
+       depends on SYSFS_DEV_CLASS
 
65
+       help
 
66
+         This option enables the support for controlling a generic fan
 
67
+         from sysfs. Sysfs will have attributes to switch the
 
68
+         fan speed into different supported states.
 
69
+
 
70
+config MEMORY_SYSFS
 
71
+       tristate "Memory class in sysfs"
 
72
+       default y
 
73
+       depends on SYSFS_DEV_CLASS
 
74
+       help
 
75
+         This option enables the support for controlling a generic
 
76
+         memory controller from sysfs. Sysfs will have attributes
 
77
+         to control the bandwidth of memory controller.
 
78
+
 
79
+
 
80
+endmenu
 
81
+
 
82
Index: linux-2.6.22/drivers/sysfsclass/Makefile
 
83
===================================================================
 
84
--- /dev/null
 
85
+++ linux-2.6.22/drivers/sysfsclass/Makefile
 
86
@@ -0,0 +1,7 @@
 
87
+#
 
88
+# Makefile for the sysfs class device driver support
 
89
+#
 
90
+
 
91
+
 
92
+obj-$(CONFIG_FAN_SYSFS)                += fan_sysfs.o
 
93
+obj-$(CONFIG_MEMORY_SYSFS)     += memory_sysfs.o
 
94
Index: linux-2.6.22/drivers/sysfsclass/fan_sysfs.c
 
95
===================================================================
 
96
--- /dev/null
 
97
+++ linux-2.6.22/drivers/sysfsclass/fan_sysfs.c
 
98
@@ -0,0 +1,200 @@
 
99
+/*
 
100
+*  fan.c - Fan sysfs driver ($Revision: 1 $)
 
101
+*
 
102
+*  Copyright (C) 2006, 2007 Sujith Thomas <sujith.thomas@intel.com>
 
103
+*  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
104
+*
 
105
+*  This program is free software; you can redistribute it and/or modify
 
106
+*  it under the terms of the GNU General Public License as published by
 
107
+*  the Free Software Foundation; version 2 of the License.
 
108
+*
 
109
+*  This program is distributed in the hope that it will be useful, but
 
110
+*  WITHOUT ANY WARRANTY; without even the implied warranty of
 
111
+*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
112
+*  General Public License for more details.
 
113
+*
 
114
+*  You should have received a copy of the GNU General Public License along
 
115
+*  with this program; if not, write to the Free Software Foundation, Inc.,
 
116
+*  59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
 
117
+*
 
118
+* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
119
+* Sysfs class driver for fan devices. Exposes attributes for get/set
 
120
+* fan speed.
 
121
+*
 
122
+*
 
123
+*/
 
124
+
 
125
+#include <linux/kernel.h>
 
126
+#include <linux/module.h>
 
127
+#include <linux/init.h>
 
128
+#include <linux/types.h>
 
129
+#include <linux/pci.h>
 
130
+#include <linux/fan.h>
 
131
+
 
132
+MODULE_AUTHOR("Sujith Thomas");
 
133
+MODULE_DESCRIPTION("Fan sysfs Driver");
 
134
+MODULE_LICENSE("GPL");
 
135
+
 
136
+static ssize_t state_show(struct class_device *cdev, char *buf)
 
137
+{
 
138
+       struct fan_device *fd;
 
139
+       if (!cdev || !buf)
 
140
+               return 0;
 
141
+
 
142
+       fd = to_fan_device(cdev);
 
143
+       if (fd->ops && fd->ops->get_cur_state)
 
144
+               if (fd->ops->get_cur_state(fd, buf))
 
145
+                       return -EIO;
 
146
+
 
147
+       return strlen(buf);
 
148
+}
 
149
+
 
150
+static ssize_t state_store(struct class_device *cdev, const char *buf,
 
151
+                          size_t count)
 
152
+{
 
153
+       struct fan_device *fd;
 
154
+
 
155
+       if (!cdev || !buf)
 
156
+               return count;
 
157
+
 
158
+       fd = to_fan_device(cdev);
 
159
+       if (fd->ops && fd->ops->set_cur_state)
 
160
+               if (fd->ops->set_cur_state(fd, buf))
 
161
+                       return -EIO;
 
162
+
 
163
+       return count;
 
164
+}
 
165
+
 
166
+static ssize_t max_state_show(struct class_device *cdev, char *buf)
 
167
+{
 
168
+       struct fan_device *fd;
 
169
+       if (!cdev || !buf)
 
170
+               return 0;
 
171
+
 
172
+       fd = to_fan_device(cdev);
 
173
+       if (fd->ops && fd->ops->get_max_state)
 
174
+               if (fd->ops->get_max_state(fd, buf))
 
175
+                       return -EIO;
 
176
+
 
177
+       return strlen(buf);
 
178
+}
 
179
+
 
180
+static void fan_class_release(struct class_device *dev)
 
181
+{
 
182
+       struct fan_device *device = to_fan_device(dev);
 
183
+       kfree(device);
 
184
+}
 
185
+
 
186
+static struct class fan_class = {
 
187
+       .name = "fan",
 
188
+       .release = fan_class_release,
 
189
+};
 
190
+
 
191
+static CLASS_DEVICE_ATTR(state, 0644, state_show, state_store);
 
192
+static CLASS_DEVICE_ATTR(max_state, 0444, max_state_show, NULL);
 
193
+
 
194
+static const struct class_device_attribute *fd_class_dev_attribs[] = {
 
195
+       &class_device_attr_state,
 
196
+       &class_device_attr_max_state,
 
197
+};
 
198
+
 
199
+/*
 
200
+ * fan_device_register
 
201
+ * --------------------------------
 
202
+ * Method for registering fan class of devices with sysfs
 
203
+ * name: The name that should appear in sysfs
 
204
+ * dev : device* on which sysfs folder should appear
 
205
+ * devdata : Device private context
 
206
+ * ops : List of call back functions for various attributes
 
207
+ * Returns either an
 
208
+ * ERR_PTR() or a pointer to the newly allocated device.
 
209
+ */
 
210
+struct fan_device *fan_device_register(const char *name,
 
211
+                                      struct device *dev,
 
212
+                                      void *devdata, struct fan_ops *ops)
 
213
+{
 
214
+       int i, rc;
 
215
+       struct fan_device *new_fd;
 
216
+
 
217
+       if (!name || !ops)
 
218
+               return ERR_PTR(-EINVAL);
 
219
+
 
220
+       pr_debug("fan_device_alloc: name=%s\n", name);
 
221
+
 
222
+       new_fd = kzalloc(sizeof(struct fan_device), GFP_KERNEL);
 
223
+       if (!new_fd)
 
224
+               return ERR_PTR(-ENOMEM);
 
225
+
 
226
+       new_fd->ops = ops;
 
227
+       new_fd->class_dev.class = &fan_class;
 
228
+       new_fd->class_dev.dev = dev;
 
229
+       strlcpy(new_fd->class_dev.class_id, name, KOBJ_NAME_LEN);
 
230
+       class_set_devdata(&new_fd->class_dev, devdata);
 
231
+
 
232
+       rc = class_device_register(&new_fd->class_dev);
 
233
+       if (rc) {
 
234
+               kfree(new_fd);
 
235
+               return ERR_PTR(rc);
 
236
+       }
 
237
+
 
238
+       for (i = 0; i < ARRAY_SIZE(fd_class_dev_attribs); i++) {
 
239
+               rc = class_device_create_file(&new_fd->class_dev,
 
240
+                                             fd_class_dev_attribs[i]);
 
241
+               if (rc) {
 
242
+                       while (--i >= 0)
 
243
+                               class_device_remove_file(&new_fd->class_dev,
 
244
+                                                        fd_class_dev_attribs
 
245
+                                                        [i]);
 
246
+                       class_device_unregister(&new_fd->class_dev);
 
247
+                       /* No need to kfree(new_bd) since release()
 
248
+                          method was called */
 
249
+                       return ERR_PTR(rc);
 
250
+               }
 
251
+       }
 
252
+
 
253
+       return new_fd;
 
254
+}
 
255
+EXPORT_SYMBOL(fan_device_register);
 
256
+
 
257
+/*
 
258
+ * fan_device_unregister
 
259
+ * ----------------------------------
 
260
+ * Method for unregistering fan devices  with sysfs
 
261
+ * fd: Pointer to fan device
 
262
+ */
 
263
+void fan_device_unregister(struct fan_device *fd)
 
264
+{
 
265
+       int i;
 
266
+
 
267
+       if (!fd)
 
268
+               return;
 
269
+
 
270
+       pr_debug("fan_device_unregister: name=%s\n", fd->class_dev.class_id);
 
271
+
 
272
+       for (i = 0; i < ARRAY_SIZE(fd_class_dev_attribs); i++)
 
273
+               class_device_remove_file(&fd->class_dev,
 
274
+                                        fd_class_dev_attribs[i]);
 
275
+
 
276
+       fd->ops = NULL;
 
277
+
 
278
+       class_device_unregister(&fd->class_dev);
 
279
+}
 
280
+EXPORT_SYMBOL(fan_device_unregister);
 
281
+
 
282
+static int __init fan_device_init(void)
 
283
+{
 
284
+       return class_register(&fan_class);
 
285
+}
 
286
+
 
287
+static void __exit fan_device_exit(void)
 
288
+{
 
289
+       class_unregister(&fan_class);
 
290
+}
 
291
+
 
292
+/*
 
293
+ * if this is compiled into the kernel, we need to ensure that the
 
294
+ * class is registered before users of the class try to register lcd's
 
295
+ */
 
296
+
 
297
+postcore_initcall(fan_device_init);
 
298
+module_exit(fan_device_exit);
 
299
Index: linux-2.6.22/drivers/sysfsclass/memory_sysfs.c
 
300
===================================================================
 
301
--- /dev/null
 
302
+++ linux-2.6.22/drivers/sysfsclass/memory_sysfs.c
 
303
@@ -0,0 +1,199 @@
 
304
+/*
 
305
+*  memory_controller.c - Memory controller sysfs driver ($Revision: 1 $)
 
306
+*
 
307
+*  Copyright (C) 2006, 2007 Sujith Thomas <sujith.thomas@intel.com>
 
308
+*  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
309
+*
 
310
+*  This program is free software; you can redistribute it and/or modify
 
311
+*  it under the terms of the GNU General Public License as published by
 
312
+*  the Free Software Foundation; version 2 of the License.
 
313
+*
 
314
+*  This program is distributed in the hope that it will be useful, but
 
315
+*  WITHOUT ANY WARRANTY; without even the implied warranty of
 
316
+*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
317
+*  General Public License for more details.
 
318
+*
 
319
+*  You should have received a copy of the GNU General Public License along
 
320
+*  with this program; if not, write to the Free Software Foundation, Inc.,
 
321
+*  59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
 
322
+*
 
323
+* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
324
+* Sysfs class driver for memory_controller. Exposes attributes for get/set
 
325
+* memory bandwidth
 
326
+*
 
327
+*
 
328
+*/
 
329
+
 
330
+#include <linux/kernel.h>
 
331
+#include <linux/module.h>
 
332
+#include <linux/init.h>
 
333
+#include <linux/types.h>
 
334
+#include <linux/pci.h>
 
335
+#include <linux/memory_controller.h>
 
336
+
 
337
+MODULE_AUTHOR("Sujith Thomas");
 
338
+MODULE_DESCRIPTION("Memory controller sysfs Driver");
 
339
+MODULE_LICENSE("GPL");
 
340
+
 
341
+static ssize_t bandwidth_show(struct class_device *cdev, char *buf)
 
342
+{
 
343
+       struct memory_controller_device *mc;
 
344
+
 
345
+       if (!cdev || !buf)
 
346
+               return 0;
 
347
+
 
348
+       mc = to_memory_controller_device(cdev);
 
349
+       if (mc->ops && mc->ops->get_cur_bandwidth)
 
350
+               if (mc->ops->get_cur_bandwidth(mc, buf))
 
351
+                       return -EIO;
 
352
+
 
353
+       return strlen(buf);
 
354
+}
 
355
+
 
356
+static ssize_t bandwidth_store(struct class_device *cdev, const char *buf,
 
357
+                              size_t count)
 
358
+{
 
359
+       struct memory_controller_device *mc;
 
360
+       if (!cdev || !buf)
 
361
+               return count;
 
362
+
 
363
+       mc = to_memory_controller_device(cdev);
 
364
+       if (mc->ops && mc->ops->set_cur_bandwidth)
 
365
+               if (mc->ops->set_cur_bandwidth(mc, buf))
 
366
+                       return -EIO;
 
367
+
 
368
+       return count;
 
369
+}
 
370
+
 
371
+static ssize_t max_bandwidth_show(struct class_device *cdev, char *buf)
 
372
+{
 
373
+       struct memory_controller_device *mc;
 
374
+       if (!cdev || !buf)
 
375
+               return 0;
 
376
+
 
377
+       mc = to_memory_controller_device(cdev);
 
378
+       if (mc->ops && mc->ops->get_max_bandwidth)
 
379
+               if (mc->ops->get_max_bandwidth(mc, buf))
 
380
+                       return -EIO;
 
381
+
 
382
+       return strlen(buf);
 
383
+}
 
384
+
 
385
+static void memory_controller_class_release(struct class_device *dev)
 
386
+{
 
387
+       struct memory_controller_device *device =
 
388
+           to_memory_controller_device(dev);
 
389
+       kfree(device);
 
390
+}
 
391
+
 
392
+static struct class memory_controller_class = {
 
393
+       .name = "memory_controller",
 
394
+       .release = memory_controller_class_release,
 
395
+};
 
396
+
 
397
+static CLASS_DEVICE_ATTR(state, 0644, bandwidth_show, bandwidth_store);
 
398
+static CLASS_DEVICE_ATTR(max_state, 0444, max_bandwidth_show, NULL);
 
399
+
 
400
+static const struct class_device_attribute  *mc_class_dev_attribs[] = {
 
401
+       &class_device_attr_state,
 
402
+       &class_device_attr_max_state,
 
403
+};
 
404
+
 
405
+/*
 
406
+ * memory_controller_device_register
 
407
+ * --------------------------------
 
408
+ * Method for registering memory_controller class of devices with sysfs
 
409
+ * name: The name that should appear in sysfs
 
410
+ * dev : device* on which sysfs folder should appear
 
411
+ * devdata : Device private context
 
412
+ * ops : List of call back functions for various attributes
 
413
+ * Returns either an
 
414
+ * ERR_PTR() or a pointer to the newly allocated device.
 
415
+ */
 
416
+struct memory_controller_device *
 
417
+memory_controller_device_register(const char *name
 
418
+                                 , struct device *dev
 
419
+                                 , void *devdata
 
420
+                                 , struct memory_controller_ops *ops)
 
421
+{
 
422
+       int i, rc;
 
423
+       struct memory_controller_device *new_mc;
 
424
+
 
425
+       if (!name || !ops)
 
426
+               return ERR_PTR(-EINVAL);
 
427
+
 
428
+       pr_debug("memory_controller_device_alloc: name=%s\n", name);
 
429
+
 
430
+       new_mc = kzalloc(sizeof(struct memory_controller_device), GFP_KERNEL);
 
431
+       if (!new_mc)
 
432
+               return ERR_PTR(-ENOMEM);
 
433
+
 
434
+       new_mc->ops = ops;
 
435
+       new_mc->class_dev.class = &memory_controller_class;
 
436
+       new_mc->class_dev.dev = dev;
 
437
+       strlcpy(new_mc->class_dev.class_id, name, KOBJ_NAME_LEN);
 
438
+       class_set_devdata(&new_mc->class_dev, devdata);
 
439
+
 
440
+       rc = class_device_register(&new_mc->class_dev);
 
441
+       if (rc) {
 
442
+               kfree(new_mc);
 
443
+               return ERR_PTR(rc);
 
444
+       }
 
445
+
 
446
+       for (i = 0; i < ARRAY_SIZE(mc_class_dev_attribs); i++) {
 
447
+               rc = class_device_create_file(&new_mc->class_dev,
 
448
+                                             mc_class_dev_attribs[i]);
 
449
+               if (rc) {
 
450
+                       while (--i >= 0)
 
451
+                               class_device_remove_file(&new_mc->class_dev,
 
452
+                                                        mc_class_dev_attribs
 
453
+                                                        [i]);
 
454
+                       class_device_unregister(&new_mc->class_dev);
 
455
+                       /* No need to kfree(new_bd) since release()
 
456
+                          method was called */
 
457
+                       return ERR_PTR(rc);
 
458
+               }
 
459
+       }
 
460
+
 
461
+       return new_mc;
 
462
+}
 
463
+EXPORT_SYMBOL(memory_controller_device_register);
 
464
+
 
465
+/*
 
466
+ * memory_controller_device_unregister
 
467
+ * ----------------------------------
 
468
+ * Method for unregistering memory_controller devices  with sysfs
 
469
+ * mc: Pointer to memory_controller device
 
470
+ */
 
471
+void memory_controller_device_unregister(struct memory_controller_device *mc)
 
472
+{
 
473
+       int i;
 
474
+
 
475
+       if (!mc)
 
476
+               return;
 
477
+
 
478
+       pr_debug("memory_controller_device_unregister: name=%s\n",
 
479
+                mc->class_dev.class_id);
 
480
+
 
481
+       for (i = 0; i < ARRAY_SIZE(mc_class_dev_attribs); i++)
 
482
+               class_device_remove_file(&mc->class_dev,
 
483
+                                        mc_class_dev_attribs[i]);
 
484
+
 
485
+       mc->ops = NULL;
 
486
+
 
487
+       class_device_unregister(&mc->class_dev);
 
488
+}
 
489
+EXPORT_SYMBOL(memory_controller_device_unregister);
 
490
+
 
491
+static int __init memory_controller_device_init(void)
 
492
+{
 
493
+       return class_register(&memory_controller_class);
 
494
+}
 
495
+
 
496
+static void __exit memory_controller_device_exit(void)
 
497
+{
 
498
+       class_unregister(&memory_controller_class);
 
499
+}
 
500
+
 
501
+module_init(memory_controller_device_init);
 
502
+module_exit(memory_controller_device_exit);
 
503
Index: linux-2.6.22/include/linux/fan.h
 
504
===================================================================
 
505
--- /dev/null
 
506
+++ linux-2.6.22/include/linux/fan.h
 
507
@@ -0,0 +1,66 @@
 
508
+/*
 
509
+*  fan.h - Generic fan driver for sysfs ($Revision: 1 $)
 
510
+*
 
511
+*  Copyright (C) 2006, 2007 Sujith Thomas <sujith.thomas@intel.com>
 
512
+*  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
513
+*
 
514
+*  This program is free software; you can redistribute it and/or modify
 
515
+*  it under the terms of the GNU General Public License as published by
 
516
+*  the Free Software Foundation; version 2 of the License.
 
517
+*
 
518
+*  This program is distributed in the hope that it will be useful, but
 
519
+*  WITHOUT ANY WARRANTY; without even the implied warranty of
 
520
+*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
521
+*  General Public License for more details.
 
522
+*
 
523
+*  You should have received a copy of the GNU General Public License along
 
524
+*  with this program; if not, write to the Free Software Foundation, Inc.,
 
525
+*  59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
 
526
+*
 
527
+* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
528
+* Sysfs class driver for fan devices. Exposes attributes for get/set
 
529
+* fan speed.
 
530
+*
 
531
+*
 
532
+*/
 
533
+
 
534
+#include <linux/device.h>
 
535
+
 
536
+struct fan_device;
 
537
+
 
538
+struct fan_ops {
 
539
+       int (*get_max_state) (struct fan_device *device, char *buf);
 
540
+       int (*get_cur_state) (struct fan_device *device, char *buf);
 
541
+       int (*set_cur_state) (struct fan_device *device, const char *buf);
 
542
+};
 
543
+
 
544
+struct fan_device {
 
545
+       struct fan_ops *ops;
 
546
+       struct class sysfs_class;       /* '/sys/class' entry */
 
547
+       struct class_device class_dev;  /*class device entry in sys/class*/
 
548
+};
 
549
+
 
550
+/*
 
551
+ * fan_device_register
 
552
+ * --------------------------------
 
553
+ * Method for registering fan class of devices with sysfs
 
554
+ * name: The name that should appear in sysfs
 
555
+ * dev : device* on which sysfs folder should appear
 
556
+ * devdata : Device private context
 
557
+ * ops : List of call back functions for various attributes
 
558
+ * Returns either an
 
559
+ * ERR_PTR() or a pointer to the newly allocated device.
 
560
+ */
 
561
+struct fan_device *fan_device_register(const char *name,
 
562
+                                      struct device *dev, void *devdata,
 
563
+                                      struct fan_ops *ops);
 
564
+
 
565
+/*
 
566
+ * fan_device_unregister
 
567
+ * ----------------------------------
 
568
+ * Method for unregistering fan devices  with sysfs
 
569
+ * fd: Pointer to fan device
 
570
+ */
 
571
+void fan_device_unregister(struct fan_device *device);
 
572
+
 
573
+#define to_fan_device(obj) container_of(obj, struct fan_device, class_dev)
 
574
Index: linux-2.6.22/include/linux/memory_controller.h
 
575
===================================================================
 
576
--- /dev/null
 
577
+++ linux-2.6.22/include/linux/memory_controller.h
 
578
@@ -0,0 +1,75 @@
 
579
+/*
 
580
+*  memory_controller.h - Generic memory controller driver for sysfs
 
581
+* ($Revision: 1 $)
 
582
+*
 
583
+*  Copyright (C) 2006, 2007 Sujith Thomas <sujith.thomas@intel.com>
 
584
+*  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
585
+*
 
586
+*  This program is free software; you can redistribute it and/or modify
 
587
+*  it under the terms of the GNU General Public License as published by
 
588
+*  the Free Software Foundation; version 2 of the License.
 
589
+*
 
590
+*  This program is distributed in the hope that it will be useful, but
 
591
+*  WITHOUT ANY WARRANTY; without even the implied warranty of
 
592
+*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
593
+*  General Public License for more details.
 
594
+*
 
595
+*  You should have received a copy of the GNU General Public License along
 
596
+*  with this program; if not, write to the Free Software Foundation, Inc.,
 
597
+*  59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
 
598
+*
 
599
+* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
600
+* Sysfs class driver for memory_controller. Exposes attributes for get/set
 
601
+* memory bandwidth
 
602
+*
 
603
+*
 
604
+*/
 
605
+
 
606
+#include <linux/device.h>
 
607
+
 
608
+struct memory_controller_device;
 
609
+
 
610
+/* Callback functions to the actual memory device driver */
 
611
+struct memory_controller_ops {
 
612
+       int (*get_max_bandwidth) (struct memory_controller_device *device,
 
613
+                                 char *buf);
 
614
+       int (*get_cur_bandwidth) (struct memory_controller_device *device,
 
615
+                                 char *buf);
 
616
+       int (*set_cur_bandwidth) (struct memory_controller_device *device,
 
617
+                                 const char *buf);
 
618
+};
 
619
+
 
620
+struct memory_controller_device {
 
621
+       struct memory_controller_ops *ops;      /* Callback routines */
 
622
+       struct class sysfs_class;       /* '/sys/class' entry*/
 
623
+       struct class_device class_dev;  /*class device entry in sys/class*/
 
624
+};
 
625
+
 
626
+/*
 
627
+ * memory_controller_device_register
 
628
+ * --------------------------------
 
629
+ * Method for registering memory_controller class of devices with sysfs
 
630
+ * name: The name that should appear in sysfs
 
631
+ * dev : device* on which sysfs folder should appear
 
632
+ * devdata : Device private context
 
633
+ * ops : List of call back functions for various attributes
 
634
+ * Returns either an
 
635
+ * ERR_PTR() or a pointer to the newly allocated device.
 
636
+ */
 
637
+struct memory_controller_device *
 
638
+memory_controller_device_register(const char *name
 
639
+                                 , struct device *dev
 
640
+                                 , void *devdata
 
641
+                                 , struct memory_controller_ops *ops);
 
642
+
 
643
+/*
 
644
+ * memory_controller_device_unregister
 
645
+ * ----------------------------------
 
646
+ * Method for unregistering memory_controller devices  with sysfs
 
647
+ * mc: Pointer to memory_controller device
 
648
+ */
 
649
+void memory_controller_device_unregister(struct memory_controller_device
 
650
+                                        *device);
 
651
+
 
652
+#define to_memory_controller_device(obj) \
 
653
+container_of(obj, struct memory_controller_device, class_dev)