linux/drivers/char/ipmi/ipmb_dev_int.c

// SPDX-License-Identifier: GPL-2.0

/*
 * IPMB driver to receive a request and send a response
 *
 * Copyright (C) 2019 Mellanox Techologies, Ltd.
 *
 * This was inspired by Brendan Higgins' ipmi-bmc-bt-i2c driver.
 */

#include <linux/acpi.h>
#include <linux/errno.h>
#include <linux/i2c.h>
#include <linux/miscdevice.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/poll.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/wait.h>

#define MAX_MSG_LEN
#define IPMB_REQUEST_LEN_MIN
#define NETFN_RSP_BIT_MASK
#define REQUEST_QUEUE_MAX_LEN

#define IPMB_MSG_LEN_IDX
#define RQ_SA_8BIT_IDX
#define NETFN_LUN_IDX

#define GET_7BIT_ADDR(addr_8bit)
#define GET_8BIT_ADDR(addr_7bit)

#define IPMB_MSG_PAYLOAD_LEN_MAX

#define SMBUS_MSG_HEADER_LENGTH
#define SMBUS_MSG_IDX_OFFSET

struct ipmb_msg {} __packed;

struct ipmb_request_elem {};

struct ipmb_dev {};

static inline struct ipmb_dev *to_ipmb_dev(struct file *file)
{}

static ssize_t ipmb_read(struct file *file, char __user *buf, size_t count,
			loff_t *ppos)
{}

static int ipmb_i2c_write(struct i2c_client *client, u8 *msg, u8 addr)
{}

static ssize_t ipmb_write(struct file *file, const char __user *buf,
			size_t count, loff_t *ppos)
{}

static __poll_t ipmb_poll(struct file *file, poll_table *wait)
{}

static const struct file_operations ipmb_fops =;

/* Called with ipmb_dev->lock held. */
static void ipmb_handle_request(struct ipmb_dev *ipmb_dev)
{}

static u8 ipmb_verify_checksum1(struct ipmb_dev *ipmb_dev, u8 rs_sa)
{}

/*
 * Verify if message has proper ipmb header with minimum length
 * and correct checksum byte.
 */
static bool is_ipmb_msg(struct ipmb_dev *ipmb_dev, u8 rs_sa)
{}

/*
 * The IPMB protocol only supports I2C Writes so there is no need
 * to support I2C_SLAVE_READ* events.
 * This i2c callback function only monitors IPMB request messages
 * and adds them in a queue, so that they can be handled by
 * receive_ipmb_request.
 */
static int ipmb_slave_cb(struct i2c_client *client,
			enum i2c_slave_event event, u8 *val)
{}

static int ipmb_probe(struct i2c_client *client)
{}

static void ipmb_remove(struct i2c_client *client)
{}

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

static const struct acpi_device_id acpi_ipmb_id[] =;
MODULE_DEVICE_TABLE(acpi, acpi_ipmb_id);

static struct i2c_driver ipmb_driver =;
module_i2c_driver();

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