drivers/s390/crypto/zcrypt_queue.c

Source file repositories/reference/linux-study-clean/drivers/s390/crypto/zcrypt_queue.c

File Facts

System
Linux kernel
Corpus path
drivers/s390/crypto/zcrypt_queue.c
Extension
.c
Size
5556 bytes
Lines
235
Domain
Driver Families
Bucket
drivers/s390
Inferred role
Driver Families: exported/initcall integration point
Status
integration implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

// SPDX-License-Identifier: GPL-2.0+
/*
 *  Copyright IBM Corp. 2001, 2012
 *  Author(s): Robert Burroughs
 *	       Eric Rossman (edrossma@us.ibm.com)
 *	       Cornelia Huck <cornelia.huck@de.ibm.com>
 *
 *  Hotplug & misc device support: Jochen Roehrig (roehrig@de.ibm.com)
 *  Major cleanup & driver split: Martin Schwidefsky <schwidefsky@de.ibm.com>
 *				  Ralph Wuerthner <rwuerthn@de.ibm.com>
 *  MSGTYPE restruct:		  Holger Dengler <hd@linux.vnet.ibm.com>
 */

#include <linux/export.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/miscdevice.h>
#include <linux/fs.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/slab.h>
#include <linux/atomic.h>
#include <linux/uaccess.h>
#include <linux/hw_random.h>
#include <linux/debugfs.h>
#include <asm/debug.h>

#include "zcrypt_debug.h"
#include "zcrypt_api.h"

#include "zcrypt_msgtype6.h"
#include "zcrypt_msgtype50.h"

/*
 * Device attributes common for all crypto queue devices.
 */

static ssize_t online_show(struct device *dev,
			   struct device_attribute *attr,
			   char *buf)
{
	struct zcrypt_queue *zq = dev_get_drvdata(dev);
	struct ap_queue *aq = to_ap_queue(dev);
	int online = aq->config && !aq->chkstop && zq->online ? 1 : 0;

	return sysfs_emit(buf, "%d\n", online);
}

static ssize_t online_store(struct device *dev,
			    struct device_attribute *attr,
			    const char *buf, size_t count)
{
	struct zcrypt_queue *zq = dev_get_drvdata(dev);
	struct ap_queue *aq = to_ap_queue(dev);
	struct zcrypt_card *zc = zq->zcard;
	int online;

	if (sscanf(buf, "%d\n", &online) != 1 || online < 0 || online > 1)
		return -EINVAL;

	if (online && (!aq->config || !aq->card->config ||
		       aq->chkstop || aq->card->chkstop))
		return -ENODEV;
	if (online && !zc->online)
		return -EINVAL;
	zq->online = online;

	ZCRYPT_DBF_INFO("%s queue=%02x.%04x online=%d\n",
			__func__, AP_QID_CARD(zq->queue->qid),
			AP_QID_QUEUE(zq->queue->qid), online);

	ap_send_online_uevent(&aq->ap_dev, online);

	if (!online)
		ap_flush_queue(zq->queue);
	return count;
}

static DEVICE_ATTR_RW(online);

static ssize_t load_show(struct device *dev,
			 struct device_attribute *attr,
			 char *buf)
{
	struct zcrypt_queue *zq = dev_get_drvdata(dev);

	return sysfs_emit(buf, "%d\n", atomic_read(&zq->load));
}

Annotation

Implementation Notes