[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <4A3A67EE.3000809@trash.net>
Date: Thu, 18 Jun 2009 18:14:38 +0200
From: Patrick McHardy <kaber@...sh.net>
To: Dmitry Eremin-Solenikov <dbaryshkov@...il.com>
CC: netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
Sergey Lapin <slapin@...fans.org>
Subject: Re: [PATCH 4/5] ieee802154: add virtual loopback driver
Dmitry Eremin-Solenikov wrote:
> fakelb is a virtual loopback driver implementing one or several
> interconnected radios. Packets from the radio are either sent
> back to the node (if no other fake radio are registered) or to
> all other fake radio.
>
> +static ssize_t
> +adddev_store(struct device *dev, struct device_attribute *attr,
> + const char *buf, size_t n)
> +{
> + struct platform_device *pdev = to_platform_device(dev);
> + struct fake_priv *priv = platform_get_drvdata(pdev);
> + char hw[8] = {};
> + int i, j, ch, err;
> +
> + for (i = 0, j = 0; i < 16 && j < n; j++) {
> + ch = buf[j];
> + switch (buf[j]) {
> + default:
> + return -EINVAL;
> + case '0'...'9':
> + ch -= '0';
> + break;
> + case 'A'...'F':
> + ch -= 'A' - 10;
> + break;
> + case 'a'...'f':
> + ch -= 'a' - 10;
> + break;
> + case ':':
> + case '.':
> + continue;
> + }
> + if (i % 2)
> + hw[i/2] = (hw[i/2] & 0xf0) | ch;
> + else
> + hw[i/2] = ch << 4;
> + i++;
> + }
> + if (i != 16)
> + return -EINVAL;
> + err = ieee802154fake_add_priv(dev, priv, hw);
> + if (err)
> + return err;
> + return n;
> +}
> +
> +static DEVICE_ATTR(adddev, 0200, NULL, adddev_store);
> +
> +static struct attribute *fake_attrs[] = {
> + &dev_attr_adddev.attr,
> + NULL,
> +};
No new sysfs interfaces for network device creation please.
Please use the rtnl_link API.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists