#define pr_fmt(fmt) …
#include <linux/backing-dev.h>
#include <linux/compat.h>
#include <linux/debugfs.h>
#include <linux/device.h>
#include <linux/errno.h>
#include <linux/file.h>
#include <linux/freezer.h>
#include <linux/kernel.h>
#include <linux/kthread.h>
#include <linux/miscdevice.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/nospec.h>
#include <linux/pktcdvd.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/types.h>
#include <linux/uaccess.h>
#include <scsi/scsi.h>
#include <scsi/scsi_cmnd.h>
#include <scsi/scsi_ioctl.h>
#include <asm/unaligned.h>
#define DRIVER_NAME …
#define MAX_SPEED …
static DEFINE_MUTEX(pktcdvd_mutex);
static struct pktcdvd_device *pkt_devs[MAX_WRITERS];
static struct proc_dir_entry *pkt_proc;
static int pktdev_major;
static int write_congestion_on = …;
static int write_congestion_off = …;
static struct mutex ctl_mutex;
static mempool_t psd_pool;
static struct bio_set pkt_bio_set;
static struct class class_pktcdvd;
static struct dentry *pkt_debugfs_root = …;
static int pkt_setup_dev(dev_t dev, dev_t* pkt_dev);
static int pkt_remove_dev(dev_t pkt_dev);
static sector_t get_zone(sector_t sector, struct pktcdvd_device *pd)
{ … }
static ssize_t packets_started_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static DEVICE_ATTR_RO(packets_started);
static ssize_t packets_finished_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static DEVICE_ATTR_RO(packets_finished);
static ssize_t kb_written_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static DEVICE_ATTR_RO(kb_written);
static ssize_t kb_read_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static DEVICE_ATTR_RO(kb_read);
static ssize_t kb_read_gather_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static DEVICE_ATTR_RO(kb_read_gather);
static ssize_t reset_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t len)
{ … }
static DEVICE_ATTR_WO(reset);
static struct attribute *pkt_stat_attrs[] = …;
static const struct attribute_group pkt_stat_group = …;
static ssize_t size_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static DEVICE_ATTR_RO(size);
static void init_write_congestion_marks(int* lo, int* hi)
{ … }
static ssize_t congestion_off_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t congestion_off_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t len)
{ … }
static DEVICE_ATTR_RW(congestion_off);
static ssize_t congestion_on_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t congestion_on_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t len)
{ … }
static DEVICE_ATTR_RW(congestion_on);
static struct attribute *pkt_wq_attrs[] = …;
static const struct attribute_group pkt_wq_group = …;
static const struct attribute_group *pkt_groups[] = …;
static void pkt_sysfs_dev_new(struct pktcdvd_device *pd)
{ … }
static void pkt_sysfs_dev_remove(struct pktcdvd_device *pd)
{ … }
static ssize_t device_map_show(const struct class *c, const struct class_attribute *attr,
char *data)
{ … }
static CLASS_ATTR_RO(device_map);
static ssize_t add_store(const struct class *c, const struct class_attribute *attr,
const char *buf, size_t count)
{ … }
static CLASS_ATTR_WO(add);
static ssize_t remove_store(const struct class *c, const struct class_attribute *attr,
const char *buf, size_t count)
{ … }
static CLASS_ATTR_WO(remove);
static struct attribute *class_pktcdvd_attrs[] = …;
ATTRIBUTE_GROUPS(…);
static struct class class_pktcdvd = …;
static int pkt_sysfs_init(void)
{ … }
static void pkt_sysfs_cleanup(void)
{ … }
static void pkt_count_states(struct pktcdvd_device *pd, int *states)
{ … }
static int pkt_seq_show(struct seq_file *m, void *p)
{ … }
DEFINE_SHOW_ATTRIBUTE(…);
static void pkt_debugfs_dev_new(struct pktcdvd_device *pd)
{ … }
static void pkt_debugfs_dev_remove(struct pktcdvd_device *pd)
{ … }
static void pkt_debugfs_init(void)
{ … }
static void pkt_debugfs_cleanup(void)
{ … }
static void pkt_bio_finished(struct pktcdvd_device *pd)
{ … }
static struct packet_data *pkt_alloc_packet_data(int frames)
{ … }
static void pkt_free_packet_data(struct packet_data *pkt)
{ … }
static void pkt_shrink_pktlist(struct pktcdvd_device *pd)
{ … }
static int pkt_grow_pktlist(struct pktcdvd_device *pd, int nr_packets)
{ … }
static inline struct pkt_rb_node *pkt_rbtree_next(struct pkt_rb_node *node)
{ … }
static void pkt_rbtree_erase(struct pktcdvd_device *pd, struct pkt_rb_node *node)
{ … }
static struct pkt_rb_node *pkt_rbtree_find(struct pktcdvd_device *pd, sector_t s)
{ … }
static void pkt_rbtree_insert(struct pktcdvd_device *pd, struct pkt_rb_node *node)
{ … }
static int pkt_generic_packet(struct pktcdvd_device *pd, struct packet_command *cgc)
{ … }
static const char *sense_key_string(__u8 index)
{ … }
static void pkt_dump_sense(struct pktcdvd_device *pd,
struct packet_command *cgc)
{ … }
static int pkt_flush_cache(struct pktcdvd_device *pd)
{ … }
static noinline_for_stack int pkt_set_speed(struct pktcdvd_device *pd,
unsigned write_speed, unsigned read_speed)
{ … }
static void pkt_queue_bio(struct pktcdvd_device *pd, struct bio *bio)
{ … }
static void pkt_iosched_process_queue(struct pktcdvd_device *pd)
{ … }
static int pkt_set_segment_merging(struct pktcdvd_device *pd, struct request_queue *q)
{ … }
static void pkt_end_io_read(struct bio *bio)
{ … }
static void pkt_end_io_packet_write(struct bio *bio)
{ … }
static void pkt_gather_data(struct pktcdvd_device *pd, struct packet_data *pkt)
{ … }
static struct packet_data *pkt_get_packet_data(struct pktcdvd_device *pd, int zone)
{ … }
static void pkt_put_packet_data(struct pktcdvd_device *pd, struct packet_data *pkt)
{ … }
static inline void pkt_set_state(struct device *ddev, struct packet_data *pkt,
enum packet_data_state state)
{ … }
static int pkt_handle_queue(struct pktcdvd_device *pd)
{ … }
static void bio_list_copy_data(struct bio *dst, struct bio *src)
{ … }
static void pkt_start_write(struct pktcdvd_device *pd, struct packet_data *pkt)
{ … }
static void pkt_finish_packet(struct packet_data *pkt, blk_status_t status)
{ … }
static void pkt_run_state_machine(struct pktcdvd_device *pd, struct packet_data *pkt)
{ … }
static void pkt_handle_packets(struct pktcdvd_device *pd)
{ … }
static int kcdrwd(void *foobar)
{ … }
static void pkt_print_settings(struct pktcdvd_device *pd)
{ … }
static int pkt_mode_sense(struct pktcdvd_device *pd, struct packet_command *cgc, int page_code, int page_control)
{ … }
static int pkt_mode_select(struct pktcdvd_device *pd, struct packet_command *cgc)
{ … }
static int pkt_get_disc_info(struct pktcdvd_device *pd, disc_information *di)
{ … }
static int pkt_get_track_info(struct pktcdvd_device *pd, __u16 track, __u8 type, track_information *ti)
{ … }
static noinline_for_stack int pkt_get_last_written(struct pktcdvd_device *pd,
long *last_written)
{ … }
static noinline_for_stack int pkt_set_write_settings(struct pktcdvd_device *pd)
{ … }
static int pkt_writable_track(struct pktcdvd_device *pd, track_information *ti)
{ … }
static int pkt_writable_disc(struct pktcdvd_device *pd, disc_information *di)
{ … }
static noinline_for_stack int pkt_probe_settings(struct pktcdvd_device *pd)
{ … }
static noinline_for_stack int pkt_write_caching(struct pktcdvd_device *pd)
{ … }
static int pkt_lock_door(struct pktcdvd_device *pd, int lockflag)
{ … }
static noinline_for_stack int pkt_get_max_speed(struct pktcdvd_device *pd,
unsigned *write_speed)
{ … }
static char clv_to_speed[16] = …;
static char hs_clv_to_speed[16] = …;
static char us_clv_to_speed[16] = …;
static noinline_for_stack int pkt_media_speed(struct pktcdvd_device *pd,
unsigned *speed)
{ … }
static noinline_for_stack int pkt_perform_opc(struct pktcdvd_device *pd)
{ … }
static int pkt_open_write(struct pktcdvd_device *pd)
{ … }
static int pkt_open_dev(struct pktcdvd_device *pd, bool write)
{ … }
static void pkt_release_dev(struct pktcdvd_device *pd, int flush)
{ … }
static struct pktcdvd_device *pkt_find_dev_from_minor(unsigned int dev_minor)
{ … }
static int pkt_open(struct gendisk *disk, blk_mode_t mode)
{ … }
static void pkt_release(struct gendisk *disk)
{ … }
static void pkt_end_io_read_cloned(struct bio *bio)
{ … }
static void pkt_make_request_read(struct pktcdvd_device *pd, struct bio *bio)
{ … }
static void pkt_make_request_write(struct bio *bio)
{ … }
static void pkt_submit_bio(struct bio *bio)
{ … }
static int pkt_new_dev(struct pktcdvd_device *pd, dev_t dev)
{ … }
static int pkt_ioctl(struct block_device *bdev, blk_mode_t mode,
unsigned int cmd, unsigned long arg)
{ … }
static unsigned int pkt_check_events(struct gendisk *disk,
unsigned int clearing)
{ … }
static char *pkt_devnode(struct gendisk *disk, umode_t *mode)
{ … }
static const struct block_device_operations pktcdvd_ops = …;
static int pkt_setup_dev(dev_t dev, dev_t* pkt_dev)
{ … }
static int pkt_remove_dev(dev_t pkt_dev)
{ … }
static void pkt_get_status(struct pkt_ctrl_command *ctrl_cmd)
{ … }
static long pkt_ctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{ … }
#ifdef CONFIG_COMPAT
static long pkt_ctl_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{ … }
#endif
static const struct file_operations pkt_ctl_fops = …;
static struct miscdevice pkt_misc = …;
static int __init pkt_init(void)
{ … }
static void __exit pkt_exit(void)
{ … }
MODULE_DESCRIPTION(…) …;
MODULE_AUTHOR(…) …;
MODULE_LICENSE(…) …;
module_init(…) …;
module_exit(pkt_exit);