]> rtime.felk.cvut.cz Git - linux-imx.git/commitdiff
firewire: move rcode_string() to core
authorClemens Ladisch <clemens@ladisch.de>
Wed, 11 Apr 2012 15:38:10 +0000 (17:38 +0200)
committerStefan Richter <stefanr@s5r6.in-berlin.de>
Tue, 17 Apr 2012 20:54:55 +0000 (22:54 +0200)
There is nothing audio-specific about the rcode_string() helper, so move
it from snd-firewire-lib into firewire-core to allow other code to use it.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de> (fixed sound/firewire/cmp.c)
drivers/firewire/core-transaction.c
include/linux/firewire.h
sound/firewire/cmp.c
sound/firewire/lib.c
sound/firewire/lib.h

index dea2dcc9310d3fc2324b7fa726c0a8590581a96f..1c4980c32f907b363ffd914f1866a3b3ef1ee4bf 100644 (file)
@@ -994,6 +994,32 @@ void fw_core_handle_response(struct fw_card *card, struct fw_packet *p)
 }
 EXPORT_SYMBOL(fw_core_handle_response);
 
+/**
+ * fw_rcode_string - convert a firewire result code to an error description
+ * @rcode: the result code
+ */
+const char *fw_rcode_string(int rcode)
+{
+       static const char *const names[] = {
+               [RCODE_COMPLETE]       = "no error",
+               [RCODE_CONFLICT_ERROR] = "conflict error",
+               [RCODE_DATA_ERROR]     = "data error",
+               [RCODE_TYPE_ERROR]     = "type error",
+               [RCODE_ADDRESS_ERROR]  = "address error",
+               [RCODE_SEND_ERROR]     = "send error",
+               [RCODE_CANCELLED]      = "timeout",
+               [RCODE_BUSY]           = "busy",
+               [RCODE_GENERATION]     = "bus reset",
+               [RCODE_NO_ACK]         = "no ack",
+       };
+
+       if ((unsigned int)rcode < ARRAY_SIZE(names) && names[rcode])
+               return names[rcode];
+       else
+               return "unknown";
+}
+EXPORT_SYMBOL(fw_rcode_string);
+
 static const struct fw_address_region topology_map_region =
        { .start = CSR_REGISTER_BASE | CSR_TOPOLOGY_MAP,
          .end   = CSR_REGISTER_BASE | CSR_TOPOLOGY_MAP_END, };
index 0a1905719f6f13b734401257aea81ce40a5d3891..584826ba2eb70be61ea91eff0d999a9f196915af 100644 (file)
@@ -334,6 +334,7 @@ int fw_cancel_transaction(struct fw_card *card,
 int fw_run_transaction(struct fw_card *card, int tcode, int destination_id,
                       int generation, int speed, unsigned long long offset,
                       void *payload, size_t length);
+const char *fw_rcode_string(int rcode);
 
 static inline int fw_stream_packet_destination_id(int tag, int channel, int sy)
 {
index 76294f2ae47f142fe128da90d5243a7ce2eac589..645cb0ba429310f1a0c2569e1a7845a9bf0c4387 100644 (file)
@@ -84,7 +84,7 @@ static int pcr_modify(struct cmp_connection *c,
        return 0;
 
 io_error:
-       cmp_error(c, "transaction failed: %s\n", rcode_string(rcode));
+       cmp_error(c, "transaction failed: %s\n", fw_rcode_string(rcode));
        return -EIO;
 
 bus_reset:
index 4750cea2210ee457634779e45e20267127319d53..14eb414983720fcc629bb55ae962c43be97e8205 100644 (file)
 
 #define ERROR_RETRY_DELAY_MS   5
 
-/**
- * rcode_string - convert a firewire result code to a string
- * @rcode: the result
- */
-const char *rcode_string(unsigned int rcode)
-{
-       static const char *const names[] = {
-               [RCODE_COMPLETE]        = "complete",
-               [RCODE_CONFLICT_ERROR]  = "conflict error",
-               [RCODE_DATA_ERROR]      = "data error",
-               [RCODE_TYPE_ERROR]      = "type error",
-               [RCODE_ADDRESS_ERROR]   = "address error",
-               [RCODE_SEND_ERROR]      = "send error",
-               [RCODE_CANCELLED]       = "cancelled",
-               [RCODE_BUSY]            = "busy",
-               [RCODE_GENERATION]      = "generation",
-               [RCODE_NO_ACK]          = "no ack",
-       };
-
-       if (rcode < ARRAY_SIZE(names) && names[rcode])
-               return names[rcode];
-       else
-               return "unknown";
-}
-EXPORT_SYMBOL(rcode_string);
-
 /**
  * snd_fw_transaction - send a request and wait for its completion
  * @unit: the driver's unit on the target device
@@ -71,7 +45,7 @@ int snd_fw_transaction(struct fw_unit *unit, int tcode,
 
                if (rcode_is_permanent_error(rcode) || ++tries >= 3) {
                        dev_err(&unit->device, "transaction failed: %s\n",
-                               rcode_string(rcode));
+                               fw_rcode_string(rcode));
                        return -EIO;
                }
 
index 064f3fd9ab06a8f60743d1fb23b1685e28df4dfe..aef301476ea943bf9bbff8a9bfb8a28b6661a906 100644 (file)
@@ -8,7 +8,6 @@ struct fw_unit;
 
 int snd_fw_transaction(struct fw_unit *unit, int tcode,
                       u64 offset, void *buffer, size_t length);
-const char *rcode_string(unsigned int rcode);
 
 /* returns true if retrying the transaction would not make sense */
 static inline bool rcode_is_permanent_error(int rcode)