OSDN Git Service

staging: unisys: include: simplify spar_check_channel_client
authorDavid Kershner <david.kershner@unisys.com>
Fri, 17 Mar 2017 15:27:10 +0000 (11:27 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 21 Mar 2017 06:58:46 +0000 (07:58 +0100)
The function spar_check_channel_client shouldn't need to do
readq's, it is referencing a local copy of the channel
header. Simplify it to just access the fields directly.

Signed-off-by: David Kershner <david.kershner@unisys.com>
Reviewed-by: Tim Sell <timothy.sell@unisys.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/unisys/include/channel.h

index d3c1dac..8c6a7ad 100644 (file)
@@ -217,7 +217,7 @@ struct signal_queue_header {
  * is used to pass the EFI_DIAG_CAPTURE_PROTOCOL needed to log messages.
  */
 static inline int
-spar_check_channel_client(void __iomem *ch,
+spar_check_channel_client(struct channel_header *ch,
                          uuid_le expected_uuid,
                          char *chname,
                          u64 expected_min_bytes,
@@ -225,48 +225,37 @@ spar_check_channel_client(void __iomem *ch,
                          u64 expected_signature)
 {
        if (uuid_le_cmp(expected_uuid, NULL_UUID_LE) != 0) {
-               uuid_le guid;
-
-               memcpy_fromio(&guid,
-                             &((struct channel_header __iomem *)(ch))->chtype,
-                             sizeof(guid));
                /* caller wants us to verify type GUID */
-               if (uuid_le_cmp(guid, expected_uuid) != 0) {
+               if (uuid_le_cmp(ch->chtype, expected_uuid) != 0) {
                        pr_err("Channel mismatch on channel=%s(%pUL) field=type expected=%pUL actual=%pUL\n",
                               chname, &expected_uuid,
-                              &expected_uuid, &guid);
+                              &expected_uuid, &ch->chtype);
                        return 0;
                }
        }
        if (expected_min_bytes > 0) {   /* verify channel size */
-               unsigned long long bytes =
-                               readq(&((struct channel_header __iomem *)
-                                       (ch))->size);
-               if (bytes < expected_min_bytes) {
+               if (ch->size < expected_min_bytes) {
                        pr_err("Channel mismatch on channel=%s(%pUL) field=size expected=0x%-8.8Lx actual=0x%-8.8Lx\n",
                               chname, &expected_uuid,
-                              (unsigned long long)expected_min_bytes, bytes);
+                              (unsigned long long)expected_min_bytes,
+                              ch->size);
                        return 0;
                }
        }
        if (expected_version > 0) {     /* verify channel version */
-               unsigned long ver = readl(&((struct channel_header __iomem *)
-                                   (ch))->version_id);
-               if (ver != expected_version) {
-                       pr_err("Channel mismatch on channel=%s(%pUL) field=version expected=0x%-8.8lx actual=0x%-8.8lx\n",
+               if (ch->version_id != expected_version) {
+                       pr_err("Channel mismatch on channel=%s(%pUL) field=version expected=0x%-8.8lx actual=0x%-8.8x\n",
                               chname, &expected_uuid,
-                              (unsigned long)expected_version, ver);
+                              (unsigned long)expected_version,
+                              ch->version_id);
                        return 0;
                }
        }
        if (expected_signature > 0) {   /* verify channel signature */
-               unsigned long long sig =
-                               readq(&((struct channel_header __iomem *)
-                                       (ch))->signature);
-               if (sig != expected_signature) {
-                       pr_err("Channel mismatch on channel=%s(%pUL) field=signature expected=0x%-8.8llx actual=0x%-8.8llx\n",
+               if (ch->signature != expected_signature) {
+                       pr_err("Channel mismatch on channel=%s(%pUL) field=signature expected=0x%-8.8Lx actual=0x%-8.8Lx\n",
                               chname, &expected_uuid,
-                              expected_signature, sig);
+                              expected_signature, ch->signature);
                        return 0;
                }
        }