drivers/s390/block/dasd_genhd.c
Source file repositories/reference/linux-study-clean/drivers/s390/block/dasd_genhd.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/s390/block/dasd_genhd.c- Extension
.c- Size
- 5831 bytes
- Lines
- 234
- Domain
- Driver Families
- Bucket
- drivers/s390
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/interrupt.hlinux/major.hlinux/fs.hlinux/blkpg.hlinux/uaccess.hdasd_int.h
Detected Declarations
function dasd_name_formatfunction dasd_gendisk_allocfunction dasd_gd_freefunction dasd_gendisk_freefunction dasd_scan_partitionsfunction dasd_destroy_partitionsfunction dasd_gendisk_initfunction dasd_gendisk_exit
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com>
* Horst Hummel <Horst.Hummel@de.ibm.com>
* Carsten Otte <Cotte@de.ibm.com>
* Martin Schwidefsky <schwidefsky@de.ibm.com>
* Bugreports.to..: <Linux390@de.ibm.com>
* Copyright IBM Corp. 1999, 2001
*
* gendisk related functions for the dasd driver.
*
*/
#include <linux/interrupt.h>
#include <linux/major.h>
#include <linux/fs.h>
#include <linux/blkpg.h>
#include <linux/uaccess.h>
#include "dasd_int.h"
static unsigned int queue_depth = 32;
static unsigned int nr_hw_queues = 4;
static void dasd_gd_free(struct gendisk *gdp);
module_param(queue_depth, uint, 0444);
MODULE_PARM_DESC(queue_depth, "Default queue depth for new DASD devices");
module_param(nr_hw_queues, uint, 0444);
MODULE_PARM_DESC(nr_hw_queues, "Default number of hardware queues for new DASD devices");
/*
* Set device name.
* dasda - dasdz : 26 devices
* dasdaa - dasdzz : 676 devices, added up = 702
* dasdaaa - dasdzzz : 17576 devices, added up = 18278
* dasdaaaa - dasdzzzz : 456976 devices, added up = 475252
*/
static int dasd_name_format(char *prefix, int index, char *buf, int buflen)
{
const int base = 'z' - 'a' + 1;
char *begin = buf + strlen(prefix);
char *end = buf + buflen;
char *p;
int unit;
p = end - 1;
*p = '\0';
unit = base;
do {
if (p == begin)
return -EINVAL;
*--p = 'a' + (index % unit);
index = (index / unit) - 1;
} while (index >= 0);
memmove(begin, p, end - p);
memcpy(buf, prefix, strlen(prefix));
return 0;
}
/*
* Allocate and register gendisk structure for device.
*/
int dasd_gendisk_alloc(struct dasd_block *block)
{
struct queue_limits lim = {
/*
* With page sized segments, each segment can be translated into
* one idaw/tidaw.
*/
.max_segment_size = PAGE_SIZE,
.seg_boundary_mask = PAGE_SIZE - 1,
.max_segments = USHRT_MAX,
};
struct gendisk *gdp;
struct dasd_device *base;
unsigned int devindex;
int rc;
/* Make sure the minor for this device exists. */
base = block->base;
devindex = base->devindex;
if (devindex >= DASD_PER_MAJOR)
return -EBUSY;
block->tag_set.ops = &dasd_mq_ops;
block->tag_set.cmd_size = sizeof(struct dasd_ccw_req);
Annotation
- Immediate include surface: `linux/interrupt.h`, `linux/major.h`, `linux/fs.h`, `linux/blkpg.h`, `linux/uaccess.h`, `dasd_int.h`.
- Detected declarations: `function dasd_name_format`, `function dasd_gendisk_alloc`, `function dasd_gd_free`, `function dasd_gendisk_free`, `function dasd_scan_partitions`, `function dasd_destroy_partitions`, `function dasd_gendisk_init`, `function dasd_gendisk_exit`.
- Atlas domain: Driver Families / drivers/s390.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.