linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: Uwe Kleine-K??nig <u.kleine-koenig@pengutronix.de>
Cc: Bjorn Helgaas <helgaas@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-pci@vger.kernel.org, kernel@pengutronix.de,
	Michael Ellerman <mpe@ellerman.id.au>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Paul Mackerras <paulus@samba.org>,
	Rafa?? Mi??ecki <zajec5@gmail.com>,
	Zhou Wang <wangzhou1@hisilicon.com>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	"David S. Miller" <davem@davemloft.net>,
	Yisen Zhuang <yisen.zhuang@huawei.com>,
	Salil Mehta <salil.mehta@huawei.com>,
	Jakub Kicinski <kuba@kernel.org>,
	Vadym Kochan <vkochan@marvell.com>,
	Taras Chornyi <tchornyi@marvell.com>,
	Jiri Pirko <jiri@nvidia.com>, Ido Schimmel <idosch@nvidia.com>,
	Simon Horman <simon.horman@corigine.com>,
	Michael Buesch <m@bues.ch>, Oliver O'Halloran <oohall@gmail.com>,
	Jesse Brandeburg <jesse.brandeburg@intel.com>,
	Alexander Duyck <alexanderduyck@fb.com>,
	linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org,
	linux-wireless@vger.kernel.org, linux-crypto@vger.kernel.org,
	netdev@vger.kernel.org, oss-drivers@corigine.com
Subject: Re: [PATCH v3 4/8] PCI: replace pci_dev::driver usage that gets the driver name
Date: Thu, 12 Aug 2021 08:07:20 +0100	[thread overview]
Message-ID: <YRTIqGm5Dr8du7a7@infradead.org> (raw)
In-Reply-To: <20210811080637.2596434-5-u.kleine-koenig@pengutronix.de>

On Wed, Aug 11, 2021 at 10:06:33AM +0200, Uwe Kleine-K??nig wrote:
>  static inline const char *eeh_driver_name(struct pci_dev *pdev)
>  {
> -	return (pdev && pdev->driver) ? pdev->driver->name : "<null>";
> +	const char *drvstr = pdev ? dev_driver_string(&pdev->dev) : "";
> +
> +	if (*drvstr == '\0')
> +		return "<null>";
> +
> +	return drvstr;

This looks rather obsfucated due to the fact that dev_driver_string
never returns '\0', and due to the strange mix of a tenary operation
and the if on a related condition.


>  }
>  
>  #endif /* CONFIG_EEH */
> diff --git a/drivers/bcma/host_pci.c b/drivers/bcma/host_pci.c
> index 69c10a7b7c61..dc2ffa686964 100644
> --- a/drivers/bcma/host_pci.c
> +++ b/drivers/bcma/host_pci.c
> @@ -175,9 +175,10 @@ static int bcma_host_pci_probe(struct pci_dev *dev,
>  	if (err)
>  		goto err_kfree_bus;
>  
> -	name = dev_name(&dev->dev);
> -	if (dev->driver && dev->driver->name)
> -		name = dev->driver->name;
> +	name = dev_driver_string(&dev->dev);
> +	if (*name == '\0')
> +		name = dev_name(&dev->dev);

Where does this '\0' check come from?

> +
> +	name = dev_driver_string(&dev->dev);
> +	if (*name == '\0')
> +		name = dev_name(&dev->dev);
> +

More of this weirdness.

  reply	other threads:[~2021-08-12  7:09 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-11  8:06 [PATCH v3 0/8] PCI: Drop duplicated tracking of a pci_dev's bound driver Uwe Kleine-König
2021-08-11  8:06 ` [PATCH v3 1/8] PCI: Simplify pci_device_remove() Uwe Kleine-König
2021-08-12  6:44   ` Christoph Hellwig
2021-08-11  8:06 ` [PATCH v3 2/8] PCI: Drop useless check from pci_device_probe() Uwe Kleine-König
2021-08-12  6:46   ` Christoph Hellwig
2021-08-11  8:06 ` [PATCH v3 3/8] xen/pci: Drop some checks that are always true Uwe Kleine-König
2021-08-11  9:51   ` Uwe Kleine-König
2021-08-12  6:50   ` Christoph Hellwig
2021-08-11  8:06 ` [PATCH v3 4/8] PCI: replace pci_dev::driver usage that gets the driver name Uwe Kleine-König
2021-08-12  7:07   ` Christoph Hellwig [this message]
2021-08-12  8:14     ` Uwe Kleine-König
2021-08-14  8:38       ` Christoph Hellwig
2021-08-11  8:06 ` [PATCH v3 5/8] scsi: message: fusion: Remove unused parameter of mpt_pci driver's probe() Uwe Kleine-König
2021-08-12  2:51   ` Martin K. Petersen
2021-08-12  7:10   ` Christoph Hellwig
2021-08-11  8:06 ` [PATCH v3 6/8] crypto: qat - simplify adf_enable_aer() Uwe Kleine-König
2021-08-11 11:56   ` Giovanni Cabiddu
2021-08-11 21:34     ` Uwe Kleine-König
2021-08-12 14:43       ` Giovanni Cabiddu
2021-08-13  8:15         ` Uwe Kleine-König
2021-08-11  8:06 ` [PATCH v3 7/8] PCI: Replace pci_dev::driver usage by pci_dev::dev.driver Uwe Kleine-König
2021-08-11 14:07   ` Boris Ostrovsky
2021-08-11  8:06 ` [PATCH v3 8/8] PCI: Drop duplicated tracking of a pci_dev's bound driver Uwe Kleine-König

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YRTIqGm5Dr8du7a7@infradead.org \
    --to=hch@infradead.org \
    --cc=alexanderduyck@fb.com \
    --cc=benh@kernel.crashing.org \
    --cc=davem@davemloft.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=helgaas@kernel.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=idosch@nvidia.com \
    --cc=jesse.brandeburg@intel.com \
    --cc=jiri@nvidia.com \
    --cc=kernel@pengutronix.de \
    --cc=kuba@kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=m@bues.ch \
    --cc=mpe@ellerman.id.au \
    --cc=netdev@vger.kernel.org \
    --cc=oohall@gmail.com \
    --cc=oss-drivers@corigine.com \
    --cc=paulus@samba.org \
    --cc=salil.mehta@huawei.com \
    --cc=simon.horman@corigine.com \
    --cc=tchornyi@marvell.com \
    --cc=u.kleine-koenig@pengutronix.de \
    --cc=vkochan@marvell.com \
    --cc=wangzhou1@hisilicon.com \
    --cc=yisen.zhuang@huawei.com \
    --cc=zajec5@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).