From b3b4eb91a2d01884cc5f976c615b70d1a162db5c Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Thu, 7 May 2020 14:29:17 -0700 Subject: [PATCH] oceanic: avoid unnecessary difference with Jef's upstream version We ended up merging Janic McLaughlin's fix for dive truncation issues into the subsurface branch, and then Jef ended up taking it too, but making some changes while at it. See commit 17ff3e066769 ("Oceanic: fix up dive truncation issues, update memory layout") vs commit 04c367fd0645 ("Oceanic: fix up dive truncation issues"). The two versions end up doing the same thing, this takes Jef's version to minimize differences to upstream. Signed-off-by: Linus Torvalds --- src/oceanic_common.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/oceanic_common.c b/src/oceanic_common.c index 691e9a6..817e3e2 100644 --- a/src/oceanic_common.c +++ b/src/oceanic_common.c @@ -521,14 +521,13 @@ oceanic_common_device_profile (dc_device_t *abstract, dc_event_progress_t *progr // Remove padding from the profile. if (layout->highmem) { - unsigned char *profile = profiles + offset; - // profile+12 and the bottom 4 bits of profile+13 and the top 3 bits of profile+13 - // is the number of pages of profile data until the start of the footer - // (not including the prepended logbook entry). - unsigned int high_part = array_uint16_le (profile + 12) & 0xE000; - unsigned int low_part = array_uint16_le (profile + 12) & 0x0FFF; - unsigned int npages = ((high_part >> 1) | low_part) + 1; - // INFO (abstract->context, "profile npages: 0x%X (%d)", npages, npages); + // The logbook entry contains the total number of pages containing + // profile data, excluding the footer page. Limit the profile size + // to this size. + unsigned int value = array_uint16_le (profiles + offset + 12); + unsigned int value_hi = value & 0xE000; + unsigned int value_lo = value & 0x0FFF; + unsigned int npages = ((value_hi >> 1) | value_lo) + 1; unsigned int length = npages * PAGESIZE; if (rb_entry_size > length) { rb_entry_size = length;