From: Niklas Cassel <cassel@kernel.org>
To: Damien Le Moal <dlemoal@kernel.org>
Cc: linux-ide@vger.kernel.org, Igor Pylypiv <ipylypiv@google.com>,
Shao Mingyin <shao.mingyin@zte.com.cn>,
Hannes Reinecke <hare@kernel.org>,
Niklas Cassel <cassel@kernel.org>
Subject: [PATCH 8/8] ata: libata-scsi: document the MODE SENSE mode page functions
Date: Tue, 3 Nov 2026 21:54:57 +0100 [thread overview]
Message-ID: <20261103205448.931471-18-cassel@kernel.org> (raw)
In-Reply-To: <20261103205448.931471-10-cassel@kernel.org>
The ata_msense_*() functions generate the mode pages returned by MODE
SENSE, and are also used by the MODE SELECT mode page handlers to check
the mode page data. They do not document where their buf argument points
and what they return, and some of them do not have a kernel-doc comment
at all.
Add kernel-doc comments for all of them, stating that the mode page is
written to buf starting with its mode page header, which matches how
the MODE SELECT mode page handlers get the mode page, and that they
return the length of the mode page, including the mode page header.
No functional change.
Signed-off-by: Niklas Cassel <cassel@kernel.org>
---
drivers/ata/libata-scsi.c | 100 +++++++++++++++++++++++++++++++++-----
1 file changed, 88 insertions(+), 12 deletions(-)
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index e91920659c22..efdaf20b0ca4 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -2645,15 +2645,23 @@ static void modecpy(u8 *dest, const u8 *src, int n, bool changeable)
/**
* ata_msense_caching - Simulate MODE SENSE caching info page
* @id: device IDENTIFY data
- * @buf: output buffer
+ * @buf: Output buffer for the mode page, including the mode page header
* @changeable: whether changeable parameters are requested
*
* Generate a caching info page, which conditionally indicates
* write caching to the SCSI layer, depending on device
* capabilities.
*
+ * The mode page is written to @buf starting with its mode page header,
+ * so offsets in @buf are the byte numbers of the mode page. For MODE
+ * SENSE, the mode parameter header and the block descriptors are written
+ * by ata_scsiop_mode_sense().
+ *
* LOCKING:
* None.
+ *
+ * RETURNS:
+ * Length of the mode page, including the mode page header.
*/
static unsigned int ata_msense_caching(u16 *id, u8 *buf, bool changeable)
{
@@ -2667,8 +2675,25 @@ static unsigned int ata_msense_caching(u16 *id, u8 *buf, bool changeable)
return sizeof(def_cache_mpage);
}
-/*
- * Simulate MODE SENSE control mode page, sub-page 0.
+/**
+ * ata_msense_control_spg0 - Simulate MODE SENSE for control sub-page 0
+ * @dev: ATA device of interest
+ * @buf: Output buffer for the mode page, including the mode page header
+ * @changeable: whether changeable parameters are requested
+ *
+ * Simulate MODE SENSE control mode page, sub-page 0, which reports the
+ * sense data format (D_SENSE) used for the device.
+ *
+ * The mode page is written to @buf starting with its mode page header,
+ * so offsets in @buf are the byte numbers of the mode page. For MODE
+ * SENSE, the mode parameter header and the block descriptors are written
+ * by ata_scsiop_mode_sense().
+ *
+ * LOCKING:
+ * None.
+ *
+ * RETURNS:
+ * Length of the mode page, including the mode page header.
*/
static unsigned int ata_msense_control_spg0(struct ata_device *dev, u8 *buf,
bool changeable)
@@ -2700,9 +2725,27 @@ static inline u16 ata_xlat_cdl_limit(u8 *buf)
return min_t(u32, limit / 10000, 65535);
}
-/*
- * Simulate MODE SENSE control mode page, sub-pages 07h and 08h
- * (command duration limits T2A and T2B mode pages).
+/**
+ * ata_msense_control_spgt2 - Simulate MODE SENSE for CDL T2A/T2B pages
+ * @dev: ATA device of interest
+ * @buf: Output buffer for the mode page, including the mode page header
+ * @spg: Sub-page code, CDL_T2A_SUB_MPAGE or CDL_T2B_SUB_MPAGE
+ *
+ * Simulate MODE SENSE control mode page, sub-pages 07h and 08h
+ * (command duration limits T2A and T2B mode pages), from the command
+ * duration limit descriptors read from the device.
+ *
+ * The mode page is written to @buf starting with its mode page header,
+ * so offsets in @buf are the byte numbers of the mode page. For MODE
+ * SENSE, the mode parameter header and the block descriptors are written
+ * by ata_scsiop_mode_sense().
+ *
+ * LOCKING:
+ * None.
+ *
+ * RETURNS:
+ * Length of the mode page, including the mode page header, or 0 if the
+ * device does not support command duration limits.
*/
static unsigned int ata_msense_control_spgt2(struct ata_device *dev, u8 *buf,
u8 spg)
@@ -2759,9 +2802,25 @@ static unsigned int ata_msense_control_spgt2(struct ata_device *dev, u8 *buf,
return CDL_T2_SUB_MPAGE_LEN;
}
-/*
- * Simulate MODE SENSE control mode page, sub-page f2h
- * (ATA feature control mode page).
+/**
+ * ata_msense_control_ata_feature - Simulate ATA Feature Control page
+ * @dev: ATA device of interest
+ * @buf: Output buffer for the mode page, including the mode page header
+ *
+ * Simulate MODE SENSE control mode page, sub-page f2h (ATA feature
+ * control mode page), which reports whether command duration limits are
+ * enabled.
+ *
+ * The mode page is written to @buf starting with its mode page header,
+ * so offsets in @buf are the byte numbers of the mode page. For MODE
+ * SENSE, the mode parameter header and the block descriptors are written
+ * by ata_scsiop_mode_sense().
+ *
+ * LOCKING:
+ * None.
+ *
+ * RETURNS:
+ * Length of the mode page, including the mode page header.
*/
static unsigned int ata_msense_control_ata_feature(struct ata_device *dev,
u8 *buf)
@@ -2787,14 +2846,23 @@ static unsigned int ata_msense_control_ata_feature(struct ata_device *dev,
/**
* ata_msense_control - Simulate MODE SENSE control mode page
* @dev: ATA device of interest
- * @buf: output buffer
+ * @buf: Output buffer for the mode pages, including the page headers
* @spg: sub-page code
* @changeable: whether changeable parameters are requested
*
- * Generate a generic MODE SENSE control mode page.
+ * Generate sub-page @spg of the control mode page, or all supported
+ * sub-pages of the control mode page if @spg is ALL_SUB_MPAGES.
+ *
+ * The mode pages are written to @buf one after the other, each starting
+ * with its mode page header. For MODE SENSE, the mode parameter header
+ * and the block descriptors are written by ata_scsiop_mode_sense().
*
* LOCKING:
* None.
+ *
+ * RETURNS:
+ * Total length of the mode pages written to @buf, including their mode
+ * page headers.
*/
static unsigned int ata_msense_control(struct ata_device *dev, u8 *buf,
u8 spg, bool changeable)
@@ -2822,13 +2890,21 @@ static unsigned int ata_msense_control(struct ata_device *dev, u8 *buf,
/**
* ata_msense_rw_recovery - Simulate MODE SENSE r/w error recovery page
- * @buf: output buffer
+ * @buf: Output buffer for the mode page, including the mode page header
* @changeable: whether changeable parameters are requested
*
* Generate a generic MODE SENSE r/w error recovery page.
*
+ * The mode page is written to @buf starting with its mode page header,
+ * so offsets in @buf are the byte numbers of the mode page. For MODE
+ * SENSE, the mode parameter header and the block descriptors are written
+ * by ata_scsiop_mode_sense().
+ *
* LOCKING:
* None.
+ *
+ * RETURNS:
+ * Length of the mode page, including the mode page header.
*/
static unsigned int ata_msense_rw_recovery(u8 *buf, bool changeable)
{
--
2.56.0
next prev parent reply other threads:[~2026-11-03 20:55 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-03 20:54 [PATCH 0/8] ata: libata-scsi: MODE SELECT fixes and cleanups Niklas Cassel
2026-11-03 20:54 ` [PATCH 1/8] ata: libata-scsi: fix MODE SELECT handling of data after the mode page Niklas Cassel
2026-11-03 21:20 ` Damien Le Moal
2026-11-03 20:54 ` [PATCH 2/8] ata: libata-scsi: do not accept subpage code FFh in MODE SELECT Niklas Cassel
2026-11-03 21:20 ` Damien Le Moal
2026-11-03 20:54 ` [PATCH 3/8] ata: libata-scsi: reject MODE SELECT mode pages with a wrong SPF bit Niklas Cassel
2026-11-03 21:22 ` Damien Le Moal
2026-11-03 20:54 ` [PATCH 4/8] ata: libata-scsi: fix MODE SELECT field pointer for unsupported subpages Niklas Cassel
2026-11-03 21:23 ` Damien Le Moal
2026-11-03 20:54 ` [PATCH 5/8] ata: libata-scsi: fix MODE SELECT field pointer for block descriptor length Niklas Cassel
2026-11-03 21:24 ` Damien Le Moal
2026-11-03 20:54 ` [PATCH 6/8] ata: libata-scsi: pass the whole mode page to the MODE SELECT handlers Niklas Cassel
2026-11-03 21:33 ` Damien Le Moal
2026-11-03 20:54 ` [PATCH 7/8] ata: libata-scsi: set the field pointer when rejecting CDL Niklas Cassel
2026-11-03 21:34 ` Damien Le Moal
2026-11-03 20:54 ` Niklas Cassel [this message]
2026-11-03 21:36 ` [PATCH 8/8] ata: libata-scsi: document the MODE SENSE mode page functions Damien Le Moal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261103205448.931471-18-cassel@kernel.org \
--to=cassel@kernel.org \
--cc=dlemoal@kernel.org \
--cc=hare@kernel.org \
--cc=ipylypiv@google.com \
--cc=linux-ide@vger.kernel.org \
--cc=shao.mingyin@zte.com.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox