linux/drivers/staging/greybus/fw-download.c

// SPDX-License-Identifier: GPL-2.0
/*
 * Greybus Firmware Download Protocol Driver.
 *
 * Copyright 2016 Google Inc.
 * Copyright 2016 Linaro Ltd.
 */

#include <linux/firmware.h>
#include <linux/jiffies.h>
#include <linux/mutex.h>
#include <linux/workqueue.h>
#include <linux/greybus.h>
#include "firmware.h"

/* Estimated minimum buffer size, actual size can be smaller than this */
#define MIN_FETCH_SIZE
/* Timeout, in jiffies, within which fetch or release firmware must be called */
#define NEXT_REQ_TIMEOUT_J

struct fw_request {};

struct fw_download {};

static void fw_req_release(struct kref *kref)
{}

/*
 * Incoming requests are serialized for a connection, and the only race possible
 * is between the timeout handler freeing this and an incoming request.
 *
 * The operations on the fw-request list are protected by the mutex and
 * get_fw_req() increments the reference count before returning a fw_req pointer
 * to the users.
 *
 * free_firmware() also takes the mutex while removing an entry from the list,
 * it guarantees that every user of fw_req has taken a kref-reference by now and
 * we wouldn't have any new users.
 *
 * Once the last user drops the reference, the fw_req structure is freed.
 */
static void put_fw_req(struct fw_request *fw_req)
{}

/* Caller must call put_fw_req() after using struct fw_request */
static struct fw_request *get_fw_req(struct fw_download *fw_download,
				     u8 firmware_id)
{}

static void free_firmware(struct fw_download *fw_download,
			  struct fw_request *fw_req)
{}

static void fw_request_timedout(struct work_struct *work)
{}

static int exceeds_release_timeout(struct fw_request *fw_req)
{}

/* This returns path of the firmware blob on the disk */
static struct fw_request *find_firmware(struct fw_download *fw_download,
					const char *tag)
{}

static int fw_download_find_firmware(struct gb_operation *op)
{}

static int fw_download_fetch_firmware(struct gb_operation *op)
{}

static int fw_download_release_firmware(struct gb_operation *op)
{}

int gb_fw_download_request_handler(struct gb_operation *op)
{}

int gb_fw_download_connection_init(struct gb_connection *connection)
{}

void gb_fw_download_connection_exit(struct gb_connection *connection)
{}