2 * UWB Multi-interface Controller device management.
4 * Copyright (C) 2007 Cambridge Silicon Radio Ltd.
6 * This file is released under the GNU GPL v2.
8 #include <linux/kernel.h>
9 #include <linux/uwb/umc.h>
11 #include <linux/uwb/debug.h>
13 static void umc_device_release(struct device
*dev
)
15 struct umc_dev
*umc
= to_umc_dev(dev
);
21 * umc_device_create - allocate a child UMC device
22 * @parent: parent of the new UMC device.
23 * @n: index of the new device.
25 * The new UMC device will have a bus ID of the parent with '-n'
28 struct umc_dev
*umc_device_create(struct device
*parent
, int n
)
32 umc
= kzalloc(sizeof(struct umc_dev
), GFP_KERNEL
);
34 dev_set_name(&umc
->dev
, "%s-%d", dev_name(parent
), n
);
35 umc
->dev
.parent
= parent
;
36 umc
->dev
.bus
= &umc_bus_type
;
37 umc
->dev
.release
= umc_device_release
;
39 umc
->dev
.dma_mask
= parent
->dma_mask
;
43 EXPORT_SYMBOL_GPL(umc_device_create
);
46 * umc_device_register - register a UMC device
47 * @umc: pointer to the UMC device
49 * The memory resource for the UMC device is acquired and the device
50 * registered with the system.
52 int umc_device_register(struct umc_dev
*umc
)
56 d_fnstart(3, &umc
->dev
, "(umc_dev %p)\n", umc
);
58 err
= request_resource(umc
->resource
.parent
, &umc
->resource
);
60 dev_err(&umc
->dev
, "can't allocate resource range "
61 "%016Lx to %016Lx: %d\n",
62 (unsigned long long)umc
->resource
.start
,
63 (unsigned long long)umc
->resource
.end
,
65 goto error_request_resource
;
68 err
= device_register(&umc
->dev
);
70 goto error_device_register
;
71 d_fnend(3, &umc
->dev
, "(umc_dev %p) = 0\n", umc
);
74 error_device_register
:
75 release_resource(&umc
->resource
);
76 error_request_resource
:
77 d_fnend(3, &umc
->dev
, "(umc_dev %p) = %d\n", umc
, err
);
80 EXPORT_SYMBOL_GPL(umc_device_register
);
83 * umc_device_unregister - unregister a UMC device
84 * @umc: pointer to the UMC device
86 * First we unregister the device, make sure the driver can do it's
87 * resource release thing and then we try to release any left over
88 * resources. We take a ref to the device, to make sure it doesn't
89 * dissapear under our feet.
91 void umc_device_unregister(struct umc_dev
*umc
)
96 dev
= get_device(&umc
->dev
);
97 d_fnstart(3, dev
, "(umc_dev %p)\n", umc
);
98 device_unregister(&umc
->dev
);
99 release_resource(&umc
->resource
);
100 d_fnend(3, dev
, "(umc_dev %p) = void\n", umc
);
103 EXPORT_SYMBOL_GPL(umc_device_unregister
);
This page took 0.038369 seconds and 6 git commands to generate.