From mboxrd@z Thu Jan 1 00:00:00 1970 From: Suman Anna Subject: Re: [PATCHv6 5/5] hwspinlock/omap: add support for dt nodes Date: Wed, 12 Nov 2014 13:50:15 -0600 Message-ID: <5463B9F7.8040105@ti.com> References: <1410553499-55951-1-git-send-email-s-anna@ti.com> <1410553499-55951-6-git-send-email-s-anna@ti.com> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: Sender: devicetree-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Ohad Ben-Cohen Cc: Mark Rutland , Kumar Gala , Tony Lindgren , Josh Cartwright , Bjorn Andersson , "devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org" , "linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org" , "linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org" , linux-arm List-Id: linux-omap@vger.kernel.org Hi Ohad, On 11/12/2014 01:14 PM, Ohad Ben-Cohen wrote: > Hi Suman, > > On Fri, Sep 12, 2014 at 11:24 PM, Suman Anna wrote: >> static int omap_hwspinlock_probe(struct platform_device *pdev) >> { >> - struct hwspinlock_pdata *pdata = pdev->dev.platform_data; >> + struct device_node *node = pdev->dev.of_node; >> struct hwspinlock_device *bank; >> struct hwspinlock *hwlock; >> struct resource *res; >> void __iomem *io_base; >> - int num_locks, i, ret; >> + int num_locks, i, ret, base_id; >> >> - if (!pdata) >> + if (!node) >> return -ENODEV; >> >> + ret = of_hwspin_lock_get_base_id(node); >> + if (ret < 0 && ret != -EINVAL) >> + return -ENODEV; >> + base_id = (ret > 0 ? ret : 0); > > Does this mean you allow nodes not to have the base_id property? How > do we protect against multiple nodes not having a base_id property > then? > > Implicitly assuming a base_id value (zero in this case) may not be always safe. None of the OMAPs have multiple IP instances, and as such the base-id is an optional property. I have made this change to make sure we atleast attempt to use the value if mentioned in DT and not hard-coding the value to begin with (going by the optional property semantics). If and when multiple instances get added and a secondary node doesn't add the property, the node will not be registered with the core due to an overlap failure. Here is the previous version [1] for reference. regards Suman [1] https://patchwork.kernel.org/patch/4096881/ -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html From mboxrd@z Thu Jan 1 00:00:00 1970 From: s-anna@ti.com (Suman Anna) Date: Wed, 12 Nov 2014 13:50:15 -0600 Subject: [PATCHv6 5/5] hwspinlock/omap: add support for dt nodes In-Reply-To: References: <1410553499-55951-1-git-send-email-s-anna@ti.com> <1410553499-55951-6-git-send-email-s-anna@ti.com> Message-ID: <5463B9F7.8040105@ti.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org Hi Ohad, On 11/12/2014 01:14 PM, Ohad Ben-Cohen wrote: > Hi Suman, > > On Fri, Sep 12, 2014 at 11:24 PM, Suman Anna wrote: >> static int omap_hwspinlock_probe(struct platform_device *pdev) >> { >> - struct hwspinlock_pdata *pdata = pdev->dev.platform_data; >> + struct device_node *node = pdev->dev.of_node; >> struct hwspinlock_device *bank; >> struct hwspinlock *hwlock; >> struct resource *res; >> void __iomem *io_base; >> - int num_locks, i, ret; >> + int num_locks, i, ret, base_id; >> >> - if (!pdata) >> + if (!node) >> return -ENODEV; >> >> + ret = of_hwspin_lock_get_base_id(node); >> + if (ret < 0 && ret != -EINVAL) >> + return -ENODEV; >> + base_id = (ret > 0 ? ret : 0); > > Does this mean you allow nodes not to have the base_id property? How > do we protect against multiple nodes not having a base_id property > then? > > Implicitly assuming a base_id value (zero in this case) may not be always safe. None of the OMAPs have multiple IP instances, and as such the base-id is an optional property. I have made this change to make sure we atleast attempt to use the value if mentioned in DT and not hard-coding the value to begin with (going by the optional property semantics). If and when multiple instances get added and a secondary node doesn't add the property, the node will not be registered with the core due to an overlap failure. Here is the previous version [1] for reference. regards Suman [1] https://patchwork.kernel.org/patch/4096881/ From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753564AbaKLTur (ORCPT ); Wed, 12 Nov 2014 14:50:47 -0500 Received: from arroyo.ext.ti.com ([192.94.94.40]:57938 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753248AbaKLTup (ORCPT ); Wed, 12 Nov 2014 14:50:45 -0500 Message-ID: <5463B9F7.8040105@ti.com> Date: Wed, 12 Nov 2014 13:50:15 -0600 From: Suman Anna User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: Ohad Ben-Cohen CC: Mark Rutland , Kumar Gala , Tony Lindgren , Josh Cartwright , Bjorn Andersson , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-omap@vger.kernel.org" , linux-arm Subject: Re: [PATCHv6 5/5] hwspinlock/omap: add support for dt nodes References: <1410553499-55951-1-git-send-email-s-anna@ti.com> <1410553499-55951-6-git-send-email-s-anna@ti.com> In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Ohad, On 11/12/2014 01:14 PM, Ohad Ben-Cohen wrote: > Hi Suman, > > On Fri, Sep 12, 2014 at 11:24 PM, Suman Anna wrote: >> static int omap_hwspinlock_probe(struct platform_device *pdev) >> { >> - struct hwspinlock_pdata *pdata = pdev->dev.platform_data; >> + struct device_node *node = pdev->dev.of_node; >> struct hwspinlock_device *bank; >> struct hwspinlock *hwlock; >> struct resource *res; >> void __iomem *io_base; >> - int num_locks, i, ret; >> + int num_locks, i, ret, base_id; >> >> - if (!pdata) >> + if (!node) >> return -ENODEV; >> >> + ret = of_hwspin_lock_get_base_id(node); >> + if (ret < 0 && ret != -EINVAL) >> + return -ENODEV; >> + base_id = (ret > 0 ? ret : 0); > > Does this mean you allow nodes not to have the base_id property? How > do we protect against multiple nodes not having a base_id property > then? > > Implicitly assuming a base_id value (zero in this case) may not be always safe. None of the OMAPs have multiple IP instances, and as such the base-id is an optional property. I have made this change to make sure we atleast attempt to use the value if mentioned in DT and not hard-coding the value to begin with (going by the optional property semantics). If and when multiple instances get added and a secondary node doesn't add the property, the node will not be registered with the core due to an overlap failure. Here is the previous version [1] for reference. regards Suman [1] https://patchwork.kernel.org/patch/4096881/