linux/drivers/hwmon/sht4x.c

// SPDX-License-Identifier: GPL-2.0-only

/*
 * Copyright (c) Linumiz 2021
 *
 * sht4x.c - Linux hwmon driver for SHT4x Temperature and Humidity sensor
 *
 * Author: Navin Sankar Velliangiri <[email protected]>
 */

#include <linux/crc8.h>
#include <linux/delay.h>
#include <linux/hwmon.h>
#include <linux/i2c.h>
#include <linux/jiffies.h>
#include <linux/module.h>

/*
 * Poll intervals (in milliseconds)
 */
#define SHT4X_MIN_POLL_INTERVAL

/*
 * I2C command delays (in microseconds)
 */
#define SHT4X_MEAS_DELAY_HPM
#define SHT4X_DELAY_EXTRA

/*
 * Command Bytes
 */
#define SHT4X_CMD_MEASURE_HPM
#define SHT4X_CMD_RESET

#define SHT4X_CMD_LEN
#define SHT4X_CRC8_LEN
#define SHT4X_WORD_LEN
#define SHT4X_RESPONSE_LENGTH
#define SHT4X_CRC8_POLYNOMIAL
#define SHT4X_CRC8_INIT
#define SHT4X_MIN_TEMPERATURE
#define SHT4X_MAX_TEMPERATURE
#define SHT4X_MIN_HUMIDITY
#define SHT4X_MAX_HUMIDITY

DECLARE_CRC8_TABLE(sht4x_crc8_table);

/**
 * struct sht4x_data - All the data required to operate an SHT4X chip
 * @client: the i2c client associated with the SHT4X
 * @lock: a mutex that is used to prevent parallel access to the i2c client
 * @valid: validity of fields below
 * @update_interval: the minimum poll interval
 * @last_updated: the previous time that the SHT4X was polled
 * @temperature: the latest temperature value received from the SHT4X
 * @humidity: the latest humidity value received from the SHT4X
 */
struct sht4x_data {};

/**
 * sht4x_read_values() - read and parse the raw data from the SHT4X
 * @data: the struct sht4x_data to use for the lock
 * Return: 0 if successful, -ERRNO if not
 */
static int sht4x_read_values(struct sht4x_data *data)
{}

static ssize_t sht4x_interval_write(struct sht4x_data *data, long val)
{}

/* sht4x_interval_read() - read the minimum poll interval in milliseconds */
static size_t sht4x_interval_read(struct sht4x_data *data, long *val)
{}

/* sht4x_temperature1_read() - read the temperature in millidegrees */
static int sht4x_temperature1_read(struct sht4x_data *data, long *val)
{}

/* sht4x_humidity1_read() - read a relative humidity in millipercent */
static int sht4x_humidity1_read(struct sht4x_data *data, long *val)
{}

static umode_t sht4x_hwmon_visible(const void *data,
				   enum hwmon_sensor_types type,
				   u32 attr, int channel)
{}

static int sht4x_hwmon_read(struct device *dev, enum hwmon_sensor_types type,
			    u32 attr, int channel, long *val)
{}

static int sht4x_hwmon_write(struct device *dev, enum hwmon_sensor_types type,
			     u32 attr, int channel, long val)
{}

static const struct hwmon_channel_info * const sht4x_info[] =;

static const struct hwmon_ops sht4x_hwmon_ops =;

static const struct hwmon_chip_info sht4x_chip_info =;

static int sht4x_probe(struct i2c_client *client)
{}

static const struct i2c_device_id sht4x_id[] =;
MODULE_DEVICE_TABLE(i2c, sht4x_id);

static const struct of_device_id sht4x_of_match[] =;
MODULE_DEVICE_TABLE(of, sht4x_of_match);

static struct i2c_driver sht4x_driver =;

module_i2c_driver();

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();