From mboxrd@z Thu Jan 1 00:00:00 1970 From: Grant Likely Subject: Re: [PATCH V5 2/2] mfd: stmpe: Update DT support in stmpe driver Date: Fri, 07 Dec 2012 13:44:22 +0000 Message-ID: <20121207134422.738A23E0B87@localhost> References: <2dcd7cb4c4022fa24b5328974e4226f5aaf89419.1354199865.git.viresh.kumar@linaro.org> <121653def4e985b0c1b59045637dd4518f97e73a.1354199865.git.viresh.kumar@linaro.org> <20121130105731.GN3176@sortiz-mobl> <20121130154542.GG23648@gmail.com> <20121205224203.691153E0E22@localhost> Return-path: In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org To: Viresh Kumar Cc: Lee Jones , Samuel Ortiz , rabin.vincent@stericsson.com, shiraz.hashim@st.com, devicetree-discuss@lists.ozlabs.org, linux-kernel@vger.kernel.org, spear-devel@list.st.com, linus.walleij@linaro.org, Vipul Kumar Samar List-Id: devicetree@vger.kernel.org On Thu, 6 Dec 2012 08:06:20 +0530, Viresh Kumar wrote: > On 6 December 2012 04:12, Grant Likely wrote: > > On Sat, 1 Dec 2012 00:33:46 +0530, Viresh Kumar wrote: > >> This first tries to match the table my patch added, _BUT_ the string will > >> never match as we had "st,stmpe810" in table and "stmpe810" in dev. > > > > of_driver_match_device() matches against the compatible list in > > dev->of_node, not against the device name. So, if the compatible > > property has a string that is in the table, then it really should match > > against it. > > Grant, but isn't it true that the final device's name would not be the DT > way of names? It would simply be "stmpe810" for us and so if we have > multiple instances of stmpe on a board, we need to distinguish them > ourselves? One way for that was passing id for these instances, which > would finally be used, when we create platform devices for sub-modules > of stmpe (gpio, keypad, ts, etc). of_modalias_node() is based on a *heruistic*. It is a best-effort attempt to convert the node's compatible lists into a string that will match against an existing driver. In the simple case it works because historically i2c has used the chip name for the driver name. We get lucky and a lot of drivers will work with DT without changes. However, it is in no way guaranteed. Sometimes the strings won't line up or a certain silicon vendor will have an extra errata or feature. In that case it makes sense to use a DT match table that can parse the entries in the compatible list. Or a driver can call of_ helper functions. For example, it might call of_alias_get_id() to figure out which device id it needs. That's why the full DT parsing exists. It's the fallback when the simple heuristic fails. Only use it when you need to. g.