diff options
-rw-r--r-- | drivers/media/video/cx18/cx18-driver.h | 19 | ||||
-rw-r--r-- | drivers/media/video/ivtv/ivtv-driver.h | 14 | ||||
-rw-r--r-- | include/media/v4l2-device.h | 57 |
3 files changed, 63 insertions, 27 deletions
diff --git a/drivers/media/video/cx18/cx18-driver.h b/drivers/media/video/cx18/cx18-driver.h index 9bc51a99376b..77be58c1096b 100644 --- a/drivers/media/video/cx18/cx18-driver.h +++ b/drivers/media/video/cx18/cx18-driver.h | |||
@@ -674,18 +674,25 @@ static inline int cx18_raw_vbi(const struct cx18 *cx) | |||
674 | 674 | ||
675 | /* Call the specified callback for all subdevs with a grp_id bit matching the | 675 | /* Call the specified callback for all subdevs with a grp_id bit matching the |
676 | * mask in hw (if 0, then match them all). Ignore any errors. */ | 676 | * mask in hw (if 0, then match them all). Ignore any errors. */ |
677 | #define cx18_call_hw(cx, hw, o, f, args...) \ | 677 | #define cx18_call_hw(cx, hw, o, f, args...) \ |
678 | __v4l2_device_call_subdevs(&(cx)->v4l2_dev, \ | 678 | do { \ |
679 | !(hw) || (sd->grp_id & (hw)), o, f , ##args) | 679 | struct v4l2_subdev *__sd; \ |
680 | __v4l2_device_call_subdevs_p(&(cx)->v4l2_dev, __sd, \ | ||
681 | !(hw) || (__sd->grp_id & (hw)), o, f , ##args); \ | ||
682 | } while (0) | ||
680 | 683 | ||
681 | #define cx18_call_all(cx, o, f, args...) cx18_call_hw(cx, 0, o, f , ##args) | 684 | #define cx18_call_all(cx, o, f, args...) cx18_call_hw(cx, 0, o, f , ##args) |
682 | 685 | ||
683 | /* Call the specified callback for all subdevs with a grp_id bit matching the | 686 | /* Call the specified callback for all subdevs with a grp_id bit matching the |
684 | * mask in hw (if 0, then match them all). If the callback returns an error | 687 | * mask in hw (if 0, then match them all). If the callback returns an error |
685 | * other than 0 or -ENOIOCTLCMD, then return with that error code. */ | 688 | * other than 0 or -ENOIOCTLCMD, then return with that error code. */ |
686 | #define cx18_call_hw_err(cx, hw, o, f, args...) \ | 689 | #define cx18_call_hw_err(cx, hw, o, f, args...) \ |
687 | __v4l2_device_call_subdevs_until_err( \ | 690 | ({ \ |
688 | &(cx)->v4l2_dev, !(hw) || (sd->grp_id & (hw)), o, f , ##args) | 691 | struct v4l2_subdev *__sd; \ |
692 | __v4l2_device_call_subdevs_until_err_p(&(cx)->v4l2_dev, \ | ||
693 | __sd, !(hw) || (__sd->grp_id & (hw)), o, f, \ | ||
694 | ##args); \ | ||
695 | }) | ||
689 | 696 | ||
690 | #define cx18_call_all_err(cx, o, f, args...) \ | 697 | #define cx18_call_all_err(cx, o, f, args...) \ |
691 | cx18_call_hw_err(cx, 0, o, f , ##args) | 698 | cx18_call_hw_err(cx, 0, o, f , ##args) |
diff --git a/drivers/media/video/ivtv/ivtv-driver.h b/drivers/media/video/ivtv/ivtv-driver.h index 75803141481e..04bacdbd10bb 100644 --- a/drivers/media/video/ivtv/ivtv-driver.h +++ b/drivers/media/video/ivtv/ivtv-driver.h | |||
@@ -811,15 +811,23 @@ static inline int ivtv_raw_vbi(const struct ivtv *itv) | |||
811 | /* Call the specified callback for all subdevs matching hw (if 0, then | 811 | /* Call the specified callback for all subdevs matching hw (if 0, then |
812 | match them all). Ignore any errors. */ | 812 | match them all). Ignore any errors. */ |
813 | #define ivtv_call_hw(itv, hw, o, f, args...) \ | 813 | #define ivtv_call_hw(itv, hw, o, f, args...) \ |
814 | __v4l2_device_call_subdevs(&(itv)->v4l2_dev, !(hw) || (sd->grp_id & (hw)), o, f , ##args) | 814 | do { \ |
815 | struct v4l2_subdev *__sd; \ | ||
816 | __v4l2_device_call_subdevs_p(&(itv)->v4l2_dev, __sd, \ | ||
817 | !(hw) || (__sd->grp_id & (hw)), o, f , ##args); \ | ||
818 | } while (0) | ||
815 | 819 | ||
816 | #define ivtv_call_all(itv, o, f, args...) ivtv_call_hw(itv, 0, o, f , ##args) | 820 | #define ivtv_call_all(itv, o, f, args...) ivtv_call_hw(itv, 0, o, f , ##args) |
817 | 821 | ||
818 | /* Call the specified callback for all subdevs matching hw (if 0, then | 822 | /* Call the specified callback for all subdevs matching hw (if 0, then |
819 | match them all). If the callback returns an error other than 0 or | 823 | match them all). If the callback returns an error other than 0 or |
820 | -ENOIOCTLCMD, then return with that error code. */ | 824 | -ENOIOCTLCMD, then return with that error code. */ |
821 | #define ivtv_call_hw_err(itv, hw, o, f, args...) \ | 825 | #define ivtv_call_hw_err(itv, hw, o, f, args...) \ |
822 | __v4l2_device_call_subdevs_until_err(&(itv)->v4l2_dev, !(hw) || (sd->grp_id & (hw)), o, f , ##args) | 826 | ({ \ |
827 | struct v4l2_subdev *__sd; \ | ||
828 | __v4l2_device_call_subdevs_until_err_p(&(itv)->v4l2_dev, __sd, \ | ||
829 | !(hw) || (__sd->grp_id & (hw)), o, f , ##args); \ | ||
830 | }) | ||
823 | 831 | ||
824 | #define ivtv_call_all_err(itv, o, f, args...) ivtv_call_hw_err(itv, 0, o, f , ##args) | 832 | #define ivtv_call_all_err(itv, o, f, args...) ivtv_call_hw_err(itv, 0, o, f , ##args) |
825 | 833 | ||
diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h index 8bcbd7a0271c..6648036b728d 100644 --- a/include/media/v4l2-device.h +++ b/include/media/v4l2-device.h | |||
@@ -101,46 +101,67 @@ void v4l2_device_unregister_subdev(struct v4l2_subdev *sd); | |||
101 | /* Call the specified callback for all subdevs matching the condition. | 101 | /* Call the specified callback for all subdevs matching the condition. |
102 | Ignore any errors. Note that you cannot add or delete a subdev | 102 | Ignore any errors. Note that you cannot add or delete a subdev |
103 | while walking the subdevs list. */ | 103 | while walking the subdevs list. */ |
104 | #define __v4l2_device_call_subdevs(v4l2_dev, cond, o, f, args...) \ | 104 | #define __v4l2_device_call_subdevs_p(v4l2_dev, sd, cond, o, f, args...) \ |
105 | do { \ | 105 | do { \ |
106 | struct v4l2_subdev *sd; \ | 106 | list_for_each_entry((sd), &(v4l2_dev)->subdevs, list) \ |
107 | if ((cond) && (sd)->ops->o && (sd)->ops->o->f) \ | ||
108 | (sd)->ops->o->f((sd) , ##args); \ | ||
109 | } while (0) | ||
110 | |||
111 | #define __v4l2_device_call_subdevs(v4l2_dev, cond, o, f, args...) \ | ||
112 | do { \ | ||
113 | struct v4l2_subdev *__sd; \ | ||
107 | \ | 114 | \ |
108 | list_for_each_entry(sd, &(v4l2_dev)->subdevs, list) \ | 115 | __v4l2_device_call_subdevs_p(v4l2_dev, __sd, cond, o, \ |
109 | if ((cond) && sd->ops->o && sd->ops->o->f) \ | 116 | f , ##args); \ |
110 | sd->ops->o->f(sd , ##args); \ | ||
111 | } while (0) | 117 | } while (0) |
112 | 118 | ||
113 | /* Call the specified callback for all subdevs matching the condition. | 119 | /* Call the specified callback for all subdevs matching the condition. |
114 | If the callback returns an error other than 0 or -ENOIOCTLCMD, then | 120 | If the callback returns an error other than 0 or -ENOIOCTLCMD, then |
115 | return with that error code. Note that you cannot add or delete a | 121 | return with that error code. Note that you cannot add or delete a |
116 | subdev while walking the subdevs list. */ | 122 | subdev while walking the subdevs list. */ |
117 | #define __v4l2_device_call_subdevs_until_err(v4l2_dev, cond, o, f, args...) \ | 123 | #define __v4l2_device_call_subdevs_until_err_p(v4l2_dev, sd, cond, o, f, args...) \ |
118 | ({ \ | 124 | ({ \ |
119 | struct v4l2_subdev *sd; \ | 125 | long __err = 0; \ |
120 | long err = 0; \ | ||
121 | \ | 126 | \ |
122 | list_for_each_entry(sd, &(v4l2_dev)->subdevs, list) { \ | 127 | list_for_each_entry((sd), &(v4l2_dev)->subdevs, list) { \ |
123 | if ((cond) && sd->ops->o && sd->ops->o->f) \ | 128 | if ((cond) && (sd)->ops->o && (sd)->ops->o->f) \ |
124 | err = sd->ops->o->f(sd , ##args); \ | 129 | __err = (sd)->ops->o->f((sd) , ##args); \ |
125 | if (err && err != -ENOIOCTLCMD) \ | 130 | if (__err && __err != -ENOIOCTLCMD) \ |
126 | break; \ | 131 | break; \ |
127 | } \ | 132 | } \ |
128 | (err == -ENOIOCTLCMD) ? 0 : err; \ | 133 | (__err == -ENOIOCTLCMD) ? 0 : __err; \ |
134 | }) | ||
135 | |||
136 | #define __v4l2_device_call_subdevs_until_err(v4l2_dev, cond, o, f, args...) \ | ||
137 | ({ \ | ||
138 | struct v4l2_subdev *__sd; \ | ||
139 | __v4l2_device_call_subdevs_until_err_p(v4l2_dev, __sd, cond, o, \ | ||
140 | f, args...); \ | ||
129 | }) | 141 | }) |
130 | 142 | ||
131 | /* Call the specified callback for all subdevs matching grp_id (if 0, then | 143 | /* Call the specified callback for all subdevs matching grp_id (if 0, then |
132 | match them all). Ignore any errors. Note that you cannot add or delete | 144 | match them all). Ignore any errors. Note that you cannot add or delete |
133 | a subdev while walking the subdevs list. */ | 145 | a subdev while walking the subdevs list. */ |
134 | #define v4l2_device_call_all(v4l2_dev, grpid, o, f, args...) \ | 146 | #define v4l2_device_call_all(v4l2_dev, grpid, o, f, args...) \ |
135 | __v4l2_device_call_subdevs(v4l2_dev, \ | 147 | do { \ |
136 | !(grpid) || sd->grp_id == (grpid), o, f , ##args) | 148 | struct v4l2_subdev *__sd; \ |
149 | \ | ||
150 | __v4l2_device_call_subdevs_p(v4l2_dev, __sd, \ | ||
151 | !(grpid) || __sd->grp_id == (grpid), o, f , \ | ||
152 | ##args); \ | ||
153 | } while (0) | ||
137 | 154 | ||
138 | /* Call the specified callback for all subdevs matching grp_id (if 0, then | 155 | /* Call the specified callback for all subdevs matching grp_id (if 0, then |
139 | match them all). If the callback returns an error other than 0 or | 156 | match them all). If the callback returns an error other than 0 or |
140 | -ENOIOCTLCMD, then return with that error code. Note that you cannot | 157 | -ENOIOCTLCMD, then return with that error code. Note that you cannot |
141 | add or delete a subdev while walking the subdevs list. */ | 158 | add or delete a subdev while walking the subdevs list. */ |
142 | #define v4l2_device_call_until_err(v4l2_dev, grpid, o, f, args...) \ | 159 | #define v4l2_device_call_until_err(v4l2_dev, grpid, o, f, args...) \ |
143 | __v4l2_device_call_subdevs_until_err(v4l2_dev, \ | 160 | ({ \ |
144 | !(grpid) || sd->grp_id == (grpid), o, f , ##args) | 161 | struct v4l2_subdev *__sd; \ |
162 | __v4l2_device_call_subdevs_until_err_p(v4l2_dev, __sd, \ | ||
163 | !(grpid) || __sd->grp_id == (grpid), o, f , \ | ||
164 | ##args); \ | ||
165 | }) | ||
145 | 166 | ||
146 | #endif | 167 | #endif |