/* * UWB Multi-interface Controller device management. * * Copyright (C) 2007 Cambridge Silicon Radio Ltd. * * This file is released under the GNU GPL v2. */ #include #include #include #include static void umc_device_release(struct device *dev) { struct umc_dev *umc = to_umc_dev(dev); kfree(umc); } /** * umc_device_create - allocate a child UMC device * @parent: parent of the new UMC device. * @n: index of the new device. * * The new UMC device will have a bus ID of the parent with '-n' * appended. */ struct umc_dev *umc_device_create(struct device *parent, int n) { struct umc_dev *umc; umc = kzalloc(sizeof(struct umc_dev), GFP_KERNEL); if (umc) { dev_set_name(&umc->dev, "%s-%d", dev_name(parent), n); umc->dev.parent = parent; umc->dev.bus = &umc_bus_type; umc->dev.release = umc_device_release; umc->dev.dma_mask = parent->dma_mask; } return umc; } EXPORT_SYMBOL_GPL(umc_device_create); /** * umc_device_register - register a UMC device * @umc: pointer to the UMC device * * The memory resource for the UMC device is acquired and the device * registered with the system. */ int umc_device_register(struct umc_dev *umc) { int err; err = request_resource(umc->resource.parent, &umc->resource); if (err < 0) { dev_err(&umc->dev, "can't allocate resource range %pR: %d\n", &umc->resource, err); goto error_request_resource; } err = device_register(&umc->dev); if (err < 0) goto error_device_register; return 0; error_device_register: put_device(&umc->dev); release_resource(&umc->resource); error_request_resource: return err; } EXPORT_SYMBOL_GPL(umc_device_register); /** * umc_device_unregister - unregister a UMC device * @umc: pointer to the UMC device * * First we unregister the device, make sure the driver can do it's * resource release thing and then we try to release any left over * resources. We take a ref to the device, to make sure it doesn't * disappear under our feet. */ void umc_device_unregister(struct umc_dev *umc) { struct device *dev; if (!umc) return; dev = get_device(&umc->dev); device_unregister(&umc->dev); release_resource(&umc->resource); put_device(dev); } EXPORT_SYMBOL_GPL(umc_device_unregister); name='id' value='10435c1192d06bdb0bac7666452d8219d7e7c477'/>
diff options
context:
space:
mode:
authorFeng <fgao@ikuai8.com>2017-01-20 21:40:43 +0800
committerPablo Neira Ayuso <pablo@netfilter.org>2017-02-02 14:30:19 +0100
commit10435c1192d06bdb0bac7666452d8219d7e7c477 (patch)
tree93b76419142fe17b1d162d062c663297a3e8a965 /net/rxrpc/security.c
parent1a28ad74ebd8f9d3c7eae0d781f72a6d30545e17 (diff)
netfilter: nf_tables: Eliminate duplicated code in nf_tables_table_enable()
If something fails in nf_tables_table_enable(), it unregisters the chains. But the rollback code is the same as nf_tables_table_disable() almostly, except there is one counter check. Now create one wrapper function to eliminate the duplicated codes. Signed-off-by: Feng <fgao@ikuai8.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'net/rxrpc/security.c')