#include <linux/module.h>
#include <linux/slab.h>
#include <linux/param.h>
#include <linux/pm.h>
#include <linux/platform_device.h>
#include <linux/power_supply.h>
#include <linux/idr.h>
#include <linux/w1.h>
#include "../../w1/slaves/w1_ds2781.h"
#define DS2781_CURRENT_UNITS …
#define DS2781_CHARGE_UNITS …
#define DS2781_USER_EEPROM_SIZE …
#define DS2781_PARAM_EEPROM_SIZE …
struct ds2781_device_info { … };
enum current_types { … };
static const char model[] = …;
static const char manufacturer[] = …;
static inline struct ds2781_device_info *
to_ds2781_device_info(struct power_supply *psy)
{ … }
static inline int ds2781_battery_io(struct ds2781_device_info *dev_info,
char *buf, int addr, size_t count, int io)
{ … }
static int w1_ds2781_read(struct ds2781_device_info *dev_info, char *buf,
int addr, size_t count)
{ … }
static inline int ds2781_read8(struct ds2781_device_info *dev_info, u8 *val,
int addr)
{ … }
static int ds2781_read16(struct ds2781_device_info *dev_info, s16 *val,
int addr)
{ … }
static inline int ds2781_read_block(struct ds2781_device_info *dev_info,
u8 *val, int addr, size_t count)
{ … }
static inline int ds2781_write(struct ds2781_device_info *dev_info, u8 *val,
int addr, size_t count)
{ … }
static inline int ds2781_store_eeprom(struct device *dev, int addr)
{ … }
static inline int ds2781_recall_eeprom(struct device *dev, int addr)
{ … }
static int ds2781_save_eeprom(struct ds2781_device_info *dev_info, int reg)
{ … }
static int ds2781_set_sense_register(struct ds2781_device_info *dev_info,
u8 conductance)
{ … }
static int ds2781_get_rsgain_register(struct ds2781_device_info *dev_info,
u16 *rsgain)
{ … }
static int ds2781_set_rsgain_register(struct ds2781_device_info *dev_info,
u16 rsgain)
{ … }
static int ds2781_get_voltage(struct ds2781_device_info *dev_info,
int *voltage_uV)
{ … }
static int ds2781_get_temperature(struct ds2781_device_info *dev_info,
int *temp)
{ … }
static int ds2781_get_current(struct ds2781_device_info *dev_info,
enum current_types type, int *current_uA)
{ … }
static int ds2781_get_accumulated_current(struct ds2781_device_info *dev_info,
int *accumulated_current)
{ … }
static int ds2781_get_capacity(struct ds2781_device_info *dev_info,
int *capacity)
{ … }
static int ds2781_get_status(struct ds2781_device_info *dev_info, int *status)
{ … }
static int ds2781_get_charge_now(struct ds2781_device_info *dev_info,
int *charge_now)
{ … }
static int ds2781_get_control_register(struct ds2781_device_info *dev_info,
u8 *control_reg)
{ … }
static int ds2781_set_control_register(struct ds2781_device_info *dev_info,
u8 control_reg)
{ … }
static int ds2781_battery_get_property(struct power_supply *psy,
enum power_supply_property psp,
union power_supply_propval *val)
{ … }
static enum power_supply_property ds2781_battery_props[] = …;
static ssize_t ds2781_get_pmod_enabled(struct device *dev,
struct device_attribute *attr,
char *buf)
{ … }
static ssize_t ds2781_set_pmod_enabled(struct device *dev,
struct device_attribute *attr,
const char *buf,
size_t count)
{ … }
static ssize_t ds2781_get_sense_resistor_value(struct device *dev,
struct device_attribute *attr,
char *buf)
{ … }
static ssize_t ds2781_set_sense_resistor_value(struct device *dev,
struct device_attribute *attr,
const char *buf,
size_t count)
{ … }
static ssize_t ds2781_get_rsgain_setting(struct device *dev,
struct device_attribute *attr,
char *buf)
{ … }
static ssize_t ds2781_set_rsgain_setting(struct device *dev,
struct device_attribute *attr,
const char *buf,
size_t count)
{ … }
static ssize_t ds2781_get_pio_pin(struct device *dev,
struct device_attribute *attr,
char *buf)
{ … }
static ssize_t ds2781_set_pio_pin(struct device *dev,
struct device_attribute *attr,
const char *buf,
size_t count)
{ … }
static ssize_t ds2781_read_param_eeprom_bin(struct file *filp,
struct kobject *kobj,
struct bin_attribute *bin_attr,
char *buf, loff_t off, size_t count)
{ … }
static ssize_t ds2781_write_param_eeprom_bin(struct file *filp,
struct kobject *kobj,
struct bin_attribute *bin_attr,
char *buf, loff_t off, size_t count)
{ … }
static struct bin_attribute ds2781_param_eeprom_bin_attr = …;
static ssize_t ds2781_read_user_eeprom_bin(struct file *filp,
struct kobject *kobj,
struct bin_attribute *bin_attr,
char *buf, loff_t off, size_t count)
{ … }
static ssize_t ds2781_write_user_eeprom_bin(struct file *filp,
struct kobject *kobj,
struct bin_attribute *bin_attr,
char *buf, loff_t off, size_t count)
{ … }
static struct bin_attribute ds2781_user_eeprom_bin_attr = …;
static DEVICE_ATTR(pmod_enabled, S_IRUGO | S_IWUSR, ds2781_get_pmod_enabled,
ds2781_set_pmod_enabled);
static DEVICE_ATTR(sense_resistor_value, S_IRUGO | S_IWUSR,
ds2781_get_sense_resistor_value, ds2781_set_sense_resistor_value);
static DEVICE_ATTR(rsgain_setting, S_IRUGO | S_IWUSR, ds2781_get_rsgain_setting,
ds2781_set_rsgain_setting);
static DEVICE_ATTR(pio_pin, S_IRUGO | S_IWUSR, ds2781_get_pio_pin,
ds2781_set_pio_pin);
static struct attribute *ds2781_sysfs_attrs[] = …;
static struct bin_attribute *ds2781_sysfs_bin_attrs[] = …;
static const struct attribute_group ds2781_sysfs_group = …;
static const struct attribute_group *ds2781_sysfs_groups[] = …;
static int ds2781_battery_probe(struct platform_device *pdev)
{ … }
static struct platform_driver ds2781_battery_driver = …;
module_platform_driver(…) …;
MODULE_LICENSE(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_ALIAS(…) …;