version 1.9, 2021/11/01 14:43:25 |
version 1.10, 2024/04/22 10:42:04 |
|
|
* Set opt's device, and (if necessary) move clients to |
* Set opt's device, and (if necessary) move clients to |
* to the new device |
* to the new device |
*/ |
*/ |
void |
int |
opt_setdev(struct opt *o, struct dev *ndev) |
opt_setdev(struct opt *o, struct dev *ndev) |
{ |
{ |
struct dev *odev; |
struct dev *odev; |
|
|
int i; |
int i; |
|
|
if (!dev_ref(ndev)) |
if (!dev_ref(ndev)) |
return; |
return 0; |
|
|
odev = o->dev; |
odev = o->dev; |
if (odev == ndev) { |
if (odev == ndev) { |
dev_unref(ndev); |
dev_unref(ndev); |
return; |
return 1; |
} |
} |
|
|
/* check if clients can use new device */ |
/* check if clients can use new device */ |
|
|
continue; |
continue; |
if (s->ops != NULL && !dev_iscompat(odev, ndev)) { |
if (s->ops != NULL && !dev_iscompat(odev, ndev)) { |
dev_unref(ndev); |
dev_unref(ndev); |
return; |
return 0; |
} |
} |
} |
} |
|
|
/* |
/* |
* if we're using MMC, move all opts to the new device, mtc_setdev() |
* if we're using MMC, move all opts to the new device, mtc_setdev() |
* will call us back |
* will call us back |
|
* |
|
* XXX: move this to the end to avoid the recursion |
*/ |
*/ |
if (o->mtc != NULL && o->mtc->dev != ndev) { |
if (o->mtc != NULL && o->mtc->dev != ndev) { |
mtc_setdev(o->mtc, ndev); |
mtc_setdev(o->mtc, ndev); |
dev_unref(ndev); |
dev_unref(ndev); |
return; |
return 1; |
} |
} |
|
|
c = ctl_find(CTL_OPT_DEV, o, o->dev); |
c = ctl_find(CTL_OPT_DEV, o, o->dev); |
|
|
} |
} |
|
|
dev_unref(ndev); |
dev_unref(ndev); |
|
return 1; |
} |
} |
|
|
/* |
/* |