Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp687827lqs; Fri, 14 Jun 2024 02:41:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUS2tuH6Lw4wuLfl+Y9phCsTFIk/QL79WtH2I4uROD2sUC1z6U4ffgJLjdMj1pNPzAvrcB9o9XqAVgKFZ7CIKPuy1MpNEpfKBhq4YQokQ== X-Google-Smtp-Source: AGHT+IFNqI5proAmHtSgRpEwKkAbccNZQtjoOBaecKbAVdTtXbvgN+ZSrtQIsptqjAM0r7PiWSLc X-Received: by 2002:a0d:d4d0:0:b0:617:d864:7e0b with SMTP id 00721157ae682-632243251d7mr16567607b3.47.1718358080326; Fri, 14 Jun 2024 02:41:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718358080; cv=pass; d=google.com; s=arc-20160816; b=tbpSRD5Nn+9f3WW10nJ2dI2V/1zypRUKWAGp8mxXHwj7t5tgC9DdmU3TNyAWUu7MGq PB8N8Ge3Xwj/POf1R3cFhWQNPTMB/H87j+qthXqoLtgfP2j8uNfKFSrWpnxO9cnXZO1y svsONnNOrcjvKrvmYC+x1a+EfuK2vNJowRM9TKWGKfr90ymnhD3Bh98bPer5srUE3yAq u/YjekE5K1e5dhxbG9Y/jM/D/PyMpzN02gDSm03kM/64ajpu1duo/Ffm8bRBc9ix9Oeb 9Md6jMaPbnyD+DV2nf9HzrWNSq1Bk6JexI+Knt9gDR0JKvHMMeqcDxEZTSKrN7ia+et6 NziQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:lines:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=gjovAfLfNNrjgn+hX2Bo680EzDz+ywxxK/R3fWfU1eA=; fh=aQagjVBcWQ6H60OAYIZDYwQBXLBKicTEw9aEr6Hb+Ug=; b=WFHbIBmCBDeZpJPrrq1b7TUiKQtCUq/uX6bW9itol5vidqfX0cZtvQFWdb5nRWbcC3 x7ikwkevatY5c0OlHZ32UFIXvmqJfJ8sTm+jhh2tAlsesBq3aHeQIH4FfJTO2yGYXrwn eRgFRI1+dFU10epZyTCIfTEcWNENdcxk9XiXD6W60sdpNkXuNHZ9gW8xlIpdZUUZXOp3 Hp8FbNQeKKY1wFGlZzR5ABIWfB5lbzkhF+q6prYC0lZCMFKY6T3+RQYaKo/4kE14oRtk s8oWavrPhbMD5ewdPnQ22gdsoCYmzHPnAPS1L/QyRsxVdviEsZtMkVpfUez07QfRJ3MB E1xg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HjhGAQQA; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-214652-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-214652-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 6a1803df08f44-6b2a5a338a3si34778866d6.125.2024.06.14.02.41.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 02:41:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-214652-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HjhGAQQA; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-214652-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-214652-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 0E8041C230CB for ; Fri, 14 Jun 2024 09:41:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0BC17192B69; Fri, 14 Jun 2024 09:41:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="HjhGAQQA" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 29A5018413A; Fri, 14 Jun 2024 09:41:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718358073; cv=none; b=Fzom/2t33+5LbkeBMc4ObzqfknSW+a+uzk+YNU1NmHwQkcUMOaxCHrRLey6az+CzXkIqthjNYQLaaGwhU2XxfeW5AIS2lkhACb929hM0Igh3aZYWRjGdjdnpTmchMNFMMz/grV4+Gt/hI4CWbQWPNoC0NwsttWGOw/D5EpzcRLc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718358073; c=relaxed/simple; bh=MYSVS817SJFLybeVanCWjJV+RmOQvgWuvklPkpl1yFA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=elRTfI5Wt7SP2hOGpQXpak2hx4q2V3avNf6tXqVHdvUXzYegccLHkdfAY5SOrw+zwpjxmeDaNkwkF/2REOi/U3DpzhwyvBeHMGMUyUaXEVeEZIJzApOKmubwDEv5kllPsX/vdmbQD8SBuF2OZrMi+WxGNSu1kAhXFoPXU/7T8GI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=HjhGAQQA; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5E450C2BD10; Fri, 14 Jun 2024 09:41:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1718358072; bh=MYSVS817SJFLybeVanCWjJV+RmOQvgWuvklPkpl1yFA=; h=From:To:Cc:Subject:Date:From; b=HjhGAQQAzBRbUBOnaCRkafwendaatuyeCEVezk84p5kl2c8CYRivMdPnStGqjQ6Li s8akvzu+DdyTE59nMm/lgcYvDvgvRK+YRWX545ztGuO+APqKeq1Whts+BbwuFV9QUU Zmsi/D4HVbOopG11sbbhyNQBG+wdRPT9RRQ7kWkA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , Fenghua Yu , Dave Jiang , Vinod Koul , Andy Shevchenko , Petr Tesarik , Alexander Lobakin , dmaengine@vger.kernel.org Subject: [PATCH] driver core: make [device_]driver_attach take a const * Date: Fri, 14 Jun 2024 11:41:02 +0200 Message-ID: <2024061401-rasping-manger-c385@gregkh> X-Mailer: git-send-email 2.45.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Lines: 92 X-Developer-Signature: v=1; a=openpgp-sha256; l=3770; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=MYSVS817SJFLybeVanCWjJV+RmOQvgWuvklPkpl1yFA=; b=owGbwMvMwCRo6H6F97bub03G02pJDGk5AnrhImJZ1m8O9KxlCBXcoCz35N0boxCGrGxpTU1pg f/3rzZ1xLIwCDIxyIopsnzZxnN0f8UhRS9D29Mwc1iZQIYwcHEKwET+uTIsmOSzVyJbxylwtZy6 v+nF75pRF45JMCyYss2m0nxf8ovD3qpR1+ervciIOdoKAA== X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit Change device_driver_attach() and driver_attach() to take a const * to struct device driver as neither of them modify the structure at all. Also, for some odd reason, drivers/dma/idxd/compat.c had a duplicate external reference to device_driver_attach(), so remove that to fix up the build, it should never have had that there in the first place. Cc: "Rafael J. Wysocki" Cc: Fenghua Yu Cc: Dave Jiang Cc: Vinod Koul Cc: Andy Shevchenko Cc: Petr Tesarik Cc: Alexander Lobakin Cc: dmaengine@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/base/dd.c | 9 +++++---- drivers/dma/idxd/compat.c | 1 - include/linux/device.h | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 8ec22229e259..9b745ba54de1 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -1118,7 +1118,7 @@ static void __device_driver_unlock(struct device *dev, struct device *parent) * Manually attach driver to a device. Will acquire both @dev lock and * @dev->parent lock if needed. Returns 0 on success, -ERR on failure. */ -int device_driver_attach(struct device_driver *drv, struct device *dev) +int device_driver_attach(const struct device_driver *drv, struct device *dev) { int ret; @@ -1154,7 +1154,7 @@ static void __driver_attach_async_helper(void *_dev, async_cookie_t cookie) static int __driver_attach(struct device *dev, void *data) { - struct device_driver *drv = data; + const struct device_driver *drv = data; bool async = false; int ret; @@ -1227,9 +1227,10 @@ static int __driver_attach(struct device *dev, void *data) * returns 0 and the @dev->driver is set, we've found a * compatible pair. */ -int driver_attach(struct device_driver *drv) +int driver_attach(const struct device_driver *drv) { - return bus_for_each_dev(drv->bus, NULL, drv, __driver_attach); + /* The (void *) will be put back to const * in __driver_attach() */ + return bus_for_each_dev(drv->bus, NULL, (void *)drv, __driver_attach); } EXPORT_SYMBOL_GPL(driver_attach); diff --git a/drivers/dma/idxd/compat.c b/drivers/dma/idxd/compat.c index 5fd38d1b9d28..a4adb0c17995 100644 --- a/drivers/dma/idxd/compat.c +++ b/drivers/dma/idxd/compat.c @@ -7,7 +7,6 @@ #include #include "idxd.h" -extern int device_driver_attach(struct device_driver *drv, struct device *dev); extern void device_driver_detach(struct device *dev); #define DRIVER_ATTR_IGNORE_LOCKDEP(_name, _mode, _show, _store) \ diff --git a/include/linux/device.h b/include/linux/device.h index 56f266429229..26cb17d49609 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -1177,12 +1177,12 @@ static inline void *dev_get_platdata(const struct device *dev) * Manual binding of a device to driver. See drivers/base/bus.c * for information on use. */ -int __must_check device_driver_attach(struct device_driver *drv, +int __must_check device_driver_attach(const struct device_driver *drv, struct device *dev); int __must_check device_bind_driver(struct device *dev); void device_release_driver(struct device *dev); int __must_check device_attach(struct device *dev); -int __must_check driver_attach(struct device_driver *drv); +int __must_check driver_attach(const struct device_driver *drv); void device_initial_probe(struct device *dev); int __must_check device_reprobe(struct device *dev); base-commit: c6c631d2b72b9390587cd1ee5b7905f8ea5bb1ea -- 2.45.2