static int __devinit ieee802154fake_probe(struct platform_device *pdev)
{
	struct net_device *dev;
	struct fakehard_priv *priv;
	struct wpan_phy *phy = wpan_phy_alloc(0);
	int err;

	if (!phy)
		return -ENOMEM;

	dev = alloc_netdev(sizeof(struct fakehard_priv), "hardwpan%d", ieee802154_fake_setup);
	if (!dev) {
		wpan_phy_free(phy);
		return -ENOMEM;
	}

	phy->dev.platform_data = dev;

	memcpy(dev->dev_addr, "\xba\xbe\xca\xfe\xde\xad\xbe\xef",
			dev->addr_len);
	memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);

	/*
	 * For now we'd like to emulate 2.4 GHz-only device,
	 * both O-QPSK and CSS
	 */
	/* 2.4 GHz O-QPSK 802.15.4-2003 */
	phy->channels_supported[0] |= 0x7FFF800;
	/* 2.4 GHz CSS 802.15.4a-2007 */
	phy->channels_supported[3] |= 0x3fff;

	phy->transmit_power = 0xbf;

	dev->netdev_ops = &fake_ops;
	dev->ml_priv = &fake_mlme;

	priv = netdev_priv(dev);
	priv->phy = phy;

	wpan_phy_set_dev(phy, &pdev->dev);
	SET_NETDEV_DEV(dev, &phy->dev);

	platform_set_drvdata(pdev, dev);

	err = wpan_phy_register(phy);
	if (err)
		goto out;

	err = register_netdev(dev);
	if (err < 0)
		goto out;

	dev_info(&pdev->dev, "Added ieee802154 HardMAC hardware\n");
	return 0;

out:
	unregister_netdev(dev);
	return err;
}
示例#2
0
static int ieee802154xbee_probe(struct platform_device *pdev)
{
	struct net_device *dev;
	struct xbee_priv *priv;
	struct wpan_phy *phy = wpan_phy_alloc(0);
	int err;

	if (!phy)
		return -ENOMEM;

	dev = alloc_netdev(sizeof(struct xbee_priv), "hardwpan%d", ieee802154_xbee_setup);

	if (!dev) {
		wpan_phy_free(phy);
		return -ENOMEM;
	}

	memcpy(dev->dev_addr, "\xba\xbe\xca\xfe\xde\xad\xbe\xef",
			dev->addr_len);

	/*
	 * For now we'd like to emulate 2.4 GHz-only device,
	 * both O-QPSK and CSS
	 */
	/* 2.4 GHz O-QPSK 802.15.4-2003 */
	phy->channels_supported[0] |= 0x7FFF800;
	/* 2.4 GHz CSS 802.15.4a-2007 */
	phy->channels_supported[3] |= 0x3fff;

	phy->transmit_power = 0xbf;

	dev->netdev_ops = &xbee_ops;
	dev->ml_priv = &xbee_mlme;

	priv = netdev_priv(dev);
	priv->phy = phy;

	wpan_phy_set_dev(phy, &pdev->dev);
	SET_NETDEV_DEV(dev, &phy->dev);

	platform_set_drvdata(pdev, dev);

	priv->rbuff = kmalloc(XBEE_MAXFRAME, GFP_KERNEL);
        priv->rcount = 0;
        priv->frame_status = UNFRAMED;
        priv->frame_len = 0;
	priv->escaped = 0;

	xbee_dev = dev; // This should be removed in a future!

	err = wpan_phy_register(phy);
	if (err)
		goto out;

	err = register_netdev(dev);
	if (err < 0)
		goto out;

	dev_info(&pdev->dev, "Added ieee802154 HardMAC hardware\n");
	return 0;

out:
	unregister_netdev(dev);
	return err;
}