All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Rosin <peda@axentia.se>
To: Alexander Shiyan <shc_work@mail.ru>, Yangbo Lu <yangbo.lu@nxp.com>
Cc: Mark Rutland <mark.rutland@arm.com>,
	Xiaobo Xie <xiaobo.xie@nxp.com>,
	Minghuan Lian <minghuan.lian@nxp.com>,
	<linux-i2c@vger.kernel.org>, <linux-clk@vger.kernel.org>,
	Qiang Zhao <qiang.zhao@nxp.com>,
	Russell King <linux@arm.linux.org.uk>,
	Bhupesh Sharma <bhupesh.sharma@freescale.com>,
	Joerg Roedel <joro@8bytes.org>,
	Jochen Friedrich <jochen@scram.de>,
	"Claudiu Manoil" <claudiu.manoil@freescale.com>,
	<devicetree@vger.kernel.org>, "Kumar Gala" <galak@codeaurora.org>,
	Rob Herring <robh+dt@kernel.org>,
	"Santosh Shilimkar" <ssantosh@kernel.org>,
	<linux-arm-kernel@lists.infradead.org>, <netdev@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, Leo Li <leoyang.li@nxp.com>,
	<iommu@lists.linux-foundation.org>,
	<linuxppc-dev@lists.ozlabs.org>, <linux-mmc@vger.kernel.org>,
	<ulf.hansson@linaro.org>, Scott Wood <oss@buserror.net>,
	Arnd Bergmann <arnd@arndb.de>
Subject: Re: [v12, 7/8] base: soc: introduce soc_device_match() interface
Date: Wed, 21 Sep 2016 10:25:08 +0200	[thread overview]
Message-ID: <aa53da4f-205d-cfa1-c85c-00e82e928bbc@axentia.se> (raw)
In-Reply-To: <1474444574.270880035@f136.i.mail.ru>

On 2016-09-21 09:56, Alexander Shiyan wrote:
>> Среда, 21 сентября 2016, 9:57 +03:00 от Yangbo Lu <yangbo.lu@nxp.com>:
>>
>> From: Arnd Bergmann < arnd@arndb.de >
>>
>> We keep running into cases where device drivers want to know the exact
>> version of the a SoC they are currently running on. In the past, this has
>> usually been done through a vendor specific API that can be called by a
>> driver, or by directly accessing some kind of version register that is
>> not part of the device itself but that belongs to a global register area
>> of the chip.
> ...
>> +const struct soc_device_attribute *soc_device_match(
>> +const struct soc_device_attribute *matches)
>> +{
>> +int ret = 0;
>> +
>> +if (!matches)
>> +return NULL;
>> +
>> +while (!ret) {
>> +if (!(matches->machine || matches->family ||
>> +      matches->revision || matches->soc_id))
>> +break;
>> +ret = bus_for_each_dev(&soc_bus_type, NULL, (void *)matches,
>> +       soc_device_match_one);
>> +if (!ret)
>> +matches++;
> 
> So, what happen if next "matches" (after increment) will be NULL?

A crash?

> I think you should use while(matches) at the start of this procedure.

*arrgh*

*If* matches wrap, you indeed have *big* problems. *Elsewhere*

Hint: Please read the review comments on the previous version of this
series [1] before commenting further.

Cheers,
Peter

[1] https://www.mail-archive.com/netdev@vger.kernel.org/msg126617.html

WARNING: multiple messages have this Message-ID (diff)
From: Peter Rosin <peda@axentia.se>
To: Alexander Shiyan <shc_work@mail.ru>, Yangbo Lu <yangbo.lu@nxp.com>
Cc: Mark Rutland <mark.rutland@arm.com>,
	ulf.hansson@linaro.org, Xiaobo Xie <xiaobo.xie@nxp.com>,
	Minghuan Lian <minghuan.lian@nxp.com>,
	linux-i2c@vger.kernel.org, linux-clk@vger.kernel.org,
	Qiang Zhao <qiang.zhao@nxp.com>,
	Russell King <linux@arm.linux.org.uk>,
	Bhupesh Sharma <bhupesh.sharma@freescale.com>,
	Joerg Roedel <joro@8bytes.org>,
	Jochen Friedrich <jochen@scram.de>,
	Claudiu Manoil <claudiu.manoil@freescale.com>,
	devicetree@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>,
	Scott Wood <oss@buserror.net>, Rob Herring <robh+dt@kernel.org>,
	Santosh Shilimkar <ssantosh@kernel.org>,
	linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org,
	linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org,
	Leo Li <leoyang.li@nxp.com>,
	iommu@lists.linux-foundation.org,
	Kumar Gala <galak@codeaurora.org>,
	linuxppc-dev@lists.ozlabs.org
Subject: Re: [v12, 7/8] base: soc: introduce soc_device_match() interface
Date: Wed, 21 Sep 2016 10:25:08 +0200	[thread overview]
Message-ID: <aa53da4f-205d-cfa1-c85c-00e82e928bbc@axentia.se> (raw)
In-Reply-To: <1474444574.270880035@f136.i.mail.ru>

On 2016-09-21 09:56, Alexander Shiyan wrote:
>> Среда, 21 сентября 2016, 9:57 +03:00 от Yangbo Lu <yangbo.lu@nxp.com>:
>>
>> From: Arnd Bergmann < arnd@arndb.de >
>>
>> We keep running into cases where device drivers want to know the exact
>> version of the a SoC they are currently running on. In the past, this has
>> usually been done through a vendor specific API that can be called by a
>> driver, or by directly accessing some kind of version register that is
>> not part of the device itself but that belongs to a global register area
>> of the chip.
> ...
>> +const struct soc_device_attribute *soc_device_match(
>> +const struct soc_device_attribute *matches)
>> +{
>> +int ret = 0;
>> +
>> +if (!matches)
>> +return NULL;
>> +
>> +while (!ret) {
>> +if (!(matches->machine || matches->family ||
>> +      matches->revision || matches->soc_id))
>> +break;
>> +ret = bus_for_each_dev(&soc_bus_type, NULL, (void *)matches,
>> +       soc_device_match_one);
>> +if (!ret)
>> +matches++;
> 
> So, what happen if next "matches" (after increment) will be NULL?

A crash?

> I think you should use while(matches) at the start of this procedure.

*arrgh*

*If* matches wrap, you indeed have *big* problems. *Elsewhere*

Hint: Please read the review comments on the previous version of this
series [1] before commenting further.

Cheers,
Peter

[1] https://www.mail-archive.com/netdev@vger.kernel.org/msg126617.html



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

WARNING: multiple messages have this Message-ID (diff)
From: Peter Rosin <peda@axentia.se>
To: Alexander Shiyan <shc_work@mail.ru>, Yangbo Lu <yangbo.lu@nxp.com>
Cc: Mark Rutland <mark.rutland@arm.com>,
	ulf.hansson@linaro.org, Xiaobo Xie <xiaobo.xie@nxp.com>,
	Minghuan Lian <minghuan.lian@nxp.com>,
	linux-i2c@vger.kernel.org, linux-clk@vger.kernel.org,
	Qiang Zhao <qiang.zhao@nxp.com>,
	Russell King <linux@arm.linux.org.uk>,
	Bhupesh Sharma <bhupesh.sharma@freescale.com>,
	Joerg Roedel <joro@8bytes.org>,
	Jochen Friedrich <jochen@scram.de>,
	Claudiu Manoil <claudiu.manoil@freescale.com>,
	devicetree@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>,
	Scott Wood <oss@buserror.net>, Rob Herring <robh+dt@kernel.org>,
	Santosh Shilimkar <ssantosh@kernel.org>,
	linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org,
	linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org,
	Leo Li <leoyang.li@nxp.com>,
	iommu@lists.linux-foundation.org,
	Kumar Gala <galak@codeaurora.org>,
	linuxppc-dev@lists.ozlabs.org
Subject: Re: [v12, 7/8] base: soc: introduce soc_device_match() interface
Date: Wed, 21 Sep 2016 10:25:08 +0200	[thread overview]
Message-ID: <aa53da4f-205d-cfa1-c85c-00e82e928bbc@axentia.se> (raw)
In-Reply-To: <1474444574.270880035@f136.i.mail.ru>

T24gMjAxNi0wOS0yMSAwOTo1NiwgQWxleGFuZGVyIFNoaXlhbiB3cm90ZToKPj4g0KHRgNC10LTQ
sCwgMjEg0YHQtdC90YLRj9Cx0YDRjyAyMDE2LCA5OjU3ICswMzowMCDQvtGCIFlhbmdibyBMdSA8
eWFuZ2JvLmx1QG54cC5jb20+Ogo+Pgo+PiBGcm9tOiBBcm5kIEJlcmdtYW5uIDwgYXJuZEBhcm5k
Yi5kZSA+Cj4+Cj4+IFdlIGtlZXAgcnVubmluZyBpbnRvIGNhc2VzIHdoZXJlIGRldmljZSBkcml2
ZXJzIHdhbnQgdG8ga25vdyB0aGUgZXhhY3QKPj4gdmVyc2lvbiBvZiB0aGUgYSBTb0MgdGhleSBh
cmUgY3VycmVudGx5IHJ1bm5pbmcgb24uIEluIHRoZSBwYXN0LCB0aGlzIGhhcwo+PiB1c3VhbGx5
IGJlZW4gZG9uZSB0aHJvdWdoIGEgdmVuZG9yIHNwZWNpZmljI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b2YgdGhpcyBwcm9jZWR1cmUuCgoqYXJyZ2gqCgoqSWYqIG1hdGNoZXMgd3JhcCwgeW91IGlu
ZGVlZCBoYXZlICpiaWcqIHByb2JsZW1zLiAqRWxzZXdoZXJlKgoKSGludDogUGxlYXNlIHJlYWQg
dGhlIHJldmlldyBjb21tZW50cyBvbiB0aGUgcHJldmlvdXMgdmVyc2lvbiBvZiB0aGlzCnNlcmll
cyBbMV0gYmVmb3JlIGNvbW1lbnRpbmcgZnVydGhlci4KCkNoZWVycywKUGV0ZXIKClsxXSBodHRw
czovL3d3dy5tYWlsLWFyY2hpdmUuY29tL25ldGRldkB2Z2VyLmtlcm5lbC5vcmcvbXNnMTI2NjE3
Lmh0bWwKCgoKX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18K
bGludXgtYXJtLWtlcm5lbCBtYWlsaW5nIGxpc3QKbGludXgtYXJtLWtlcm5lbEBsaXN0cy5pbmZy
YWRlYWQub3JnCmh0dHA6Ly9saXN0cy5pbmZyYWRlYWQub3JnL21haWxtYW4vbGlzdGluZm8vbGlu
dXgtYXJtLWtlcm5lbAo=

WARNING: multiple messages have this Message-ID (diff)
From: peda@axentia.se (Peter Rosin)
To: linux-arm-kernel@lists.infradead.org
Subject: [v12, 7/8] base: soc: introduce soc_device_match() interface
Date: Wed, 21 Sep 2016 10:25:08 +0200	[thread overview]
Message-ID: <aa53da4f-205d-cfa1-c85c-00e82e928bbc@axentia.se> (raw)
In-Reply-To: <1474444574.270880035@f136.i.mail.ru>

On 2016-09-21 09:56, Alexander Shiyan wrote:
>> ?????, 21 ???????? 2016, 9:57 +03:00 ?? Yangbo Lu <yangbo.lu@nxp.com>:
>>
>> From: Arnd Bergmann < arnd@arndb.de >
>>
>> We keep running into cases where device drivers want to know the exact
>> version of the a SoC they are currently running on. In the past, this has
>> usually been done through a vendor specific API that can be called by a
>> driver, or by directly accessing some kind of version register that is
>> not part of the device itself but that belongs to a global register area
>> of the chip.
> ...
>> +const struct soc_device_attribute *soc_device_match(
>> +const struct soc_device_attribute *matches)
>> +{
>> +int ret = 0;
>> +
>> +if (!matches)
>> +return NULL;
>> +
>> +while (!ret) {
>> +if (!(matches->machine || matches->family ||
>> +      matches->revision || matches->soc_id))
>> +break;
>> +ret = bus_for_each_dev(&soc_bus_type, NULL, (void *)matches,
>> +       soc_device_match_one);
>> +if (!ret)
>> +matches++;
> 
> So, what happen if next "matches" (after increment) will be NULL?

A crash?

> I think you should use while(matches) at the start of this procedure.

*arrgh*

*If* matches wrap, you indeed have *big* problems. *Elsewhere*

Hint: Please read the review comments on the previous version of this
series [1] before commenting further.

Cheers,
Peter

[1] https://www.mail-archive.com/netdev at vger.kernel.org/msg126617.html

  reply	other threads:[~2016-09-21  8:41 UTC|newest]

Thread overview: 92+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-21  6:57 [v12, 0/8] Fix eSDHC host version register bug Yangbo Lu
2016-09-21  6:57 ` Yangbo Lu
2016-09-21  6:57 ` Yangbo Lu
2016-09-21  6:57 ` Yangbo Lu
2016-09-21  6:57 ` [v12, 1/8] dt: bindings: update Freescale DCFG compatible Yangbo Lu
2016-09-21  6:57   ` Yangbo Lu
2016-09-21  6:57   ` Yangbo Lu
2016-09-21  6:57   ` Yangbo Lu
2016-09-21  6:57 ` [v12, 2/8] ARM64: dts: ls2080a: add device configuration node Yangbo Lu
2016-09-21  6:57   ` Yangbo Lu
2016-09-21  6:57   ` Yangbo Lu
2016-09-21  6:57   ` Yangbo Lu
2016-09-21  6:57   ` Yangbo Lu
2016-09-21  6:57 ` [v12, 3/8] dt: bindings: move guts devicetree doc out of powerpc directory Yangbo Lu
2016-09-21  6:57   ` Yangbo Lu
2016-09-21  6:57   ` Yangbo Lu
2016-09-21  6:57   ` Yangbo Lu
2016-09-21  6:57   ` Yangbo Lu
2016-09-21  6:57 ` [v12, 4/8] powerpc/fsl: move mpc85xx.h to include/linux/fsl Yangbo Lu
2016-09-21  6:57   ` Yangbo Lu
2016-09-21  6:57   ` Yangbo Lu
2016-09-21  6:57   ` Yangbo Lu
2016-09-21  6:57   ` Yangbo Lu
2016-09-21  6:57 ` [v12, 5/8] soc: fsl: add GUTS driver for QorIQ platforms Yangbo Lu
2016-09-21  6:57   ` Yangbo Lu
2016-09-21  6:57   ` Yangbo Lu
2016-09-21  6:57   ` Yangbo Lu
2016-09-21  6:57   ` Yangbo Lu
2016-10-26 17:06   ` Scott Wood
2016-10-26 17:06     ` Scott Wood
2016-10-27  4:34     ` Y.B. Lu
2016-10-27  4:34       ` Y.B. Lu
2016-10-27  4:34       ` Y.B. Lu
2016-10-27  4:34       ` Y.B. Lu
2016-10-27  4:34       ` Y.B. Lu
2016-10-27  4:34       ` Y.B. Lu
2016-09-21  6:57 ` [v12, 6/8] MAINTAINERS: add entry for Freescale SoC drivers Yangbo Lu
2016-09-21  6:57   ` Yangbo Lu
2016-09-21  6:57   ` Yangbo Lu
2016-09-21  6:57   ` Yangbo Lu
2016-09-21  6:57   ` Yangbo Lu
2016-09-21  6:57 ` [v12, 7/8] base: soc: introduce soc_device_match() interface Yangbo Lu
2016-09-21  6:57   ` Yangbo Lu
2016-09-21  6:57   ` Yangbo Lu
2016-09-21  6:57   ` Yangbo Lu
2016-09-21  7:56   ` Alexander Shiyan
2016-09-21  7:56     ` Alexander Shiyan
2016-09-21  7:56     ` Alexander Shiyan
2016-09-21  7:56     ` Alexander Shiyan
2016-09-21  7:56     ` Alexander Shiyan
2016-09-21  7:56     ` Alexander Shiyan
2016-09-21  8:25     ` Peter Rosin [this message]
2016-09-21  8:25       ` Peter Rosin
2016-09-21  8:25       ` Peter Rosin
2016-09-21  8:25       ` Peter Rosin
2016-09-21  6:57 ` [v12, 8/8] mmc: sdhci-of-esdhc: fix host version for T4240-R1.0-R2.0 Yangbo Lu
2016-09-21  6:57   ` Yangbo Lu
2016-09-21  6:57   ` Yangbo Lu
2016-09-21  6:57   ` Yangbo Lu
2016-09-21  6:57   ` Yangbo Lu
2016-09-26  3:14 ` [v12, 0/8] Fix eSDHC host version register bug Y.B. Lu
2016-09-26  3:14   ` Y.B. Lu
2016-09-26  3:14   ` Y.B. Lu
2016-09-26  3:14   ` Y.B. Lu
2016-09-26  3:14   ` Y.B. Lu
2016-10-08  3:28 ` Y.B. Lu
2016-10-08  3:28   ` Y.B. Lu
2016-10-08  3:28   ` Y.B. Lu
2016-10-08  3:28   ` Y.B. Lu
2016-10-08  3:28   ` Y.B. Lu
2016-10-18 10:47 ` Ulf Hansson
2016-10-18 10:47   ` Ulf Hansson
2016-10-18 10:47   ` Ulf Hansson
2016-10-18 10:47   ` Ulf Hansson
2016-10-18 10:47   ` Ulf Hansson
2016-10-19  2:40   ` Y.B. Lu
2016-10-19  2:40     ` Y.B. Lu
2016-10-19  2:40     ` Y.B. Lu
2016-10-19  2:40     ` Y.B. Lu
2016-10-19  2:40     ` Y.B. Lu
2016-10-19  2:40     ` Y.B. Lu
2016-10-19  2:47   ` Y.B. Lu
2016-10-19  2:47     ` Y.B. Lu
2016-10-19  2:47     ` Y.B. Lu
2016-10-19  2:47     ` Y.B. Lu
2016-10-19  2:47     ` Y.B. Lu
2016-10-19  2:47     ` Y.B. Lu
     [not found]     ` <AM5PR0401MB2529BA70C6E7AF7C71631A47F8D20-oQ3wXcTHOqqGPub0A97BiI3W/0Ik+aLCnBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>
2016-10-19  8:27       ` gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r
2016-10-19  8:27         ` gregkh at linuxfoundation.org
2016-10-19  8:27         ` gregkh
2016-10-19  8:27         ` gregkh
2016-10-19  8:27         ` gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r

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=aa53da4f-205d-cfa1-c85c-00e82e928bbc@axentia.se \
    --to=peda@axentia.se \
    --cc=arnd@arndb.de \
    --cc=bhupesh.sharma@freescale.com \
    --cc=claudiu.manoil@freescale.com \
    --cc=devicetree@vger.kernel.org \
    --cc=galak@codeaurora.org \
    --cc=iommu@lists.linux-foundation.org \
    --cc=jochen@scram.de \
    --cc=joro@8bytes.org \
    --cc=leoyang.li@nxp.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mark.rutland@arm.com \
    --cc=minghuan.lian@nxp.com \
    --cc=netdev@vger.kernel.org \
    --cc=oss@buserror.net \
    --cc=qiang.zhao@nxp.com \
    --cc=robh+dt@kernel.org \
    --cc=shc_work@mail.ru \
    --cc=ssantosh@kernel.org \
    --cc=ulf.hansson@linaro.org \
    --cc=xiaobo.xie@nxp.com \
    --cc=yangbo.lu@nxp.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.