Commit 041b5eac254107cd3ba60034c38a411531cc64ee
Committed by
Jeff Garzik
1 parent
f90f613c3e
Exists in
master
and in
7 other branches
drivers/ata: use resource_size
Use the function resource_size, which reduces the chance of introducing off-by-one errors in calculating the resource size. The semantic patch that makes this change is as follows: (http://www.emn.fr/x-info/coccinelle/) // <smpl> @@ struct resource *res; @@ - (res->end - res->start) + 1 + resource_size(res) // </smpl> Signed-off-by: Julia Lawall <julia@diku.dk> Cc: Jeff Garzik <jeff@garzik.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Showing 4 changed files with 7 additions and 7 deletions Side-by-side Diff
drivers/ata/pata_octeon_cf.c
drivers/ata/pata_platform.c
... | ... | @@ -151,14 +151,14 @@ |
151 | 151 | */ |
152 | 152 | if (mmio) { |
153 | 153 | ap->ioaddr.cmd_addr = devm_ioremap(dev, io_res->start, |
154 | - io_res->end - io_res->start + 1); | |
154 | + resource_size(io_res)); | |
155 | 155 | ap->ioaddr.ctl_addr = devm_ioremap(dev, ctl_res->start, |
156 | - ctl_res->end - ctl_res->start + 1); | |
156 | + resource_size(ctl_res)); | |
157 | 157 | } else { |
158 | 158 | ap->ioaddr.cmd_addr = devm_ioport_map(dev, io_res->start, |
159 | - io_res->end - io_res->start + 1); | |
159 | + resource_size(io_res)); | |
160 | 160 | ap->ioaddr.ctl_addr = devm_ioport_map(dev, ctl_res->start, |
161 | - ctl_res->end - ctl_res->start + 1); | |
161 | + resource_size(ctl_res)); | |
162 | 162 | } |
163 | 163 | if (!ap->ioaddr.cmd_addr || !ap->ioaddr.ctl_addr) { |
164 | 164 | dev_err(dev, "failed to map IO/CTL base\n"); |
drivers/ata/pata_rb532_cf.c
drivers/ata/sata_mv.c