#include <linux/module.h>
#include <linux/init.h>
#include <linux/platform_device.h>
#include <linux/mutex.h>
#include <linux/err.h>
#include <linux/i2c.h>
#include <linux/delay.h>
#include <linux/interrupt.h>
#include <linux/power_supply.h>
#include <linux/of.h>
#include <linux/regmap.h>
#include <linux/slab.h>
#include <linux/iio/consumer.h>
#define MAX17040_VCELL …
#define MAX17040_SOC …
#define MAX17040_MODE …
#define MAX17040_VER …
#define MAX17040_CONFIG …
#define MAX17040_STATUS …
#define MAX17040_CMD …
#define MAX17040_DELAY …
#define MAX17040_BATTERY_FULL …
#define MAX17040_RCOMP_DEFAULT …
#define MAX17040_ATHD_MASK …
#define MAX17040_ALSC_MASK …
#define MAX17040_ATHD_DEFAULT_POWER_UP …
#define MAX17040_STATUS_HD_MASK …
#define MAX17040_STATUS_SC_MASK …
#define MAX17040_CFG_RCOMP_MASK …
enum chip_id { … };
struct chip_data { … };
static struct chip_data max17040_family[] = …;
struct max17040_chip { … };
static int max17040_reset(struct max17040_chip *chip)
{ … }
static int max17040_set_low_soc_alert(struct max17040_chip *chip, u32 level)
{ … }
static int max17040_set_soc_alert(struct max17040_chip *chip, bool enable)
{ … }
static int max17040_set_rcomp(struct max17040_chip *chip, u16 rcomp)
{ … }
static int max17040_raw_vcell_to_uvolts(struct max17040_chip *chip, u16 vcell)
{ … }
static int max17040_get_vcell(struct max17040_chip *chip)
{ … }
static int max17040_get_soc(struct max17040_chip *chip)
{ … }
static int max17040_get_version(struct max17040_chip *chip)
{ … }
static int max17040_get_online(struct max17040_chip *chip)
{ … }
static int max17040_get_of_data(struct max17040_chip *chip)
{ … }
static void max17040_check_changes(struct max17040_chip *chip)
{ … }
static void max17040_queue_work(struct max17040_chip *chip)
{ … }
static void max17040_stop_work(void *data)
{ … }
static void max17040_work(struct work_struct *work)
{ … }
static bool max17040_handle_soc_alert(struct max17040_chip *chip)
{ … }
static irqreturn_t max17040_thread_handler(int id, void *dev)
{ … }
static int max17040_enable_alert_irq(struct max17040_chip *chip)
{ … }
static int max17040_prop_writeable(struct power_supply *psy,
enum power_supply_property psp)
{ … }
static int max17040_set_property(struct power_supply *psy,
enum power_supply_property psp,
const union power_supply_propval *val)
{ … }
static int max17040_get_property(struct power_supply *psy,
enum power_supply_property psp,
union power_supply_propval *val)
{ … }
static const struct regmap_config max17040_regmap = …;
static enum power_supply_property max17040_battery_props[] = …;
static const struct power_supply_desc max17040_battery_desc = …;
static int max17040_probe(struct i2c_client *client)
{ … }
#ifdef CONFIG_PM_SLEEP
static int max17040_suspend(struct device *dev)
{ … }
static int max17040_resume(struct device *dev)
{ … }
static SIMPLE_DEV_PM_OPS(max17040_pm_ops, max17040_suspend, max17040_resume);
#define MAX17040_PM_OPS …
#else
#define MAX17040_PM_OPS …
#endif
static const struct i2c_device_id max17040_id[] = …;
MODULE_DEVICE_TABLE(i2c, max17040_id);
static const struct of_device_id max17040_of_match[] = …;
MODULE_DEVICE_TABLE(of, max17040_of_match);
static struct i2c_driver max17040_i2c_driver = …;
module_i2c_driver(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;