Thread (18 messages) 18 messages, 6 authors, 2012-06-06

[PATCH] slimbus: Linux driver framework for SLIMbus.

From: joe@perches.com (Joe Perches)
Date: 2012-06-03 16:34:24
Also in: linux-arm-msm, linux-devicetree, lkml

On Tue, 2012-05-29 at 19:11 -0600, Sagar Dharia wrote:
SLIMbus (Serial Low Power Interchip Media Bus) is a specification
developed by MIPI (Mobile Industry Processor Interface) alliance.
Just a few trivial notes before stopped reading as it was
very long.
quoted hunk ↗ jump to hunk
diff --git a/drivers/of/of_slimbus.c b/drivers/of/of_slimbus.c
[]
+		name = kzalloc(SLIMBUS_NAME_SIZE, GFP_KERNEL);
+		if (!name) {
+			dev_err(&ctrl->dev, "of_slim: out of memory");
OOM messages aren't necessary as they are reported
with a dump_stack in the alloc functions and please
make sure all messages are newline terminated.

[]
+		binfo = krealloc(binfo, (n + 1) * sizeof(struct slim_boardinfo),
+					GFP_KERNEL);
Reallocs should _always_ use a new temporary.
Otherwise, there will be a memory leak of the
original pointer memory on failure.
quoted hunk ↗ jump to hunk
diff --git a/drivers/slimbus/slimbus.c b/drivers/slimbus/slimbus.c
[]
+	if (ctrl->nchans) {
+		ctrl->chans = kzalloc(ctrl->nchans * sizeof(struct slim_ich),
+					GFP_KERNEL);
please use kcalloc where appropriate.
+		ctrl->sched.chc1 =
+			kzalloc(ctrl->nchans * sizeof(struct slim_ich *),
+			GFP_KERNEL);
[]
+		ctrl->sched.chc3 =
+			kzalloc(ctrl->nchans * sizeof(struct slim_ich *),
+			GFP_KERNEL);
kcalloc...
+			ctrl->txnt = krealloc(ctrl->txnt,
+					(i + 1) * sizeof(struct slim_msg_txn *),
+					GFP_KERNEL);
that realloc ptr use again.
+int slim_assign_laddr(struct slim_controller *ctrl, struct slim_eaddr *e_addr,
+				u8 *laddr)
[]
+			ctrl->addrt = krealloc(ctrl->addrt,
+					(ctrl->num_dev + 1) *
+					sizeof(struct slim_addrt),
+					GFP_KERNEL);
and again, I won't look for it again.
+static u16 slim_slicesize(u32 code)
+{
+	static const u8 sizetocode[16] = {0, 1, 2, 3, 3, 4, 4, 5, 5, 5, 5, 6, 6,
+						6, 6, 7};
Perhaps more style conformant as:

	static const u8 sizetocode[16] = {
		0, 1, 2, 3, 3, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7
	};
+	if (code == 0)
+		code = 1;
+	if (code > ARRAY_SIZE(sizetocode))
+		code = 16;
clamp()
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help