Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a6cb869b authored by Varka Bhadram's avatar Varka Bhadram Committed by Marcel Holtmann
Browse files

cfg802154: add PM hooks



This patch help to implement suspend/resume in mac802154, these
hooks will be run before the device is suspended and after it
resumes.

Signed-off-by: default avatarVarka Bhadram <varkab@cdac.in>
Signed-off-by: default avatarAlexander Aring <alex.aring@gmail.com>
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent c4227c8a
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -34,6 +34,8 @@ struct cfg802154_ops {
							   int type);
	void	(*del_virtual_intf_deprecated)(struct wpan_phy *wpan_phy,
					       struct net_device *dev);
	int	(*suspend)(struct wpan_phy *wpan_phy);
	int	(*resume)(struct wpan_phy *wpan_phy);
	int	(*add_virtual_intf)(struct wpan_phy *wpan_phy,
				    const char *name,
				    unsigned char name_assign_type,
+20 −0
Original line number Diff line number Diff line
@@ -23,6 +23,26 @@ rdev_del_virtual_intf_deprecated(struct cfg802154_registered_device *rdev,
	rdev->ops->del_virtual_intf_deprecated(&rdev->wpan_phy, dev);
}

static inline int
rdev_suspend(struct cfg802154_registered_device *rdev)
{
	int ret;
	trace_802154_rdev_suspend(&rdev->wpan_phy);
	ret = rdev->ops->suspend(&rdev->wpan_phy);
	trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
	return ret;
}

static inline int
rdev_resume(struct cfg802154_registered_device *rdev)
{
	int ret;
	trace_802154_rdev_resume(&rdev->wpan_phy);
	ret = rdev->ops->resume(&rdev->wpan_phy);
	trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
	return ret;
}

static inline int
rdev_add_virtual_intf(struct cfg802154_registered_device *rdev, char *name,
		      unsigned char name_assign_type,
+38 −0
Original line number Diff line number Diff line
@@ -14,11 +14,13 @@
 */

#include <linux/device.h>
#include <linux/rtnetlink.h>

#include <net/cfg802154.h>

#include "core.h"
#include "sysfs.h"
#include "rdev-ops.h"

static inline struct cfg802154_registered_device *
dev_to_rdev(struct device *dev)
@@ -62,10 +64,46 @@ static struct attribute *pmib_attrs[] = {
};
ATTRIBUTE_GROUPS(pmib);

#ifdef CONFIG_PM_SLEEP
static int wpan_phy_suspend(struct device *dev)
{
	struct cfg802154_registered_device *rdev = dev_to_rdev(dev);
	int ret = 0;

	if (rdev->ops->suspend) {
		rtnl_lock();
		ret = rdev_suspend(rdev);
		rtnl_unlock();
	}

	return ret;
}

static int wpan_phy_resume(struct device *dev)
{
	struct cfg802154_registered_device *rdev = dev_to_rdev(dev);
	int ret = 0;

	if (rdev->ops->resume) {
		rtnl_lock();
		ret = rdev_resume(rdev);
		rtnl_unlock();
	}

	return ret;
}

static SIMPLE_DEV_PM_OPS(wpan_phy_pm_ops, wpan_phy_suspend, wpan_phy_resume);
#define WPAN_PHY_PM_OPS (&wpan_phy_pm_ops)
#else
#define WPAN_PHY_PM_OPS NULL
#endif

struct class wpan_phy_class = {
	.name = "ieee802154",
	.dev_release = wpan_phy_release,
	.dev_groups = pmib_groups,
	.pm = WPAN_PHY_PM_OPS,
};

int wpan_phy_sysfs_init(void)
+22 −0
Original line number Diff line number Diff line
@@ -40,6 +40,28 @@
 *			rdev->ops traces		     *
 *************************************************************/

DECLARE_EVENT_CLASS(wpan_phy_only_evt,
	TP_PROTO(struct wpan_phy *wpan_phy),
	TP_ARGS(wpan_phy),
	TP_STRUCT__entry(
		WPAN_PHY_ENTRY
	),
	TP_fast_assign(
		WPAN_PHY_ASSIGN;
	),
	TP_printk(WPAN_PHY_PR_FMT, WPAN_PHY_PR_ARG)
);

DEFINE_EVENT(wpan_phy_only_evt, 802154_rdev_suspend,
	TP_PROTO(struct wpan_phy *wpan_phy),
	TP_ARGS(wpan_phy)
);

DEFINE_EVENT(wpan_phy_only_evt, 802154_rdev_resume,
	TP_PROTO(struct wpan_phy *wpan_phy),
	TP_ARGS(wpan_phy)
);

TRACE_EVENT(802154_rdev_add_virtual_intf,
	TP_PROTO(struct wpan_phy *wpan_phy, char *name,
		 enum nl802154_iftype type, __le64 extended_addr),