#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/hwmon.h>
#include <linux/hwmon-vid.h>
#include <linux/err.h>
#include <linux/kstrtox.h>
#include <linux/mutex.h>
#include <linux/sysfs.h>
#include <linux/slab.h>
MODULE_LICENSE(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_VERSION(…) …;
MODULE_AUTHOR(…) …;
#define ATXP1_VID …
#define ATXP1_CVID …
#define ATXP1_GPIO1 …
#define ATXP1_GPIO2 …
#define ATXP1_VIDENA …
#define ATXP1_VIDMASK …
#define ATXP1_GPIO1MASK …
struct atxp1_data { … };
static struct atxp1_data *atxp1_update_device(struct device *dev)
{ … }
static ssize_t cpu0_vid_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t cpu0_vid_store(struct device *dev,
struct device_attribute *attr, const char *buf,
size_t count)
{ … }
static DEVICE_ATTR_RW(cpu0_vid);
static ssize_t gpio1_show(struct device *dev, struct device_attribute *attr,
char *buf)
{ … }
static ssize_t gpio1_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static DEVICE_ATTR_RW(gpio1);
static ssize_t gpio2_show(struct device *dev, struct device_attribute *attr,
char *buf)
{ … }
static ssize_t gpio2_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static DEVICE_ATTR_RW(gpio2);
static struct attribute *atxp1_attrs[] = …;
ATTRIBUTE_GROUPS(…);
static int atxp1_probe(struct i2c_client *client)
{
struct device *dev = &client->dev;
struct atxp1_data *data;
struct device *hwmon_dev;
data = devm_kzalloc(dev, sizeof(struct atxp1_data), GFP_KERNEL);
if (!data)
return -ENOMEM;
data->vrm = vid_which_vrm();
if (data->vrm != 90 && data->vrm != 91) {
dev_err(dev, "atxp1: Not supporting VRM %d.%d\n",
data->vrm / 10, data->vrm % 10);
return -ENODEV;
}
data->client = client;
mutex_init(&data->update_lock);
hwmon_dev = devm_hwmon_device_register_with_groups(dev, client->name,
data,
atxp1_groups);
if (IS_ERR(hwmon_dev))
return PTR_ERR(hwmon_dev);
dev_info(dev, "Using VRM: %d.%d\n", data->vrm / 10, data->vrm % 10);
return 0;
};
static const struct i2c_device_id atxp1_id[] = …;
MODULE_DEVICE_TABLE(i2c, atxp1_id);
static struct i2c_driver atxp1_driver = …;
module_i2c_driver(…) …;