Add a 'ctrans()' test for sparse matrix/dense matrix additions ('smatdmatadd')

--- blazetest/blazetest/mathtest/smatdmatadd/OperationTest.h
+++ blazetest/blazetest/mathtest/smatdmatadd/OperationTest.h
@@ -168,8 +168,9 @@
                           void testNegatedOperation  ();
    template< typename T > void testScaledOperation   ( T scalar );
                           void testTransposeOperation();
+                          void testConjOperation     ();
+                          void testCTransOperation   ();
                           void testAbsOperation      ();
-                          void testConjOperation     ();
                           void testEvalOperation     ();
                           void testSerialOperation   ();
                           void testSubmatrixOperation();
@@ -346,8 +347,9 @@
    testScaledOperation( 2.0F );
    testScaledOperation( 2.0 );
    testTransposeOperation();
+   testConjOperation();
+   testCTransOperation();
    testAbsOperation();
-   testConjOperation();
    testEvalOperation();
    testSerialOperation();
    testSubmatrixOperation();
@@ -3227,6 +3229,564 @@

 //*************************************************************************************************
+/*!\brief Testing the conjugate sparse matrix/dense matrix addition.
+//
+// \return void
+// \exception std::runtime_error Addition error detected.
+//
+// This function tests the conjugate matrix addition with plain assignment, addition assignment,
+// and subtraction assignment. In case any error resulting from the addition or the subsequent
+// assignment is detected, a \a std::runtime_error exception is thrown.
+*/
+template< typename MT1    // Type of the left-hand side sparse matrix
+        , typename MT2 >  // Type of the right-hand side dense matrix
+void OperationTest<MT1,MT2>::testConjOperation()
+{
+#if BLAZETEST_MATHTEST_TEST_CONJ_OPERATION
+   if( BLAZETEST_MATHTEST_TEST_CONJ_OPERATION > 1 )
+   {
+      //=====================================================================================
+      // Conjugate addition
+      //=====================================================================================
+
+      // Conjugate addition with the given matrices
+      {
+         test_  = "Conjugate addition with the given matrices";
+         error_ = "Failed addition operation";
+
+         try {
+            initResults();
+            dres_   = conj( lhs_ + rhs_ );
+            odres_  = conj( lhs_ + rhs_ );
+            sres_   = conj( lhs_ + rhs_ );
+            osres_  = conj( lhs_ + rhs_ );
+            refres_ = conj( reflhs_ + refrhs_ );
+         }
+         catch( std::exception& ex ) {
+            convertException<MT1,MT2>( ex );
+         }
+
+         checkResults<MT1,MT2>();
+
+         try {
+            initResults();
+            dres_   = conj( lhs_ + orhs_ );
+            odres_  = conj( lhs_ + orhs_ );
+            sres_   = conj( lhs_ + orhs_ );
+            osres_  = conj( lhs_ + orhs_ );
+            refres_ = conj( reflhs_ + refrhs_ );
+         }
+         catch( std::exception& ex ) {
+            convertException<MT1,OMT2>( ex );
+         }
+
+         checkResults<MT1,OMT2>();
+
+         try {
+            initResults();
+            dres_   = conj( olhs_ + rhs_ );
+            odres_  = conj( olhs_ + rhs_ );
+            sres_   = conj( olhs_ + rhs_ );
+            osres_  = conj( olhs_ + rhs_ );
+            refres_ = conj( reflhs_ + refrhs_ );
+         }
+         catch( std::exception& ex ) {
+            convertException<OMT1,MT2>( ex );
+         }
+
+         checkResults<OMT1,MT2>();
+
+         try {
+            initResults();
+            dres_   = conj( olhs_ + orhs_ );
+            odres_  = conj( olhs_ + orhs_ );
+            sres_   = conj( olhs_ + orhs_ );
+            osres_  = conj( olhs_ + orhs_ );
+            refres_ = conj( reflhs_ + refrhs_ );
+         }
+         catch( std::exception& ex ) {
+            convertException<OMT1,OMT2>( ex );
+         }
+
+         checkResults<OMT1,OMT2>();
+      }
+
+      // Conjugate addition with evaluated matrices
+      {
+         test_  = "Conjugate addition with evaluated matrices";
+         error_ = "Failed addition operation";
+
+         try {
+            initResults();
+            dres_   = conj( eval( lhs_ ) + eval( rhs_ ) );
+            odres_  = conj( eval( lhs_ ) + eval( rhs_ ) );
+            sres_   = conj( eval( lhs_ ) + eval( rhs_ ) );
+            osres_  = conj( eval( lhs_ ) + eval( rhs_ ) );
+            refres_ = conj( eval( reflhs_ ) + eval( refrhs_ ) );
+         }
+         catch( std::exception& ex ) {
+            convertException<MT1,MT2>( ex );
+         }
+
+         checkResults<MT1,MT2>();
+
+         try {
+            initResults();
+            dres_   = conj( eval( lhs_ ) + eval( orhs_ ) );
+            odres_  = conj( eval( lhs_ ) + eval( orhs_ ) );
+            sres_   = conj( eval( lhs_ ) + eval( orhs_ ) );
+            osres_  = conj( eval( lhs_ ) + eval( orhs_ ) );
+            refres_ = conj( eval( reflhs_ ) + eval( refrhs_ ) );
+         }
+         catch( std::exception& ex ) {
+            convertException<MT1,OMT2>( ex );
+         }
+
+         checkResults<MT1,OMT2>();
+
+         try {
+            initResults();
+            dres_   = conj( eval( olhs_ ) + eval( rhs_ ) );
+            odres_  = conj( eval( olhs_ ) + eval( rhs_ ) );
+            sres_   = conj( eval( olhs_ ) + eval( rhs_ ) );
+            osres_  = conj( eval( olhs_ ) + eval( rhs_ ) );
+            refres_ = conj( eval( reflhs_ ) + eval( refrhs_ ) );
+         }
+         catch( std::exception& ex ) {
+            convertException<OMT1,MT2>( ex );
+         }
+
+         checkResults<OMT1,MT2>();
+
+         try {
+            initResults();
+            dres_   = conj( eval( olhs_ ) + eval( orhs_ ) );
+            odres_  = conj( eval( olhs_ ) + eval( orhs_ ) );
+            sres_   = conj( eval( olhs_ ) + eval( orhs_ ) );
+            osres_  = conj( eval( olhs_ ) + eval( orhs_ ) );
+            refres_ = conj( eval( reflhs_ ) + eval( refrhs_ ) );
+         }
+         catch( std::exception& ex ) {
+            convertException<OMT1,OMT2>( ex );
+         }
+
+         checkResults<OMT1,OMT2>();
+      }
+
+
+      //=====================================================================================
+      // Conjugate addition with addition assignment
+      //=====================================================================================
+
+      // Conjugate addition with addition assignment with the given matrices
+      {
+         test_  = "Conjugate addition with addition assignment with the given matrices";
+         error_ = "Failed addition assignment operation";
+
+         try {
+            initResults();
+            dres_   += conj( lhs_ + rhs_ );
+            odres_  += conj( lhs_ + rhs_ );
+            sres_   += conj( lhs_ + rhs_ );
+            osres_  += conj( lhs_ + rhs_ );
+            refres_ += conj( reflhs_ + refrhs_ );
+         }
+         catch( std::exception& ex ) {
+            convertException<MT1,MT2>( ex );
+         }
+
+         checkResults<MT1,MT2>();
+
+         try {
+            initResults();
+            dres_   += conj( lhs_ + orhs_ );
+            odres_  += conj( lhs_ + orhs_ );
+            sres_   += conj( lhs_ + orhs_ );
+            osres_  += conj( lhs_ + orhs_ );
+            refres_ += conj( reflhs_ + refrhs_ );
+         }
+         catch( std::exception& ex ) {
+            convertException<MT1,OMT2>( ex );
+         }
+
+         checkResults<MT1,OMT2>();
+
+         try {
+            initResults();
+            dres_   += conj( olhs_ + rhs_ );
+            odres_  += conj( olhs_ + rhs_ );
+            sres_   += conj( olhs_ + rhs_ );
+            osres_  += conj( olhs_ + rhs_ );
+            refres_ += conj( reflhs_ + refrhs_ );
+         }
+         catch( std::exception& ex ) {
+            convertException<OMT1,MT2>( ex );
+         }
+
+         checkResults<OMT1,MT2>();
+
+         try {
+            initResults();
+            dres_   += conj( olhs_ + orhs_ );
+            odres_  += conj( olhs_ + orhs_ );
+            sres_   += conj( olhs_ + orhs_ );
+            osres_  += conj( olhs_ + orhs_ );
+            refres_ += conj( reflhs_ + refrhs_ );
+         }
+         catch( std::exception& ex ) {
+            convertException<OMT1,OMT2>( ex );
+         }
+
+         checkResults<OMT1,OMT2>();
+      }
+
+      // Conjugate addition with addition assignment with evaluated matrices
+      {
+         test_  = "Conjugate addition with addition assignment with evaluated matrices";
+         error_ = "Failed addition assignment operation";
+
+         try {
+            initResults();
+            dres_   += conj( eval( lhs_ ) + eval( rhs_ ) );
+            odres_  += conj( eval( lhs_ ) + eval( rhs_ ) );
+            sres_   += conj( eval( lhs_ ) + eval( rhs_ ) );
+            osres_  += conj( eval( lhs_ ) + eval( rhs_ ) );
+            refres_ += conj( eval( reflhs_ ) + eval( refrhs_ ) );
+         }
+         catch( std::exception& ex ) {
+            convertException<MT1,MT2>( ex );
+         }
+
+         checkResults<MT1,MT2>();
+
+         try {
+            initResults();
+            dres_   += conj( eval( lhs_ ) + eval( orhs_ ) );
+            odres_  += conj( eval( lhs_ ) + eval( orhs_ ) );
+            sres_   += conj( eval( lhs_ ) + eval( orhs_ ) );
+            osres_  += conj( eval( lhs_ ) + eval( orhs_ ) );
+            refres_ += conj( eval( reflhs_ ) + eval( refrhs_ ) );
+         }
+         catch( std::exception& ex ) {
+            convertException<MT1,OMT2>( ex );
+         }
+
+         checkResults<MT1,OMT2>();
+
+         try {
+            initResults();
+            dres_   += conj( eval( olhs_ ) + eval( rhs_ ) );
+            odres_  += conj( eval( olhs_ ) + eval( rhs_ ) );
+            sres_   += conj( eval( olhs_ ) + eval( rhs_ ) );
+            osres_  += conj( eval( olhs_ ) + eval( rhs_ ) );
+            refres_ += conj( eval( reflhs_ ) + eval( refrhs_ ) );
+         }
+         catch( std::exception& ex ) {
+            convertException<OMT1,MT2>( ex );
+         }
+
+         checkResults<OMT1,MT2>();
+
+         try {
+            initResults();
+            dres_   += conj( eval( olhs_ ) + eval( orhs_ ) );
+            odres_  += conj( eval( olhs_ ) + eval( orhs_ ) );
+            sres_   += conj( eval( olhs_ ) + eval( orhs_ ) );
+            osres_  += conj( eval( olhs_ ) + eval( orhs_ ) );
+            refres_ += conj( eval( reflhs_ ) + eval( refrhs_ ) );
+         }
+         catch( std::exception& ex ) {
+            convertException<OMT1,OMT2>( ex );
+         }
+
+         checkResults<OMT1,OMT2>();
+      }
+
+
+      //=====================================================================================
+      // Conjugate addition with subtraction assignment
+      //=====================================================================================
+
+      // Conjugate addition with subtraction assignment with the given matrices
+      {
+         test_  = "Conjugate addition with subtraction assignment with the given matrices";
+         error_ = "Failed subtraction assignment operation";
+
+         try {
+            initResults();
+            dres_   -= conj( lhs_ + rhs_ );
+            odres_  -= conj( lhs_ + rhs_ );
+            sres_   -= conj( lhs_ + rhs_ );
+            osres_  -= conj( lhs_ + rhs_ );
+            refres_ -= conj( reflhs_ + refrhs_ );
+         }
+         catch( std::exception& ex ) {
+            convertException<MT1,MT2>( ex );
+         }
+
+         checkResults<MT1,MT2>();
+
+         try {
+            initResults();
+            dres_   -= conj( lhs_ + orhs_ );
+            odres_  -= conj( lhs_ + orhs_ );
+            sres_   -= conj( lhs_ + orhs_ );
+            osres_  -= conj( lhs_ + orhs_ );
+            refres_ -= conj( reflhs_ + refrhs_ );
+         }
+         catch( std::exception& ex ) {
+            convertException<MT1,OMT2>( ex );
+         }
+
+         checkResults<MT1,OMT2>();
+
+         try {
+            initResults();
+            dres_   -= conj( olhs_ + rhs_ );
+            odres_  -= conj( olhs_ + rhs_ );
+            sres_   -= conj( olhs_ + rhs_ );
+            osres_  -= conj( olhs_ + rhs_ );
+            refres_ -= conj( reflhs_ + refrhs_ );
+         }
+         catch( std::exception& ex ) {
+            convertException<OMT1,MT2>( ex );
+         }
+
+         checkResults<OMT1,MT2>();
+
+         try {
+            initResults();
+            dres_   -= conj( olhs_ + orhs_ );
+            odres_  -= conj( olhs_ + orhs_ );
+            sres_   -= conj( olhs_ + orhs_ );
+            osres_  -= conj( olhs_ + orhs_ );
+            refres_ -= conj( reflhs_ + refrhs_ );
+         }
+         catch( std::exception& ex ) {
+            convertException<OMT1,OMT2>( ex );
+         }
+
+         checkResults<OMT1,OMT2>();
+      }
+
+      // Conjugate addition with subtraction assignment with evaluated matrices
+      {
+         test_  = "Conjugate addition with subtraction assignment with evaluated matrices";
+         error_ = "Failed subtraction assignment operation";
+
+         try {
+            initResults();
+            dres_   -= conj( eval( lhs_ ) + eval( rhs_ ) );
+            odres_  -= conj( eval( lhs_ ) + eval( rhs_ ) );
+            sres_   -= conj( eval( lhs_ ) + eval( rhs_ ) );
+            osres_  -= conj( eval( lhs_ ) + eval( rhs_ ) );
+            refres_ -= conj( eval( reflhs_ ) + eval( refrhs_ ) );
+         }
+         catch( std::exception& ex ) {
+            convertException<MT1,MT2>( ex );
+         }
+
+         checkResults<MT1,MT2>();
+
+         try {
+            initResults();
+            dres_   -= conj( eval( lhs_ ) + eval( orhs_ ) );
+            odres_  -= conj( eval( lhs_ ) + eval( orhs_ ) );
+            sres_   -= conj( eval( lhs_ ) + eval( orhs_ ) );
+            osres_  -= conj( eval( lhs_ ) + eval( orhs_ ) );
+            refres_ -= conj( eval( reflhs_ ) + eval( refrhs_ ) );
+         }
+         catch( std::exception& ex ) {
+            convertException<MT1,OMT2>( ex );
+         }
+
+         checkResults<MT1,OMT2>();
+
+         try {
+            initResults();
+            dres_   -= conj( eval( olhs_ ) + eval( rhs_ ) );
+            odres_  -= conj( eval( olhs_ ) + eval( rhs_ ) );
+            sres_   -= conj( eval( olhs_ ) + eval( rhs_ ) );
+            osres_  -= conj( eval( olhs_ ) + eval( rhs_ ) );
+            refres_ -= conj( eval( reflhs_ ) + eval( refrhs_ ) );
+         }
+         catch( std::exception& ex ) {
+            convertException<OMT1,MT2>( ex );
+         }
+
+         checkResults<OMT1,MT2>();
+
+         try {
+            initResults();
+            dres_   -= conj( eval( olhs_ ) + eval( orhs_ ) );
+            odres_  -= conj( eval( olhs_ ) + eval( orhs_ ) );
+            sres_   -= conj( eval( olhs_ ) + eval( orhs_ ) );
+            osres_  -= conj( eval( olhs_ ) + eval( orhs_ ) );
+            refres_ -= conj( eval( reflhs_ ) + eval( refrhs_ ) );
+         }
+         catch( std::exception& ex ) {
+            convertException<OMT1,OMT2>( ex );
+         }
+
+         checkResults<OMT1,OMT2>();
+      }
+   }
+#endif
+}
+//*************************************************************************************************
+
+
+//*************************************************************************************************
+/*!\brief Testing the conjugate transpose sparse matrix/dense matrix addition.
+//
+// \return void
+// \exception std::runtime_error Addition error detected.
+//
+// This function tests the conjugate transpose matrix addition with plain assignment. In
+// case any error resulting from the addition or the subsequent assignment is detected, a
+// \a std::runtime_error exception is thrown.
+*/
+template< typename MT1    // Type of the left-hand side sparse matrix
+        , typename MT2 >  // Type of the right-hand side dense matrix
+void OperationTest<MT1,MT2>::testCTransOperation()
+{
+#if BLAZETEST_MATHTEST_TEST_CTRANS_OPERATION
+   if( BLAZETEST_MATHTEST_TEST_CTRANS_OPERATION > 1 )
+   {
+      //=====================================================================================
+      // Conjugate transpose addition
+      //=====================================================================================
+
+      // Conjugate transpose addition with the given matrices
+      {
+         test_  = "Conjugate transpose addition with the given matrices";
+         error_ = "Failed addition operation";
+
+         try {
+            initTransposeResults();
+            tdres_  = ctrans( lhs_ + rhs_ );
+            todres_ = ctrans( lhs_ + rhs_ );
+            tsres_  = ctrans( lhs_ + rhs_ );
+            tosres_ = ctrans( lhs_ + rhs_ );
+            refres_ = ctrans( reflhs_ + refrhs_ );
+         }
+         catch( std::exception& ex ) {
+            convertException<MT1,MT2>( ex );
+         }
+
+         checkTransposeResults<MT1,MT2>();
+
+         try {
+            initTransposeResults();
+            tdres_  = ctrans( lhs_ + orhs_ );
+            todres_ = ctrans( lhs_ + orhs_ );
+            tsres_  = ctrans( lhs_ + orhs_ );
+            tosres_ = ctrans( lhs_ + orhs_ );
+            refres_ = ctrans( reflhs_ + refrhs_ );
+         }
+         catch( std::exception& ex ) {
+            convertException<MT1,OMT2>( ex );
+         }
+
+         checkTransposeResults<MT1,OMT2>();
+
+         try {
+            initTransposeResults();
+            tdres_  = ctrans( olhs_ + rhs_ );
+            todres_ = ctrans( olhs_ + rhs_ );
+            tsres_  = ctrans( olhs_ + rhs_ );
+            tosres_ = ctrans( olhs_ + rhs_ );
+            refres_ = ctrans( reflhs_ + refrhs_ );
+         }
+         catch( std::exception& ex ) {
+            convertException<OMT1,MT2>( ex );
+         }
+
+         checkTransposeResults<OMT1,MT2>();
+
+         try {
+            initTransposeResults();
+            tdres_  = ctrans( olhs_ + orhs_ );
+            todres_ = ctrans( olhs_ + orhs_ );
+            tsres_  = ctrans( olhs_ + orhs_ );
+            tosres_ = ctrans( olhs_ + orhs_ );
+            refres_ = ctrans( reflhs_ + refrhs_ );
+         }
+         catch( std::exception& ex ) {
+            convertException<OMT1,OMT2>( ex );
+         }
+
+         checkTransposeResults<OMT1,OMT2>();
+      }
+
+      // Conjugate transpose addition with evaluated matrices
+      {
+         test_  = "Conjugate transpose addition with evaluated matrices";
+         error_ = "Failed addition operation";
+
+         try {
+            initTransposeResults();
+            tdres_  = ctrans( eval( lhs_ ) + eval( rhs_ ) );
+            todres_ = ctrans( eval( lhs_ ) + eval( rhs_ ) );
+            tsres_  = ctrans( eval( lhs_ ) + eval( rhs_ ) );
+            tosres_ = ctrans( eval( lhs_ ) + eval( rhs_ ) );
+            refres_ = ctrans( eval( reflhs_ ) + eval( refrhs_ ) );
+         }
+         catch( std::exception& ex ) {
+            convertException<MT1,MT2>( ex );
+         }
+
+         checkTransposeResults<MT1,MT2>();
+
+         try {
+            initTransposeResults();
+            tdres_  = ctrans( eval( lhs_ ) + eval( orhs_ ) );
+            todres_ = ctrans( eval( lhs_ ) + eval( orhs_ ) );
+            tsres_  = ctrans( eval( lhs_ ) + eval( orhs_ ) );
+            tosres_ = ctrans( eval( lhs_ ) + eval( orhs_ ) );
+            refres_ = ctrans( eval( reflhs_ ) + eval( refrhs_ ) );
+         }
+         catch( std::exception& ex ) {
+            convertException<MT1,OMT2>( ex );
+         }
+
+         checkTransposeResults<MT1,OMT2>();
+
+         try {
+            initTransposeResults();
+            tdres_  = ctrans( eval( olhs_ ) + eval( rhs_ ) );
+            todres_ = ctrans( eval( olhs_ ) + eval( rhs_ ) );
+            tsres_  = ctrans( eval( olhs_ ) + eval( rhs_ ) );
+            tosres_ = ctrans( eval( olhs_ ) + eval( rhs_ ) );
+            refres_ = ctrans( eval( reflhs_ ) + eval( refrhs_ ) );
+         }
+         catch( std::exception& ex ) {
+            convertException<OMT1,MT2>( ex );
+         }
+
+         checkTransposeResults<OMT1,MT2>();
+
+         try {
+            initTransposeResults();
+            tdres_  = ctrans( eval( olhs_ ) + eval( orhs_ ) );
+            todres_ = ctrans( eval( olhs_ ) + eval( orhs_ ) );
+            tsres_  = ctrans( eval( olhs_ ) + eval( orhs_ ) );
+            tosres_ = ctrans( eval( olhs_ ) + eval( orhs_ ) );
+            refres_ = ctrans( eval( reflhs_ ) + eval( refrhs_ ) );
+         }
+         catch( std::exception& ex ) {
+            convertException<OMT1,OMT2>( ex );
+         }
+
+         checkTransposeResults<OMT1,OMT2>();
+      }
+   }
+#endif
+}
+//*************************************************************************************************
+
+
+//*************************************************************************************************
 /*!\brief Testing the abs sparse matrix/dense matrix addition.
 //
 // \return void
@@ -3621,414 +4181,6 @@
             sres_   -= abs( eval( olhs_ ) + eval( orhs_ ) );
             osres_  -= abs( eval( olhs_ ) + eval( orhs_ ) );
             refres_ -= abs( eval( reflhs_ ) + eval( refrhs_ ) );
-         }
-         catch( std::exception& ex ) {
-            convertException<OMT1,OMT2>( ex );
-         }
-
-         checkResults<OMT1,OMT2>();
-      }
-   }
-#endif
-}
-//*************************************************************************************************
-
-
-//*************************************************************************************************
-/*!\brief Testing the conj sparse matrix/dense matrix addition.
-//
-// \return void
-// \exception std::runtime_error Addition error detected.
-//
-// This function tests the conj matrix addition with plain assignment, addition assignment,
-// and subtraction assignment. In case any error resulting from the addition or the subsequent
-// assignment is detected, a \a std::runtime_error exception is thrown.
-*/
-template< typename MT1    // Type of the left-hand side sparse matrix
-        , typename MT2 >  // Type of the right-hand side dense matrix
-void OperationTest<MT1,MT2>::testConjOperation()
-{
-#if BLAZETEST_MATHTEST_TEST_CONJ_OPERATION
-   if( BLAZETEST_MATHTEST_TEST_CONJ_OPERATION > 1 )
-   {
-      //=====================================================================================
-      // Conj addition
-      //=====================================================================================
-
-      // Conj addition with the given matrices
-      {
-         test_  = "Conj addition with the given matrices";
-         error_ = "Failed addition operation";
-
-         try {
-            initResults();
-            dres_   = conj( lhs_ + rhs_ );
-            odres_  = conj( lhs_ + rhs_ );
-            sres_   = conj( lhs_ + rhs_ );
-            osres_  = conj( lhs_ + rhs_ );
-            refres_ = conj( reflhs_ + refrhs_ );
-         }
-         catch( std::exception& ex ) {
-            convertException<MT1,MT2>( ex );
-         }
-
-         checkResults<MT1,MT2>();
-
-         try {
-            initResults();
-            dres_   = conj( lhs_ + orhs_ );
-            odres_  = conj( lhs_ + orhs_ );
-            sres_   = conj( lhs_ + orhs_ );
-            osres_  = conj( lhs_ + orhs_ );
-            refres_ = conj( reflhs_ + refrhs_ );
-         }
-         catch( std::exception& ex ) {
-            convertException<MT1,OMT2>( ex );
-         }
-
-         checkResults<MT1,OMT2>();
-
-         try {
-            initResults();
-            dres_   = conj( olhs_ + rhs_ );
-            odres_  = conj( olhs_ + rhs_ );
-            sres_   = conj( olhs_ + rhs_ );
-            osres_  = conj( olhs_ + rhs_ );
-            refres_ = conj( reflhs_ + refrhs_ );
-         }
-         catch( std::exception& ex ) {
-            convertException<OMT1,MT2>( ex );
-         }
-
-         checkResults<OMT1,MT2>();
-
-         try {
-            initResults();
-            dres_   = conj( olhs_ + orhs_ );
-            odres_  = conj( olhs_ + orhs_ );
-            sres_   = conj( olhs_ + orhs_ );
-            osres_  = conj( olhs_ + orhs_ );
-            refres_ = conj( reflhs_ + refrhs_ );
-         }
-         catch( std::exception& ex ) {
-            convertException<OMT1,OMT2>( ex );
-         }
-
-         checkResults<OMT1,OMT2>();
-      }
-
-      // Conj addition with evaluated matrices
-      {
-         test_  = "Conj addition with evaluated matrices";
-         error_ = "Failed addition operation";
-
-         try {
-            initResults();
-            dres_   = conj( eval( lhs_ ) + eval( rhs_ ) );
-            odres_  = conj( eval( lhs_ ) + eval( rhs_ ) );
-            sres_   = conj( eval( lhs_ ) + eval( rhs_ ) );
-            osres_  = conj( eval( lhs_ ) + eval( rhs_ ) );
-            refres_ = conj( eval( reflhs_ ) + eval( refrhs_ ) );
-         }
-         catch( std::exception& ex ) {
-            convertException<MT1,MT2>( ex );
-         }
-
-         checkResults<MT1,MT2>();
-
-         try {
-            initResults();
-            dres_   = conj( eval( lhs_ ) + eval( orhs_ ) );
-            odres_  = conj( eval( lhs_ ) + eval( orhs_ ) );
-            sres_   = conj( eval( lhs_ ) + eval( orhs_ ) );
-            osres_  = conj( eval( lhs_ ) + eval( orhs_ ) );
-            refres_ = conj( eval( reflhs_ ) + eval( refrhs_ ) );
-         }
-         catch( std::exception& ex ) {
-            convertException<MT1,OMT2>( ex );
-         }
-
-         checkResults<MT1,OMT2>();
-
-         try {
-            initResults();
-            dres_   = conj( eval( olhs_ ) + eval( rhs_ ) );
-            odres_  = conj( eval( olhs_ ) + eval( rhs_ ) );
-            sres_   = conj( eval( olhs_ ) + eval( rhs_ ) );
-            osres_  = conj( eval( olhs_ ) + eval( rhs_ ) );
-            refres_ = conj( eval( reflhs_ ) + eval( refrhs_ ) );
-         }
-         catch( std::exception& ex ) {
-            convertException<OMT1,MT2>( ex );
-         }
-
-         checkResults<OMT1,MT2>();
-
-         try {
-            initResults();
-            dres_   = conj( eval( olhs_ ) + eval( orhs_ ) );
-            odres_  = conj( eval( olhs_ ) + eval( orhs_ ) );
-            sres_   = conj( eval( olhs_ ) + eval( orhs_ ) );
-            osres_  = conj( eval( olhs_ ) + eval( orhs_ ) );
-            refres_ = conj( eval( reflhs_ ) + eval( refrhs_ ) );
-         }
-         catch( std::exception& ex ) {
-            convertException<OMT1,OMT2>( ex );
-         }
-
-         checkResults<OMT1,OMT2>();
-      }
-
-
-      //=====================================================================================
-      // Conj addition with addition assignment
-      //=====================================================================================
-
-      // Conj addition with addition assignment with the given matrices
-      {
-         test_  = "Conj addition with addition assignment with the given matrices";
-         error_ = "Failed addition assignment operation";
-
-         try {
-            initResults();
-            dres_   += conj( lhs_ + rhs_ );
-            odres_  += conj( lhs_ + rhs_ );
-            sres_   += conj( lhs_ + rhs_ );
-            osres_  += conj( lhs_ + rhs_ );
-            refres_ += conj( reflhs_ + refrhs_ );
-         }
-         catch( std::exception& ex ) {
-            convertException<MT1,MT2>( ex );
-         }
-
-         checkResults<MT1,MT2>();
-
-         try {
-            initResults();
-            dres_   += conj( lhs_ + orhs_ );
-            odres_  += conj( lhs_ + orhs_ );
-            sres_   += conj( lhs_ + orhs_ );
-            osres_  += conj( lhs_ + orhs_ );
-            refres_ += conj( reflhs_ + refrhs_ );
-         }
-         catch( std::exception& ex ) {
-            convertException<MT1,OMT2>( ex );
-         }
-
-         checkResults<MT1,OMT2>();
-
-         try {
-            initResults();
-            dres_   += conj( olhs_ + rhs_ );
-            odres_  += conj( olhs_ + rhs_ );
-            sres_   += conj( olhs_ + rhs_ );
-            osres_  += conj( olhs_ + rhs_ );
-            refres_ += conj( reflhs_ + refrhs_ );
-         }
-         catch( std::exception& ex ) {
-            convertException<OMT1,MT2>( ex );
-         }
-
-         checkResults<OMT1,MT2>();
-
-         try {
-            initResults();
-            dres_   += conj( olhs_ + orhs_ );
-            odres_  += conj( olhs_ + orhs_ );
-            sres_   += conj( olhs_ + orhs_ );
-            osres_  += conj( olhs_ + orhs_ );
-            refres_ += conj( reflhs_ + refrhs_ );
-         }
-         catch( std::exception& ex ) {
-            convertException<OMT1,OMT2>( ex );
-         }
-
-         checkResults<OMT1,OMT2>();
-      }
-
-      // Conj addition with addition assignment with evaluated matrices
-      {
-         test_  = "Conj addition with addition assignment with evaluated matrices";
-         error_ = "Failed addition assignment operation";
-
-         try {
-            initResults();
-            dres_   += conj( eval( lhs_ ) + eval( rhs_ ) );
-            odres_  += conj( eval( lhs_ ) + eval( rhs_ ) );
-            sres_   += conj( eval( lhs_ ) + eval( rhs_ ) );
-            osres_  += conj( eval( lhs_ ) + eval( rhs_ ) );
-            refres_ += conj( eval( reflhs_ ) + eval( refrhs_ ) );
-         }
-         catch( std::exception& ex ) {
-            convertException<MT1,MT2>( ex );
-         }
-
-         checkResults<MT1,MT2>();
-
-         try {
-            initResults();
-            dres_   += conj( eval( lhs_ ) + eval( orhs_ ) );
-            odres_  += conj( eval( lhs_ ) + eval( orhs_ ) );
-            sres_   += conj( eval( lhs_ ) + eval( orhs_ ) );
-            osres_  += conj( eval( lhs_ ) + eval( orhs_ ) );
-            refres_ += conj( eval( reflhs_ ) + eval( refrhs_ ) );
-         }
-         catch( std::exception& ex ) {
-            convertException<MT1,OMT2>( ex );
-         }
-
-         checkResults<MT1,OMT2>();
-
-         try {
-            initResults();
-            dres_   += conj( eval( olhs_ ) + eval( rhs_ ) );
-            odres_  += conj( eval( olhs_ ) + eval( rhs_ ) );
-            sres_   += conj( eval( olhs_ ) + eval( rhs_ ) );
-            osres_  += conj( eval( olhs_ ) + eval( rhs_ ) );
-            refres_ += conj( eval( reflhs_ ) + eval( refrhs_ ) );
-         }
-         catch( std::exception& ex ) {
-            convertException<OMT1,MT2>( ex );
-         }
-
-         checkResults<OMT1,MT2>();
-
-         try {
-            initResults();
-            dres_   += conj( eval( olhs_ ) + eval( orhs_ ) );
-            odres_  += conj( eval( olhs_ ) + eval( orhs_ ) );
-            sres_   += conj( eval( olhs_ ) + eval( orhs_ ) );
-            osres_  += conj( eval( olhs_ ) + eval( orhs_ ) );
-            refres_ += conj( eval( reflhs_ ) + eval( refrhs_ ) );
-         }
-         catch( std::exception& ex ) {
-            convertException<OMT1,OMT2>( ex );
-         }
-
-         checkResults<OMT1,OMT2>();
-      }
-
-
-      //=====================================================================================
-      // Conj addition with subtraction assignment
-      //=====================================================================================
-
-      // Conj addition with subtraction assignment with the given matrices
-      {
-         test_  = "Conj addition with subtraction assignment with the given matrices";
-         error_ = "Failed subtraction assignment operation";
-
-         try {
-            initResults();
-            dres_   -= conj( lhs_ + rhs_ );
-            odres_  -= conj( lhs_ + rhs_ );
-            sres_   -= conj( lhs_ + rhs_ );
-            osres_  -= conj( lhs_ + rhs_ );
-            refres_ -= conj( reflhs_ + refrhs_ );
-         }
-         catch( std::exception& ex ) {
-            convertException<MT1,MT2>( ex );
-         }
-
-         checkResults<MT1,MT2>();
-
-         try {
-            initResults();
-            dres_   -= conj( lhs_ + orhs_ );
-            odres_  -= conj( lhs_ + orhs_ );
-            sres_   -= conj( lhs_ + orhs_ );
-            osres_  -= conj( lhs_ + orhs_ );
-            refres_ -= conj( reflhs_ + refrhs_ );
-         }
-         catch( std::exception& ex ) {
-            convertException<MT1,OMT2>( ex );
-         }
-
-         checkResults<MT1,OMT2>();
-
-         try {
-            initResults();
-            dres_   -= conj( olhs_ + rhs_ );
-            odres_  -= conj( olhs_ + rhs_ );
-            sres_   -= conj( olhs_ + rhs_ );
-            osres_  -= conj( olhs_ + rhs_ );
-            refres_ -= conj( reflhs_ + refrhs_ );
-         }
-         catch( std::exception& ex ) {
-            convertException<OMT1,MT2>( ex );
-         }
-
-         checkResults<OMT1,MT2>();
-
-         try {
-            initResults();
-            dres_   -= conj( olhs_ + orhs_ );
-            odres_  -= conj( olhs_ + orhs_ );
-            sres_   -= conj( olhs_ + orhs_ );
-            osres_  -= conj( olhs_ + orhs_ );
-            refres_ -= conj( reflhs_ + refrhs_ );
-         }
-         catch( std::exception& ex ) {
-            convertException<OMT1,OMT2>( ex );
-         }
-
-         checkResults<OMT1,OMT2>();
-      }
-
-      // Conj addition with subtraction assignment with evaluated matrices
-      {
-         test_  = "Conj addition with subtraction assignment with evaluated matrices";
-         error_ = "Failed subtraction assignment operation";
-
-         try {
-            initResults();
-            dres_   -= conj( eval( lhs_ ) + eval( rhs_ ) );
-            odres_  -= conj( eval( lhs_ ) + eval( rhs_ ) );
-            sres_   -= conj( eval( lhs_ ) + eval( rhs_ ) );
-            osres_  -= conj( eval( lhs_ ) + eval( rhs_ ) );
-            refres_ -= conj( eval( reflhs_ ) + eval( refrhs_ ) );
-         }
-         catch( std::exception& ex ) {
-            convertException<MT1,MT2>( ex );
-         }
-
-         checkResults<MT1,MT2>();
-
-         try {
-            initResults();
-            dres_   -= conj( eval( lhs_ ) + eval( orhs_ ) );
-            odres_  -= conj( eval( lhs_ ) + eval( orhs_ ) );
-            sres_   -= conj( eval( lhs_ ) + eval( orhs_ ) );
-            osres_  -= conj( eval( lhs_ ) + eval( orhs_ ) );
-            refres_ -= conj( eval( reflhs_ ) + eval( refrhs_ ) );
-         }
-         catch( std::exception& ex ) {
-            convertException<MT1,OMT2>( ex );
-         }
-
-         checkResults<MT1,OMT2>();
-
-         try {
-            initResults();
-            dres_   -= conj( eval( olhs_ ) + eval( rhs_ ) );
-            odres_  -= conj( eval( olhs_ ) + eval( rhs_ ) );
-            sres_   -= conj( eval( olhs_ ) + eval( rhs_ ) );
-            osres_  -= conj( eval( olhs_ ) + eval( rhs_ ) );
-            refres_ -= conj( eval( reflhs_ ) + eval( refrhs_ ) );
-         }
-         catch( std::exception& ex ) {
-            convertException<OMT1,MT2>( ex );
-         }
-
-         checkResults<OMT1,MT2>();
-
-         try {
-            initResults();
-            dres_   -= conj( eval( olhs_ ) + eval( orhs_ ) );
-            odres_  -= conj( eval( olhs_ ) + eval( orhs_ ) );
-            sres_   -= conj( eval( olhs_ ) + eval( orhs_ ) );
-            osres_  -= conj( eval( olhs_ ) + eval( orhs_ ) );
-            refres_ -= conj( eval( reflhs_ ) + eval( refrhs_ ) );
          }
          catch( std::exception& ex ) {
             convertException<OMT1,OMT2>( ex );


Fix invalid argument handling

Fix invalid argument handling

Fixes #61

--- src/asound/bluealsa-pcm.c
+++ src/asound/bluealsa-pcm.c
@@ -620,23 +620,21 @@
 		return -EINVAL;
 	}

+	bdaddr_t addr;
+	enum pcm_type type;
+
+	if (device == NULL || str2ba(device, &addr) != 0) {
+		SNDERR("Invalid BT device address: %s", device);
+		return -EINVAL;
+	}
+
+	if ((type = bluealsa_parse_profile(profile)) == PCM_TYPE_NULL) {
+		SNDERR("Invalid BT profile [a2dp, sco]: %s", profile);
+		return -EINVAL;
+	}
+
 	if ((pcm = calloc(1, sizeof(*pcm))) == NULL)
 		return -ENOMEM;
-
-	bdaddr_t addr;
-	enum pcm_type type;
-
-	if (device == NULL || str2ba(device, &addr) != 0) {
-		SNDERR("Invalid BT device address: %s", device);
-		ret = -errno;
-		goto fail;
-	}
-
-	if ((type = bluealsa_parse_profile(profile)) == PCM_TYPE_NULL) {
-		SNDERR("Invalid BT profile [a2dp, sco]: %s", profile);
-		ret = -errno;
-		goto fail;
-	}

 	pcm->fd = -1;
 	pcm->event_fd = -1;


Stream: core module variables.

Stream: core module variables.

--- src/stream/ngx_stream_variables.c
+++ src/stream/ngx_stream_variables.c
@@ -11,14 +11,75 @@
 #include <nginx.h>

+static ngx_int_t ngx_stream_variable_binary_remote_addr(
+    ngx_stream_session_t *s, ngx_stream_variable_value_t *v, uintptr_t data);
+static ngx_int_t ngx_stream_variable_remote_addr(ngx_stream_session_t *s,
+    ngx_stream_variable_value_t *v, uintptr_t data);
+static ngx_int_t ngx_stream_variable_remote_port(ngx_stream_session_t *s,
+    ngx_stream_variable_value_t *v, uintptr_t data);
+static ngx_int_t ngx_stream_variable_server_addr(ngx_stream_session_t *s,
+    ngx_stream_variable_value_t *v, uintptr_t data);
+static ngx_int_t ngx_stream_variable_server_port(ngx_stream_session_t *s,
+    ngx_stream_variable_value_t *v, uintptr_t data);
+static ngx_int_t ngx_stream_variable_bytes_sent(ngx_stream_session_t *s,
+    ngx_stream_variable_value_t *v, uintptr_t data);
+static ngx_int_t ngx_stream_variable_connection(ngx_stream_session_t *s,
+    ngx_stream_variable_value_t *v, uintptr_t data);
+
 static ngx_int_t ngx_stream_variable_nginx_version(ngx_stream_session_t *s,
     ngx_stream_variable_value_t *v, uintptr_t data);
+static ngx_int_t ngx_stream_variable_hostname(ngx_stream_session_t *s,
+    ngx_stream_variable_value_t *v, uintptr_t data);
+static ngx_int_t ngx_stream_variable_pid(ngx_stream_session_t *s,
+    ngx_stream_variable_value_t *v, uintptr_t data);
+static ngx_int_t ngx_stream_variable_msec(ngx_stream_session_t *s,
+    ngx_stream_variable_value_t *v, uintptr_t data);
+static ngx_int_t ngx_stream_variable_time_iso8601(ngx_stream_session_t *s,
+    ngx_stream_variable_value_t *v, uintptr_t data);
+static ngx_int_t ngx_stream_variable_time_local(ngx_stream_session_t *s,
+    ngx_stream_variable_value_t *v, uintptr_t data);

 static ngx_stream_variable_t  ngx_stream_core_variables[] = {
+
+    { ngx_string("binary_remote_addr"), NULL,
+      ngx_stream_variable_binary_remote_addr, 0, 0, 0 },
+
+    { ngx_string("remote_addr"), NULL,
+      ngx_stream_variable_remote_addr, 0, 0, 0 },
+
+    { ngx_string("remote_port"), NULL,
+      ngx_stream_variable_remote_port, 0, 0, 0 },
+
+    { ngx_string("server_addr"), NULL,
+      ngx_stream_variable_server_addr, 0, 0, 0 },
+
+    { ngx_string("server_port"), NULL,
+      ngx_stream_variable_server_port, 0, 0, 0 },
+
+    { ngx_string("bytes_sent"), NULL, ngx_stream_variable_bytes_sent,
+      0, 0, 0 },
+
+    { ngx_string("connection"), NULL,
+      ngx_stream_variable_connection, 0, 0, 0 },

     { ngx_string("nginx_version"), NULL, ngx_stream_variable_nginx_version,
       0, 0, 0 },
+
+    { ngx_string("hostname"), NULL, ngx_stream_variable_hostname,
+      0, 0, 0 },
+
+    { ngx_string("pid"), NULL, ngx_stream_variable_pid,
+      0, 0, 0 },
+
+    { ngx_string("msec"), NULL, ngx_stream_variable_msec,
+      0, NGX_STREAM_VAR_NOCACHEABLE, 0 },
+
+    { ngx_string("time_iso8601"), NULL, ngx_stream_variable_time_iso8601,
+      0, NGX_STREAM_VAR_NOCACHEABLE, 0 },
+
+    { ngx_string("time_local"), NULL, ngx_stream_variable_time_local,
+      0, NGX_STREAM_VAR_NOCACHEABLE, 0 },

     { ngx_null_string, NULL, NULL, 0, 0, 0 }
 };
@@ -259,6 +320,189 @@

 static ngx_int_t
+ngx_stream_variable_binary_remote_addr(ngx_stream_session_t *s,
+     ngx_stream_variable_value_t *v, uintptr_t data)
+ {
+    struct sockaddr_in   *sin;
+#if (NGX_HAVE_INET6)
+    struct sockaddr_in6  *sin6;
+#endif
+
+    switch (s->connection->sockaddr->sa_family) {
+
+#if (NGX_HAVE_INET6)
+    case AF_INET6:
+        sin6 = (struct sockaddr_in6 *) s->connection->sockaddr;
+
+        v->len = sizeof(struct in6_addr);
+        v->valid = 1;
+        v->no_cacheable = 0;
+        v->not_found = 0;
+        v->data = sin6->sin6_addr.s6_addr;
+
+        break;
+#endif
+
+    default: /* AF_INET */
+        sin = (struct sockaddr_in *) s->connection->sockaddr;
+
+        v->len = sizeof(in_addr_t);
+        v->valid = 1;
+        v->no_cacheable = 0;
+        v->not_found = 0;
+        v->data = (u_char *) &sin->sin_addr;
+
+        break;
+    }
+
+    return NGX_OK;
+}
+
+
+static ngx_int_t
+ngx_stream_variable_remote_addr(ngx_stream_session_t *s,
+    ngx_stream_variable_value_t *v, uintptr_t data)
+{
+    v->len = s->connection->addr_text.len;
+    v->valid = 1;
+    v->no_cacheable = 0;
+    v->not_found = 0;
+    v->data = s->connection->addr_text.data;
+
+    return NGX_OK;
+}
+
+
+static ngx_int_t
+ngx_stream_variable_remote_port(ngx_stream_session_t *s,
+    ngx_stream_variable_value_t *v, uintptr_t data)
+{
+    ngx_uint_t  port;
+
+    v->len = 0;
+    v->valid = 1;
+    v->no_cacheable = 0;
+    v->not_found = 0;
+
+    v->data = ngx_pnalloc(s->connection->pool, sizeof("65535") - 1);
+    if (v->data == NULL) {
+        return NGX_ERROR;
+    }
+
+    port = ngx_inet_get_port(s->connection->sockaddr);
+
+    if (port > 0 && port < 65536) {
+        v->len = ngx_sprintf(v->data, "%ui", port) - v->data;
+    }
+
+    return NGX_OK;
+}
+
+
+static ngx_int_t
+ngx_stream_variable_server_addr(ngx_stream_session_t *s,
+    ngx_stream_variable_value_t *v, uintptr_t data)
+{
+    ngx_str_t  str;
+    u_char     addr[NGX_SOCKADDR_STRLEN];
+
+    str.len = NGX_SOCKADDR_STRLEN;
+    str.data = addr;
+
+    if (ngx_connection_local_sockaddr(s->connection, &str, 0) != NGX_OK) {
+        return NGX_ERROR;
+    }
+
+    str.data = ngx_pnalloc(s->connection->pool, str.len);
+    if (str.data == NULL) {
+        return NGX_ERROR;
+    }
+
+    ngx_memcpy(str.data, addr, str.len);
+
+    v->len = str.len;
+    v->valid = 1;
+    v->no_cacheable = 0;
+    v->not_found = 0;
+    v->data = str.data;
+
+    return NGX_OK;
+}
+
+
+static ngx_int_t
+ngx_stream_variable_server_port(ngx_stream_session_t *s,
+    ngx_stream_variable_value_t *v, uintptr_t data)
+{
+    ngx_uint_t  port;
+
+    v->len = 0;
+    v->valid = 1;
+    v->no_cacheable = 0;
+    v->not_found = 0;
+
+    if (ngx_connection_local_sockaddr(s->connection, NULL, 0) != NGX_OK) {
+        return NGX_ERROR;
+    }
+
+    v->data = ngx_pnalloc(s->connection->pool, sizeof("65535") - 1);
+    if (v->data == NULL) {
+        return NGX_ERROR;
+    }
+
+    port = ngx_inet_get_port(s->connection->local_sockaddr);
+
+    if (port > 0 && port < 65536) {
+        v->len = ngx_sprintf(v->data, "%ui", port) - v->data;
+    }
+
+    return NGX_OK;
+}
+
+
+static ngx_int_t
+ngx_stream_variable_bytes_sent(ngx_stream_session_t *s,
+    ngx_stream_variable_value_t *v, uintptr_t data)
+{
+    u_char  *p;
+
+    p = ngx_pnalloc(s->connection->pool, NGX_OFF_T_LEN);
+    if (p == NULL) {
+        return NGX_ERROR;
+    }
+
+    v->len = ngx_sprintf(p, "%O", s->connection->sent) - p;
+    v->valid = 1;
+    v->no_cacheable = 0;
+    v->not_found = 0;
+    v->data = p;
+
+    return NGX_OK;
+}
+
+
+static ngx_int_t
+ngx_stream_variable_connection(ngx_stream_session_t *s,
+    ngx_stream_variable_value_t *v, uintptr_t data)
+{
+    u_char  *p;
+
+    p = ngx_pnalloc(s->connection->pool, NGX_ATOMIC_T_LEN);
+    if (p == NULL) {
+        return NGX_ERROR;
+    }
+
+    v->len = ngx_sprintf(p, "%uA", s->connection->number) - p;
+    v->valid = 1;
+    v->no_cacheable = 0;
+    v->not_found = 0;
+    v->data = p;
+
+    return NGX_OK;
+}
+
+
+static ngx_int_t
 ngx_stream_variable_nginx_version(ngx_stream_session_t *s,
     ngx_stream_variable_value_t *v, uintptr_t data)
 {
@@ -267,6 +511,112 @@
     v->no_cacheable = 0;
     v->not_found = 0;
     v->data = (u_char *) NGINX_VERSION;
+
+    return NGX_OK;
+}
+
+
+static ngx_int_t
+ngx_stream_variable_hostname(ngx_stream_session_t *s,
+    ngx_stream_variable_value_t *v, uintptr_t data)
+{
+    v->len = ngx_cycle->hostname.len;
+    v->valid = 1;
+    v->no_cacheable = 0;
+    v->not_found = 0;
+    v->data = ngx_cycle->hostname.data;
+
+    return NGX_OK;
+}
+
+
+static ngx_int_t
+ngx_stream_variable_pid(ngx_stream_session_t *s,
+    ngx_stream_variable_value_t *v, uintptr_t data)
+{
+    u_char  *p;
+
+    p = ngx_pnalloc(s->connection->pool, NGX_INT64_LEN);
+    if (p == NULL) {
+        return NGX_ERROR;
+    }
+
+    v->len = ngx_sprintf(p, "%P", ngx_pid) - p;
+    v->valid = 1;
+    v->no_cacheable = 0;
+    v->not_found = 0;
+    v->data = p;
+
+    return NGX_OK;
+}
+
+
+static ngx_int_t
+ngx_stream_variable_msec(ngx_stream_session_t *s,
+    ngx_stream_variable_value_t *v, uintptr_t data)
+{
+    u_char      *p;
+    ngx_time_t  *tp;
+
+    p = ngx_pnalloc(s->connection->pool, NGX_TIME_T_LEN + 4);
+    if (p == NULL) {
+        return NGX_ERROR;
+    }
+
+    tp = ngx_timeofday();
+
+    v->len = ngx_sprintf(p, "%T.%03M", tp->sec, tp->msec) - p;
+    v->valid = 1;
+    v->no_cacheable = 0;
+    v->not_found = 0;
+    v->data = p;
+
+    return NGX_OK;
+}
+
+
+static ngx_int_t
+ngx_stream_variable_time_iso8601(ngx_stream_session_t *s,
+    ngx_stream_variable_value_t *v, uintptr_t data)
+{
+    u_char  *p;
+
+    p = ngx_pnalloc(s->connection->pool, ngx_cached_http_log_iso8601.len);
+    if (p == NULL) {
+        return NGX_ERROR;
+    }
+
+    ngx_memcpy(p, ngx_cached_http_log_iso8601.data,
+               ngx_cached_http_log_iso8601.len);
+
+    v->len = ngx_cached_http_log_iso8601.len;
+    v->valid = 1;
+    v->no_cacheable = 0;
+    v->not_found = 0;
+    v->data = p;
+
+    return NGX_OK;
+}
+
+
+static ngx_int_t
+ngx_stream_variable_time_local(ngx_stream_session_t *s,
+    ngx_stream_variable_value_t *v, uintptr_t data)
+{
+    u_char  *p;
+
+    p = ngx_pnalloc(s->connection->pool, ngx_cached_http_log_time.len);
+    if (p == NULL) {
+        return NGX_ERROR;
+    }
+
+    ngx_memcpy(p, ngx_cached_http_log_time.data, ngx_cached_http_log_time.len);
+
+    v->len = ngx_cached_http_log_time.len;
+    v->valid = 1;
+    v->no_cacheable = 0;
+    v->not_found = 0;
+    v->data = p;

     return NGX_OK;
 }


Update drv_flash_f1.c

Update drv_flash_f1.c

调整stm32_flash_erase的返回值

--- bsp/stm32/libraries/HAL_Drivers/drv_flash/drv_flash_f1.c
+++ bsp/stm32/libraries/HAL_Drivers/drv_flash/drv_flash_f1.c
@@ -231,6 +231,11 @@
         }
     }

+    if (result != RT_EOK)
+    {
+        return result;
+    }
+
     return size_bank1 + size_bank2;
 #else
     return stm32_flash_erase_bank(FLASH_BANK_1, addr, size);


Removed misleading comment about errno check after failed sndlib_allocate_buffers.

--- src/audio/sndlibsupport.c
+++ src/audio/sndlibsupport.c
@@ -1035,7 +1035,7 @@
 /* ---------------------------------------------- sndlib_allocate_buffers --- */
 /* Allocate the multi-dimensional array required by sndlib I/O functions.
    Returns an array of <nchans> arrays of <nframes> integers. The memory
-   is cleared. If the return value is NULL, check errno.
+   is cleared.
 */
 int **
 sndlib_allocate_buffers(int nchans, int nframes)


aout: remove choices list on the device variable

This does not support hot plug and unplug of devices.

Also, it prevented selecting a device not in the choices list due to
checks in the variables subsystem. (At least with ALSA, not all valid
devices are included in the suggestions.)

--- src/audio_output/output.c
+++ src/audio_output/output.c
@@ -113,8 +113,6 @@
     var_Create (aout, "mute", VLC_VAR_BOOL | VLC_VAR_DOINHERIT);
     var_AddCallback (aout, "mute", var_Copy, parent);
     var_Create (aout, "device", VLC_VAR_STRING | VLC_VAR_HASCHOICE);
-    text.psz_string = _("Audio Device");
-    var_Change (aout, "device", VLC_VAR_SETTEXT, &text, NULL);

     aout->event.volume_report = aout_VolumeNotify;
     aout->event.mute_report = aout_MuteNotify;
@@ -136,27 +134,6 @@
         msg_Err (aout, "no suitable audio output module");
         vlc_object_release (aout);
         return NULL;
-    }
-
-    if (aout->device_enum != NULL)
-    {   /* Backward compatibility with UIs using GETCHOICES/GETLIST */
-        /* Note: this does NOT support hot-plugged devices. */
-        char **ids, **names;
-        int n = aout->device_enum (aout, &ids, &names);
-
-        for (int i = 0; i < n; i++)
-        {
-            val.psz_string = ids[i];
-            text.psz_string = names[i];
-            var_Change (aout, "device", VLC_VAR_ADDCHOICE, &val, &text);
-            free (names[i]);
-            free (ids[i]);
-        }
-        if (n >= 0)
-        {
-            free (names);
-            free (ids);
-        }
     }

     /*


auth: If parsing passwd-file takes a long time, log a warning.

--- src/auth/db-passwd-file.c
+++ src/auth/db-passwd-file.c
@@ -17,7 +17,11 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <fcntl.h>
+#include <time.h>
 #include <sys/stat.h>
+
+#define PARSE_TIME_STARTUP_WARN_SECS 60
+#define PARSE_TIME_RELOAD_WARN_SECS 10

 static struct db_passwd_file *passwd_files;

@@ -155,12 +159,14 @@
 	return pw;
 }

-static bool passwd_file_open(struct passwd_file *pw)
+static bool passwd_file_open(struct passwd_file *pw, bool startup)
 {
 	const char *no_args = NULL;
 	struct istream *input;
 	const char *line;
 	struct stat st;
+	time_t start_time, end_time;
+	unsigned int time_secs;
 	int fd;

 	fd = open(pw->path, O_RDONLY);
@@ -189,6 +195,7 @@
 	pw->users = hash_table_create(default_pool, pw->pool, 100,
 				      str_hash, (hash_cmp_callback_t *)strcmp);

+	start_time = time(NULL);
 	input = i_stream_create_fd(pw->fd, 4096, FALSE);
 	i_stream_set_return_partial_line(input, TRUE);
 	while ((line = i_stream_read_next_line(input)) != NULL) {
@@ -207,10 +214,16 @@
 		} T_END;
 	}
 	i_stream_destroy(&input);
-
-	if (pw->db->debug) {
-		i_debug("passwd-file %s: Read %u users",
-			pw->path, hash_table_count(pw->users));
+	end_time = time(NULL);
+	time_secs = end_time - start_time;
+
+	if ((time_secs > PARSE_TIME_STARTUP_WARN_SECS && startup) ||
+	    (time_secs > PARSE_TIME_RELOAD_WARN_SECS && !startup)) {
+		i_warning("passwd-file %s: Reading %u users took %u secs",
+			  pw->path, hash_table_count(pw->users), time_secs);
+	} else if (pw->db->debug) {
+		i_debug("passwd-file %s: Read %u users in %u secs",
+			pw->path, hash_table_count(pw->users), time_secs);
 	}
 	return TRUE;
 }
@@ -260,7 +273,7 @@

 	if (st.st_mtime != pw->stamp || st.st_size != pw->size) {
 		passwd_file_close(pw);
-		return passwd_file_open(pw);
+		return passwd_file_open(pw, FALSE);
 	}
 	return TRUE;
 }
@@ -334,7 +347,7 @@
 {
 	if (db->default_file != NULL && db->default_file->stamp == 0) {
 		/* no variables, open the file immediately */
-		(void)passwd_file_open(db->default_file);
+		(void)passwd_file_open(db->default_file, TRUE);
 	}
 }


audiotrack: more precise sleep when buffer is full

--- modules/audio_output/audiotrack.c
+++ modules/audio_output/audiotrack.c
@@ -1313,8 +1313,7 @@

 static int
 AudioTrack_Play( JNIEnv *env, audio_output_t *p_aout,
-                 block_t *p_buffer, size_t *p_buffer_offset, mtime_t *p_wait,
-                 bool b_force )
+                 block_t *p_buffer, size_t *p_buffer_offset, bool b_force )
 {
     aout_sys_t *p_sys = p_aout->sys;
     int i_ret;
@@ -1358,11 +1357,6 @@
                 str = "ERROR";
             msg_Err( p_aout, "Write failed: %s", str );
         }
-    } else if( i_ret == 0 )
-    {
-        /* audiotrack internal buffer is full, wait a little: between 10ms and
-         * 20ms depending on devices or rate */
-        *p_wait = FRAMES_TO_US( p_sys->i_max_audiotrack_samples / 20 );
     } else
     {
         uint64_t i_samples = BYTES_TO_FRAMES( i_ret );
@@ -1396,10 +1390,7 @@
         if( i_play_wait != 0 )
             msleep( i_play_wait );

-        i_play_wait = 0;
-        i_ret = AudioTrack_Play( env, p_aout, p_buffer,
-                                 &i_buffer_offset,
-                                 &i_play_wait,
+        i_ret = AudioTrack_Play( env, p_aout, p_buffer, &i_buffer_offset,
                                  i_nb_try > 100 );
         if( i_ret < 0 )
             p_sys->b_error = true;
@@ -1413,6 +1404,14 @@
              * quickly. */
             i_nb_try = i_ret == 0 ? i_nb_try + 1 : 0;
         }
+
+        if( p_buffer->i_buffer - i_buffer_offset > 0 )
+        {
+            i_play_wait = FRAMES_TO_US( BYTES_TO_FRAMES( p_buffer->i_buffer
+                                                         - i_buffer_offset ) );
+            i_play_wait = __MAX( 10000, i_play_wait );
+        }
+
     }
 bailout:
     block_Release( p_buffer );


coap_common: send reset message after reboot

--- modules/coap_common/coap_common.c
+++ modules/coap_common/coap_common.c
@@ -90,4 +90,6 @@
     else {
         puts("Successfuly created beaconing thread !\n");
     }
+
+    send_coap_post((uint8_t*)"/alive", (uint8_t*)"reset");
 }


Fixed AXIS2C-307

Fixed AXIS2C-307

git-svn-id: fbb392d5347ebc45c06187f72dfd8bab02595dbf@467262 13f79535-47bb-0310-9956-ffa450edef68

--- modules/core/receivers/msg_recv.c
+++ modules/core/receivers/msg_recv.c
@@ -475,7 +475,8 @@
     AXIS2_ENGINE_FREE(engine, env);
     /* test code: uncomment this when test is over */
     axis2_core_utils_reset_out_msg_ctx(env, out_msg_ctx);
-    AXIS2_MSG_CTX_FREE(out_msg_ctx, env);
+    if (!AXIS2_MSG_CTX_IS_PAUSED(out_msg_ctx, env))
+        AXIS2_MSG_CTX_FREE(out_msg_ctx, env);
     /*end test code */
     return status;
 }


Fixed wrong log level/tool

Fixed wrong log level/tool

--- modules/ffmpeg_in/ffmpeg_decode.c
+++ modules/ffmpeg_in/ffmpeg_decode.c
@@ -362,9 +362,9 @@
 			nb_threads = atoi(sOpt);
 		}
 		if (nb_threads > detected_nb_threads) {
-			GF_LOG(GF_LOG_CODEC, GF_LOG_WARNING, ("[HEVC@ffmpeg] Initializing with %d threads but only %d available cores detected on the system\n", nb_threads, rti.nb_cores));
+			GF_LOG(GF_LOG_WARNING, GF_LOG_CODEC, ("[HEVC@ffmpeg] Initializing with %d threads but only %d available cores detected on the system\n", nb_threads, rti.nb_cores));
 		} else {
-			GF_LOG(GF_LOG_CODEC, GF_LOG_INFO, ("[HEVC@ffmpeg] Initializing with %d threads\n", nb_threads));
+			GF_LOG(GF_LOG_INFO, GF_LOG_CODEC, ("[HEVC@ffmpeg] Initializing with %d threads\n", nb_threads));
 		}
 		fprintf(stderr, "[HEVC@ffmpeg] Initializing with %d threads\n", nb_threads);
 		av_opt_set_int(*ctx, "threads", nb_threads, 0);


comment out noisy logging

comment out noisy logging

--- dlm-kernel/src2/lock.c
+++ dlm-kernel/src2/lock.c
@@ -2088,8 +2088,8 @@
 {
 	struct dlm_header *hd = (struct dlm_header *) ms;

-	log_print("send %d lkid %x remlkid %x", ms->m_type,
-		  ms->m_lkid, ms->m_remlkid);
+	/* log_print("send %d lkid %x remlkid %x", ms->m_type,
+		  ms->m_lkid, ms->m_remlkid); */

 	/* FIXME: do byte swapping here */
 	hd->h_length = cpu_to_le16(hd->h_length);
@@ -2170,7 +2170,6 @@

 int send_unlock(struct dlm_rsb *r, struct dlm_lkb *lkb)
 {
-	log_print("send_unlock %x %s", lkb->lkb_id, r->res_name);
 	return send_common(r, lkb, DLM_MSG_UNLOCK);
 }

@@ -3003,8 +3002,8 @@
 		schedule();
 	}

-	log_print("recv %d lkid %x remlkid %x result %d", ms->m_type,
-		  ms->m_lkid, ms->m_remlkid, ms->m_result);
+	/* log_print("recv %d lkid %x remlkid %x result %d", ms->m_type,
+		  ms->m_lkid, ms->m_remlkid, ms->m_result); */

 	switch (ms->m_type) {


added rubix for fast mode

added rubix for fast mode

--- NQ/lens.c
+++ NQ/lens.c
@@ -1260,15 +1260,8 @@
 // Lens Map Creation
 // ----------------------------------------

-// set a pixel on the lensmap from cubemap coordinate
-inline void set_lensmap_from_cubemap(int lx, int ly, int cx, int cy, int side)
-{
-   // increase the number of times this side is used
-   ++side_count[side];
-
-   // map the lens pixel to this cubeface pixel
-   *LENSMAP(lx,ly) = CUBEFACE(side,cx,cy);
-
+void set_lensmap_grid(int lx, int ly, int cx, int cy, int side)
+{
    // designate the palette for this pixel
    // This will set the palette index map such that a grid is shown
    int numdivs = colorcells*colorwfrac+1;
@@ -1284,6 +1277,18 @@
       *PALIMAP(lx,ly) = side;
 }

+// set a pixel on the lensmap from cubemap coordinate
+inline void set_lensmap_from_cubemap(int lx, int ly, int cx, int cy, int side)
+{
+   // increase the number of times this side is used
+   ++side_count[side];
+
+   // map the lens pixel to this cubeface pixel
+   *LENSMAP(lx,ly) = CUBEFACE(side,cx,cy);
+
+   set_lensmap_grid(lx,ly,cx,cy,side);
+}
+
 // set the (lx,ly) pixel on the lensmap to the (sx,sy,sz) view vector
 void set_lensmap_from_ray(int lx, int ly, double sx, double sy, double sz)
 {
@@ -1293,6 +1298,7 @@
       int side,fx,fy;
       if (ray_to_fastmap(ray, &side, &fx, &fy)) {
          *LENSMAP(lx,ly) = CUBEFACE(side,fx,fy);
+         set_lensmap_grid(lx,ly,fx,fy,side);
       }
       else {
          *LENSMAP(lx,ly) = 0;


added sortBy, groupBy to Prelude

added sortBy, groupBy to Prelude

--- Prelude.h
+++ Prelude.h
@@ -131,6 +131,17 @@
     {
         R ret(range.begin(),range.end());
         std::sort(ret.begin(), ret.end());
+        return ret;
+    }
+
+    /*
+     * The sort function implements a sorting algorithm. It is not guaranteed to be stable.
+     */
+    template<typename F,typename R>
+    R sortBy(F &&lessthan, const R &range)
+    {
+        R ret(range.begin(),range.end());
+        std::sort(ret.begin(), ret.end(),lessthan);
         return ret;
     }

@@ -350,6 +361,44 @@
     std::vector<R> groupR(const R &range)
     {
         return groupByR([](const T &lhs, const T &rhs){return lhs == rhs;}, range);
+    }
+
+    /**
+    * The group function takes a range and returns a vector of ranges such that the concatenation of the
+    * result is equal to the argument. Moreover, each sublist in the result contains only equal (by f) elements.
+    */
+    template<typename F,typename R>
+    std::vector<R> groupBy(F &&eq, const R &range)
+    {
+        R current;
+        std::vector<R> ret;
+        for (auto &elem : range) {
+            if (current.empty()) {
+                current.push_back(elem);
+            } else {
+                if (eq(head(current), elem)) {
+                    current.push_back(elem);
+                } else {
+                    ret.push_back(current);
+                    R newCurrent;
+                    newCurrent.push_back(elem);
+                    current = newCurrent;
+                }
+            }
+        }
+        if (!current.empty()) {
+            ret.push_back(current);
+        }
+        return ret;
+    }
+
+    /**
+      * group by the the default comparison operator
+      */
+    template<typename R,typename T = typename R::value_type>
+    std::vector<R> group(const R &range)
+    {
+        return groupBy([](const T &lhs, const T &rhs){return lhs == rhs;}, range);
     }

     /*


clk: ti: LLVMLinux: Move __init outside of type definition

As written, the __init for ti_clk_get_div_table is in the middle of the return
type.

The gcc documentation indicates that section attributes should be added to the
end of the function declaration:

  extern void foobar (void) __attribute__ ((section ("bar")));

However gcc seems to be very permissive with where attributes can be placed.
clang on the other hand isn't so permissive, and fails if you put the section
definition in the middle of the return type:

drivers/clk/ti/divider.c:298:28: error: expected ';' after struct
static struct clk_div_table
                           ^
                           ;
drivers/clk/ti/divider.c:298:1: warning: 'static' ignored on this
      declaration [-Wmissing-declarations]
static struct clk_div_table
^
drivers/clk/ti/divider.c:299:9: error: type specifier missing,
      defaults to 'int' [-Werror,-Wimplicit-int]
__init *ti_clk_get_div_table(struct device_node *node)
~~~~~~  ^
drivers/clk/ti/divider.c:345:9: warning: incompatible pointer types
      returning 'struct clk_div_table *' from a function with result type 'int *' [-Wincompatible-pointer-types]
        return table;
               ^~~~~
drivers/clk/ti/divider.c:419:9: warning: incompatible pointer types
      assigning to 'const struct clk_div_table *' from 'int *' [-Wincompatible-pointer-types]
        *table = ti_clk_get_div_table(node);
               ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~
3 warnings and 2 errors generated.

By convention, most of the kernel code puts section attributes between the
return type and function name. In the case where the return type is a pointer,
it's important to place the '*' on left of the __init.

This updated code works for both gcc and clang.

Signed-off-by: Behan Webster <9152da451d71c2a1ceb0c7b0908d4018fc127ae6@converseincode.com>
Reviewed-by: Mark Charlebois <f1891e7fc976ae1bd489627e2954fb730751d728@gmail.com>
Reviewed-by: Felipe Balbi <94dddeeef08b001e003cce128ddc162a4e2c6cd2@ti.com>
Signed-off-by: Tero Kristo <060a12f1fbc7e2e5d830b72f402ff04fdae8d312@ti.com>

--- drivers/clk/ti/divider.c
+++ drivers/clk/ti/divider.c
@@ -295,8 +295,8 @@
 	return clk;
 }

-static struct clk_div_table
-__init *ti_clk_get_div_table(struct device_node *node)
+static struct clk_div_table *
+__init ti_clk_get_div_table(struct device_node *node)
 {
 	struct clk_div_table *table;
 	const __be32 *divspec;


ARM: PL08x: don't manipulate txd->srcbus or txd->dstbus during LLI fill

Don't alter any txd->srcbus or txd->dstbus values while building the
LLI list.  This allows us to see the original dma_addr_t values passed
in via the prep_memcpy() method.

Signed-off-by: Russell King <f6aa0246ff943bfa8602cdf60d40c481b38ed232@arm.linux.org.uk>
Acked-by: Linus Walleij <9cd9d802d23c0ed5e224beabf4ae4a5c478746ef@stericsson.com>
Signed-off-by: Dan Williams <24ee2bf0bd8ac766c348bf1f0639943bac1535c6@intel.com>

--- drivers/dma/amba-pl08x.c
+++ drivers/dma/amba-pl08x.c
@@ -481,38 +481,45 @@
 	return retbits;
 }

+struct pl08x_lli_build_data {
+	struct pl08x_txd *txd;
+	struct pl08x_driver_data *pl08x;
+	struct pl08x_bus_data srcbus;
+	struct pl08x_bus_data dstbus;
+	size_t remainder;
+};
+
 /*
  * Autoselect a master bus to use for the transfer
  * this prefers the destination bus if both available
  * if fixed address on one bus the other will be chosen
  */
-static void pl08x_choose_master_bus(struct pl08x_bus_data *src_bus,
-	struct pl08x_bus_data *dst_bus, struct pl08x_bus_data **mbus,
-	struct pl08x_bus_data **sbus, u32 cctl)
+static void pl08x_choose_master_bus(struct pl08x_lli_build_data *bd,
+	struct pl08x_bus_data **mbus, struct pl08x_bus_data **sbus, u32 cctl)
 {
 	if (!(cctl & PL080_CONTROL_DST_INCR)) {
-		*mbus = src_bus;
-		*sbus = dst_bus;
+		*mbus = &bd->srcbus;
+		*sbus = &bd->dstbus;
 	} else if (!(cctl & PL080_CONTROL_SRC_INCR)) {
-		*mbus = dst_bus;
-		*sbus = src_bus;
+		*mbus = &bd->dstbus;
+		*sbus = &bd->srcbus;
 	} else {
-		if (dst_bus->buswidth == 4) {
-			*mbus = dst_bus;
-			*sbus = src_bus;
-		} else if (src_bus->buswidth == 4) {
-			*mbus = src_bus;
-			*sbus = dst_bus;
-		} else if (dst_bus->buswidth == 2) {
-			*mbus = dst_bus;
-			*sbus = src_bus;
-		} else if (src_bus->buswidth == 2) {
-			*mbus = src_bus;
-			*sbus = dst_bus;
+		if (bd->dstbus.buswidth == 4) {
+			*mbus = &bd->dstbus;
+			*sbus = &bd->srcbus;
+		} else if (bd->srcbus.buswidth == 4) {
+			*mbus = &bd->srcbus;
+			*sbus = &bd->dstbus;
+		} else if (bd->dstbus.buswidth == 2) {
+			*mbus = &bd->dstbus;
+			*sbus = &bd->srcbus;
+		} else if (bd->srcbus.buswidth == 2) {
+			*mbus = &bd->srcbus;
+			*sbus = &bd->dstbus;
 		} else {
-			/* src_bus->buswidth == 1 */
-			*mbus = dst_bus;
-			*sbus = src_bus;
+			/* bd->srcbus.buswidth == 1 */
+			*mbus = &bd->dstbus;
+			*sbus = &bd->srcbus;
 		}
 	}
 }
@@ -521,29 +528,29 @@
  * Fills in one LLI for a certain transfer descriptor
  * and advance the counter
  */
-static void pl08x_fill_lli_for_desc(struct pl08x_driver_data *pl08x,
-	struct pl08x_txd *txd, int num_llis, int len, u32 cctl, u32 *remainder)
-{
-	struct pl08x_lli *llis_va = txd->llis_va;
-	dma_addr_t llis_bus = txd->llis_bus;
+static void pl08x_fill_lli_for_desc(struct pl08x_lli_build_data *bd,
+	int num_llis, int len, u32 cctl)
+{
+	struct pl08x_lli *llis_va = bd->txd->llis_va;
+	dma_addr_t llis_bus = bd->txd->llis_bus;

 	BUG_ON(num_llis >= MAX_NUM_TSFR_LLIS);

 	llis_va[num_llis].cctl = cctl;
-	llis_va[num_llis].src = txd->srcbus.addr;
-	llis_va[num_llis].dst = txd->dstbus.addr;
+	llis_va[num_llis].src = bd->srcbus.addr;
+	llis_va[num_llis].dst = bd->dstbus.addr;
 	llis_va[num_llis].lli = llis_bus + (num_llis + 1) * sizeof(struct pl08x_lli);
-	if (pl08x->lli_buses & PL08X_AHB2)
+	if (bd->pl08x->lli_buses & PL08X_AHB2)
 		llis_va[num_llis].lli |= PL080_LLI_LM_AHB2;

 	if (cctl & PL080_CONTROL_SRC_INCR)
-		txd->srcbus.addr += len;
+		bd->srcbus.addr += len;
 	if (cctl & PL080_CONTROL_DST_INCR)
-		txd->dstbus.addr += len;
-
-	BUG_ON(*remainder < len);
-
-	*remainder -= len;
+		bd->dstbus.addr += len;
+
+	BUG_ON(bd->remainder < len);
+
+	bd->remainder -= len;
 }

 /*
@@ -567,7 +574,7 @@
 			      struct pl08x_txd *txd)
 {
 	struct pl08x_bus_data *mbus, *sbus;
-	size_t remainder;
+	struct pl08x_lli_build_data bd;
 	int num_llis = 0;
 	u32 cctl;
 	size_t max_bytes_per_lli;
@@ -586,38 +593,43 @@
 	/* Get the default CCTL */
 	cctl = txd->cctl;

+	bd.txd = txd;
+	bd.pl08x = pl08x;
+	bd.srcbus.addr = txd->srcbus.addr;
+	bd.dstbus.addr = txd->dstbus.addr;
+
 	/* Find maximum width of the source bus */
-	txd->srcbus.maxwidth =
+	bd.srcbus.maxwidth =
 		pl08x_get_bytes_for_cctl((cctl & PL080_CONTROL_SWIDTH_MASK) >>
 				       PL080_CONTROL_SWIDTH_SHIFT);

 	/* Find maximum width of the destination bus */
-	txd->dstbus.maxwidth =
+	bd.dstbus.maxwidth =
 		pl08x_get_bytes_for_cctl((cctl & PL080_CONTROL_DWIDTH_MASK) >>
 				       PL080_CONTROL_DWIDTH_SHIFT);

 	/* Set up the bus widths to the maximum */
-	txd->srcbus.buswidth = txd->srcbus.maxwidth;
-	txd->dstbus.buswidth = txd->dstbus.maxwidth;
+	bd.srcbus.buswidth = bd.srcbus.maxwidth;
+	bd.dstbus.buswidth = bd.dstbus.maxwidth;
 	dev_vdbg(&pl08x->adev->dev,
 		 "%s source bus is %d bytes wide, dest bus is %d bytes wide\n",
-		 __func__, txd->srcbus.buswidth, txd->dstbus.buswidth);
+		 __func__, bd.srcbus.buswidth, bd.dstbus.buswidth);

 	/*
 	 * Bytes transferred == tsize * MIN(buswidths), not max(buswidths)
 	 */
-	max_bytes_per_lli = min(txd->srcbus.buswidth, txd->dstbus.buswidth) *
+	max_bytes_per_lli = min(bd.srcbus.buswidth, bd.dstbus.buswidth) *
 		PL080_CONTROL_TRANSFER_SIZE_MASK;
 	dev_vdbg(&pl08x->adev->dev,
 		 "%s max bytes per lli = %zu\n",
 		 __func__, max_bytes_per_lli);

 	/* We need to count this down to zero */
-	remainder = txd->len;
+	bd.remainder = txd->len;
 	dev_vdbg(&pl08x->adev->dev,
 		 "%s remainder = %zu\n",
-		 __func__, remainder);
+		 __func__, bd.remainder);

 	/*
 	 * Choose bus to align to
@@ -625,22 +637,20 @@
 	 * - if fixed address on one bus chooses other
 	 * - modifies cctl to choose an appropriate master
 	 */
-	pl08x_choose_master_bus(&txd->srcbus, &txd->dstbus,
-				&mbus, &sbus, cctl);
+	pl08x_choose_master_bus(&bd, &mbus, &sbus, cctl);

 	if (txd->len < mbus->buswidth) {
 		/*
 		 * Less than a bus width available
 		 * - send as single bytes
 		 */
-		while (remainder) {
+		while (bd.remainder) {
 			dev_vdbg(&pl08x->adev->dev,
 				 "%s single byte LLIs for a transfer of "
 				 "less than a bus width (remain 0x%08x)\n",
-				 __func__, remainder);
+				 __func__, bd.remainder);
 			cctl = pl08x_cctl_bits(cctl, 1, 1, 1);
-			pl08x_fill_lli_for_desc(pl08x, txd, num_llis++, 1,
-					cctl, &remainder);
+			pl08x_fill_lli_for_desc(&bd, num_llis++, 1, cctl);
 			total_bytes++;
 		}
 	} else {
@@ -652,10 +662,9 @@
 			dev_vdbg(&pl08x->adev->dev,
 				"%s adjustment lli for less than bus width "
 				 "(remain 0x%08x)\n",
-				 __func__, remainder);
+				 __func__, bd.remainder);
 			cctl = pl08x_cctl_bits(cctl, 1, 1, 1);
-			pl08x_fill_lli_for_desc(pl08x, txd, num_llis++, 1,
-					cctl, &remainder);
+			pl08x_fill_lli_for_desc(&bd, num_llis++, 1, cctl);
 			total_bytes++;
 		}

@@ -675,14 +684,14 @@
 		 * Make largest possible LLIs until less than one bus
 		 * width left
 		 */
-		while (remainder > (mbus->buswidth - 1)) {
+		while (bd.remainder > (mbus->buswidth - 1)) {
 			size_t lli_len, target_len, tsize, odd_bytes;

 			/*
 			 * If enough left try to send max possible,
 			 * otherwise try to send the remainder
 			 */
-			target_len = min(remainder, max_bytes_per_lli);
+			target_len = min(bd.remainder, max_bytes_per_lli);

 			/*
 			 * Set bus lengths for incrementing buses to the
@@ -690,24 +699,24 @@
 			 * limiting on the target length calculated above.
 			 */
 			if (cctl & PL080_CONTROL_SRC_INCR)
-				txd->srcbus.fill_bytes =
-					pl08x_pre_boundary(txd->srcbus.addr,
+				bd.srcbus.fill_bytes =
+					pl08x_pre_boundary(bd.srcbus.addr,
 						target_len);
 			else
-				txd->srcbus.fill_bytes = target_len;
+				bd.srcbus.fill_bytes = target_len;

 			if (cctl & PL080_CONTROL_DST_INCR)
-				txd->dstbus.fill_bytes =
-					pl08x_pre_boundary(txd->dstbus.addr,
+				bd.dstbus.fill_bytes =
+					pl08x_pre_boundary(bd.dstbus.addr,
 						target_len);
 			else
-				txd->dstbus.fill_bytes = target_len;
+				bd.dstbus.fill_bytes = target_len;

 			/* Find the nearest */
-			lli_len	= min(txd->srcbus.fill_bytes,
-				txd->dstbus.fill_bytes);
-
-			BUG_ON(lli_len > remainder);
+			lli_len	= min(bd.srcbus.fill_bytes,
+				      bd.dstbus.fill_bytes);
+
+			BUG_ON(lli_len > bd.remainder);

 			if (lli_len <= 0) {
 				dev_err(&pl08x->adev->dev,
@@ -764,15 +773,15 @@
 				}

 				cctl = pl08x_cctl_bits(cctl,
-						       txd->srcbus.buswidth,
-						       txd->dstbus.buswidth,
+						       bd.srcbus.buswidth,
+						       bd.dstbus.buswidth,
 						       tsize);

 				dev_vdbg(&pl08x->adev->dev,
 					"%s fill lli with single lli chunk of size 0x%08zx (remainder 0x%08zx)\n",
-					__func__, lli_len, remainder);
-				pl08x_fill_lli_for_desc(pl08x, txd, num_llis++,
-						lli_len, cctl, &remainder);
+					__func__, lli_len, bd.remainder);
+				pl08x_fill_lli_for_desc(&bd, num_llis++,
+					lli_len, cctl);
 				total_bytes += lli_len;
 			}

@@ -784,14 +793,13 @@
 				 */
 				int j;
 				for (j = 0; (j < mbus->buswidth)
-						&& (remainder); j++) {
+						&& (bd.remainder); j++) {
 					cctl = pl08x_cctl_bits(cctl, 1, 1, 1);
 					dev_vdbg(&pl08x->adev->dev,
 						"%s align with boundary, single byte (remain 0x%08zx)\n",
-						__func__, remainder);
-					pl08x_fill_lli_for_desc(pl08x, txd,
-							num_llis++, 1, cctl,
-							&remainder);
+						__func__, bd.remainder);
+					pl08x_fill_lli_for_desc(&bd,
+						num_llis++, 1, cctl);
 					total_bytes++;
 				}
 			}
@@ -800,13 +808,12 @@
 		/*
 		 * Send any odd bytes
 		 */
-		while (remainder) {
+		while (bd.remainder) {
 			cctl = pl08x_cctl_bits(cctl, 1, 1, 1);
 			dev_vdbg(&pl08x->adev->dev,
 				"%s align with boundary, single odd byte (remain %zu)\n",
-				__func__, remainder);
-			pl08x_fill_lli_for_desc(pl08x, txd, num_llis++, 1,
-					cctl, &remainder);
+				__func__, bd.remainder);
+			pl08x_fill_lli_for_desc(&bd, num_llis++, 1, cctl);
 			total_bytes++;
 		}
 	}


driver: eSPI: npcx: select the host interface to eSPI explicitly

Set the host interface type to eSPI if it is not configured by the
booter.

Signed-off-by: Jun Lin <4865d89268068846db8afe2dcacc793288c792a0@nuvoton.com>

--- drivers/espi/espi_npcx.c
+++ drivers/espi/espi_npcx.c
@@ -856,6 +856,11 @@
 	const struct device *const clk_dev = DEVICE_DT_GET(NPCX_CLK_CTRL_NODE);
 	int i, ret;

+	/* If booter doesn't set the host interface type */
+	if (!NPCX_BOOTER_IS_HIF_TYPE_SET()) {
+		npcx_host_interface_sel(NPCX_HIF_TYPE_ESPI_SHI);
+	}
+
 	/* Turn on eSPI device clock first */
 	ret = clock_control_on(clk_dev, (clock_control_subsys_t *)
 							&config->clk_cfg);


hwmon: (coretemp) Add missing section annotations

Many functions in the coretemp driver lack a proper section
annotation. Add them to let the kernel free the memory after
initialization when possible.

Signed-off-by: Jean Delvare <49ad6a9f5aa17024c23048df346d55bda6837e01@linux-fr.org>
Cc: Durgadoss R <673e0e5f8c3c626a7af9597f488cfee48e05bd21@intel.com>
Acked-by: Guenter Roeck <32ce62c5480002985aec58d7044038218061ef55@ericsson.com>
Cc: Fenghua Yu <94fe9a7ec8ff966c1952fe98e39b5ae3a7477695@intel.com>

--- drivers/hwmon/coretemp.c
+++ drivers/hwmon/coretemp.c
@@ -190,7 +190,8 @@
 	return tdata->valid ? sprintf(buf, "%d\n", tdata->temp) : -EAGAIN;
 }

-static int adjust_tjmax(struct cpuinfo_x86 *c, u32 id, struct device *dev)
+static int __cpuinit adjust_tjmax(struct cpuinfo_x86 *c, u32 id,
+				  struct device *dev)
 {
 	/* The 100C is default for both mobile and non mobile CPUs */

@@ -284,7 +285,8 @@
 	return tjmax;
 }

-static int get_tjmax(struct cpuinfo_x86 *c, u32 id, struct device *dev)
+static int __cpuinit get_tjmax(struct cpuinfo_x86 *c, u32 id,
+			       struct device *dev)
 {
 	int err;
 	u32 eax, edx;
@@ -323,7 +325,8 @@
 	return adjust_tjmax(c, id, dev);
 }

-static int create_name_attr(struct platform_data *pdata, struct device *dev)
+static int __devinit create_name_attr(struct platform_data *pdata,
+				      struct device *dev)
 {
 	sysfs_attr_init(&pdata->name_attr.attr);
 	pdata->name_attr.attr.name = "name";
@@ -332,8 +335,8 @@
 	return device_create_file(dev, &pdata->name_attr);
 }

-static int create_core_attrs(struct temp_data *tdata, struct device *dev,
-				int attr_no)
+static int __cpuinit create_core_attrs(struct temp_data *tdata,
+				       struct device *dev, int attr_no)
 {
 	int err, i;
 	static ssize_t (*const rd_ptr[TOTAL_ATTRS]) (struct device *dev,
@@ -383,7 +386,7 @@
 	return 0;
 }

-static struct platform_device *coretemp_get_pdev(unsigned int cpu)
+static struct platform_device __cpuinit *coretemp_get_pdev(unsigned int cpu)
 {
 	u16 phys_proc_id = TO_PHYS_ID(cpu);
 	struct pdev_entry *p;
@@ -400,7 +403,8 @@
 	return NULL;
 }

-static struct temp_data *init_temp_data(unsigned int cpu, int pkg_flag)
+static struct temp_data __cpuinit *init_temp_data(unsigned int cpu,
+						  int pkg_flag)
 {
 	struct temp_data *tdata;

@@ -418,7 +422,7 @@
 	return tdata;
 }

-static int create_core_data(struct platform_device *pdev,
+static int __cpuinit create_core_data(struct platform_device *pdev,
 				unsigned int cpu, int pkg_flag)
 {
 	struct temp_data *tdata;
@@ -489,7 +493,7 @@
 	return err;
 }

-static void coretemp_add_core(unsigned int cpu, int pkg_flag)
+static void __cpuinit coretemp_add_core(unsigned int cpu, int pkg_flag)
 {
 	struct platform_device *pdev = coretemp_get_pdev(cpu);
 	int err;
@@ -618,7 +622,7 @@
 	return err;
 }

-static void coretemp_device_remove(unsigned int cpu)
+static void __cpuinit coretemp_device_remove(unsigned int cpu)
 {
 	struct pdev_entry *p, *n;
 	u16 phys_proc_id = TO_PHYS_ID(cpu);
@@ -634,7 +638,7 @@
 	mutex_unlock(&pdev_list_mutex);
 }

-static bool is_any_core_online(struct platform_data *pdata)
+static bool __cpuinit is_any_core_online(struct platform_data *pdata)
 {
 	int i;


drivers: i2c_sifive: fix deprecation warnings

The init macro used outdated spellings for the instance-specific
properties, resulting in build warnings when I2C was enabled.

Signed-off-by: Peter A. Bigot <650538893330be855f76604594b4820eb226769e@pabigot.com>

--- drivers/i2c/i2c_sifive.c
+++ drivers/i2c/i2c_sifive.c
@@ -332,12 +332,12 @@

 #define I2C_SIFIVE_INIT(n) \
 	static struct i2c_sifive_cfg i2c_sifive_cfg_##n = { \
-		.base = DT_SIFIVE_I2C0_##n##_BASE_ADDRESS, \
-		.f_sys = DT_SIFIVE_I2C0_##n##_INPUT_FREQUENCY, \
-		.f_bus = DT_SIFIVE_I2C0_##n##_CLOCK_FREQUENCY, \
+		.base = DT_INST_##n##_SIFIVE_I2C0_BASE_ADDRESS, \
+		.f_sys = DT_INST_##n##_SIFIVE_I2C0_INPUT_FREQUENCY, \
+		.f_bus = DT_INST_##n##_SIFIVE_I2C0_CLOCK_FREQUENCY, \
 	}; \
 	DEVICE_AND_API_INIT(i2c_##n, \
-			    DT_SIFIVE_I2C0_##n##_LABEL, \
+			    DT_INST_##n##_SIFIVE_I2C0_LABEL, \
 			    i2c_sifive_init, \
 			    NULL, \
 			    &i2c_sifive_cfg_##n, \
@@ -345,7 +345,6 @@
 			    CONFIG_I2C_INIT_PRIORITY, \
 			    &i2c_sifive_api)

-#ifdef DT_INST_0_SIFIVE_I2C0_LABEL
+#ifdef DT_INST_0_SIFIVE_I2C0
 I2C_SIFIVE_INIT(0);
 #endif
-


iio: dac: ad5446: Don't set error code to voltage_uv

regulator_get_voltage() may return negative error code.
Add error checking to avoid setting error code to voltage_uv.

Signed-off-by: Axel Lin <b6ffd6973e972cb999e8e535ab74da7fee0c035f@ingics.com>
Signed-off-by: Jonathan Cameron <09f65b71b7655725897b2fd41a09a0cefe2e1ace@kernel.org>

--- drivers/iio/dac/ad5446.c
+++ drivers/iio/dac/ad5446.c
@@ -226,7 +226,11 @@
 		if (ret)
 			goto error_put_reg;

-		voltage_uv = regulator_get_voltage(reg);
+		ret = regulator_get_voltage(reg);
+		if (ret < 0)
+			goto error_disable_reg;
+
+		voltage_uv = ret;
 	}

 	indio_dev = iio_device_alloc(sizeof(*st));


Input: mousedev - do not wake up readers when receiving 0-motion
       event.

Signed-off-by: Dmitry Torokhov <10a8c465cefc9bdd6c925e26964d23c90f1141cc@mail.ru>

--- drivers/input/mousedev.c
+++ drivers/input/mousedev.c
@@ -220,6 +220,7 @@
 	struct mousedev_list *list;
 	struct mousedev_motion *p;
 	unsigned long flags;
+	int wake_readers = 0;

 	list_for_each_entry(list, &mousedev->list, node) {
 		spin_lock_irqsave(&list->packet_lock, flags);
@@ -255,11 +256,14 @@

 		spin_unlock_irqrestore(&list->packet_lock, flags);

-		if (list->ready)
+		if (list->ready) {
 			kill_fasync(&list->fasync, SIGIO, POLL_IN);
-	}
-
-	wake_up_interruptible(&mousedev->wait);
+			wake_readers = 1;
+		}
+	}
+
+	if (wake_readers)
+		wake_up_interruptible(&mousedev->wait);
 }

 static void mousedev_touchpad_touch(struct mousedev *mousedev, int value)


mmc: sdhci: implement the .card_event() method

Extracting a part of the SDHCI card tasklet into a .card_event()
implementation allows SDHCI hosts to use generic card-detection
services, e.g. the GPIO slot function.

Signed-off-by: Guennadi Liakhovetski <50875182aae23d69ca7738697596f18a14e926fc@gmx.de>
Reviewed-by: Shawn Guo <912cf7eb7d8018e2943586ae6657d21fd4e38239@linaro.org>
Signed-off-by: Chris Ball <6ca7faee6ca9a094b1ee341f11b840a5608a8746@laptop.org>

--- drivers/mmc/host/sdhci.c
+++ drivers/mmc/host/sdhci.c
@@ -1994,6 +1994,31 @@
 	sdhci_runtime_pm_put(host);
 }

+static void sdhci_card_event(struct mmc_host *mmc)
+{
+	struct sdhci_host *host = mmc_priv(mmc);
+	unsigned long flags;
+
+	spin_lock_irqsave(&host->lock, flags);
+
+	/* Check host->mrq first in case we are runtime suspended */
+	if (host->mrq &&
+	    !(sdhci_readl(host, SDHCI_PRESENT_STATE) & SDHCI_CARD_PRESENT)) {
+		pr_err("%s: Card removed during transfer!\n",
+			mmc_hostname(host->mmc));
+		pr_err("%s: Resetting controller.\n",
+			mmc_hostname(host->mmc));
+
+		sdhci_reset(host, SDHCI_RESET_CMD);
+		sdhci_reset(host, SDHCI_RESET_DATA);
+
+		host->mrq->cmd->error = -ENOMEDIUM;
+		tasklet_schedule(&host->finish_tasklet);
+	}
+
+	spin_unlock_irqrestore(&host->lock, flags);
+}
+
 static const struct mmc_host_ops sdhci_ops = {
 	.request	= sdhci_request,
 	.set_ios	= sdhci_set_ios,
@@ -2003,6 +2028,7 @@
 	.start_signal_voltage_switch	= sdhci_start_signal_voltage_switch,
 	.execute_tuning			= sdhci_execute_tuning,
 	.enable_preset_value		= sdhci_enable_preset_value,
+	.card_event			= sdhci_card_event,
 };

 /*****************************************************************************\
@@ -2013,29 +2039,9 @@

 static void sdhci_tasklet_card(unsigned long param)
 {
-	struct sdhci_host *host;
-	unsigned long flags;
-
-	host = (struct sdhci_host*)param;
-
-	spin_lock_irqsave(&host->lock, flags);
-
-	/* Check host->mrq first in case we are runtime suspended */
-	if (host->mrq &&
-	    !(sdhci_readl(host, SDHCI_PRESENT_STATE) & SDHCI_CARD_PRESENT)) {
-		pr_err("%s: Card removed during transfer!\n",
-			mmc_hostname(host->mmc));
-		pr_err("%s: Resetting controller.\n",
-			mmc_hostname(host->mmc));
-
-		sdhci_reset(host, SDHCI_RESET_CMD);
-		sdhci_reset(host, SDHCI_RESET_DATA);
-
-		host->mrq->cmd->error = -ENOMEDIUM;
-		tasklet_schedule(&host->finish_tasklet);
-	}
-
-	spin_unlock_irqrestore(&host->lock, flags);
+	struct sdhci_host *host = (struct sdhci_host*)param;
+
+	sdhci_card_event(host->mmc);

 	mmc_detect_change(host->mmc, msecs_to_jiffies(200));
 }


UBI: Update comments to reflect UBI_METAONLY flag

This patch trivially updates code comments to reflect the addition of the
UBI_METAONLY flag - as discussed https://lkml.org/lkml/2014/10/29/764

Cc: Richard Weinberger <320bca71fc381a4a025636043ca86e734e31cf8b@nod.at>
Cc: f2fc8123700c95880a53d4a1576282f2ca68c4b0@kernel.org
Signed-off-by: Andrew Murray <40338b79d540ddaabc97c1a04fbf156d85f7b399@embedded-bits.co.uk>
Signed-off-by: Richard Weinberger <320bca71fc381a4a025636043ca86e734e31cf8b@nod.at>

--- drivers/mtd/ubi/gluebi.c
+++ drivers/mtd/ubi/gluebi.c
@@ -112,8 +112,8 @@
 		 * The MTD device is already referenced and this is just one
 		 * more reference. MTD allows many users to open the same
 		 * volume simultaneously and do not distinguish between
-		 * readers/writers/exclusive openers as UBI does. So we do not
-		 * open the UBI volume again - just increase the reference
+		 * readers/writers/exclusive/meta openers as UBI does. So we do
+		 * not open the UBI volume again - just increase the reference
 		 * counter and return.
 		 */
 		gluebi->refcnt += 1;


bnx2x: Set LED in loopback test

bnx2x: Set LED in loopback test

Signed-off-by: Eilon Greenstein <5ba67022bcc5f9ee9b9819ddc35fa83823aa47ee@broadcom.com>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>

--- drivers/net/bnx2x_link.c
+++ drivers/net/bnx2x_link.c
@@ -5494,6 +5494,11 @@
 		}
 		REG_WR(bp, NIG_REG_EGRESS_DRAIN0_MODE +
 			    params->port*4, 0);
+
+		bnx2x_set_led(bp, params->port, LED_MODE_OPER,
+			    vars->line_speed, params->hw_led_mode,
+			    params->chip_id);
+
 	} else
 	/* No loopback */
 	{


Fixed commit

Fixed commit

git-svn-id: 5a113f46df058f8047e288f4f3e948d899353d9a@50 410355f2-c4ea-45de-a5b5-301721f902b9

--- prs/src/prs_server.c
+++ prs/src/prs_server.c
@@ -235,16 +235,16 @@
      ATTACK_TIME,
      RELEASE_TIME,
      1,
-     OUTPUT_GAIN*30);
+     OUTPUT_GAIN*31);
   multiband_audio_compressor_add_band
     (f,
      300,
-     -40,
-     4,
-     ATTACK_TIME,
-     RELEASE_TIME,
-     1,
-     OUTPUT_GAIN*30);
+     -30,
+     3,
+     ATTACK_TIME,
+     RELEASE_TIME,
+     1,
+     OUTPUT_GAIN*10);
   multiband_audio_compressor_add_band
     (f,
      600,
@@ -253,7 +253,7 @@
      ATTACK_TIME,
      RELEASE_TIME,
      1,
-     OUTPUT_GAIN*10);
+     OUTPUT_GAIN*8);
   multiband_audio_compressor_add_band
     (f,
      6000,
@@ -271,7 +271,7 @@
      ATTACK_TIME,
      RELEASE_TIME,
      1,
-     OUTPUT_GAIN*6);
+     OUTPUT_GAIN*7);
   mixer_bus_add_filter (b, f);
   mixer_add_output (m, o);
   mixer_patch_bus (m, "air", "soundcard");


controllers realize

controllers realize

git-svn-id: bd6e61130530ab01186c33a20f55445ba6f1e843@57695 954022d7-b5bf-4e40-9824-e11837661b57

--- DesktopEditor/Word_Api/Editor_Api.h
+++ DesktopEditor/Word_Api/Editor_Api.h
@@ -1041,7 +1041,7 @@
 	class CAscMenuEventListener
 	{
 	public:
-		// alloc memory release!!!
+		// memory release!!!
 		virtual void OnEvent(CAscMenuEvent* pEvent)
 		{
 			if (NULL != pEvent)


tun2socks: fix possible crash due to the use of a wrong dead-variable

--- tun2socks/tun2socks.c
+++ tun2socks/tun2socks.c
@@ -1564,10 +1564,10 @@
             SYNC_DECL
             SYNC_FROMHERE
             client_socks_recv_initiate(client);
-            DEAD_ENTER(client->dead)
+            DEAD_ENTER(client->dead_client)
             SYNC_COMMIT
-            DEAD_LEAVE2(client->dead)
-            if (DEAD_KILLED) {
+            DEAD_LEAVE2(client->dead_client)
+            if (DEAD_KILLED == -1) {
                 return ERR_ABRT;
             }
         }


usbnet: rx_submit() should return an error code.

This patch makes rx_submit() return an error code, and makes some call sites
that care check the return value. This is important because it lets us properly
handle cases where the device isn't ready to handle URB submissions (e.g., when
it is autosuspended under some drivers); previously, we would attempt and fail
to submit URBs and reschedule ourselves to try and fail again. This patch is
against Linus's 2.6 repo commit 45d7f32c7a43cbb9592886d38190e379e2eb2226.

Signed-Off-By: Elizabeth Jones <1693f95ea06ee6d7b2276cb599c3f4f33a951d9c@google.com>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>

--- drivers/net/usb/usbnet.c
+++ drivers/net/usb/usbnet.c
@@ -316,7 +316,7 @@

 static void rx_complete (struct urb *urb);

-static void rx_submit (struct usbnet *dev, struct urb *urb, gfp_t flags)
+static int rx_submit (struct usbnet *dev, struct urb *urb, gfp_t flags)
 {
 	struct sk_buff		*skb;
 	struct skb_data		*entry;
@@ -328,7 +328,7 @@
 		netif_dbg(dev, rx_err, dev->net, "no rx skb\n");
 		usbnet_defer_kevent (dev, EVENT_RX_MEMORY);
 		usb_free_urb (urb);
-		return;
+		return -ENOMEM;
 	}
 	skb_reserve (skb, NET_IP_ALIGN);

@@ -358,6 +358,9 @@
 			netif_dbg(dev, ifdown, dev->net, "device gone\n");
 			netif_device_detach (dev->net);
 			break;
+		case -EHOSTUNREACH:
+			retval = -ENOLINK;
+			break;
 		default:
 			netif_dbg(dev, rx_err, dev->net,
 				  "rx submit, %d\n", retval);
@@ -375,6 +378,7 @@
 		dev_kfree_skb_any (skb);
 		usb_free_urb (urb);
 	}
+	return retval;
 }

@@ -913,6 +917,7 @@
 	/* tasklet could resubmit itself forever if memory is tight */
 	if (test_bit (EVENT_RX_MEMORY, &dev->flags)) {
 		struct urb	*urb = NULL;
+		int resched = 1;

 		if (netif_running (dev->net))
 			urb = usb_alloc_urb (0, GFP_KERNEL);
@@ -923,10 +928,12 @@
 			status = usb_autopm_get_interface(dev->intf);
 			if (status < 0)
 				goto fail_lowmem;
-			rx_submit (dev, urb, GFP_KERNEL);
+			if (rx_submit (dev, urb, GFP_KERNEL) == -ENOLINK)
+				resched = 0;
 			usb_autopm_put_interface(dev->intf);
 fail_lowmem:
-			tasklet_schedule (&dev->bh);
+			if (resched)
+				tasklet_schedule (&dev->bh);
 		}
 	}

@@ -1176,8 +1183,11 @@
 			// don't refill the queue all at once
 			for (i = 0; i < 10 && dev->rxq.qlen < qlen; i++) {
 				urb = usb_alloc_urb (0, GFP_ATOMIC);
-				if (urb != NULL)
-					rx_submit (dev, urb, GFP_ATOMIC);
+				if (urb != NULL) {
+					if (rx_submit (dev, urb, GFP_ATOMIC) ==
+					    -ENOLINK)
+						return;
+				}
 			}
 			if (temp != dev->rxq.qlen)
 				netif_dbg(dev, link, dev->net,


Relax CHECK line from r290906

Relax CHECK line from r290906

git-svn-id: ffe668792ed300d6c2daa1f6eba2e0aa28d7ec6c@290907 91177308-0d34-0410-b5e6-96231b3b80d8


tun2socks: simplify code, no functional change

--- tun2socks/tun2socks.c
+++ tun2socks/tun2socks.c
@@ -204,7 +204,7 @@
 static void client_logfunc (struct tcp_client *client);
 static void client_log (struct tcp_client *client, int level, const char *fmt, ...);
 static err_t listener_accept_func (void *arg, struct tcp_pcb *newpcb, err_t err);
-static void client_handle_freed_client (struct tcp_client *client, int was_abrt);
+static void client_handle_freed_client (struct tcp_client *client);
 static int client_free_client (struct tcp_client *client);
 static void client_abort_client (struct tcp_client *client);
 static void client_free_socks (struct tcp_client *client);
@@ -1130,15 +1130,14 @@
     return ERR_OK;
 }

-void client_handle_freed_client (struct tcp_client *client, int was_abrt)
+void client_handle_freed_client (struct tcp_client *client)
 {
     ASSERT(!client->client_closed)
-    ASSERT(was_abrt == 0 || was_abrt == 1)

     // pcb was taken care of by the caller

     // kill client dead var
-    DEAD_KILL_WITH(client->dead_client, (was_abrt ? -1 : 1));
+    DEAD_KILL_WITH(client->dead_client, -1);

     // set client closed
     client->client_closed = 1;
@@ -1171,7 +1170,7 @@
         tcp_abort(client->pcb);
     }

-    client_handle_freed_client(client, 1);
+    client_handle_freed_client(client);

     return 1;
 }
@@ -1188,7 +1187,7 @@
     // free pcb
     tcp_abort(client->pcb);

-    client_handle_freed_client(client, 1);
+    client_handle_freed_client(client);
 }

 void client_free_socks (struct tcp_client *client)
@@ -1280,7 +1279,7 @@
     client_log(client, BLOG_INFO, "client error (%d)", (int)err);

     // the pcb was taken care of by the caller
-    client_handle_freed_client(client, 1);
+    client_handle_freed_client(client);
 }

 err_t client_recv_func (void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t err)


virtio_net: Fix panic in virtnet_remove

virtio_net: Fix panic in virtnet_remove

Fix a panic in virtnet_remove. unregister_netdev has already
freed up the netdev (and virtnet_info) due to dev->destructor
being set, while virtnet_info is still required. Remove
virtnet_free altogether, and move the freeing of the per-cpu
statistics from virtnet_free to virtnet_remove.

Tested patch below.

Signed-off-by: Krishna Kumar <a758f1965fc476e21d55bc933f32c59cf6606720@in.ibm.com>
Acked-by: Michael S. Tsirkin <255103e50249e3d658441816e0597170ebfc16ef@redhat.com>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>

--- drivers/net/virtio_net.c
+++ drivers/net/virtio_net.c
@@ -705,14 +705,6 @@
 }
 #endif

-static void virtnet_free(struct net_device *dev)
-{
-	struct virtnet_info *vi = netdev_priv(dev);
-
-	free_percpu(vi->stats);
-	free_netdev(dev);
-}
-
 static int virtnet_open(struct net_device *dev)
 {
 	struct virtnet_info *vi = netdev_priv(dev);
@@ -959,7 +951,6 @@
 	/* Set up network device as normal. */
 	dev->netdev_ops = &virtnet_netdev;
 	dev->features = NETIF_F_HIGHDMA;
-	dev->destructor = virtnet_free;

 	SET_ETHTOOL_OPS(dev, &virtnet_ethtool_ops);
 	SET_NETDEV_DEV(dev, &vdev->dev);
@@ -1122,6 +1113,7 @@
 	while (vi->pages)
 		__free_pages(get_a_page(vi, GFP_KERNEL), 0);

+	free_percpu(vi->stats);
 	free_netdev(vi->dev);
 }


PCI PM: make the PM core more careful with drivers using the new PM framework

Currently, the PM core always attempts to manage devices with drivers
that use the new PM framework.  In particular, it attempts to disable
the devices (which is unnecessary), to save their state (which may be
undesirable if the driver has done that already) and to put them into
low power states (again, this may be undesirable if the driver has
already put the device into a low power state).  That need not be
the right thing to do, so make the core be more careful in this
respect.

Generally, there are the following categories of devices to consider:
* bridge devices without drivers
* non-bridge devices without drivers
* bridge devices with drivers
* non-bridge devices with drivers
and each of them should be handled differently.

For bridge devices without drivers the PCI PM core will save their
state on suspend and restore it (early) during resume, after putting
them into D0 if necessary.  It will not attempt to do anything else
to these devices.

For non-bridge devices without drivers the PCI PM core will disable
them and save their state on suspend.  During resume, it will put
them into D0, if necessary, restore their state (early) and reenable
them.

For bridge devices with drivers the PCI PM core will only save
their state on suspend if the driver hasn't done that already.
Still, the core will restore their state (early) during resume,
after putting them into D0, if necessary.

For non-bridge devices with drivers the PCI PM core will only save
their state on suspend if the driver hasn't done that already.  Also,
if the state of the device hasn't been saved by the driver, the core
will attempt to put the device into a low power state.  During
resume the core will restore the state of the device (early), after
putting it into D0, if necessary.

Signed-off-by: Rafael J. Wysocki <a11f87183a953ab11f50fbafff689c5a7fa3506c@sisk.pl>
Acked-by: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>
Signed-off-by: Jesse Barnes <bc7add126c2dbb8382bf1c28ac262b9363a32706@virtuousgeek.org>

--- drivers/pci/pci-driver.c
+++ drivers/pci/pci-driver.c
@@ -430,37 +430,20 @@
 	pci_fixup_device(pci_fixup_resume_early, pci_dev);
 }

-static int pci_pm_default_resume(struct pci_dev *pci_dev)
+static void pci_pm_default_resume(struct pci_dev *pci_dev)
 {
 	pci_fixup_device(pci_fixup_resume, pci_dev);

-	if (pci_is_bridge(pci_dev))
-		return 0;
-
-	pci_enable_wake(pci_dev, PCI_D0, false);
-	return pci_pm_reenable_device(pci_dev);
-}
-
-static void pci_pm_default_suspend_generic(struct pci_dev *pci_dev)
-{
-	/* If a non-bridge device is enabled at this point, disable it */
+	if (!pci_is_bridge(pci_dev))
+		pci_enable_wake(pci_dev, PCI_D0, false);
+}
+
+static void pci_pm_default_suspend(struct pci_dev *pci_dev)
+{
+	/* Disable non-bridge devices without PM support */
 	if (!pci_is_bridge(pci_dev))
 		pci_disable_enabled_device(pci_dev);
-	/*
-	 * Save state with interrupts enabled, because in principle the bus the
-	 * device is on may be put into a low power state after this code runs.
-	 */
 	pci_save_state(pci_dev);
-}
-
-static void pci_pm_default_suspend(struct pci_dev *pci_dev, bool prepare)
-{
-	pci_pm_default_suspend_generic(pci_dev);
-
-	if (prepare && !pci_is_bridge(pci_dev))
-		pci_prepare_to_sleep(pci_dev);
-
-	pci_fixup_device(pci_fixup_suspend, pci_dev);
 }

 static bool pci_has_legacy_pm_support(struct pci_dev *pci_dev)
@@ -506,20 +489,48 @@
 {
 	struct pci_dev *pci_dev = to_pci_dev(dev);
 	struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
-	int error = 0;

 	if (pci_has_legacy_pm_support(pci_dev))
 		return pci_legacy_suspend(dev, PMSG_SUSPEND);

-	if (pm && pm->suspend) {
+	if (!pm) {
+		pci_pm_default_suspend(pci_dev);
+		goto Fixup;
+	}
+
+	pci_dev->state_saved = false;
+
+	if (pm->suspend) {
+		pci_power_t prev = pci_dev->current_state;
+		int error;
+
 		error = pm->suspend(dev);
 		suspend_report_result(pm->suspend, error);
-	}
-
-	if (!error)
-		pci_pm_default_suspend(pci_dev, !!pm);
-
-	return error;
+		if (error)
+			return error;
+
+		if (pci_dev->state_saved)
+			goto Fixup;
+
+		if (pci_dev->current_state != PCI_D0
+		    && pci_dev->current_state != PCI_UNKNOWN) {
+			WARN_ONCE(pci_dev->current_state != prev,
+				"PCI PM: State of device not saved by %pF\n",
+				pm->suspend);
+			goto Fixup;
+		}
+	}
+
+	if (!pci_dev->state_saved) {
+		pci_save_state(pci_dev);
+		if (!pci_is_bridge(pci_dev))
+			pci_prepare_to_sleep(pci_dev);
+	}
+
+ Fixup:
+	pci_fixup_device(pci_fixup_suspend, pci_dev);
+
+	return 0;
 }

 static int pci_pm_suspend_noirq(struct device *dev)
@@ -562,7 +573,7 @@
 static int pci_pm_resume(struct device *dev)
 {
 	struct pci_dev *pci_dev = to_pci_dev(dev);
-	struct device_driver *drv = dev->driver;
+	struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
 	int error = 0;

 	/*
@@ -575,12 +586,16 @@
 	if (pci_has_legacy_pm_support(pci_dev))
 		return pci_legacy_resume(dev);

-	error = pci_pm_default_resume(pci_dev);
-
-	if (!error && drv && drv->pm && drv->pm->resume)
-		error = drv->pm->resume(dev);
-
-	return error;
+	pci_pm_default_resume(pci_dev);
+
+	if (pm) {
+		if (pm->resume)
+			error = pm->resume(dev);
+	} else {
+		pci_pm_reenable_device(pci_dev);
+	}
+
+	return 0;
 }

 #else /* !CONFIG_SUSPEND */
@@ -597,21 +612,31 @@
 static int pci_pm_freeze(struct device *dev)
 {
 	struct pci_dev *pci_dev = to_pci_dev(dev);
-	struct device_driver *drv = dev->driver;
-	int error = 0;
+	struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;

 	if (pci_has_legacy_pm_support(pci_dev))
 		return pci_legacy_suspend(dev, PMSG_FREEZE);

-	if (drv && drv->pm && drv->pm->freeze) {
-		error = drv->pm->freeze(dev);
-		suspend_report_result(drv->pm->freeze, error);
-	}
-
-	if (!error)
-		pci_pm_default_suspend_generic(pci_dev);
-
-	return error;
+	if (!pm) {
+		pci_pm_default_suspend(pci_dev);
+		return 0;
+	}
+
+	pci_dev->state_saved = false;
+
+	if (pm->freeze) {
+		int error;
+
+		error = pm->freeze(dev);
+		suspend_report_result(pm->freeze, error);
+		if (error)
+			return error;
+	}
+
+	if (!pci_dev->state_saved)
+		pci_save_state(pci_dev);
+
+	return 0;
 }

 static int pci_pm_freeze_noirq(struct device *dev)
@@ -654,16 +679,18 @@
 static int pci_pm_thaw(struct device *dev)
 {
 	struct pci_dev *pci_dev = to_pci_dev(dev);
-	struct device_driver *drv = dev->driver;
+	struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
 	int error = 0;

 	if (pci_has_legacy_pm_support(pci_dev))
 		return pci_legacy_resume(dev);

-	pci_pm_reenable_device(pci_dev);
-
-	if (drv && drv->pm && drv->pm->thaw)
-		error =  drv->pm->thaw(dev);
+	if (pm) {
+		if (pm->thaw)
+			error = pm->thaw(dev);
+	} else {
+		pci_pm_reenable_device(pci_dev);
+	}

 	return error;
 }
@@ -677,13 +704,23 @@
 	if (pci_has_legacy_pm_support(pci_dev))
 		return pci_legacy_suspend(dev, PMSG_HIBERNATE);

-	if (pm && pm->poweroff) {
+	if (!pm) {
+		pci_pm_default_suspend(pci_dev);
+		goto Fixup;
+	}
+
+	pci_dev->state_saved = false;
+
+	if (pm->poweroff) {
 		error = pm->poweroff(dev);
 		suspend_report_result(pm->poweroff, error);
 	}

-	if (!error)
-		pci_pm_default_suspend(pci_dev, !!pm);
+	if (!pci_dev->state_saved && !pci_is_bridge(pci_dev))
+		pci_prepare_to_sleep(pci_dev);
+
+ Fixup:
+	pci_fixup_device(pci_fixup_suspend, pci_dev);

 	return error;
 }
@@ -724,7 +761,7 @@
 static int pci_pm_restore(struct device *dev)
 {
 	struct pci_dev *pci_dev = to_pci_dev(dev);
-	struct device_driver *drv = dev->driver;
+	struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
 	int error = 0;

 	/*
@@ -737,10 +774,14 @@
 	if (pci_has_legacy_pm_support(pci_dev))
 		return pci_legacy_resume(dev);

-	error = pci_pm_default_resume(pci_dev);
-
-	if (!error && drv && drv->pm && drv->pm->restore)
-		error = drv->pm->restore(dev);
+	pci_pm_default_resume(pci_dev);
+
+	if (pm) {
+		if (pm->restore)
+			error = pm->restore(dev);
+	} else {
+		pci_pm_reenable_device(pci_dev);
+	}

 	return error;
 }


regulator: core: Use IS_ERR_OR_NULL()

regulator: core: Use IS_ERR_OR_NULL()

Use IS_ERR_OR_NULL() rather than open coding it.

Signed-off-by: Viresh Kumar <5ff32272b3d9f86512eddc8e0af523fc6f7924e5@linaro.org>
Signed-off-by: Mark Brown <b51b9a92386687a9ac927cebfa0f978adeb8cea5@kernel.org>

--- drivers/regulator/core.c
+++ drivers/regulator/core.c
@@ -1588,7 +1588,7 @@
 {
 	struct regulator_dev *rdev;

-	if (regulator == NULL || IS_ERR(regulator))
+	if (IS_ERR_OR_NULL(regulator))
 		return;

 	lockdep_assert_held_once(&regulator_list_mutex);