Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp121536lqz; Fri, 29 Mar 2024 10:25:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWMwXcuGfrxwFH64RI/MLkLB6+Vsp7x1UYvK934RFbSQBQfy6FwyGD36fTXsIsNsChn28nli3PrmDBMMCqFeZUj5DqtBM9U2zBaoyXB6w== X-Google-Smtp-Source: AGHT+IF4EgUOoxvAo9gkkaO2Eu7i5LrqN1HfD7R/o+oqqEl1Izqd2Hw5RTcRZZfiHoOSn8WRI1GN X-Received: by 2002:a17:906:5fc3:b0:a47:20c3:7c51 with SMTP id k3-20020a1709065fc300b00a4720c37c51mr1862391ejv.71.1711733112620; Fri, 29 Mar 2024 10:25:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711733112; cv=pass; d=google.com; s=arc-20160816; b=Jnhb6H5JMj41CdE2IIm/p5+sRv7uEl8hctgdw/qDfpOzL2ExcXMNHbbOgPPoUTX0P7 BiAiKk05p9E5+kBeS6BVUu7FfFBza7BRDqNlkw6MnipfSsGfGR1snB8BuUO2kfuKGsvY +pLgWVODzEYjExlQPRXOO4WjyOmag+sQDaCH0x20fZKcDnfESK1o8Z1cHwwSBDK0Y8OJ 6IBGLKvqdF4zgcLD+RbtAtlwRdobyjEKln6ZIp/euR3T0yBSUK9Ty3kXIFVRGw6pZDeT +w7XrioF2d+t0kjNa4RG/S75dQBYXs55Fi1pmr6P81qn76BNhJTPzUXKKuPZd3HpE0cZ 5LRQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=kFzm6a3OkT0i9mJjLjkWWJLXNlo1hESx6fgfPVhA+Mo=; fh=hfUk+VW6bkRRmlCtMnjFYnZmiT0N+9brWh3TME0GdUY=; b=KYs6qnjAprsVEdMyw1rJfDt9FT863y+8x/ROfvu5QiarNfW5RNCqFL9noLIZaZYdhF uSsiZeOkKmZGxSg6pW8Dt9AmUDK5dKPPF9kSF5psqarN7fd/EMwModtG/PiR8tpJb2/a cUrLURLRuI2LEZXjTZYGa75k/tYU3NlNPKQX8KByugSoBMBPvY32iOfK3wkLoAf+WgQA 8RBZuurMtf+nP/Eu301oXGeYY2Rcdow2/CLAB5y4xlbxbXMf9xMrjyB4f9hKy9gYtMYw f7Nj4A+zo8psYa2G2L/TQiK14NzT2rk+h7vYE2aUTdIBzf6kQQGZ8ZllSBzQoF5YAP8u 8XQg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="X/qzsjPH"; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-wireless+bounces-5598-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-wireless+bounces-5598-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id t4-20020a170906268400b00a471bc13618si1932023ejc.1012.2024.03.29.10.25.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 10:25:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless+bounces-5598-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="X/qzsjPH"; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-wireless+bounces-5598-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-wireless+bounces-5598-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 359471F26634 for ; Fri, 29 Mar 2024 17:25:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 488EB1369A3; Fri, 29 Mar 2024 17:24:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="X/qzsjPH" X-Original-To: linux-wireless@vger.kernel.org Received: from mail-lj1-f182.google.com (mail-lj1-f182.google.com [209.85.208.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 13DFF12FB3B for ; Fri, 29 Mar 2024 17:24:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711733093; cv=none; b=KI6GU2c2mwSNqO8BcDHgF1oeArR272r0DbvZBHxykXtDB7WBvSuii58oVamEteL8yKQER8B562+9VlAYpIKrSXIFz/KFjvItlP2zAKGfNIcBo3frf8XznPQ+534SGaziGsInIx15v/Pd/lbbGJ+A4pA65cTvCNx1BclYOTlERBo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711733093; c=relaxed/simple; bh=qIRA9OHgdR8YIBTlq3gIwcNOO+uS8S8xKPRXlpB/umk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=RFGLj8Q3IuDONMcz93rhsAEUM4onEvbLQ0/ycDVgzIBYUDsGVxYftLWxPJXI+tOGSJkEMwX4O2/+Rc6zciaBo/mjhSr5ZQ8m+RaBewcaVk5+T3QaOoWC1Nt/u6yVAMfo1f4V4K6gK/8s9tVe1FHJ+E/5QpD4u0F5KxTlQgQI2RU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=X/qzsjPH; arc=none smtp.client-ip=209.85.208.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-lj1-f182.google.com with SMTP id 38308e7fff4ca-2d47a92cfefso25785891fa.1 for ; Fri, 29 Mar 2024 10:24:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711733089; x=1712337889; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=kFzm6a3OkT0i9mJjLjkWWJLXNlo1hESx6fgfPVhA+Mo=; b=X/qzsjPHaZv1y4ISWIvdnKtmmK4fxUkvSnOiIeC/a+XoxGGcdF/Xd5Ql4B1DojuJnY jcWuUQOBuGnOMLl/6yKGhAEyUE5Qb1IFNJIHtuSXsdboGN3+ncRNPswrZpSS5vldA+q1 eRAajVpF6XM17WHlZ1r1pH0YXrKR7QKjP6uFdFfLFqGEkAYh1z0e+I7xcVT5GPc9IQyE 3O7HKK7bh4oa1jLV3Dx2G5Xeq8c45R7pDUhSLnukhSYyCxIwYs6aC+W77i9eE4Kk+Tpk UI6GnCP8GczkFNDWPeBgUWwCtPw5pPn/1BPPH2KsNvb7I69At66TgB//QEszrUjRHO2Q xs0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711733089; x=1712337889; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kFzm6a3OkT0i9mJjLjkWWJLXNlo1hESx6fgfPVhA+Mo=; b=fS+yc3TfU8H+h6vqod5RhhNzYH7SCqbGh4r/GW36b3YUWh/DleE/QkrPxq2Fhq+sUT Xsc0VTMaWD4u371Kay2S4P9tt9S6QuqjwRgN5TeeRBcj6DZP5Y47AlkA2yH5xaYQHd7C 2Kyq9mww8tnqfndX4/RPdlgkYawVt+oq4kFGlG6nSGLtQl3P6UYq1XLepEuM44l3YNF8 Q5B39x/uNa7euH6xP02qdynMialMgOErOKSOj4IzCzNKykn7FLVeLdahdDpOcpVRJHBg MWdWmqppIBT10KIj6whno88y8ZfX0tsikWCfF1fFjI5/rNpXZ7klaj2GVhNSfGkr/cJj ddIg== X-Forwarded-Encrypted: i=1; AJvYcCUV6xDQl77oYeYpicmeOeTygC77AXi0ABQxXZXeDq5B9435qPQSkHpFEvN20xo7lwEc+HH7W3r6yEkHH8rzgawcNMlHjB0SERMYWy29fT4= X-Gm-Message-State: AOJu0Ywu0q5h092L7vlJW3f5IQbIBwvi/xVqEVnz6uUX84k5upyCLTKY Z1lobUCQo1E6QdS/hF/YaJOzaQqryIr2PMfJ8ODx2JghHV/1+lsR/VNBBQBOPYY= X-Received: by 2002:a2e:aa14:0:b0:2d6:fb69:114e with SMTP id bf20-20020a2eaa14000000b002d6fb69114emr1610147ljb.21.1711733089178; Fri, 29 Mar 2024 10:24:49 -0700 (PDT) Received: from [127.0.1.1] ([178.197.223.16]) by smtp.gmail.com with ESMTPSA id v8-20020a05600c470800b004149543c82fsm8491069wmo.39.2024.03.29.10.24.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 10:24:48 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 29 Mar 2024 18:24:31 +0100 Subject: [PATCH 1/7] mmc: sdio: store owner from modules with sdio_register_driver() Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240329-module-owner-sdio-v1-1-e4010b11ccaa@linaro.org> References: <20240329-module-owner-sdio-v1-0-e4010b11ccaa@linaro.org> In-Reply-To: <20240329-module-owner-sdio-v1-0-e4010b11ccaa@linaro.org> To: Ulf Hansson , Marcel Holtmann , Luiz Augusto von Dentz , Matthias Brugger , AngeloGioacchino Del Regno , Kalle Valo , Jeff Johnson , Arend van Spriel , Brian Norris , =?utf-8?q?J=C3=A9r=C3=B4me_Pouiller?= Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-wireless@vger.kernel.org, ath10k@lists.infradead.org, brcm80211@lists.linux.dev, brcm80211-dev-list.pdl@broadcom.com, Krzysztof Kozlowski X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2435; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=qIRA9OHgdR8YIBTlq3gIwcNOO+uS8S8xKPRXlpB/umk=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmBvlXjkx37wyBAQGQOT6sB1E4cO+yYNWsO5eLT rZK/pkw8gKJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZgb5VwAKCRDBN2bmhouD 12Q+D/4r2bAXL0I+Rva8krUxwDKONjhLy/RAdoomv1G8VLLxgxmRMOfpm1Pkxfo9yTW9xR0MrXU F0kxQO2ER7mBPNdakHZtypI3ta0tuqVPymL4CPLM+PlkzV+HQeerwPcrRK47nag4Hp96k1+UihU 2mXL4J96PzaFw1gUSyVp0R/qXXbnYL5mHdRtQODuH3UKrGles3CpAGCcNNJ0IbRGizylng4Gydd P83OjP3n6MPDstQzggysCFJ6SwZ8Xfwx3KGZdIezOx/iHBAKnezGHYRbaM8iRTkVQ+/poTSmkMh IKPK3lqz7DlsykQ5m6hW5ON8FKt0wKzepa7yR5dG0z143oWXLzCGrQXLaclD7preMMjprbuyDpn pI/bzPvl4IsP9DPOXQZP2Zs26nJghFSH2i/U6awAMDC2p6E/fsf4NVw+OQTVm8lkSStZDzV6/Re 7mYjBBMVt3wMA4PN7Gc3uidvAQyYOdEDQeS+iUSlpLZ3V8b9QiiU/QGirxRmvpNHc3rr42O2XPR zJWsf5wVpTTlEGkl4WojuuesQzHs7Pp5xjl2L+GfiQ1vLypFxr31wnjMmqUTbHfhH0SWKcA+jke SaIstusD9D1XQLVDVaUEowVbTM/223LViZ8CIY9saoDAv5BwcQAVxH1XFJA1TkLrg+GybsqZ3X3 rUDwGILZTCIgEyg== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Modules registering driver with sdio_register_driver() might forget to set .owner field. The field is used by some of other kernel parts for reference counting (try_module_get()), so it is expected that drivers will set it. Solve the problem by moving this task away from the drivers to the core code, just like we did for platform_driver in commit 9447057eaff8 ("platform_device: use a macro instead of platform_driver_register"). Since many drivers forget to set the .owner, this effectively will fix them. Examples of fixed drivers are: ath6kl, b43, btsdio.c, ks7010, libertas, MediaTek WiFi drivers, Realtek WiFi drivers, rsi, siano, wilc1000, wl1251 and more. Signed-off-by: Krzysztof Kozlowski --- drivers/mmc/core/sdio_bus.c | 9 ++++++--- include/linux/mmc/sdio_func.h | 5 ++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/mmc/core/sdio_bus.c b/drivers/mmc/core/sdio_bus.c index 71d885fbc228..c5fdfe2325f8 100644 --- a/drivers/mmc/core/sdio_bus.c +++ b/drivers/mmc/core/sdio_bus.c @@ -265,16 +265,19 @@ void sdio_unregister_bus(void) } /** - * sdio_register_driver - register a function driver + * __sdio_register_driver - register a function driver * @drv: SDIO function driver + * @owner: owning module/driver */ -int sdio_register_driver(struct sdio_driver *drv) +int __sdio_register_driver(struct sdio_driver *drv, struct module *owner) { drv->drv.name = drv->name; drv->drv.bus = &sdio_bus_type; + drv->drv.owner = owner; + return driver_register(&drv->drv); } -EXPORT_SYMBOL_GPL(sdio_register_driver); +EXPORT_SYMBOL_GPL(__sdio_register_driver); /** * sdio_unregister_driver - unregister a function driver diff --git a/include/linux/mmc/sdio_func.h b/include/linux/mmc/sdio_func.h index 478855b8e406..fed1f5f4a8d3 100644 --- a/include/linux/mmc/sdio_func.h +++ b/include/linux/mmc/sdio_func.h @@ -106,7 +106,10 @@ struct sdio_driver { .class = (dev_class), \ .vendor = SDIO_ANY_ID, .device = SDIO_ANY_ID -extern int sdio_register_driver(struct sdio_driver *); +/* use a macro to avoid include chaining to get THIS_MODULE */ +#define sdio_register_driver(drv) \ + __sdio_register_driver(drv, THIS_MODULE) +extern int __sdio_register_driver(struct sdio_driver *, struct module *); extern void sdio_unregister_driver(struct sdio_driver *); /** -- 2.34.1