lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Wed, 30 Oct 2013 12:45:57 -0700
From:	Stephen Boyd <sboyd@...eaurora.org>
To:	Josh Cartwright <joshc@...eaurora.org>
CC:	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
	linux-arm-msm@...r.kernel.org,
	Sagar Dharia <sdharia@...eaurora.org>,
	Gilad Avidov <gavidov@...eaurora.org>,
	Michael Bohan <mbohan@...eaurora.org>
Subject: Re: [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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ