lkml.org 
[lkml]   [2019]   [Apr]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2/7] iommu/dma-iommu: Split iommu_dma_map_msi_msg in two parts
On Thu, Apr 18, 2019 at 06:26:06PM +0100, Julien Grall wrote:
> +int iommu_dma_prepare_msi(struct msi_desc *desc, phys_addr_t msi_addr)
> {
> + struct device *dev = msi_desc_to_dev(desc);
> struct iommu_domain *domain = iommu_get_domain_for_dev(dev);
> struct iommu_dma_cookie *cookie;
> unsigned long flags;
>
> + if (!domain || !domain->iova_cookie) {
> + desc->iommu_cookie = NULL;
> + return 0;
> + }
>
> cookie = domain->iova_cookie;
>
> @@ -908,10 +908,33 @@ void iommu_dma_map_msi_msg(int irq, struct msi_msg *msg)
> * of an MSI from within an IPI handler.
> */
> spin_lock_irqsave(&cookie->msi_lock, flags);
> + desc->iommu_cookie = iommu_dma_get_msi_page(dev, msi_addr, domain);
> spin_unlock_irqrestore(&cookie->msi_lock, flags);
>
> + return (desc->iommu_cookie) ? 0 : -ENOMEM;

No need for the braces. Also I personally find a:

if (!desc->iommu_cookie)
return -ENOMEM;
return 0;

much more readable, but that might just be personal preference.

\
 
 \ /
  Last update: 2019-04-23 09:09    [W:0.246 / U:1.584 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site