mac80211: A-MPDU Rx adding basic functionality
[safe/jmp/linux-2.6] / include / linux / ioprio.h
index 7811300..2a3bb1b 100644 (file)
@@ -2,6 +2,7 @@
 #define IOPRIO_H
 
 #include <linux/sched.h>
+#include <linux/iocontext.h>
 
 /*
  * Gives us 8 prio classes with 13-bits of data for each class
@@ -12,6 +13,7 @@
 
 #define IOPRIO_PRIO_CLASS(mask)        ((mask) >> IOPRIO_CLASS_SHIFT)
 #define IOPRIO_PRIO_DATA(mask) ((mask) & IOPRIO_PRIO_MASK)
+#define IOPRIO_PRIO_VALUE(class, data) (((class) << IOPRIO_CLASS_SHIFT) | data)
 
 #define ioprio_valid(mask)     (IOPRIO_PRIO_CLASS((mask)) != IOPRIO_CLASS_NONE)
 
@@ -33,9 +35,6 @@ enum {
  */
 #define IOPRIO_BE_NR   (8)
 
-asmlinkage int sys_ioprio_set(int, int, int);
-asmlinkage int sys_ioprio_get(int, int);
-
 enum {
        IOPRIO_WHO_PROCESS = 1,
        IOPRIO_WHO_PGRP,
@@ -47,10 +46,20 @@ enum {
  * the cpu scheduler nice value to an io priority
  */
 #define IOPRIO_NORM    (4)
-static inline int task_ioprio(struct task_struct *task)
+static inline int task_ioprio(struct io_context *ioc)
+{
+       if (ioprio_valid(ioc->ioprio))
+               return IOPRIO_PRIO_DATA(ioc->ioprio);
+
+       return IOPRIO_NORM;
+}
+
+static inline int task_ioprio_class(struct io_context *ioc)
 {
-       WARN_ON(!ioprio_valid(task->ioprio));
-       return IOPRIO_PRIO_DATA(task->ioprio);
+       if (ioprio_valid(ioc->ioprio))
+               return IOPRIO_PRIO_CLASS(ioc->ioprio);
+
+       return IOPRIO_CLASS_BE;
 }
 
 static inline int task_nice_ioprio(struct task_struct *task)
@@ -61,27 +70,6 @@ static inline int task_nice_ioprio(struct task_struct *task)
 /*
  * For inheritance, return the highest of the two given priorities
  */
-static inline int ioprio_best(unsigned short aprio, unsigned short bprio)
-{
-       unsigned short aclass = IOPRIO_PRIO_CLASS(aprio);
-       unsigned short bclass = IOPRIO_PRIO_CLASS(bprio);
-
-       if (!ioprio_valid(aprio))
-               return bprio;
-       if (!ioprio_valid(bprio))
-               return aprio;
-
-       if (aclass == IOPRIO_CLASS_NONE)
-               aclass = IOPRIO_CLASS_BE;
-       if (bclass == IOPRIO_CLASS_NONE)
-               bclass = IOPRIO_CLASS_BE;
-
-       if (aclass == bclass)
-               return min(aprio, bprio);
-       if (aclass > bclass)
-               return bprio;
-       else
-               return aprio;
-}
+extern int ioprio_best(unsigned short aprio, unsigned short bprio);
 
 #endif