linux/drivers/mtd/ubi/block.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2014 Ezequiel Garcia
 * Copyright (c) 2011 Free Electrons
 *
 * Driver parameter handling strongly based on drivers/mtd/ubi/build.c
 *   Copyright (c) International Business Machines Corp., 2006
 *   Copyright (c) Nokia Corporation, 2007
 *   Authors: Artem Bityutskiy, Frank Haverkamp
 */

/*
 * Read-only block devices on top of UBI volumes
 *
 * A simple implementation to allow a block device to be layered on top of a
 * UBI volume. The implementation is provided by creating a static 1-to-1
 * mapping between the block device and the UBI volume.
 *
 * The addressed byte is obtained from the addressed block sector, which is
 * mapped linearly into the corresponding LEB:
 *
 *   LEB number = addressed byte / LEB size
 *
 * This feature is compiled in the UBI core, and adds a 'block' parameter
 * to allow early creation of block devices on top of UBI volumes. Runtime
 * block creation/removal for UBI volumes is provided through two UBI ioctls:
 * UBI_IOCVOLCRBLK and UBI_IOCVOLRMBLK.
 */

#include <linux/module.h>
#include <linux/init.h>
#include <linux/err.h>
#include <linux/kernel.h>
#include <linux/list.h>
#include <linux/mutex.h>
#include <linux/slab.h>
#include <linux/mtd/ubi.h>
#include <linux/blkdev.h>
#include <linux/blk-mq.h>
#include <linux/hdreg.h>
#include <linux/scatterlist.h>
#include <linux/idr.h>
#include <asm/div64.h>

#include "ubi-media.h"
#include "ubi.h"

/* Maximum number of supported devices */
#define UBIBLOCK_MAX_DEVICES

/* Maximum length of the 'block=' parameter */
#define UBIBLOCK_PARAM_LEN

/* Maximum number of comma-separated items in the 'block=' parameter */
#define UBIBLOCK_PARAM_COUNT

struct ubiblock_param {};

struct ubiblock_pdu {};

/* Numbers of elements set in the @ubiblock_param array */
static int ubiblock_devs;

/* MTD devices specification parameters */
static struct ubiblock_param ubiblock_param[UBIBLOCK_MAX_DEVICES];

struct ubiblock {};

/* Linked list of all ubiblock instances */
static LIST_HEAD(ubiblock_devices);
static DEFINE_IDR(ubiblock_minor_idr);
/* Protects ubiblock_devices and ubiblock_minor_idr */
static DEFINE_MUTEX(devices_mutex);
static int ubiblock_major;

static int __init ubiblock_set_param(const char *val,
				     const struct kernel_param *kp)
{}

static const struct kernel_param_ops ubiblock_param_ops =;
module_param_cb();
MODULE_PARM_DESC();

static struct ubiblock *find_dev_nolock(int ubi_num, int vol_id)
{}

static blk_status_t ubiblock_read(struct request *req)
{}

static int ubiblock_open(struct gendisk *disk, blk_mode_t mode)
{}

static void ubiblock_release(struct gendisk *gd)
{}

static int ubiblock_getgeo(struct block_device *bdev, struct hd_geometry *geo)
{}

static const struct block_device_operations ubiblock_ops =;

static blk_status_t ubiblock_queue_rq(struct blk_mq_hw_ctx *hctx,
			     const struct blk_mq_queue_data *bd)
{}

static int ubiblock_init_request(struct blk_mq_tag_set *set,
		struct request *req, unsigned int hctx_idx,
		unsigned int numa_node)
{}

static const struct blk_mq_ops ubiblock_mq_ops =;

static int calc_disk_capacity(struct ubi_volume_info *vi, u64 *disk_capacity)
{}

int ubiblock_create(struct ubi_volume_info *vi)
{}

static void ubiblock_cleanup(struct ubiblock *dev)
{}

int ubiblock_remove(struct ubi_volume_info *vi)
{}

static int ubiblock_resize(struct ubi_volume_info *vi)
{}

static bool
match_volume_desc(struct ubi_volume_info *vi, const char *name, int ubi_num, int vol_id)
{}

static void
ubiblock_create_from_param(struct ubi_volume_info *vi)
{}

static int ubiblock_notify(struct notifier_block *nb,
			 unsigned long notification_type, void *ns_ptr)
{}

static struct notifier_block ubiblock_notifier =;

static void ubiblock_remove_all(void)
{}

int __init ubiblock_init(void)
{}

void ubiblock_exit(void)
{}