]> sigrok.org Git - libsigrokdecode.git/commitdiff
sdcard_spi: Use ternary operator where possible.
authorUwe Hermann <redacted>
Fri, 10 Jan 2020 19:41:57 +0000 (20:41 +0100)
committerUwe Hermann <redacted>
Fri, 10 Jan 2020 19:50:15 +0000 (20:50 +0100)
decoders/sdcard_spi/pd.py

index af896af59a5b5b5e5d52c1b0d42408b404e8bcd2..49cfdef1f8522c5bf6bd7c8f490fc3f25ff99d6a 100644 (file)
@@ -437,11 +437,9 @@ class Decoder(srd.Decoder):
         elif miso == 0x0d:
             self.put(m[3][1], m[1][2], self.out_ann, [Ann.BIT, ['Data rejected (write error)']])
         self.put(m[0][1], m[0][2], self.out_ann, [Ann.BIT, ['Always 1']])
-        ann_class = None
-        if self.is_cmd24:
-            ann_class = Ann.CMD24
-        if ann_class is not None:
-            self.put(self.ss, self.es, self.out_ann, [ann_class, ['Data Response']])
+        cls = Ann.CMD24 if self.is_cmd24 else None
+        if cls is not None:
+            self.put(self.ss, self.es, self.out_ann, [cls, ['Data Response']])
         if self.is_cmd24:
             # We just send a block of data to be written to the card,
             # this takes some time.
@@ -452,11 +450,9 @@ class Decoder(srd.Decoder):
 
     def wait_while_busy(self, miso):
         if miso != 0x00:
-            ann_class = None
-            if self.is_cmd24:
-                ann_class = Ann.CMD24
-            if ann_class is not None:
-                self.put(self.ss_busy, self.es_busy, self.out_ann, [Ann.CMD24, ['Card is busy']])
+            cls = Ann.CMD24 if self.is_cmd24 else None
+            if cls is not None:
+                self.put(self.ss_busy, self.es_busy, self.out_ann, [cls, ['Card is busy']])
             self.state = 'IDLE'
             return
         else: