region: publicize region_end() and add region_device_end()
Provide region_device_end() and make region_end() publically available for use to match a pattern of open coding the offset + size calculation for both struct region and struct region_device. Apply the use of the helpers where the usage matches in the code. Change-Id: Iaef5d007eef9a77f7f33b0e89298abef0197352d Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/36689 Reviewed-by: Julius Werner <jwerner@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
parent
b1ea53d846
commit
56aeae0400
|
@ -122,6 +122,11 @@ static inline size_t region_sz(const struct region *r)
|
||||||
return r->size;
|
return r->size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline size_t region_end(const struct region *r)
|
||||||
|
{
|
||||||
|
return region_offset(r) + region_sz(r);
|
||||||
|
}
|
||||||
|
|
||||||
static inline const struct region *region_device_region(
|
static inline const struct region *region_device_region(
|
||||||
const struct region_device *rdev)
|
const struct region_device *rdev)
|
||||||
{
|
{
|
||||||
|
@ -138,6 +143,11 @@ static inline size_t region_device_offset(const struct region_device *rdev)
|
||||||
return region_offset(region_device_region(rdev));
|
return region_offset(region_device_region(rdev));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline size_t region_device_end(const struct region_device *rdev)
|
||||||
|
{
|
||||||
|
return region_end(region_device_region(rdev));
|
||||||
|
}
|
||||||
|
|
||||||
/* Memory map entire region device. Same semantics as rdev_mmap() above. */
|
/* Memory map entire region device. Same semantics as rdev_mmap() above. */
|
||||||
static inline void *rdev_mmap_full(const struct region_device *rd)
|
static inline void *rdev_mmap_full(const struct region_device *rd)
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,11 +15,6 @@
|
||||||
#include <commonlib/region.h>
|
#include <commonlib/region.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
static inline size_t region_end(const struct region *r)
|
|
||||||
{
|
|
||||||
return region_sz(r) + region_offset(r);
|
|
||||||
}
|
|
||||||
|
|
||||||
int region_is_subregion(const struct region *p, const struct region *c)
|
int region_is_subregion(const struct region *p, const struct region *c)
|
||||||
{
|
{
|
||||||
if (region_offset(c) < region_offset(p))
|
if (region_offset(c) < region_offset(p))
|
||||||
|
|
|
@ -431,8 +431,7 @@ static int winbond_get_write_protection(const struct spi_flash *flash,
|
||||||
}
|
}
|
||||||
|
|
||||||
printk(BIOS_DEBUG, "WINBOND: flash protected range 0x%08zx-0x%08zx\n",
|
printk(BIOS_DEBUG, "WINBOND: flash protected range 0x%08zx-0x%08zx\n",
|
||||||
region_offset(&wp_region),
|
region_offset(&wp_region), region_end(&wp_region));
|
||||||
region_offset(&wp_region) + region_sz(&wp_region));
|
|
||||||
|
|
||||||
return region_is_subregion(&wp_region, region);
|
return region_is_subregion(&wp_region, region);
|
||||||
}
|
}
|
||||||
|
@ -562,8 +561,7 @@ winbond_set_write_protection(const struct spi_flash *flash,
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Need to touch TOP or BOTTOM */
|
/* Need to touch TOP or BOTTOM */
|
||||||
if (region_offset(region) != 0 &&
|
if (region_offset(region) != 0 && region_end(region) != flash->size)
|
||||||
(region_offset(region) + region_sz(region)) != flash->size)
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
params = (const struct winbond_spi_flash_params *)flash->driver_private;
|
params = (const struct winbond_spi_flash_params *)flash->driver_private;
|
||||||
|
@ -654,8 +652,7 @@ winbond_set_write_protection(const struct spi_flash *flash,
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
printk(BIOS_DEBUG, "WINBOND: write-protection set to range "
|
printk(BIOS_DEBUG, "WINBOND: write-protection set to range "
|
||||||
"0x%08zx-0x%08zx\n", region_offset(region),
|
"0x%08zx-0x%08zx\n", region_offset(region), region_end(region));
|
||||||
region_offset(region) + region_sz(region));
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue