From patchwork Tue Mar 13 12:02:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haneen Mohammed X-Patchwork-Id: 10281565 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D5E38602C2 for ; Wed, 14 Mar 2018 08:02:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C753D27FE4 for ; Wed, 14 Mar 2018 08:02:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BC1F72832D; Wed, 14 Mar 2018 08:02:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2ABEC27FE4 for ; Wed, 14 Mar 2018 08:02:34 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0D6DD6E684; Wed, 14 Mar 2018 08:02:12 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qt0-x241.google.com (mail-qt0-x241.google.com [IPv6:2607:f8b0:400d:c0d::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id B1D036E483 for ; Tue, 13 Mar 2018 12:02:09 +0000 (UTC) Received: by mail-qt0-x241.google.com with SMTP id z14so22345307qti.2 for ; Tue, 13 Mar 2018 05:02:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=+s1plrU1UFvbIgXzAkVBbb7xrxmWqQsIzL1+k4+g1JE=; b=LMd7JKd4Oqf+NfCP4m7WS/W9rReq4hCK4YXtt3r2w+nvJQhrptaHYTp3+u931/f0Re d8Oi1elQWztN+0ghdoaVty4BSAFLhkoD2qEZoJsjxk1qaancXnUu1i3Li9Mij0Y0DV2Y KTfn97U0+S2Ya/jFSgC8KY0XBP9+CrrMKEvRzgLd8dAKiO3bjBRuYoGcvk0fVRv3PgCh B8LGnddpWhKnhrzA/cGozVWM1MfD59+q+QmMrRW+R3xpUnwkeJH4BZ0zxCBWluCRwOlQ Sfguwl9JkFxgJn2ryj+8pliZ+Bf4Cqflba41g2Zhgh9OShGslOQAesvpCBoUoMBEa/aR /K8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=+s1plrU1UFvbIgXzAkVBbb7xrxmWqQsIzL1+k4+g1JE=; b=YTHjAf3T/L86RMQsGi+BjzRo05VDsUsSbGFUXi6AMtFp4MtUiQDDNCACqjSkxX5b3W vwNro+YuAkfdSdeBH638tZmBYayNjxcZblyNw2tpAaYKjzZwyEAua0Tf0xS+i7YZWAjC ChJkkREvLyOTsgMBNn4nVMkevPfGSLvMLP1Q4W8WK5QHovuA3mcm4/hcoZ8oMtwF56g7 zptjTh8yZlM3xjuAQfIbu8TiULz0k3gaY8XDC1IC6AXDBAOCHupsHRhs+2AZZPszMr+X KIuYCB6KxCrFTK0ViUs0isWUAMuqcYh7nYCQThrESSqQVmiwAmwM3z8wPr3oEQHHVQ1a nXbg== X-Gm-Message-State: AElRT7F/FwDZf+6Nwlt78eiOQkDdcYOyWFj4HkGBKEGS4c0VQlte5r+t VkAyb2LBA1lIWzvBByKhmhM= X-Google-Smtp-Source: AG47ELt103qNfUIk2GzWvI0G+zeZnLdDUAKnSYzHVJS3t14Jk8rasinaPI9rkmTuU4JKBTiRfpyYAA== X-Received: by 10.200.56.109 with SMTP id r42mr577366qtb.125.1520942528516; Tue, 13 Mar 2018 05:02:08 -0700 (PDT) Received: from Haneen ([2601:184:4881:288:55e9:133d:c79:d67e]) by smtp.gmail.com with ESMTPSA id f54sm27027qta.87.2018.03.13.05.02.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Mar 2018 05:02:07 -0700 (PDT) Date: Tue, 13 Mar 2018 08:02:05 -0400 From: Haneen Mohammed To: Daniel Vetter , Gustavo Padovan , Sean Paul , David Airlie Subject: [PATCH DRM] drm: Introduce drm_global_item_{get/put}() Message-ID: <20180313120205.GA12094@Haneen> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-Mailman-Approved-At: Wed, 14 Mar 2018 08:01:47 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: outreachy-kernel@googlegroups.com, dri-devel@lists.freedesktop.org, hamohammed.sa@gmail.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP For consistency with other reference counting APIs in the kernel, introduce drm_global_item_{get/put} functions instead of drm_global_item_{ref/unref}. Compatibility aliases are added to keep existing code working. The semantic patch scripts/coccinelle/api/drm-get-put.cocci has been extended to account for the new helpers. Signed-off-by: Haneen Mohammed --- drivers/gpu/drm/drm_global.c | 43 +++++++++++++++++++++++++++----- include/drm/drm_global.h | 2 ++ scripts/coccinelle/api/drm-get-put.cocci | 10 ++++++++ 3 files changed, 49 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c index b2dc21e..76cf948 100644 --- a/drivers/gpu/drm/drm_global.c +++ b/drivers/gpu/drm/drm_global.c @@ -64,7 +64,7 @@ void drm_global_release(void) } /** - * drm_global_item_ref - Initialize and acquire reference to memory + * drm_global_item_get - Initialize and acquire reference to memory * object * @ref: Object for initialization * @@ -75,7 +75,7 @@ void drm_global_release(void) * Returns: * Zero on success, non-zero otherwise. */ -int drm_global_item_ref(struct drm_global_reference *ref) +int drm_global_item_get(struct drm_global_reference *ref) { int ret = 0; struct drm_global_item *item = &glob[ref->global_type]; @@ -107,10 +107,10 @@ int drm_global_item_ref(struct drm_global_reference *ref) mutex_unlock(&item->mutex); return ret; } -EXPORT_SYMBOL(drm_global_item_ref); +EXPORT_SYMBOL(drm_global_item_get); /** - * drm_global_item_unref - Drop reference to memory + * drm_global_item_put - Drop reference to memory * object * @ref: Object being removed * @@ -120,7 +120,7 @@ EXPORT_SYMBOL(drm_global_item_ref); * */ -void drm_global_item_unref(struct drm_global_reference *ref) +void drm_global_item_put(struct drm_global_reference *ref) { struct drm_global_item *item = &glob[ref->global_type]; @@ -133,5 +133,36 @@ void drm_global_item_unref(struct drm_global_reference *ref) } mutex_unlock(&item->mutex); } -EXPORT_SYMBOL(drm_global_item_unref); +EXPORT_SYMBOL(drm_global_item_put); +/** + * drm_global_item_ref - Initialize and acquire reference to memory + * object + * @ref: Object for initialization + * + * This is a compatibility alias for drm_global_item_get() and should + * not be used by new code. + * + * Returns: + * Zero on success, non-zero otherwise. + */ +int drm_global_item_ref(struct drm_global_reference *ref) +{ + return drm_global_item_get(ref); +} +EXPORT_SYMBOL(drm_global_item_ref); + +/** + * drm_global_item_unref - Drop reference to memory + * object + * @ref: Object being removed + * + * This is a compatibility alias for drm_global_item_get() and should not + * be used by new code. + */ + +void drm_global_item_unref(struct drm_global_reference *ref) +{ + drm_global_item_put(ref); +} +EXPORT_SYMBOL(drm_global_item_unref); diff --git a/include/drm/drm_global.h b/include/drm/drm_global.h index 3a83060..5eb6f0c 100644 --- a/include/drm/drm_global.h +++ b/include/drm/drm_global.h @@ -47,6 +47,8 @@ struct drm_global_reference { void drm_global_init(void); void drm_global_release(void); +int drm_global_item_get(struct drm_global_reference *ref); +void drm_global_item_put(struct drm_global_reference *ref); int drm_global_item_ref(struct drm_global_reference *ref); void drm_global_item_unref(struct drm_global_reference *ref); diff --git a/scripts/coccinelle/api/drm-get-put.cocci b/scripts/coccinelle/api/drm-get-put.cocci index 91fceb8..db1c465 100644 --- a/scripts/coccinelle/api/drm-get-put.cocci +++ b/scripts/coccinelle/api/drm-get-put.cocci @@ -54,6 +54,12 @@ expression object; | - drm_dev_unref(object) + drm_dev_put(object) +| +- drm_global_item_ref(object) ++ drm_global_item_get(object) +| +- drm_global_item_unref(object) ++ drm_global_item_put(object) ) @r depends on report@ @@ -87,6 +93,10 @@ drm_property_unreference_blob@p(object) drm_property_reference_blob@p(object) | drm_dev_unref@p(object) +| +drm_global_item_ref@p(object) +| +drm_global_item_unref@p(object) ) @script:python depends on report@