lkml.org 
[lkml]   [2009]   [Jun]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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.


\
 
 \ /
  Last update: 2009-06-18 18:17    [W:0.152 / U:0.172 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site