Skip to content

Commit

Permalink
net: nfc: have genetlink code to parse the attrs during dumpit
Browse files Browse the repository at this point in the history
Benefit from the fact that the generic netlink code can parse the attrs
for dumpit op and avoid need to parse it in the op callback.

Signed-off-by: Jiri Pirko <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
jpirko authored and davem330 committed Oct 6, 2019
1 parent 75cdbdd commit 4495af3
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions net/nfc/netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,22 +102,14 @@ static int nfc_genl_send_target(struct sk_buff *msg, struct nfc_target *target,

static struct nfc_dev *__get_device_from_cb(struct netlink_callback *cb)
{
struct nlattr **attrbuf = genl_family_attrbuf(&nfc_genl_family);
const struct genl_dumpit_info *info = genl_dumpit_info(cb);
struct nfc_dev *dev;
int rc;
u32 idx;

rc = nlmsg_parse_deprecated(cb->nlh,
GENL_HDRLEN + nfc_genl_family.hdrsize,
attrbuf, nfc_genl_family.maxattr,
nfc_genl_policy, NULL);
if (rc < 0)
return ERR_PTR(rc);

if (!attrbuf[NFC_ATTR_DEVICE_INDEX])
if (!info->attrs[NFC_ATTR_DEVICE_INDEX])
return ERR_PTR(-EINVAL);

idx = nla_get_u32(attrbuf[NFC_ATTR_DEVICE_INDEX]);
idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]);

dev = nfc_get_device(idx);
if (!dev)
Expand Down Expand Up @@ -1697,7 +1689,8 @@ static const struct genl_ops nfc_genl_ops[] = {
},
{
.cmd = NFC_CMD_GET_TARGET,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.validate = GENL_DONT_VALIDATE_STRICT |
GENL_DONT_VALIDATE_DUMP_STRICT,
.dumpit = nfc_genl_dump_targets,
.done = nfc_genl_dump_targets_done,
},
Expand Down

0 comments on commit 4495af3

Please sign in to comment.