From: Mattijs Korpershoek <mkorpershoek@baylibre.com>
To: Simon Glass <sjg@chromium.org>,
U-Boot Mailing List <u-boot@lists.denx.de>
Cc: Bin Meng <bmeng.cn@gmail.com>, Simon Glass <sjg@chromium.org>,
Heinrich Schuchardt <xypron.glpk@gmx.de>
Subject: Re: [PATCH 10/30] ide: Correct use of ATAPI
Date: Tue, 28 Mar 2023 16:23:20 +0200 [thread overview]
Message-ID: <87jzz10xbb.fsf@baylibre.com> (raw)
In-Reply-To: <20230328080702.10.Ia41ab329f6a5b52b15e58c5f405ce07c5b5545d1@changeid>
On mar., mars 28, 2023 at 08:06, Simon Glass <sjg@chromium.org> wrote:
> The use of atapi_read() was incorrect dropped. Fix this so that it will
> be used when needed. Use a udevice for the first argument of atapi_read()
> so it is consistent with ide_read().
>
> This requires much of the ATAPI code to be brought out from behind the
> existing #ifdef. It will still be removed by the compiler if it is not
> needed.
>
> Add an atapi flag to struct blk_desc so the information can be retained.
>
> Fixes: 145df842b44 ("dm: ide: Add support for driver-model block devices")
> Fixes: d0075059e4d ("ide: Drop non-DM code for BLK")
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
> ---
>
> drivers/block/ide.c | 20 +++++++++++++++++---
> include/blk.h | 1 +
> 2 files changed, 18 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/block/ide.c b/drivers/block/ide.c
> index fa5f68ffeb01..875192cba163 100644
> --- a/drivers/block/ide.c
> +++ b/drivers/block/ide.c
> @@ -155,7 +155,6 @@ OUT:
> *last = '\0';
> }
>
> -#ifdef CONFIG_ATAPI
> /****************************************************************************
> * ATAPI Support
> */
> @@ -422,9 +421,10 @@ error:
> #define ATAPI_READ_BLOCK_SIZE 2048 /* assuming CD part */
> #define ATAPI_READ_MAX_BLOCK (ATAPI_READ_MAX_BYTES/ATAPI_READ_BLOCK_SIZE)
>
> -ulong atapi_read(struct blk_desc *block_dev, lbaint_t blknr, lbaint_t blkcnt,
> +ulong atapi_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt,
> void *buffer)
> {
> + struct blk_desc *block_dev = dev_get_uclass_plat(dev);
> int device = block_dev->devnum;
> ulong n = 0;
> unsigned char ccb[12]; /* Command descriptor block */
> @@ -466,6 +466,8 @@ ulong atapi_read(struct blk_desc *block_dev, lbaint_t blknr, lbaint_t blkcnt,
> return n;
> }
>
> +#ifdef CONFIG_ATAPI
> +
> static void atapi_inquiry(struct blk_desc *dev_desc)
> {
> unsigned char ccb[12]; /* Command descriptor block */
> @@ -653,6 +655,7 @@ static void ide_ident(struct blk_desc *dev_desc)
>
> #ifdef CONFIG_ATAPI
> if (is_atapi) {
> + dev_desc->atapi = true;
> atapi_inquiry(dev_desc);
> return;
> }
> @@ -1010,6 +1013,17 @@ WR_OUT:
> return n;
> }
>
> +ulong ide_or_atapi_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt,
> + void *buffer)
> +{
> + struct blk_desc *desc = dev_get_uclass_plat(dev);
> +
> + if (IS_ENABLED(CONFIG_ATAPI) && desc->atapi)
> + return atapi_read(dev, blknr, blkcnt, buffer);
> +
> + return ide_read(dev, blknr, blkcnt, buffer);
> +}
> +
> static int ide_blk_probe(struct udevice *udev)
> {
> struct blk_desc *desc = dev_get_uclass_plat(udev);
> @@ -1029,7 +1043,7 @@ static int ide_blk_probe(struct udevice *udev)
> }
>
> static const struct blk_ops ide_blk_ops = {
> - .read = ide_read,
> + .read = ide_or_atapi_read,
> .write = ide_write,
> };
>
> diff --git a/include/blk.h b/include/blk.h
> index 1db203c1baba..871922dcde07 100644
> --- a/include/blk.h
> +++ b/include/blk.h
> @@ -66,6 +66,7 @@ struct blk_desc {
> /* device can use 48bit addr (ATA/ATAPI v7) */
> unsigned char lba48;
> #endif
> + unsigned char atapi; /* Use ATAPI protocol */
> lbaint_t lba; /* number of blocks */
> unsigned long blksz; /* block size */
> int log2blksz; /* for convenience: log2(blksz) */
> --
> 2.40.0.348.gf938b09366-goog
next prev parent reply other threads:[~2023-03-28 14:24 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-27 19:06 [PATCH 00/30] ide: Clean up code and fix a few bugs Simon Glass
2023-03-27 19:06 ` [PATCH 01/30] ide: Move ATA_CURR_BASE to C file Simon Glass
2023-03-27 19:06 ` [PATCH 02/30] ide: Use mdelay() for long delays Simon Glass
2023-03-27 19:06 ` [PATCH 03/30] ide: Drop CONFIG_START_IDE Simon Glass
2023-03-27 19:06 ` [PATCH 04/30] ide: Drop init for not using BLK Simon Glass
2023-03-27 19:06 ` [PATCH 05/30] ide: Move ide_init() into probing Simon Glass
2023-03-27 19:06 ` [PATCH 06/30] ide: Drop ide_device_present() Simon Glass
2023-03-27 19:06 ` [PATCH 08/30] ide: Drop weak functions Simon Glass
2023-03-27 19:06 ` [PATCH 09/30] ide: Create a prototype for ide_set_reset() Simon Glass
2023-03-27 19:06 ` [PATCH 10/30] ide: Correct use of ATAPI Simon Glass
2023-03-28 14:23 ` Mattijs Korpershoek [this message]
2023-03-27 19:06 ` [PATCH 11/30] ide: Make function static Simon Glass
2023-03-27 19:06 ` [PATCH 12/30] ide: Change the retries variable Simon Glass
2023-03-27 19:07 ` [PATCH 13/30] ide: Refactor confusing loop code Simon Glass
2023-03-27 19:07 ` [PATCH 14/30] ide: Simplify success condition Simon Glass
2023-03-27 19:07 ` [PATCH 15/30] ide: Avoid preprocessor for CONFIG_ATAPI Simon Glass
2023-03-27 19:07 ` [PATCH 16/30] ide: Avoid preprocessor for CONFIG_LBA48 Simon Glass
2023-03-28 14:18 ` Mattijs Korpershoek
2023-04-19 1:46 ` Simon Glass
2023-03-27 19:07 ` [PATCH 17/30] ide: Move bus init into a function Simon Glass
2023-03-27 19:07 ` [PATCH 18/30] ide: Make ide_bus_ok[] a local variable Simon Glass
2023-03-27 19:07 ` [PATCH 19/30] ide: Move setting of vendor strings into ide_probe() Simon Glass
2023-03-27 19:07 ` [PATCH 20/30] ide: Move ide_init() entirely within ide_probe() Simon Glass
2023-03-27 19:07 ` [PATCH 21/30] ide: Combine the two loops in ide_probe() Simon Glass
2023-03-27 19:07 ` [PATCH 22/30] ide: Use desc consistently for struct blk_desc Simon Glass
2023-03-27 19:07 ` [PATCH 23/30] ide: Make ide_ident() return an error code Simon Glass
2023-03-27 19:07 ` [PATCH 24/30] ide: Move all blk_desc init into ide_ident() Simon Glass
2023-03-27 19:07 ` [PATCH 25/30] ide: Use a single local blk_desc for ide_ident() Simon Glass
2023-03-27 19:07 ` [PATCH 26/30] ide: Correct LBA setting Simon Glass
2023-03-27 19:07 ` [PATCH 27/30] ide: Tidy up ide_reset() Simon Glass
2023-03-27 19:07 ` [PATCH 28/30] ide: Convert to use log_debug() Simon Glass
2023-03-27 19:07 ` [PATCH 29/30] ide: Simplify expressions and hex values Simon Glass
2023-03-27 19:07 ` [PATCH 30/30] ide: Make use of U-Boot types Simon Glass
2023-04-25 15:36 ` [PATCH 00/30] ide: Clean up code and fix a few bugs Tom Rini
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=87jzz10xbb.fsf@baylibre.com \
--to=mkorpershoek@baylibre.com \
--cc=bmeng.cn@gmail.com \
--cc=sjg@chromium.org \
--cc=u-boot@lists.denx.de \
--cc=xypron.glpk@gmx.de \
/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