static SENSOR_DEVICE_ATTR(occ_quick_pwr_drop, 0444, occ_sysfs_show, NULL, 5);
#include <linux/bitops.h>
#include <linux/device.h>
#include <linux/hwmon-sysfs.h>
#include <linux/kernel.h>
#define OCC_STAT_MASTER BIT(7)
#define OCC_STAT_ACTIVE BIT(0)
#define OCC_EXT_STAT_DVFS_OT BIT(7)
#define OCC_EXT_STAT_DVFS_POWER BIT(6)
#define OCC_EXT_STAT_MEM_THROTTLE BIT(5)
#define OCC_EXT_STAT_QUICK_DROP BIT(4)
static ssize_t occ_sysfs_show(struct device *dev,
struct device_attribute *attr, char *buf)
struct occ *occ = dev_get_drvdata(dev);
struct occ_poll_response_header *header;
struct sensor_device_attribute *sattr = to_sensor_dev_attr(attr);
rc = occ_update_response(occ);
header = (struct occ_poll_response_header *)occ->resp.data;
val = !!(header->status & OCC_STAT_MASTER);
val = !!(header->status & OCC_STAT_ACTIVE);
val = !!(header->ext_status & OCC_EXT_STAT_DVFS_OT);
val = !!(header->ext_status & OCC_EXT_STAT_DVFS_POWER);
val = !!(header->ext_status & OCC_EXT_STAT_MEM_THROTTLE);
val = !!(header->ext_status & OCC_EXT_STAT_QUICK_DROP);
if (header->status & OCC_STAT_MASTER)
val = hweight8(header->occs_present);