On Tue, 21 Apr 2020, Dilip Kota wrote: > > On 4/17/2020 5:35 PM, Lee Jones wrote: > > On Mon, 06 Apr 2020, Dilip Kota wrote: > > > > > Traverse regmap handle entry from firmware node handle. > > > > > > Signed-off-by: Dilip Kota <eswara.kota@xxxxxxxxxxxxxxx> > > > --- > > > Changes on v5: > > > No changes > > > Changes on v5: > > > No changes > > > > > > Changes on v4: > > > No changes > > > > > > drivers/mfd/syscon.c | 8 ++++++++ > > > include/linux/mfd/syscon.h | 6 ++++++ > > > 2 files changed, 14 insertions(+) > > > > > > diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c > > > index 3a97816d0cba..e085c50816b9 100644 > > > --- a/drivers/mfd/syscon.c > > > +++ b/drivers/mfd/syscon.c > > > @@ -178,6 +178,14 @@ struct regmap *device_node_to_regmap(struct device_node *np) > > > } > > > EXPORT_SYMBOL_GPL(device_node_to_regmap); > > > +struct regmap *fwnode_to_regmap(struct fwnode_handle *fwnode) > > > +{ > > > + struct device_node *np = to_of_node(fwnode); > > You are assuming that the fwnode was Device Tree pointer. > > > > The point of a fwnode is that it could be one of multiple types. > > > > What if it was a pointer to an ACPI property? > Yes, i missed to check in other perspective. Thanks for pointing it. > While going through the System control driver to address the query, i > noticed that System Control > driver is talking with 'of' framework only. (No ACPI) > > So, i think to add a defensive check and return error pointer if > 'to_of_node' returns NULL > As System control Driver cannot talk with ACPI, so fwnode_to_regmap() cannot > talk and return error. > > Or, the other option is removing the 'fwnode_to_regmap()' definition itself, > to avoid confusion as fwnode can > point to 'OF', 'ACPI'or 'swnode'. > > But, i feel return error for ACPI or oother, looks better because > 'device_node' has fwnode pointer. And provide description > in the header file, mentioning function is success for 'OF' and returns > error for the rest. I don't think this patch adds much to be honest. Better to just do: device_node_get_regmap(to_of_node(fwnode), false); ... from the call site I think. -- Lee Jones [李琼斯] Linaro Services Technical Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog