Skip to content

Commit

Permalink
Merge branches 'pm-epoll', 'pnp' and 'powercap'
Browse files Browse the repository at this point in the history
* pm-epoll:
  epoll: drop EPOLLWAKEUP if PM_SLEEP is disabled

* pnp:
  PNP: fix restoring devices after hibernation

* powercap:
  PowerCap: Fix mode for energy counter
  • Loading branch information
Rafael J. Wysocki committed Dec 6, 2013
4 parents 7cdcec9 + 95f19f6 + 8a37ea5 + 95677a9 commit 8e70300
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 5 deletions.
12 changes: 11 additions & 1 deletion drivers/pnp/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,11 @@ static int pnp_bus_freeze(struct device *dev)
return __pnp_bus_suspend(dev, PMSG_FREEZE);
}

static int pnp_bus_poweroff(struct device *dev)
{
return __pnp_bus_suspend(dev, PMSG_HIBERNATE);
}

static int pnp_bus_resume(struct device *dev)
{
struct pnp_dev *pnp_dev = to_pnp_dev(dev);
Expand Down Expand Up @@ -234,9 +239,14 @@ static int pnp_bus_resume(struct device *dev)
}

static const struct dev_pm_ops pnp_bus_dev_pm_ops = {
/* Suspend callbacks */
.suspend = pnp_bus_suspend,
.freeze = pnp_bus_freeze,
.resume = pnp_bus_resume,
/* Hibernate callbacks */
.freeze = pnp_bus_freeze,
.thaw = pnp_bus_resume,
.poweroff = pnp_bus_poweroff,
.restore = pnp_bus_resume,
};

struct bus_type pnp_bus_type = {
Expand Down
7 changes: 6 additions & 1 deletion drivers/powercap/powercap_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,9 +377,14 @@ static void create_power_zone_common_attributes(
if (power_zone->ops->get_max_energy_range_uj)
power_zone->zone_dev_attrs[count++] =
&dev_attr_max_energy_range_uj.attr;
if (power_zone->ops->get_energy_uj)
if (power_zone->ops->get_energy_uj) {
if (power_zone->ops->reset_energy_uj)
dev_attr_energy_uj.attr.mode = S_IWUSR | S_IRUGO;
else
dev_attr_energy_uj.attr.mode = S_IRUGO;
power_zone->zone_dev_attrs[count++] =
&dev_attr_energy_uj.attr;
}
if (power_zone->ops->get_power_uw)
power_zone->zone_dev_attrs[count++] =
&dev_attr_power_uw.attr;
Expand Down
3 changes: 1 addition & 2 deletions fs/eventpoll.c
Original file line number Diff line number Diff line change
Expand Up @@ -1852,8 +1852,7 @@ SYSCALL_DEFINE4(epoll_ctl, int, epfd, int, op, int, fd,
goto error_tgt_fput;

/* Check if EPOLLWAKEUP is allowed */
if ((epds.events & EPOLLWAKEUP) && !capable(CAP_BLOCK_SUSPEND))
epds.events &= ~EPOLLWAKEUP;
ep_take_care_of_epollwakeup(&epds);

/*
* We have to check that the file structure underneath the file descriptor
Expand Down
13 changes: 12 additions & 1 deletion include/uapi/linux/eventpoll.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,16 @@ struct epoll_event {
__u64 data;
} EPOLL_PACKED;


#ifdef CONFIG_PM_SLEEP
static inline void ep_take_care_of_epollwakeup(struct epoll_event *epev)
{
if ((epev->events & EPOLLWAKEUP) && !capable(CAP_BLOCK_SUSPEND))
epev->events &= ~EPOLLWAKEUP;
}
#else
static inline void ep_take_care_of_epollwakeup(struct epoll_event *epev)
{
epev->events &= ~EPOLLWAKEUP;
}
#endif
#endif /* _UAPI_LINUX_EVENTPOLL_H */

0 comments on commit 8e70300

Please sign in to comment.