Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

iommu/fsl_pamu: merge handle_attach_device into fsl_pamu_attach_device

No good reason to split this functionality over two functions.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Will Deacon <will@kernel.org>
Acked-by: Li Yang <leoyang.li@nxp.com>
Link: https://lore.kernel.org/r/20210401155256.298656-10-hch@lst.de
Signed-off-by: Joerg Roedel <jroedel@suse.de>

authored by

Christoph Hellwig and committed by
Joerg Roedel
85e362ca dae7747a

+20 -39
+20 -39
drivers/iommu/fsl_pamu_domain.c
··· 240 240 return ret; 241 241 } 242 242 243 - /* 244 - * Attach the LIODN to the DMA domain and configure the geometry 245 - * and window mappings. 246 - */ 247 - static int handle_attach_device(struct fsl_dma_domain *dma_domain, 248 - struct device *dev, const u32 *liodn, 249 - int num) 250 - { 251 - unsigned long flags; 252 - int ret = 0; 253 - int i; 254 - 255 - spin_lock_irqsave(&dma_domain->domain_lock, flags); 256 - for (i = 0; i < num; i++) { 257 - /* Ensure that LIODN value is valid */ 258 - if (liodn[i] >= PAACE_NUMBER_ENTRIES) { 259 - pr_debug("Invalid liodn %d, attach device failed for %pOF\n", 260 - liodn[i], dev->of_node); 261 - ret = -EINVAL; 262 - break; 263 - } 264 - 265 - attach_device(dma_domain, liodn[i], dev); 266 - ret = pamu_set_liodn(dma_domain, dev, liodn[i]); 267 - if (ret) 268 - break; 269 - } 270 - spin_unlock_irqrestore(&dma_domain->domain_lock, flags); 271 - 272 - return ret; 273 - } 274 - 275 243 static int fsl_pamu_attach_device(struct iommu_domain *domain, 276 244 struct device *dev) 277 245 { 278 246 struct fsl_dma_domain *dma_domain = to_fsl_dma_domain(domain); 247 + unsigned long flags; 248 + int len, ret = 0, i; 279 249 const u32 *liodn; 280 - u32 liodn_cnt; 281 - int len, ret = 0; 282 250 struct pci_dev *pdev = NULL; 283 251 struct pci_controller *pci_ctl; 284 252 ··· 266 298 } 267 299 268 300 liodn = of_get_property(dev->of_node, "fsl,liodn", &len); 269 - if (liodn) { 270 - liodn_cnt = len / sizeof(u32); 271 - ret = handle_attach_device(dma_domain, dev, liodn, liodn_cnt); 272 - } else { 301 + if (!liodn) { 273 302 pr_debug("missing fsl,liodn property at %pOF\n", dev->of_node); 274 - ret = -EINVAL; 303 + return -EINVAL; 275 304 } 276 305 306 + spin_lock_irqsave(&dma_domain->domain_lock, flags); 307 + for (i = 0; i < len / sizeof(u32); i++) { 308 + /* Ensure that LIODN value is valid */ 309 + if (liodn[i] >= PAACE_NUMBER_ENTRIES) { 310 + pr_debug("Invalid liodn %d, attach device failed for %pOF\n", 311 + liodn[i], dev->of_node); 312 + ret = -EINVAL; 313 + break; 314 + } 315 + 316 + attach_device(dma_domain, liodn[i], dev); 317 + ret = pamu_set_liodn(dma_domain, dev, liodn[i]); 318 + if (ret) 319 + break; 320 + } 321 + spin_unlock_irqrestore(&dma_domain->domain_lock, flags); 277 322 return ret; 278 323 } 279 324