Re: [PATCH 08/39] wimax: Mappping of generic netlink family IDs to net devices

Johannes Berg
2008-11-27T09:48:07Z

[-- Attachment #1: Type: text/plain, Size: 1266 bytes --]

On Wed, 2008-11-26 at 15:07 -0800, Inaky Perez-Gonzalez wrote:

> +/*
> + * wimax_get_netdev_by_info - lookup a wimax_dev from the gennetlink info
> + *
> + * The generic netlink family ID has been filled out in the
> + * nlmsghdr->nlmsg_type field, so we pull it from there, look it up in
> + * the mapping table and reference the wimax_dev.
> + *
> + * When done, the reference should be dropped with
> + * 'dev_put(wimax_dev->net_dev)'.
> + */
> +struct wimax_dev *wimax_dev_get_by_genl_info(struct genl_info *info)
> +{
> + struct wimax_dev *wimax_dev;

= NULL;

> + int id = info->nlhdr->nlmsg_type;
> +
> + d_fnstart(3, NULL, "(info %p [id %d])\n", info, id);
> + spin_lock(&wimax_id_table_lock);
> + list_for_each_entry(wimax_dev, &wimax_id_table, id_table_node) {
> + if (wimax_dev->gnl_family.id == id) {
> + dev_hold(wimax_dev->net_dev);
> + goto out_unlock;

break;

> + }
> + }
> + d_printf(1, NULL, "wimax: no device associated to ID %d\n", id);

remove debug statement (or make it depend on !wimax_dev)

> + wimax_dev = NULL;
> +out_unlock:
> + spin_unlock(&wimax_id_table_lock);
> + d_fnend(3, NULL, "(info %p) = %p\n", info, wimax_dev);
> + return wimax_dev;

No need for gotos any more :)

johannes

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]