Allow card.resource to be built with the right name again (by using the
[AROS.git] / arch / m68k-amiga / card / owncard.c
blob2b5aa4cb2900d012c72357d996969abee6e88cff
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: OwnCard() function.
6 Lang: english
7 */
9 #include <proto/exec.h>
11 #include "card_intern.h"
13 AROS_LH1(struct CardHandle*, OwnCard,
14 AROS_LHA(struct CardHandle*, handle, A1),
15 struct CardResource*, CardResource, 1, Card)
17 AROS_LIBFUNC_INIT
19 struct CardHandle *ret = NULL;
21 CARDDEBUG(bug("OwnCard(%p,%08x)\n", handle, handle->cah_CardFlags));
23 handle->cah_CardFlags &= ~CARDF_USED;
24 if (handle->cah_CardFlags & CARDF_DELAYOWNERSHIP) {
25 Forbid();
26 Enqueue(&CardResource->handles, &handle->cah_CardNode);
27 Permit();
28 pcmcia_newowner(CardResource, TRUE);
29 ret = (struct CardHandle*)-1;
30 } else if (handle->cah_CardFlags & CARDF_IFAVAILABLE) {
31 if (CardResource->removed)
32 ret = (struct CardHandle*)-1;
33 else if (CardResource->ownedcard)
34 ret = CardResource->ownedcard;
37 if (ret == NULL) {
38 if (CardResource->removed)
39 ret = (struct CardHandle*)-1;
40 else if (CardResource->ownedcard == NULL) {
41 Forbid();
42 AddHead(&CardResource->handles, &handle->cah_CardNode);
43 Permit();
44 pcmcia_newowner(CardResource, FALSE);
45 } else
46 ret = 0;
49 CARDDEBUG(bug("=%p\n", ret));
51 return ret;
53 AROS_LIBFUNC_EXIT