@@ -1075,6 +1075,37 @@ static int finalize_and_send(struct opal_dev *dev, cont_fn cont)
10751075 return opal_send_recv (dev , cont );
10761076}
10771077
1078+ /*
1079+ * request @column from table @table on device @dev. On success, the column
1080+ * data will be available in dev->resp->tok[4]
1081+ */
1082+ static int generic_get_column (struct opal_dev * dev , const u8 * table ,
1083+ u64 column )
1084+ {
1085+ int err ;
1086+
1087+ err = cmd_start (dev , table , opalmethod [OPAL_GET ]);
1088+
1089+ add_token_u8 (& err , dev , OPAL_STARTLIST );
1090+
1091+ add_token_u8 (& err , dev , OPAL_STARTNAME );
1092+ add_token_u8 (& err , dev , OPAL_STARTCOLUMN );
1093+ add_token_u64 (& err , dev , column );
1094+ add_token_u8 (& err , dev , OPAL_ENDNAME );
1095+
1096+ add_token_u8 (& err , dev , OPAL_STARTNAME );
1097+ add_token_u8 (& err , dev , OPAL_ENDCOLUMN );
1098+ add_token_u64 (& err , dev , column );
1099+ add_token_u8 (& err , dev , OPAL_ENDNAME );
1100+
1101+ add_token_u8 (& err , dev , OPAL_ENDLIST );
1102+
1103+ if (err )
1104+ return err ;
1105+
1106+ return finalize_and_send (dev , parse_and_check_status );
1107+ }
1108+
10781109static int gen_key (struct opal_dev * dev , void * data )
10791110{
10801111 u8 uid [OPAL_UID_LENGTH ];
@@ -1129,23 +1160,11 @@ static int get_active_key(struct opal_dev *dev, void *data)
11291160 if (err )
11301161 return err ;
11311162
1132- err = cmd_start (dev , uid , opalmethod [OPAL_GET ]);
1133- add_token_u8 (& err , dev , OPAL_STARTLIST );
1134- add_token_u8 (& err , dev , OPAL_STARTNAME );
1135- add_token_u8 (& err , dev , 3 ); /* startCloumn */
1136- add_token_u8 (& err , dev , 10 ); /* ActiveKey */
1137- add_token_u8 (& err , dev , OPAL_ENDNAME );
1138- add_token_u8 (& err , dev , OPAL_STARTNAME );
1139- add_token_u8 (& err , dev , 4 ); /* endColumn */
1140- add_token_u8 (& err , dev , 10 ); /* ActiveKey */
1141- add_token_u8 (& err , dev , OPAL_ENDNAME );
1142- add_token_u8 (& err , dev , OPAL_ENDLIST );
1143- if (err ) {
1144- pr_debug ("Error building get active key command\n" );
1163+ err = generic_get_column (dev , uid , OPAL_ACTIVEKEY );
1164+ if (err )
11451165 return err ;
1146- }
11471166
1148- return finalize_and_send (dev , get_active_key_cont );
1167+ return get_active_key_cont (dev );
11491168}
11501169
11511170static int generic_lr_enable_disable (struct opal_dev * dev ,
@@ -1754,14 +1773,16 @@ static int activate_lsp(struct opal_dev *dev, void *data)
17541773 return finalize_and_send (dev , parse_and_check_status );
17551774}
17561775
1757- static int get_lsp_lifecycle_cont (struct opal_dev * dev )
1776+ /* Determine if we're in the Manufactured Inactive or Active state */
1777+ static int get_lsp_lifecycle (struct opal_dev * dev , void * data )
17581778{
17591779 u8 lc_status ;
1760- int error = 0 ;
1780+ int err ;
17611781
1762- error = parse_and_check_status (dev );
1763- if (error )
1764- return error ;
1782+ err = generic_get_column (dev , opaluid [OPAL_LOCKINGSP_UID ],
1783+ OPAL_LIFECYCLE );
1784+ if (err )
1785+ return err ;
17651786
17661787 lc_status = response_get_u64 (& dev -> parsed , 4 );
17671788 /* 0x08 is Manufactured Inactive */
@@ -1774,49 +1795,19 @@ static int get_lsp_lifecycle_cont(struct opal_dev *dev)
17741795 return 0 ;
17751796}
17761797
1777- /* Determine if we're in the Manufactured Inactive or Active state */
1778- static int get_lsp_lifecycle (struct opal_dev * dev , void * data )
1779- {
1780- int err ;
1781-
1782- err = cmd_start (dev , opaluid [OPAL_LOCKINGSP_UID ],
1783- opalmethod [OPAL_GET ]);
1784-
1785- add_token_u8 (& err , dev , OPAL_STARTLIST );
1786-
1787- add_token_u8 (& err , dev , OPAL_STARTNAME );
1788- add_token_u8 (& err , dev , 3 ); /* Start Column */
1789- add_token_u8 (& err , dev , OPAL_LIFECYCLE );
1790- add_token_u8 (& err , dev , OPAL_ENDNAME );
1791-
1792- add_token_u8 (& err , dev , OPAL_STARTNAME );
1793- add_token_u8 (& err , dev , 4 ); /* End Column */
1794- add_token_u8 (& err , dev , OPAL_LIFECYCLE );
1795- add_token_u8 (& err , dev , OPAL_ENDNAME );
1796-
1797- add_token_u8 (& err , dev , OPAL_ENDLIST );
1798-
1799- if (err ) {
1800- pr_debug ("Error Building GET Lifecycle Status command\n" );
1801- return err ;
1802- }
1803-
1804- return finalize_and_send (dev , get_lsp_lifecycle_cont );
1805- }
1806-
1807- static int get_msid_cpin_pin_cont (struct opal_dev * dev )
1798+ static int get_msid_cpin_pin (struct opal_dev * dev , void * data )
18081799{
18091800 const char * msid_pin ;
18101801 size_t strlen ;
1811- int error = 0 ;
1802+ int err ;
18121803
1813- error = parse_and_check_status (dev );
1814- if (error )
1815- return error ;
1804+ err = generic_get_column (dev , opaluid [ OPAL_C_PIN_MSID ], OPAL_PIN );
1805+ if (err )
1806+ return err ;
18161807
18171808 strlen = response_get_string (& dev -> parsed , 4 , & msid_pin );
18181809 if (!msid_pin ) {
1819- pr_debug ("%s: Couldn't extract PIN from response\n" , __func__ );
1810+ pr_debug ("Couldn't extract MSID_CPIN from response\n" );
18201811 return OPAL_INVAL_PARAM ;
18211812 }
18221813
@@ -1829,33 +1820,6 @@ static int get_msid_cpin_pin_cont(struct opal_dev *dev)
18291820 return 0 ;
18301821}
18311822
1832- static int get_msid_cpin_pin (struct opal_dev * dev , void * data )
1833- {
1834- int err ;
1835-
1836- err = cmd_start (dev , opaluid [OPAL_C_PIN_MSID ],
1837- opalmethod [OPAL_GET ]);
1838-
1839- add_token_u8 (& err , dev , OPAL_STARTLIST );
1840- add_token_u8 (& err , dev , OPAL_STARTNAME );
1841- add_token_u8 (& err , dev , 3 ); /* Start Column */
1842- add_token_u8 (& err , dev , 3 ); /* PIN */
1843- add_token_u8 (& err , dev , OPAL_ENDNAME );
1844-
1845- add_token_u8 (& err , dev , OPAL_STARTNAME );
1846- add_token_u8 (& err , dev , 4 ); /* End Column */
1847- add_token_u8 (& err , dev , 3 ); /* Lifecycle Column */
1848- add_token_u8 (& err , dev , OPAL_ENDNAME );
1849- add_token_u8 (& err , dev , OPAL_ENDLIST );
1850-
1851- if (err ) {
1852- pr_debug ("Error building Get MSID CPIN PIN command.\n" );
1853- return err ;
1854- }
1855-
1856- return finalize_and_send (dev , get_msid_cpin_pin_cont );
1857- }
1858-
18591823static int end_opal_session (struct opal_dev * dev , void * data )
18601824{
18611825 int err = 0 ;
0 commit comments