Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp6766492rdb; Fri, 15 Dec 2023 07:51:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IFswbqwbDJT6qeVKRuDFkzeQmShcnMXuFNjU9xM59WWBYI8gE+eyfWty+N0JVVMMbhhPL6R X-Received: by 2002:a05:6358:515e:b0:170:17eb:14c2 with SMTP id 30-20020a056358515e00b0017017eb14c2mr7161519rwj.50.1702655469016; Fri, 15 Dec 2023 07:51:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702655468; cv=none; d=google.com; s=arc-20160816; b=mHpdJFX6OE/4McZD3t5rgsXfc6yw/Aqulny802gpxMJ8KvAVNA2CptpjYvRsjuwP5M P305SPNoVrbnDS7CwpfWj5WbEZLAU11KkuPcsV1DZmCwk3q8417yY3hcDkJyw/4XoYmd KERPFjqOcaMp4uxmCBSD4HYakMH2zuDx87GendlT098Kbc3wW6fSBdSjF9TcOzr1F9DW eZq66Z3jpLm/F8id2Fkif4YDDUaDmmWgh6/t3AhLNkVGUBuF8OKcfSxwQVHzsfrjczX3 8DCV5BqGYFL5OHS62xYlTn/jdWFtTGIwnsdo13DjO4gQCruGE39kgZrfDwpSjkaY4dpr Zj7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=N8dOlsoxTXoPqByw9tZA8ePxrHwhjQK4Ev1medPc2Pc=; fh=SO9ERT1/470GP2fOZ/Qrm9+hLtCi/QQbuniZZKUgo/M=; b=c2MwG21grkzza0T7gn9wdg/pS18Zo/11o7fksGMlcRL5sFw73Z573wZw4aGY3u79kr MGGoEaRwhtyOBrTFUQAom56mi6A05U40KP+Rk/cUtM1jPrfsFfdUn2g8L7OPVvS3aXgI JvkCXdlb9hmsvGqN0D9vF5wqUESMBeThR8vxoOlcr2IdE/mv8lgBY3Owdz0/sadzeEBT GG+q2H6O4ObfdhQ+W5b4NSYrFW6bri2J3ykYgtFl+nbV/HY2qZeoqh39u44W6lXxb8Rx 2Sf1HvS4RLj1mxOTeYfwu4EFDnzIGAcnT43yhbRLKxJs4bb09ruUe6U9In6x0SHRop4S 1FpQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-1233-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1233-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=harvard.edu Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id b13-20020a630c0d000000b005bda77217eesi13329044pgl.209.2023.12.15.07.51.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 07:51:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-1233-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-1233-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1233-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=harvard.edu 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 67A65B22AC9 for ; Fri, 15 Dec 2023 15:50:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AD41C381C7; Fri, 15 Dec 2023 15:50:38 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by smtp.subspace.kernel.org (Postfix) with SMTP id D0A783716F for ; Fri, 15 Dec 2023 15:50:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=rowland.harvard.edu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=netrider.rowland.org Received: (qmail 275031 invoked by uid 1000); 15 Dec 2023 10:50:19 -0500 Date: Fri, 15 Dec 2023 10:50:19 -0500 From: Alan Stern To: Yajun Deng Cc: gregkh@linuxfoundation.org, marcel@holtmann.org, johan.hedberg@gmail.com, luiz.dentz@gmail.com, wg@grandegger.com, mkl@pengutronix.de, aspriel@gmail.com, franky.lin@broadcom.com, hante.meuleman@broadcom.com, kvalo@kernel.org, briannorris@chromium.org, mka@chromium.org, johan@kernel.org, oneukum@suse.com, valentina.manea.m@gmail.com, shuah@kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] USB: core: Use device_driver directly in struct usb_driver and usb_device_driver Message-ID: References: <20231215063101.792991-1-yajun.deng@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231215063101.792991-1-yajun.deng@linux.dev> On Fri, Dec 15, 2023 at 02:31:01PM +0800, Yajun Deng wrote: > There is usbdrv_wrap in struct usb_driver and usb_device_driver, > it contains device_driver and for_devices. for_devices is used to > distinguish between device drivers and interface drivers. > > We can compare that if 'drv->probe' is equal to usb_probe_device instead > of using for_devices in is_usb_device_driver(). > > Remove struct usbdrv_wrap, use device_driver directly in struct usb_driver > and usb_device_driver. This makes the code more concise. > > Signed-off-by: Yajun Deng > --- Acked-by: Alan Stern However you should simplify the new test: > --- a/drivers/usb/core/usb.h > +++ b/drivers/usb/core/usb.h > @@ -176,11 +176,12 @@ static inline int is_root_hub(struct usb_device *udev) > } > > /* Do the same for device drivers and interface drivers. */ > - > +extern int usb_probe_device(struct device *dev); > static inline int is_usb_device_driver(struct device_driver *drv) > { > - return container_of(drv, struct usbdrv_wrap, driver)-> > - for_devices; > + if (drv->probe == usb_probe_device) > + return 1; > + return 0; > } This should just be: return drv->probe == usb_probe_device; Alan Stern