lkml.org 
[lkml]   [2013]   [Oct]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v3 02/10] spmi: Linux driver framework for SPMI
On 10/30/13 12:37, Josh Cartwright wrote:
> On Tue, Oct 29, 2013 at 09:52:15AM -0700, Stephen Boyd wrote:
>> On 10/28/13 11:12, Josh Cartwright wrote:
>>> +int spmi_register_read(struct spmi_device *sdev, u8 addr, u8 *buf)
>>> +{
>>> + /* 5-bit register address */
>>> + if (addr > 0x1F)
>> Perhaps 0x1f should be a #define.
> Is 0x1F with the comment above it not clear enough?

It triggered my 'magic number used twice' alarm. I'm ok with it either way.

>>> +struct spmi_controller *spmi_controller_alloc(struct device *parent,
>>> + size_t size)
>>> +{
>>> + struct spmi_controller *ctrl;
>>> + int id;
>>> +
>>> + if (WARN_ON(!parent))
>>> + return NULL;
>>> +
>>> + ctrl = kzalloc(sizeof(*ctrl) + size, GFP_KERNEL);
>>> + if (!ctrl)
>>> + return NULL;
>>> +
>>> + device_initialize(&ctrl->dev);
>>> + ctrl->dev.type = &spmi_ctrl_type;
>>> + ctrl->dev.bus = &spmi_bus_type;
>>> + ctrl->dev.parent = parent;
>>> + ctrl->dev.of_node = parent->of_node;
>>> + spmi_controller_set_drvdata(ctrl, &ctrl[1]);
>>> +
>>> + idr_preload(GFP_KERNEL);
>>> + mutex_lock(&ctrl_idr_lock);
>>> + id = idr_alloc(&ctrl_idr, ctrl, 0, 0, GFP_NOWAIT);
>>> + mutex_unlock(&ctrl_idr_lock);
>>> + idr_preload_end();
>> This can just be:
>>
>> mutex_lock(&ctrl_idr_lock);
>> id = idr_alloc(&ctrl_idr, ctrl, 0, 0, GFP_KERNEL);
>> mutex_unlock(&ctrl_idr_lock);
> Actually, I'm wondering if it's just easier to leverage the simpler
> ida_simple_* APIs instead.

Yes that also works.

--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation



\
 
 \ /
  Last update: 2013-10-30 21:21    [W:0.088 / U:0.248 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site