All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hdparm: Show form factor and media rotation rate
@ 2009-02-21  1:01 Martin K. Petersen
  2009-02-21 22:41 ` Michael Tokarev
  2009-02-22  5:53 ` Mark Lord
  0 siblings, 2 replies; 6+ messages in thread
From: Martin K. Petersen @ 2009-02-21  1:01 UTC (permalink / raw)
  To: Mark Lord; +Cc: linux-ide


Make hdparm display form factor and media rotation rate when using -I.

Surprisingly, I have a few devices that export these already.

diff -purN -X /home/mkp/bin/dontdiff hdparm-9.11.orig/identify.c hdparm-9.11/identify.c
--- hdparm-9.11.orig/identify.c	2009-01-27 12:48:41.000000000 -0500
+++ hdparm-9.11/identify.c	2009-02-20 19:56:12.000000000 -0500
@@ -96,6 +96,7 @@
 #define RM_STAT 		127 /* removable media status notification feature set support */
 #define SECU_STATUS		128 /* security status */
 #define CFA_PWR_MODE		160 /* CFA power mode 1 */
+#define FORM_FACTOR		168 /* device nominal form factor */
 #define START_MEDIA             176 /* media serial number */
 #define LENGTH_MEDIA            20  /* 20 words (40 bytes or characters)*/
 #define START_MANUF             196 /* media manufacturer I.D. */
@@ -103,6 +104,7 @@
 #define SCT_SUPP		206 /* SMART command transport (SCT) support */
 #define TRANSPORT_MAJOR		222 /* PATA vs. SATA etc.. */
 #define TRANSPORT_MINOR		223 /* minor revision number */
+#define NMRR			217 /* nominal media rotation rate */
 #define INTEGRITY		255 /* integrity word */
 
 /* bit definitions within the words */
@@ -897,6 +899,35 @@ void identify (__u16 *id_supplied)
 	}
 	putchar('\n');
 
+	/* Form factor */
+	if(val[FORM_FACTOR] > 0) {
+		printf("\tForm Factor: ");
+		switch(val[FORM_FACTOR]) {
+		case 1:
+			printf("5.25 inch");
+			break;
+		case 2:
+			printf("3.5 inch");
+			break;
+		case 3:
+			printf("2.5 inch");
+			break;
+		case 4:
+			printf("1.8 inch");
+			break;
+		default:
+			printf("unknown");
+			break;
+		}
+		printf("\n");
+	}
+
+	/* Spinning disk or solid state? */
+	if(val[NMRR] == 1)
+		printf("\tNominal Media Rotation Rate: Solid State Device\n");
+	else if(val[NMRR] > 0x401)
+		printf("\tNominal Media Rotation Rate: %u\n", val[NMRR]);
+
 	/* hw support of commands (capabilities) */
 	printf("Capabilities:\n");
 	printf("\t");

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

* Re: [PATCH] hdparm: Show form factor and media rotation rate
  2009-02-21  1:01 [PATCH] hdparm: Show form factor and media rotation rate Martin K. Petersen
@ 2009-02-21 22:41 ` Michael Tokarev
  2009-02-23 16:14   ` Martin K. Petersen
  2009-02-22  5:53 ` Mark Lord
  1 sibling, 1 reply; 6+ messages in thread
From: Michael Tokarev @ 2009-02-21 22:41 UTC (permalink / raw)
  To: Martin K. Petersen; +Cc: Mark Lord, linux-ide

Martin K. Petersen wrote:
> Make hdparm display form factor and media rotation rate when using -I.

Ok, just a small (but I think very useful) nitpick:

[]
> +	/* Form factor */
> +	if(val[FORM_FACTOR] > 0) {
> +		printf("\tForm Factor: ");
> +		switch(val[FORM_FACTOR]) {
...
> +			printf("1.8 inch");
> +			break;
> +		default:
> +			printf("unknown");
> +			break;

How about printing the actual (unrecognized) value here?   Like this:

  +		default:
  +			printf("unknown (raw value = %d)", val[FORM_FACTOR]);
  +			break;

(with whatever %d needed)

Thanks!

/mjt

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

* Re: [PATCH] hdparm: Show form factor and media rotation rate
  2009-02-21  1:01 [PATCH] hdparm: Show form factor and media rotation rate Martin K. Petersen
  2009-02-21 22:41 ` Michael Tokarev
@ 2009-02-22  5:53 ` Mark Lord
  2009-02-23 16:13   ` Martin K. Petersen
  1 sibling, 1 reply; 6+ messages in thread
From: Mark Lord @ 2009-02-22  5:53 UTC (permalink / raw)
  To: Martin K. Petersen; +Cc: linux-ide

Martin K. Petersen wrote:
> Make hdparm display form factor and media rotation rate when using -I.
> 
> Surprisingly, I have a few devices that export these already.
..

Peachy.  I'll add it for hdparm-9.12, if you agree to the hdparm copyright
(BSD style licensing).

Cheers

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

* Re: [PATCH] hdparm: Show form factor and media rotation rate
  2009-02-22  5:53 ` Mark Lord
@ 2009-02-23 16:13   ` Martin K. Petersen
  0 siblings, 0 replies; 6+ messages in thread
From: Martin K. Petersen @ 2009-02-23 16:13 UTC (permalink / raw)
  To: Mark Lord; +Cc: Martin K. Petersen, linux-ide

>>>>> "Mark" == Mark Lord <liml@rtr.ca> writes:

Mark> Peachy.  I'll add it for hdparm-9.12, if you agree to the hdparm
Mark> copyright (BSD style licensing).

That's fine.

-- 
Martin K. Petersen	Oracle Linux Engineering

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

* Re: [PATCH] hdparm: Show form factor and media rotation rate
  2009-02-21 22:41 ` Michael Tokarev
@ 2009-02-23 16:14   ` Martin K. Petersen
  2009-02-23 20:26     ` Mark Lord
  0 siblings, 1 reply; 6+ messages in thread
From: Martin K. Petersen @ 2009-02-23 16:14 UTC (permalink / raw)
  To: Michael Tokarev; +Cc: Martin K. Petersen, Mark Lord, linux-ide

>>>>> "Michael" == Michael Tokarev <mjt@tls.msk.ru> writes:

Michael> How about printing the actual (unrecognized) value here?  Like
Michael> this:

Michael>   + default:
Michael>   + printf("unknown (raw value = %d)", val[FORM_FACTOR]);
Michael>   + break;

I'm ok with that.  Mark?

-- 
Martin K. Petersen	Oracle Linux Engineering

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

* Re: [PATCH] hdparm: Show form factor and media rotation rate
  2009-02-23 16:14   ` Martin K. Petersen
@ 2009-02-23 20:26     ` Mark Lord
  0 siblings, 0 replies; 6+ messages in thread
From: Mark Lord @ 2009-02-23 20:26 UTC (permalink / raw)
  To: Martin K. Petersen; +Cc: Michael Tokarev, linux-ide

Martin K. Petersen wrote:
>>>>>> "Michael" == Michael Tokarev <mjt@tls.msk.ru> writes:
> 
> Michael> How about printing the actual (unrecognized) value here?  Like
> Michael> this:
> 
> Michael>   + default:
> Michael>   + printf("unknown (raw value = %d)", val[FORM_FACTOR]);
> Michael>   + break;
> 
> I'm ok with that.  Mark?
..

Already done, except in hex.

Cheers

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

end of thread, other threads:[~2009-02-23 20:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-21  1:01 [PATCH] hdparm: Show form factor and media rotation rate Martin K. Petersen
2009-02-21 22:41 ` Michael Tokarev
2009-02-23 16:14   ` Martin K. Petersen
2009-02-23 20:26     ` Mark Lord
2009-02-22  5:53 ` Mark Lord
2009-02-23 16:13   ` Martin K. Petersen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.