From mboxrd@z Thu Jan 1 00:00:00 1970 From: Masahiro Yamada Date: Wed, 19 Nov 2014 18:02:12 +0900 Subject: [U-Boot] [PATCH v2 08/17] dm: i2c: Add a uclass for I2C In-Reply-To: <20141119175634.9405.AA925319@jp.panasonic.com> References: <1415727993-22032-9-git-send-email-sjg@chromium.org> <20141119175634.9405.AA925319@jp.panasonic.com> Message-ID: <20141119180212.653C.AA925319@jp.panasonic.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Simon, Let me correct my question. (I should have read my mail three times before sending.) On Wed, 19 Nov 2014 17:56:34 +0900 Masahiro Yamada wrote: > > > > + > > +int i2c_get_chip(struct udevice *bus, uint chip_addr, struct udevice **devp) > > +{ > > + struct udevice *dev; > > + > > + debug("%s: Searching bus '%s' for address %02x: ", __func__, > > + bus->name, chip_addr); > > + for (device_find_first_child(bus, &dev); dev; > > + device_find_next_child(&dev)) { > > + struct dm_i2c_chip store; > > + struct dm_i2c_chip *chip = dev_get_parentdata(dev); > > + int ret; > > + > > + if (!chip) { > > + chip = &store; > > + i2c_chip_ofdata_to_platdata(gd->fdt_blob, > > + dev->of_offset, chip); > > + } > > + if (chip->chip_addr == chip_addr) { > > + ret = device_probe(dev); > > + debug("found, ret=%d\n", ret); > > + if (ret) > > + return ret; > > + *devp = dev; > > + return 0; > > + } > > > If "chip" is "NULL", i2c_chip_ofdata_to_platdata() is called to create > struct dm_i2c_chip, but it is not thrown away soon. It is not efficient. I mean: but it *is* thrown away soon. Best Regards Masahiro Yamada