diff options
author | Stefan Richter <stefanr@s5r6.in-berlin.de> | 2009-11-08 16:29:08 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-12-05 15:41:41 -0500 |
commit | 054286b12c7ba7d37a945326d38716a00434002b (patch) | |
tree | d0d236c5f9d4341e38a3896f9d81a93bc51b8d4b /drivers/media | |
parent | 56411f49f69140b97e259256b99dc276f2b2b427 (diff) |
V4L/DVB (13398): firedtv: reform lock transaction backend call
Preparation for the port of firedtv to the firewire-core kernel API:
The fdtv->backend->lock() hook and thus the CMP code is slightly changed
to better fit with the new API.
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/dvb/firewire/firedtv-1394.c | 11 | ||||
-rw-r--r-- | drivers/media/dvb/firewire/firedtv-avc.c | 50 | ||||
-rw-r--r-- | drivers/media/dvb/firewire/firedtv.h | 2 |
3 files changed, 37 insertions, 26 deletions
diff --git a/drivers/media/dvb/firewire/firedtv-1394.c b/drivers/media/dvb/firewire/firedtv-1394.c index a2e3841f8ee9..22ea4c90f5c9 100644 --- a/drivers/media/dvb/firewire/firedtv-1394.c +++ b/drivers/media/dvb/firewire/firedtv-1394.c | |||
@@ -87,10 +87,15 @@ static inline struct node_entry *node_of(struct firedtv *fdtv) | |||
87 | return container_of(fdtv->device, struct unit_directory, device)->ne; | 87 | return container_of(fdtv->device, struct unit_directory, device)->ne; |
88 | } | 88 | } |
89 | 89 | ||
90 | static int node_lock(struct firedtv *fdtv, u64 addr, void *data, __be32 arg) | 90 | static int node_lock(struct firedtv *fdtv, u64 addr, __be32 data[]) |
91 | { | 91 | { |
92 | return hpsb_node_lock(node_of(fdtv), addr, EXTCODE_COMPARE_SWAP, data, | 92 | int ret; |
93 | (__force quadlet_t)arg); | 93 | |
94 | ret = hpsb_node_lock(node_of(fdtv), addr, EXTCODE_COMPARE_SWAP, | ||
95 | (__force quadlet_t *)&data[1], (__force quadlet_t)data[0]); | ||
96 | data[0] = data[1]; | ||
97 | |||
98 | return ret; | ||
94 | } | 99 | } |
95 | 100 | ||
96 | static int node_read(struct firedtv *fdtv, u64 addr, void *data, size_t len) | 101 | static int node_read(struct firedtv *fdtv, u64 addr, void *data, size_t len) |
diff --git a/drivers/media/dvb/firewire/firedtv-avc.c b/drivers/media/dvb/firewire/firedtv-avc.c index 485d061319ab..5516c33b1453 100644 --- a/drivers/media/dvb/firewire/firedtv-avc.c +++ b/drivers/media/dvb/firewire/firedtv-avc.c | |||
@@ -1251,14 +1251,14 @@ static int cmp_read(struct firedtv *fdtv, void *buf, u64 addr, size_t len) | |||
1251 | return ret; | 1251 | return ret; |
1252 | } | 1252 | } |
1253 | 1253 | ||
1254 | static int cmp_lock(struct firedtv *fdtv, void *data, u64 addr, __be32 arg) | 1254 | static int cmp_lock(struct firedtv *fdtv, u64 addr, __be32 data[]) |
1255 | { | 1255 | { |
1256 | int ret; | 1256 | int ret; |
1257 | 1257 | ||
1258 | if (mutex_lock_interruptible(&fdtv->avc_mutex)) | 1258 | if (mutex_lock_interruptible(&fdtv->avc_mutex)) |
1259 | return -EINTR; | 1259 | return -EINTR; |
1260 | 1260 | ||
1261 | ret = fdtv->backend->lock(fdtv, addr, data, arg); | 1261 | ret = fdtv->backend->lock(fdtv, addr, data); |
1262 | if (ret < 0) | 1262 | if (ret < 0) |
1263 | dev_err(fdtv->device, "CMP: lock I/O error\n"); | 1263 | dev_err(fdtv->device, "CMP: lock I/O error\n"); |
1264 | 1264 | ||
@@ -1288,25 +1288,25 @@ static inline void set_opcr(__be32 *opcr, u32 value, u32 mask, u32 shift) | |||
1288 | 1288 | ||
1289 | int cmp_establish_pp_connection(struct firedtv *fdtv, int plug, int channel) | 1289 | int cmp_establish_pp_connection(struct firedtv *fdtv, int plug, int channel) |
1290 | { | 1290 | { |
1291 | __be32 old_opcr, opcr; | 1291 | __be32 old_opcr, opcr[2]; |
1292 | u64 opcr_address = CMP_OUTPUT_PLUG_CONTROL_REG_0 + (plug << 2); | 1292 | u64 opcr_address = CMP_OUTPUT_PLUG_CONTROL_REG_0 + (plug << 2); |
1293 | int attempts = 0; | 1293 | int attempts = 0; |
1294 | int ret; | 1294 | int ret; |
1295 | 1295 | ||
1296 | ret = cmp_read(fdtv, &opcr, opcr_address, 4); | 1296 | ret = cmp_read(fdtv, opcr, opcr_address, 4); |
1297 | if (ret < 0) | 1297 | if (ret < 0) |
1298 | return ret; | 1298 | return ret; |
1299 | 1299 | ||
1300 | repeat: | 1300 | repeat: |
1301 | if (!get_opcr_online(opcr)) { | 1301 | if (!get_opcr_online(*opcr)) { |
1302 | dev_err(fdtv->device, "CMP: output offline\n"); | 1302 | dev_err(fdtv->device, "CMP: output offline\n"); |
1303 | return -EBUSY; | 1303 | return -EBUSY; |
1304 | } | 1304 | } |
1305 | 1305 | ||
1306 | old_opcr = opcr; | 1306 | old_opcr = *opcr; |
1307 | 1307 | ||
1308 | if (get_opcr_p2p_connections(opcr)) { | 1308 | if (get_opcr_p2p_connections(*opcr)) { |
1309 | if (get_opcr_channel(opcr) != channel) { | 1309 | if (get_opcr_channel(*opcr) != channel) { |
1310 | dev_err(fdtv->device, "CMP: cannot change channel\n"); | 1310 | dev_err(fdtv->device, "CMP: cannot change channel\n"); |
1311 | return -EBUSY; | 1311 | return -EBUSY; |
1312 | } | 1312 | } |
@@ -1314,11 +1314,11 @@ repeat: | |||
1314 | 1314 | ||
1315 | /* We don't allocate isochronous resources. */ | 1315 | /* We don't allocate isochronous resources. */ |
1316 | } else { | 1316 | } else { |
1317 | set_opcr_channel(&opcr, channel); | 1317 | set_opcr_channel(opcr, channel); |
1318 | set_opcr_data_rate(&opcr, 2); /* S400 */ | 1318 | set_opcr_data_rate(opcr, 2); /* S400 */ |
1319 | 1319 | ||
1320 | /* FIXME: this is for the worst case - optimize */ | 1320 | /* FIXME: this is for the worst case - optimize */ |
1321 | set_opcr_overhead_id(&opcr, 0); | 1321 | set_opcr_overhead_id(opcr, 0); |
1322 | 1322 | ||
1323 | /* | 1323 | /* |
1324 | * FIXME: allocate isochronous channel and bandwidth at IRM | 1324 | * FIXME: allocate isochronous channel and bandwidth at IRM |
@@ -1326,13 +1326,16 @@ repeat: | |||
1326 | */ | 1326 | */ |
1327 | } | 1327 | } |
1328 | 1328 | ||
1329 | set_opcr_p2p_connections(&opcr, get_opcr_p2p_connections(opcr) + 1); | 1329 | set_opcr_p2p_connections(opcr, get_opcr_p2p_connections(*opcr) + 1); |
1330 | 1330 | ||
1331 | ret = cmp_lock(fdtv, &opcr, opcr_address, old_opcr); | 1331 | opcr[1] = *opcr; |
1332 | opcr[0] = old_opcr; | ||
1333 | |||
1334 | ret = cmp_lock(fdtv, opcr_address, opcr); | ||
1332 | if (ret < 0) | 1335 | if (ret < 0) |
1333 | return ret; | 1336 | return ret; |
1334 | 1337 | ||
1335 | if (old_opcr != opcr) { | 1338 | if (old_opcr != *opcr) { |
1336 | /* | 1339 | /* |
1337 | * FIXME: if old_opcr.P2P_Connections > 0, | 1340 | * FIXME: if old_opcr.P2P_Connections > 0, |
1338 | * deallocate isochronous channel and bandwidth at IRM | 1341 | * deallocate isochronous channel and bandwidth at IRM |
@@ -1350,27 +1353,30 @@ repeat: | |||
1350 | 1353 | ||
1351 | void cmp_break_pp_connection(struct firedtv *fdtv, int plug, int channel) | 1354 | void cmp_break_pp_connection(struct firedtv *fdtv, int plug, int channel) |
1352 | { | 1355 | { |
1353 | __be32 old_opcr, opcr; | 1356 | __be32 old_opcr, opcr[2]; |
1354 | u64 opcr_address = CMP_OUTPUT_PLUG_CONTROL_REG_0 + (plug << 2); | 1357 | u64 opcr_address = CMP_OUTPUT_PLUG_CONTROL_REG_0 + (plug << 2); |
1355 | int attempts = 0; | 1358 | int attempts = 0; |
1356 | 1359 | ||
1357 | if (cmp_read(fdtv, &opcr, opcr_address, 4) < 0) | 1360 | if (cmp_read(fdtv, opcr, opcr_address, 4) < 0) |
1358 | return; | 1361 | return; |
1359 | 1362 | ||
1360 | repeat: | 1363 | repeat: |
1361 | if (!get_opcr_online(opcr) || !get_opcr_p2p_connections(opcr) || | 1364 | if (!get_opcr_online(*opcr) || !get_opcr_p2p_connections(*opcr) || |
1362 | get_opcr_channel(opcr) != channel) { | 1365 | get_opcr_channel(*opcr) != channel) { |
1363 | dev_err(fdtv->device, "CMP: no connection to break\n"); | 1366 | dev_err(fdtv->device, "CMP: no connection to break\n"); |
1364 | return; | 1367 | return; |
1365 | } | 1368 | } |
1366 | 1369 | ||
1367 | old_opcr = opcr; | 1370 | old_opcr = *opcr; |
1368 | set_opcr_p2p_connections(&opcr, get_opcr_p2p_connections(opcr) - 1); | 1371 | set_opcr_p2p_connections(opcr, get_opcr_p2p_connections(*opcr) - 1); |
1372 | |||
1373 | opcr[1] = *opcr; | ||
1374 | opcr[0] = old_opcr; | ||
1369 | 1375 | ||
1370 | if (cmp_lock(fdtv, &opcr, opcr_address, old_opcr) < 0) | 1376 | if (cmp_lock(fdtv, opcr_address, opcr) < 0) |
1371 | return; | 1377 | return; |
1372 | 1378 | ||
1373 | if (old_opcr != opcr) { | 1379 | if (old_opcr != *opcr) { |
1374 | /* | 1380 | /* |
1375 | * FIXME: if old_opcr.P2P_Connections == 1, i.e. we were last | 1381 | * FIXME: if old_opcr.P2P_Connections == 1, i.e. we were last |
1376 | * owner, deallocate isochronous channel and bandwidth at IRM | 1382 | * owner, deallocate isochronous channel and bandwidth at IRM |
diff --git a/drivers/media/dvb/firewire/firedtv.h b/drivers/media/dvb/firewire/firedtv.h index d48530b81e61..1b99660a8397 100644 --- a/drivers/media/dvb/firewire/firedtv.h +++ b/drivers/media/dvb/firewire/firedtv.h | |||
@@ -72,7 +72,7 @@ struct input_dev; | |||
72 | struct firedtv; | 72 | struct firedtv; |
73 | 73 | ||
74 | struct firedtv_backend { | 74 | struct firedtv_backend { |
75 | int (*lock)(struct firedtv *fdtv, u64 addr, void *data, __be32 arg); | 75 | int (*lock)(struct firedtv *fdtv, u64 addr, __be32 data[]); |
76 | int (*read)(struct firedtv *fdtv, u64 addr, void *data, size_t len); | 76 | int (*read)(struct firedtv *fdtv, u64 addr, void *data, size_t len); |
77 | int (*write)(struct firedtv *fdtv, u64 addr, void *data, size_t len); | 77 | int (*write)(struct firedtv *fdtv, u64 addr, void *data, size_t len); |
78 | int (*start_iso)(struct firedtv *fdtv); | 78 | int (*start_iso)(struct firedtv *fdtv); |