From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58501C48BE8 for ; Tue, 15 Jun 2021 14:10:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 42D5E61450 for ; Tue, 15 Jun 2021 14:10:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230452AbhFOOM1 (ORCPT ); Tue, 15 Jun 2021 10:12:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230487AbhFOOMB (ORCPT ); Tue, 15 Jun 2021 10:12:01 -0400 Received: from mail-ot1-x32a.google.com (mail-ot1-x32a.google.com [IPv6:2607:f8b0:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36286C06175F for ; Tue, 15 Jun 2021 07:09:53 -0700 (PDT) Received: by mail-ot1-x32a.google.com with SMTP id 6-20020a9d07860000b02903e83bf8f8fcso14362614oto.12 for ; Tue, 15 Jun 2021 07:09:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=G03LeVSqzx4r6UWRg21tN37T3lMTHXfodYVAYedgndk=; b=CQWma7GynKiGTf/Cfus0SAXooczcUtAUWmj8IMcII3ayR0fKCmZlvQCTp2kl51BNqC UBRoHcbAAUBRK+qrsVV2EAsxHEOBbQnbH9nChYvVvUDW34ReH9str/1pEbuzDJXnn6x2 LE5uC+WvITpjeejAf1fIDtVu5tyUBV5lx0kGE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=G03LeVSqzx4r6UWRg21tN37T3lMTHXfodYVAYedgndk=; b=G7aiTCA7pxmDAkSTJKTTb6wB+Nx7obIesxyuTuHPcrJeWXYhi4xNv4rXxOgBIJZPfu jdsKTYgcRKN19xUwybfxD4d4y++Sz5PfuhW4gE9h0riruag3/KjLUuIsF0QjKsjXZ5o4 I7sVaxJjK0AQyR1TV1DZg8y+J/1nLYCI9OIBEL9i+50HQw1gzQvXYEZEprE68AK/leiW nYgvh0Uy7/8OMRSG1IJF26PzO2ABaHTx6WE/C6pS1NPNWdbYbbC3B0VMBCZO+t/vMABm 3L//9w+FKeVQMU0nFU3Y18T8winLPS71Ec8574JKu6J7lZe9ns/FSMAQ5fE51UgPfSEc osHg== X-Gm-Message-State: AOAM530Em6j4Hn+Nedwkv1DySvmWhDUtsn/28gOQMEmpq3HtfF7FQtJN Wc1z3Sy5x3Bf2NG18rBU11iqYPscUNhwVw== X-Google-Smtp-Source: ABdhPJzif/rlAZ6AcdzlQfzAzDQSxFh0lbrTGIvzUs2Bf5Btgj19yIiD+Dgccd+ZOgiGbJJ3LAy97g== X-Received: by 2002:a05:6830:17c8:: with SMTP id p8mr17682543ota.167.1623766192538; Tue, 15 Jun 2021 07:09:52 -0700 (PDT) Received: from [192.168.1.112] (c-24-9-64-241.hsd1.co.comcast.net. [24.9.64.241]) by smtp.gmail.com with ESMTPSA id k8sm3760778ool.5.2021.06.15.07.09.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 15 Jun 2021 07:09:51 -0700 (PDT) Subject: Re: [PATCH] media: Fix Media Controller API config checks To: Hans Verkuil , sakari.ailus@linux.intel.com, laurent.pinchart@ideasonboard.com, dan.carpenter@oracle.com, mchehab@kernel.org Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, Shuah Khan References: <20210611015849.42589-1-skhan@linuxfoundation.org> <3745852a-a14d-3e66-dd9f-409ec7e43f48@xs4all.nl> From: Shuah Khan Message-ID: <04f0ce7b-71c3-948c-fdb0-72e234f8c7da@linuxfoundation.org> Date: Tue, 15 Jun 2021 08:09:50 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <3745852a-a14d-3e66-dd9f-409ec7e43f48@xs4all.nl> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/15/21 7:36 AM, Hans Verkuil wrote: > Hi Shuah, > > On 11/06/2021 03:58, Shuah Khan wrote: >> Smatch static checker warns that "mdev" can be null: >> >> sound/usb/media.c:287 snd_media_device_create() >> warn: 'mdev' can also be NULL >> >> If CONFIG_MEDIA_CONTROLLER is disabled, this file should not be included >> in the build. >> >> The below conditions in the sound/usb/Makefile are in place to ensure that >> media.c isn't included in the build. >> >> sound/usb/Makefile: >> snd-usb-audio-$(CONFIG_SND_USB_AUDIO_USE_MEDIA_CONTROLLER) += media.o >> >> select SND_USB_AUDIO_USE_MEDIA_CONTROLLER if MEDIA_CONTROLLER && >> (MEDIA_SUPPORT=y || MEDIA_SUPPORT=SND_USB_AUDIO) >> >> The following config check in include/media/media-dev-allocator.h is >> in place to enable the API only when CONFIG_MEDIA_CONTROLLER and >> CONFIG_USB are enabled. >> >> #if defined(CONFIG_MEDIA_CONTROLLER) && defined(CONFIG_USB) >> >> This check doesn't work as intended when CONFIG_USB=m. When CONFIG_USB=m, >> CONFIG_USB_MODULE is defined and CONFIG_USB is not. The above config check >> doesn't catch that CONFIG_USB is defined as a module and disables the API. >> This results in sound/usb enabling Media Controller specific ALSA driver >> code, while Media disables the Media Controller API. >> >> Fix the problem requires two changes: >> >> 1. Change the check to use IS_ENABLED to detect when CONFIG_USB is enabled >> as a module or static. Since CONFIG_MEDIA_CONTROLLER is a bool, leave >> the check unchanged to be consistent with drivers/media/Makefile. >> >> 2. Change the drivers/media/mc/Makefile to include mc-dev-allocator.o >> in mc-objs when CONFIG_USB is y or m. > > If I test this patch, then I get: > > drivers/media/mc/mc-dev-allocator.c:97:22: error: redefinition of 'media_device_usb_allocate' > 97 | struct media_device *media_device_usb_allocate(struct usb_device *udev, > | ^~~~~~~~~~~~~~~~~~~~~~~~~ > In file included from drivers/media/mc/mc-dev-allocator.c:24: > include/media/media-dev-allocator.h:55:36: note: previous definition of 'media_device_usb_allocate' was here > 55 | static inline struct media_device *media_device_usb_allocate( > | ^~~~~~~~~~~~~~~~~~~~~~~~~ > drivers/media/mc/mc-dev-allocator.c:119:6: error: redefinition of 'media_device_delete' > 119 | void media_device_delete(struct media_device *mdev, const char *module_name, > | ^~~~~~~~~~~~~~~~~~~ > In file included from drivers/media/mc/mc-dev-allocator.c:24: > include/media/media-dev-allocator.h:59:20: note: previous definition of 'media_device_delete' was here > 59 | static inline void media_device_delete( > | ^~~~~~~~~~~~~~~~~~~ > > The .config has: > > # CONFIG_USB_SUPPORT is not set > CONFIG_MEDIA_CONTROLLER=y > Oops. I tried different combinations of CONFIG_USB and didn't try this one. Will send v2. thanks, -- Shuah From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 08FCFC48BE5 for ; Tue, 15 Jun 2021 14:10:53 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5DE6761450 for ; Tue, 15 Jun 2021 14:10:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5DE6761450 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 61FA41660; Tue, 15 Jun 2021 16:10:00 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 61FA41660 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623766250; bh=5Eala36z3fsuK70M+Qc0HSDimDvKYvsrG7+Uc+awhgQ=; h=Subject:To:References:From:Date:In-Reply-To:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=m/8koVN78eCG2LeR/vw3eBiwyAADcdZH11IzIkb5cZOTrZcRDY9lm2cIoL8ChsImG Uz0GnUGMmjyAHc9KQJZEQloypeRTYOQuIo6yRZ/zYryinXpfSXK0fxK5a1ajb93Iqe VIoYJ2Pht6K9VBL5+wD2rwWLEptgz8Lk4kU+qMmY= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id E7C0CF8016D; Tue, 15 Jun 2021 16:09:59 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id E4941F80171; Tue, 15 Jun 2021 16:09:58 +0200 (CEST) Received: from mail-ot1-x32c.google.com (mail-ot1-x32c.google.com [IPv6:2607:f8b0:4864:20::32c]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 3F329F8016C for ; Tue, 15 Jun 2021 16:09:55 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 3F329F8016C Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="CQWma7Gy" Received: by mail-ot1-x32c.google.com with SMTP id q5-20020a9d66450000b02903f18d65089fso14368124otm.11 for ; Tue, 15 Jun 2021 07:09:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=G03LeVSqzx4r6UWRg21tN37T3lMTHXfodYVAYedgndk=; b=CQWma7GynKiGTf/Cfus0SAXooczcUtAUWmj8IMcII3ayR0fKCmZlvQCTp2kl51BNqC UBRoHcbAAUBRK+qrsVV2EAsxHEOBbQnbH9nChYvVvUDW34ReH9str/1pEbuzDJXnn6x2 LE5uC+WvITpjeejAf1fIDtVu5tyUBV5lx0kGE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=G03LeVSqzx4r6UWRg21tN37T3lMTHXfodYVAYedgndk=; b=EKYDczxQbQ7ZCfmhE3AnweWG3lZlkczb7Jrblnnle3JjXYtdRGLKD/9tHZjZdBBurb 5mk0ACuM4VCDOMiaSZTXiQSZ+YcYuy38pP3SsK0rlQVeENwcShGh1rstSTiI2RbqQbD6 ukRCAtkY7F1FMNVmnkr2Tqupo8TxFMXoPRyk7VevOB+4rIxP3i/GYMksM5vz5pkA6WH6 xG86h9kKkKad64fczVktWu1a8zy6YUtkFVpQyjzoyuJZJYHss0FTSlDLrqX2sxuU67M2 1YmkWVEp2LiOsib4ot6NIcLktpwAzOvwz8uYpputFUJLzJrIv7imcKR7s9w1iR+Qbuk7 f1tQ== X-Gm-Message-State: AOAM530Ol5V/WE2PYWbluNX6PfLuJ3QFg0hc93kzF8LXo7rjFcrGpV1d Jc3pzHHxFJz+N/zOT314h53Bvw== X-Google-Smtp-Source: ABdhPJzif/rlAZ6AcdzlQfzAzDQSxFh0lbrTGIvzUs2Bf5Btgj19yIiD+Dgccd+ZOgiGbJJ3LAy97g== X-Received: by 2002:a05:6830:17c8:: with SMTP id p8mr17682543ota.167.1623766192538; Tue, 15 Jun 2021 07:09:52 -0700 (PDT) Received: from [192.168.1.112] (c-24-9-64-241.hsd1.co.comcast.net. [24.9.64.241]) by smtp.gmail.com with ESMTPSA id k8sm3760778ool.5.2021.06.15.07.09.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 15 Jun 2021 07:09:51 -0700 (PDT) Subject: Re: [PATCH] media: Fix Media Controller API config checks To: Hans Verkuil , sakari.ailus@linux.intel.com, laurent.pinchart@ideasonboard.com, dan.carpenter@oracle.com, mchehab@kernel.org References: <20210611015849.42589-1-skhan@linuxfoundation.org> <3745852a-a14d-3e66-dd9f-409ec7e43f48@xs4all.nl> From: Shuah Khan Message-ID: <04f0ce7b-71c3-948c-fdb0-72e234f8c7da@linuxfoundation.org> Date: Tue, 15 Jun 2021 08:09:50 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <3745852a-a14d-3e66-dd9f-409ec7e43f48@xs4all.nl> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Cc: alsa-devel@alsa-project.org, Shuah Khan , linux-kernel@vger.kernel.org, linux-media@vger.kernel.org X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" On 6/15/21 7:36 AM, Hans Verkuil wrote: > Hi Shuah, > > On 11/06/2021 03:58, Shuah Khan wrote: >> Smatch static checker warns that "mdev" can be null: >> >> sound/usb/media.c:287 snd_media_device_create() >> warn: 'mdev' can also be NULL >> >> If CONFIG_MEDIA_CONTROLLER is disabled, this file should not be included >> in the build. >> >> The below conditions in the sound/usb/Makefile are in place to ensure that >> media.c isn't included in the build. >> >> sound/usb/Makefile: >> snd-usb-audio-$(CONFIG_SND_USB_AUDIO_USE_MEDIA_CONTROLLER) += media.o >> >> select SND_USB_AUDIO_USE_MEDIA_CONTROLLER if MEDIA_CONTROLLER && >> (MEDIA_SUPPORT=y || MEDIA_SUPPORT=SND_USB_AUDIO) >> >> The following config check in include/media/media-dev-allocator.h is >> in place to enable the API only when CONFIG_MEDIA_CONTROLLER and >> CONFIG_USB are enabled. >> >> #if defined(CONFIG_MEDIA_CONTROLLER) && defined(CONFIG_USB) >> >> This check doesn't work as intended when CONFIG_USB=m. When CONFIG_USB=m, >> CONFIG_USB_MODULE is defined and CONFIG_USB is not. The above config check >> doesn't catch that CONFIG_USB is defined as a module and disables the API. >> This results in sound/usb enabling Media Controller specific ALSA driver >> code, while Media disables the Media Controller API. >> >> Fix the problem requires two changes: >> >> 1. Change the check to use IS_ENABLED to detect when CONFIG_USB is enabled >> as a module or static. Since CONFIG_MEDIA_CONTROLLER is a bool, leave >> the check unchanged to be consistent with drivers/media/Makefile. >> >> 2. Change the drivers/media/mc/Makefile to include mc-dev-allocator.o >> in mc-objs when CONFIG_USB is y or m. > > If I test this patch, then I get: > > drivers/media/mc/mc-dev-allocator.c:97:22: error: redefinition of 'media_device_usb_allocate' > 97 | struct media_device *media_device_usb_allocate(struct usb_device *udev, > | ^~~~~~~~~~~~~~~~~~~~~~~~~ > In file included from drivers/media/mc/mc-dev-allocator.c:24: > include/media/media-dev-allocator.h:55:36: note: previous definition of 'media_device_usb_allocate' was here > 55 | static inline struct media_device *media_device_usb_allocate( > | ^~~~~~~~~~~~~~~~~~~~~~~~~ > drivers/media/mc/mc-dev-allocator.c:119:6: error: redefinition of 'media_device_delete' > 119 | void media_device_delete(struct media_device *mdev, const char *module_name, > | ^~~~~~~~~~~~~~~~~~~ > In file included from drivers/media/mc/mc-dev-allocator.c:24: > include/media/media-dev-allocator.h:59:20: note: previous definition of 'media_device_delete' was here > 59 | static inline void media_device_delete( > | ^~~~~~~~~~~~~~~~~~~ > > The .config has: > > # CONFIG_USB_SUPPORT is not set > CONFIG_MEDIA_CONTROLLER=y > Oops. I tried different combinations of CONFIG_USB and didn't try this one. Will send v2. thanks, -- Shuah