netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: Rob Herring <robh@kernel.org>,
	Grygorii Strashko <grygorii.strashko@ti.com>,
	David Lechner <david@lechnology.com>,
	Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>,
	Kevin Hilman <khilman@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Sekhar Nori <nsekhar@ti.com>,
	Russell King <linux@armlinux.org.uk>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Bartosz Golaszewski <bgolaszewski@baylibre.com>,
	Lukas Wunner <lukas@wunner.de>,
	Srinivas Kandagatla <srinivas.kandagatla@linaro.org>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>,
	netdev@vger.kernel.org, Florian Fainelli <f.fainelli@gmail.com>,
	linux-omap@vger.kernel.org,
	"David S . Miller" <davem@davemloft.net>,
	Dan Carpenter <dan.carpenter@oracle.com>
Subject: Re: [PATCH 00/14] ARM: davinci: step towards removing at24_platform_data
Date: Tue, 26 Jun 2018 10:38:23 +0200	[thread overview]
Message-ID: <20180626083823.GA28068@lunn.ch> (raw)
In-Reply-To: <CAMRc=MejDn=t6EPbKOfhMfRAb_O-5hxtWRyjAWH1mb5BUySrDA@mail.gmail.com>

On Tue, Jun 26, 2018 at 09:44:19AM +0200, Bartosz Golaszewski wrote:
> 2018-06-25 20:02 GMT+02:00 Andrew Lunn <andrew@lunn.ch>:
> >> With my patch 1/14 you'll get -EPROBE_DEFER from nvmem_cell_get() if
> >> the nvmem provider is not yet registered. Will that help in your case?
> >
> > I don't think so. My driver instantiates the AT24 device. So if i get
> > -EPROBE_DEFER, i need to cleanup the probe, and return -EPROBDE_DEFER
> > to the code. Which means i need to remove the AT24 device...
> >
> >        Andrew
> 
> Are you sure this is the correct approach? I understand that you want
> to use something like board files for your machine? Wouldn't it be
> better to register a platform device for at24, register a cell lookup
> and then depend on that cell from your driver?

Hi Bartosz

The machine is based around a Kontron Com Express module, with an
intel Ivy Bridge CPU. This is then placed into a custom carrier board,
which has a number of i2c devices.

I have a platform driver which matches on the DMI system ID for the
Kontron module.

The Com Express module has a PLD which implements i2c, gpio,
etc. There is an MFD for this, which instantiates the i2c-kempld i2c
bus driver.

My platform driver finds this i2c-kempld bus driver. If it does not
exist yet, it return -EPROBE_DEFER. If it is found it instantiates an
at24 device on it. I need to look at the content of the EEPROM to
determine the hardware revision, plus do a checksum.  From that, i
need to instantiates 1 or 2 additional AT24, up to 4 GPIO expanders,
and i2c to spi converter, add some gpio-leds on the gpio expanders,
create a bit-banging MDIO bus, instantiate an Ethernet switch on the
MDIO bus, maybe add an Ethernet switch to the SPI bus, etc.

As you can see, i have a chain of events. I cannot move onto the next
part of the chain until i know the probe for the previous part has
finished. e.g. i cannot add gpio-leds until i know the gpio expander
has probed. But the gpio expander provides a call back, similar to the
at24 setup(). The MDIO bus and the SPI bus has a mechanism to register
an info structure, just like you have done for NVMEM cells. So that
works out.

The weak link in this chain is that first at24 probe, and knowing when
i can access the nvmem cells for the revision and checksum
information. -EPROBE_DEFER does not help me here. I need either some
sort of blocking wait for the cells to become available, or a callback
in a context which allows me to instantiate more devices.

I also have some steps which cannot be undone. You don't provide a
mechanism to unregister the nvmem info structure. The I2C and MDIO
equivalent also does not provide an unregister for bus info. So once i
register the first info structure, i'm past the point of no return. I
cannot return -EPROBE_DEFER because i cannot unregister the info
structures, so that i can register them again the next time the
platform driver gets probed.

	 Andrew

  reply	other threads:[~2018-06-26  8:38 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-25 15:50 [PATCH 00/14] ARM: davinci: step towards removing at24_platform_data Bartosz Golaszewski
2018-06-25 15:50 ` [PATCH 01/14] nvmem: add support for cell lookups Bartosz Golaszewski
2018-06-25 15:50 ` [PATCH 02/14] ARM: davinci: dm365-evm: use nvmem lookup for mac address Bartosz Golaszewski
2018-06-25 15:50 ` [PATCH 03/14] ARM: davinci: dm644-evm: " Bartosz Golaszewski
2018-06-25 15:50 ` [PATCH 04/14] ARM: davinci: dm646x-evm: " Bartosz Golaszewski
2018-06-25 15:50 ` [PATCH 05/14] ARM: davinci: da830-evm: " Bartosz Golaszewski
2018-06-25 15:50 ` [PATCH 06/14] ARM: davinci: mityomapl138: add nvmem cells lookup entries Bartosz Golaszewski
2018-06-25 15:50 ` [PATCH 07/14] net: davinci_emac: use nvmem to retrieve the mac address Bartosz Golaszewski
2018-06-25 23:09   ` Grygorii Strashko
2018-06-25 15:50 ` [PATCH 08/14] ARM: davinci: mityomapl138: don't read the MAC address from machine code Bartosz Golaszewski
2018-06-25 15:50 ` [PATCH 09/14] ARM: davinci: dm365-evm: use device properties for at24 eeprom Bartosz Golaszewski
2018-06-25 15:50 ` [PATCH 10/14] ARM: davinci: da830-evm: " Bartosz Golaszewski
2018-06-25 15:50 ` [PATCH 11/14] ARM: davinci: dm644x-evm: " Bartosz Golaszewski
2018-06-25 15:50 ` [PATCH 12/14] ARM: davinci: dm646x-evm: " Bartosz Golaszewski
2018-06-25 15:50 ` [PATCH 13/14] ARM: davinci: sffsdr: fix the at24 eeprom device name Bartosz Golaszewski
2018-06-25 15:50 ` [PATCH 14/14] ARM: davinci: sffsdr: use device properties for at24 eeprom Bartosz Golaszewski
2018-06-25 17:40 ` [PATCH 00/14] ARM: davinci: step towards removing at24_platform_data Andrew Lunn
2018-06-25 17:46   ` Bartosz Golaszewski
2018-06-25 18:02     ` Andrew Lunn
2018-06-26  7:44       ` Bartosz Golaszewski
2018-06-26  8:38         ` Andrew Lunn [this message]
2018-06-26  9:31           ` Bartosz Golaszewski
2018-06-26 13:21             ` Andrew Lunn
2018-06-26 13:38               ` Bartosz Golaszewski
2018-06-27  9:40                 ` Bartosz Golaszewski

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=20180626083823.GA28068@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=bgolaszewski@baylibre.com \
    --cc=brgl@bgdev.pl \
    --cc=dan.carpenter@oracle.com \
    --cc=davem@davemloft.net \
    --cc=david@lechnology.com \
    --cc=f.fainelli@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=grygorii.strashko@ti.com \
    --cc=ivan.khoronzhuk@linaro.org \
    --cc=khilman@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=lukas@wunner.de \
    --cc=netdev@vger.kernel.org \
    --cc=nsekhar@ti.com \
    --cc=robh@kernel.org \
    --cc=srinivas.kandagatla@linaro.org \
    /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).