Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp363639pxb; Wed, 3 Nov 2021 05:35:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwqVlmtxem2drzaR1+CsdyzN5VheaNITViWvequwNtxRPMD9xxU89/ebATvluQr4ZNOF6QD X-Received: by 2002:a05:6602:15d3:: with SMTP id f19mr19953481iow.14.1635942958647; Wed, 03 Nov 2021 05:35:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635942958; cv=none; d=google.com; s=arc-20160816; b=sMn046++rIqEY6wL/aK83us/I0voEExBUBRWoiUCV3wHaL+jzmdN/DCrJNLTPt7GEW +FzQQRt6X1EuR72ViswYY+IgIQmxbOvt4eB0eoaEfrgJ57m+NRNp4nlutA5J9ZiR2ApJ UN+zELKITQpQO0u4u7mNLKUd7iig9/JqDIABK0SI4TO4VLyYTdtt8j67UeeghUvpwgOu hBfx5n4GmMoQKp1patd2Ga+9DDQQD+NBa0PV8ojh7vTkdvqPZT+2NAX5X8ew5tZI2+2u XlLRmmbsyrxHkKVxyOqnYPR42ua6UQcCSUydRrE6HwQSJfvG591zQ/m90wrhHG5+KmZR HQyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=WYRilsKXTSd9rCQl94c3WtrJx+PErIlJFSZVj4QEnnA=; b=0k3mURQ+Dl+RVrWUxy36I6zIHQh7VIy+r47tZqdF56VQ2LEQspm2SQHicRaILJQXhW pUJGllT/uUrAk9pNnWRadKrs/fpyUhrFaDZMnu3e53221SF3xPlEhEIaJGtZ6xoy9cbF bM6mgfcNmT+aGN4qpIlyLrrVHWcFEAweo1xpq+jnRCBGH7VNMN/D/b+kL2PkUYS5xxBm ZPemv1jbmjGN9cdt3o/EYKr9zlINPXQky9fqumYfFsV+Y24bdZdvDLcQH2Guzl/nzaXO zWHydczDhOlWgJqyC1OG4w1BGxT2EJkC4ak3EayoIanDB7MWFfMfB3opd8PIMNdF/RwS LdUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cT5xaZkC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z10si3586207ilu.34.2021.11.03.05.35.44; Wed, 03 Nov 2021 05:35:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cT5xaZkC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232095AbhKCMfa (ORCPT + 99 others); Wed, 3 Nov 2021 08:35:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:41074 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232081AbhKCMf1 (ORCPT ); Wed, 3 Nov 2021 08:35:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635942771; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=WYRilsKXTSd9rCQl94c3WtrJx+PErIlJFSZVj4QEnnA=; b=cT5xaZkCgZl6c1soc6dSMfwreVmba4uKECqqvHhpi8zGp7/7ObSS791NXlC/OW74/Lfdme on+ToTyy3542oNWKjjXM6m9W9Ue1Rrlqm28+IUpQoh49E9wioXkcLKf424RdCll4EXoc7j pvShaHx2qiyhqgb3XzYEkbv2zSPYwKE= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-435-danWSMkzNWG7Z6fnsmE0Sw-1; Wed, 03 Nov 2021 08:32:50 -0400 X-MC-Unique: danWSMkzNWG7Z6fnsmE0Sw-1 Received: by mail-wm1-f69.google.com with SMTP id f20-20020a05600c155400b0030db7b29174so1031114wmg.2 for ; Wed, 03 Nov 2021 05:32:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=WYRilsKXTSd9rCQl94c3WtrJx+PErIlJFSZVj4QEnnA=; b=CLt55H6mZC6PSlyCjEM1vqPbZohr4EoxXy850aCDfgTMIsrRQlfWd1ZOSAJNLu7w9V k3ez+A/Dq3Xyy5v5v9n2ORibJfhxWd80/alqq7cRDau8ugCoP43LWN9HCPbBWg73UnID VB50OK7a2NBhxE57vWtu+PfkmR4Cj3uFOZ29RuSU11dg66CFCzvEtTEtDtFDueqp6m8c 5HBmA8j7yqwpyTApL2VbqG5St4yKVyQeHcmXB3xoUbkBHtjXroYzwNoKyoYSqQTK/kt9 dvHUEVYof1dsdnRlsThi3MubqfLvoeZNNqciohGIHBz/VAPTRDPh+JzhBt5mS3uydV9b zulA== X-Gm-Message-State: AOAM532ko7qz0gd0gZ7aO6N5tf9CIROJUSuTw5P5mhqm44tPLlQL1Aqt XrNkhU10IvyLfxdw6CLnwW+U4w/8Jp8wyqt04X65kNBwnb8mNjFdMy79eQwcMom0i3V1KWax7qj XyGoPI1SmpJmE0ImLl0koS7/zyS8yP4sDck+Wa2bBhc3h42xvge3CMrXIYhulB80jttTTv4qEaO 4= X-Received: by 2002:a5d:4b45:: with SMTP id w5mr28163706wrs.272.1635942768525; Wed, 03 Nov 2021 05:32:48 -0700 (PDT) X-Received: by 2002:a5d:4b45:: with SMTP id w5mr28163669wrs.272.1635942768316; Wed, 03 Nov 2021 05:32:48 -0700 (PDT) Received: from minerva.home ([92.176.231.106]) by smtp.gmail.com with ESMTPSA id o8sm1774844wrm.67.2021.11.03.05.32.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Nov 2021 05:32:47 -0700 (PDT) From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Cc: Pekka Paalanen , Thomas Zimmermann , Peter Robinson , Daniel Vetter , Neal Gompa , =?UTF-8?q?Michel=20D=C3=A4nzer?= , David Airlie , Maarten Lankhorst , Maxime Ripard , dri-devel@lists.freedesktop.org, Javier Martinez Canillas Subject: [RESEND PATCH 4/5] drm: Add a drm_drv_enabled() helper function Date: Wed, 3 Nov 2021 13:32:06 +0100 Message-Id: <20211103123206.1041442-1-javierm@redhat.com> X-Mailer: git-send-email 2.33.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org DRM drivers can use this to determine whether they can be enabled or not. For now it's just a wrapper around drm_modeset_disabled() but having the indirection level will allow to add other conditions besides "nomodeset". Suggested-by: Thomas Zimmermann Signed-off-by: Javier Martinez Canillas --- drivers/gpu/drm/drm_drv.c | 21 +++++++++++++++++++++ include/drm/drm_drv.h | 1 + 2 files changed, 22 insertions(+) diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c index 8214a0b1ab7f..70ef08941e06 100644 --- a/drivers/gpu/drm/drm_drv.c +++ b/drivers/gpu/drm/drm_drv.c @@ -975,6 +975,27 @@ int drm_dev_set_unique(struct drm_device *dev, const char *name) } EXPORT_SYMBOL(drm_dev_set_unique); +/** + * drm_drv_enabled - Checks if a DRM driver can be enabled + * @driver: DRM driver to check + * + * Checks whether a DRM driver can be enabled or not. This may be the case + * if the "nomodeset" kernel command line parameter is used. + * + * Returns: + * True if the DRM driver is enabled and false otherwise. + */ +bool drm_drv_enabled(const struct drm_driver *driver) +{ + if (drm_modeset_disabled()) { + DRM_INFO("%s driver is disabled\n", driver->name); + return false; + } + + return true; +} +EXPORT_SYMBOL(drm_drv_enabled); + /* * DRM Core * The DRM core module initializes all global DRM objects and makes them diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h index 0cd95953cdf5..48f2b6eec012 100644 --- a/include/drm/drm_drv.h +++ b/include/drm/drm_drv.h @@ -598,5 +598,6 @@ static inline bool drm_drv_uses_atomic_modeset(struct drm_device *dev) int drm_dev_set_unique(struct drm_device *dev, const char *name); +bool drm_drv_enabled(const struct drm_driver *driver); #endif -- 2.33.1