mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] block: efi-block-io: add devinfo callback for media info
@ 2022-01-19  9:28 Ahmad Fatoum
  2022-01-19  9:31 ` [PATCH] fixup! " Ahmad Fatoum
  2022-01-20  8:36 ` [PATCH] " Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2022-01-19  9:28 UTC (permalink / raw)
  To: barebox; +Cc: mol, Ahmad Fatoum

There's some useful info in efi_block_io_media that's only compiled in
at debug log level. While we need not print it always, it would be nice
to have this printed when doing devinfo. Add a custom devinfo callback
that does so and that invokes the normal EFI devinfo afterwards.

Defining DEBUG in the file will still print it early in probe as before.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/block/efi-block-io.c | 42 +++++++++++++++++++++++-------------
 1 file changed, 27 insertions(+), 15 deletions(-)

diff --git a/drivers/block/efi-block-io.c b/drivers/block/efi-block-io.c
index ff0e467d2c4f..fc6832294b37 100644
--- a/drivers/block/efi-block-io.c
+++ b/drivers/block/efi-block-io.c
@@ -52,6 +52,7 @@ struct efi_bio_priv {
 	struct device_d *dev;
 	struct block_device blk;
 	u32 media_id;
+	void (*efi_info)(struct device_d *);
 };
 
 static int efi_bio_read(struct block_device *blk, void *buffer, sector_t block,
@@ -101,35 +102,40 @@ static struct block_device_ops efi_bio_ops = {
 	.flush = efi_bio_flush,
 };
 
-static void efi_bio_print_info(struct efi_bio_priv *priv)
+static void efi_bio_print_info(struct device_d *dev)
 {
+	struct efi_bio_priv *priv = dev->priv;
 	struct efi_block_io_media *media = priv->protocol->media;
 	u64 revision = priv->protocol->revision;
 
-	dev_dbg(priv->dev, "revision: 0x%016llx\n", revision);
-	dev_dbg(priv->dev, "media_id: 0x%08x\n", media->media_id);
-	dev_dbg(priv->dev, "removable_media: %d\n", media->removable_media);
-	dev_dbg(priv->dev, "media_present: %d\n", media->media_present);
-	dev_dbg(priv->dev, "logical_partition: %d\n", media->logical_partition);
-	dev_dbg(priv->dev, "read_only: %d\n", media->read_only);
-	dev_dbg(priv->dev, "write_caching: %d\n", media->write_caching);
-	dev_dbg(priv->dev, "block_size: 0x%08x\n", media->block_size);
-	dev_dbg(priv->dev, "io_align: 0x%08x\n", media->io_align);
-	dev_dbg(priv->dev, "last_block: 0x%016llx\n", media->last_block);
+	printf("Protocols:\n");
+	printf("  revision: 0x%016llx\n", revision);
+	printf("  media_id: 0x%08x\n", media->media_id);
+	printf("  removable_media: %d\n", media->removable_media);
+	printf("  media_present: %d\n", media->media_present);
+	printf("  logical_partition: %d\n", media->logical_partition);
+	printf("  read_only: %d\n", media->read_only);
+	printf("  write_caching: %d\n", media->write_caching);
+	printf("  block_size: 0x%08x\n", media->block_size);
+	printf("  io_align: 0x%08x\n", media->io_align);
+	printf("  last_block: 0x%016llx\n", media->last_block);
 
 	if (revision < EFI_BLOCK_IO_PROTOCOL_REVISION2)
 		return;
 
-	dev_dbg(priv->dev, "u64 lowest_aligned_lba: 0x%08llx\n",
+	printf("  lowest_aligned_lba: 0x%08llx\n",
 			media->lowest_aligned_lba);
-	dev_dbg(priv->dev, "logical_blocks_per_physical_block: 0x%08x\n",
+	printf("  logical_blocks_per_physical_block: 0x%08x\n",
 			media->logical_blocks_per_physical_block);
 
 	if (revision < EFI_BLOCK_IO_PROTOCOL_REVISION3)
 		return;
 
-	dev_dbg(priv->dev, "optimal_transfer_length_granularity: 0x%08x\n",
+	printf("  optimal_transfer_length_granularity: 0x%08x\n",
 			media->optimal_transfer_length_granularity);
+
+	if (priv->efi_info)
+		priv->efi_info(dev);
 }
 
 static bool is_bio_usbdev(struct efi_device *efidev)
@@ -143,6 +149,7 @@ static int efi_bio_probe(struct efi_device *efidev)
 	int instance;
 	struct efi_bio_priv *priv;
 	struct efi_block_io_media *media;
+	struct device_d *dev = &efidev->dev;
 
 	priv = xzalloc(sizeof(*priv));
 
@@ -151,8 +158,13 @@ static int efi_bio_probe(struct efi_device *efidev)
 	if (!priv->protocol)
 		return -ENODEV;
 
+	dev->priv = priv;
+	priv->efi_info = dev->info;
+	dev->info = efi_bio_print_info;
+
 	media = priv->protocol->media;
-	efi_bio_print_info(priv);
+	if (__is_defined(DEBUG))
+		efi_bio_print_info(dev);
 	priv->dev = &efidev->dev;
 
 	if (is_bio_usbdev(efidev)) {
-- 
2.30.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] fixup! block: efi-block-io: add devinfo callback for media info
  2022-01-19  9:28 [PATCH] block: efi-block-io: add devinfo callback for media info Ahmad Fatoum
@ 2022-01-19  9:31 ` Ahmad Fatoum
  2022-01-20  8:36 ` [PATCH] " Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2022-01-19  9:31 UTC (permalink / raw)
  To: barebox; +Cc: mol, Ahmad Fatoum

The heading could be made a tiny little bit more descriptive.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
Argh, missed to squash
---
 drivers/block/efi-block-io.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/efi-block-io.c b/drivers/block/efi-block-io.c
index fc6832294b37..086afb378ab4 100644
--- a/drivers/block/efi-block-io.c
+++ b/drivers/block/efi-block-io.c
@@ -108,7 +108,7 @@ static void efi_bio_print_info(struct device_d *dev)
 	struct efi_block_io_media *media = priv->protocol->media;
 	u64 revision = priv->protocol->revision;
 
-	printf("Protocols:\n");
+	printf("Block I/O Media:\n");
 	printf("  revision: 0x%016llx\n", revision);
 	printf("  media_id: 0x%08x\n", media->media_id);
 	printf("  removable_media: %d\n", media->removable_media);
-- 
2.30.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] block: efi-block-io: add devinfo callback for media info
  2022-01-19  9:28 [PATCH] block: efi-block-io: add devinfo callback for media info Ahmad Fatoum
  2022-01-19  9:31 ` [PATCH] fixup! " Ahmad Fatoum
@ 2022-01-20  8:36 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2022-01-20  8:36 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox, mol

On Wed, Jan 19, 2022 at 10:28:27AM +0100, Ahmad Fatoum wrote:
> There's some useful info in efi_block_io_media that's only compiled in
> at debug log level. While we need not print it always, it would be nice
> to have this printed when doing devinfo. Add a custom devinfo callback
> that does so and that invokes the normal EFI devinfo afterwards.
> 
> Defining DEBUG in the file will still print it early in probe as before.
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
>  drivers/block/efi-block-io.c | 42 +++++++++++++++++++++++-------------
>  1 file changed, 27 insertions(+), 15 deletions(-)

Applied, thanks

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-01-20  8:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-19  9:28 [PATCH] block: efi-block-io: add devinfo callback for media info Ahmad Fatoum
2022-01-19  9:31 ` [PATCH] fixup! " Ahmad Fatoum
2022-01-20  8:36 ` [PATCH] " Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox