@@ -1147,69 +1147,27 @@ int dma_async_device_register(struct dma_device *device)
1147
1147
1148
1148
device -> owner = device -> dev -> driver -> owner ;
1149
1149
1150
- if (dma_has_cap (DMA_MEMCPY , device -> cap_mask ) && !device -> device_prep_dma_memcpy ) {
1151
- dev_err (device -> dev ,
1152
- "Device claims capability %s, but op is not defined\n" ,
1153
- "DMA_MEMCPY" );
1154
- return - EIO ;
1155
- }
1156
-
1157
- if (dma_has_cap (DMA_XOR , device -> cap_mask ) && !device -> device_prep_dma_xor ) {
1158
- dev_err (device -> dev ,
1159
- "Device claims capability %s, but op is not defined\n" ,
1160
- "DMA_XOR" );
1161
- return - EIO ;
1162
- }
1163
-
1164
- if (dma_has_cap (DMA_XOR_VAL , device -> cap_mask ) && !device -> device_prep_dma_xor_val ) {
1165
- dev_err (device -> dev ,
1166
- "Device claims capability %s, but op is not defined\n" ,
1167
- "DMA_XOR_VAL" );
1168
- return - EIO ;
1169
- }
1170
-
1171
- if (dma_has_cap (DMA_PQ , device -> cap_mask ) && !device -> device_prep_dma_pq ) {
1172
- dev_err (device -> dev ,
1173
- "Device claims capability %s, but op is not defined\n" ,
1174
- "DMA_PQ" );
1175
- return - EIO ;
1176
- }
1177
-
1178
- if (dma_has_cap (DMA_PQ_VAL , device -> cap_mask ) && !device -> device_prep_dma_pq_val ) {
1179
- dev_err (device -> dev ,
1180
- "Device claims capability %s, but op is not defined\n" ,
1181
- "DMA_PQ_VAL" );
1182
- return - EIO ;
1183
- }
1184
-
1185
- if (dma_has_cap (DMA_MEMSET , device -> cap_mask ) && !device -> device_prep_dma_memset ) {
1186
- dev_err (device -> dev ,
1187
- "Device claims capability %s, but op is not defined\n" ,
1188
- "DMA_MEMSET" );
1189
- return - EIO ;
1190
- }
1191
-
1192
- if (dma_has_cap (DMA_INTERRUPT , device -> cap_mask ) && !device -> device_prep_dma_interrupt ) {
1193
- dev_err (device -> dev ,
1194
- "Device claims capability %s, but op is not defined\n" ,
1195
- "DMA_INTERRUPT" );
1196
- return - EIO ;
1197
- }
1198
-
1199
- if (dma_has_cap (DMA_CYCLIC , device -> cap_mask ) && !device -> device_prep_dma_cyclic ) {
1200
- dev_err (device -> dev ,
1201
- "Device claims capability %s, but op is not defined\n" ,
1202
- "DMA_CYCLIC" );
1203
- return - EIO ;
1204
- }
1205
-
1206
- if (dma_has_cap (DMA_INTERLEAVE , device -> cap_mask ) && !device -> device_prep_interleaved_dma ) {
1207
- dev_err (device -> dev ,
1208
- "Device claims capability %s, but op is not defined\n" ,
1209
- "DMA_INTERLEAVE" );
1210
- return - EIO ;
1211
- }
1150
+ #define CHECK_CAP (_name , _type ) \
1151
+ { \
1152
+ if (dma_has_cap(_type, device->cap_mask) && !device->device_prep_##_name) { \
1153
+ dev_err(device->dev, \
1154
+ "Device claims capability %s, but op is not defined\n", \
1155
+ __stringify(_type)); \
1156
+ return -EIO; \
1157
+ } \
1158
+ }
1212
1159
1160
+ CHECK_CAP (dma_memcpy , DMA_MEMCPY );
1161
+ CHECK_CAP (dma_xor , DMA_XOR );
1162
+ CHECK_CAP (dma_xor_val , DMA_XOR_VAL );
1163
+ CHECK_CAP (dma_pq , DMA_PQ );
1164
+ CHECK_CAP (dma_pq_val , DMA_PQ_VAL );
1165
+ CHECK_CAP (dma_memset , DMA_MEMSET );
1166
+ CHECK_CAP (dma_interrupt , DMA_INTERRUPT );
1167
+ CHECK_CAP (dma_cyclic , DMA_CYCLIC );
1168
+ CHECK_CAP (interleaved_dma , DMA_INTERLEAVE );
1169
+
1170
+ #undef CHECK_CAP
1213
1171
1214
1172
if (!device -> device_tx_status ) {
1215
1173
dev_err (device -> dev , "Device tx_status is not defined\n" );
0 commit comments