Re: [RFC PATCH 4/8] misc: emif: add basic infrastructure for EMIFdriver

From: Cousson, Benoit
Date: Fri Feb 17 2012 - 08:44:47 EST


Hi Aneesh,

On 2/17/2012 2:26 PM, Aneesh V wrote:
On Thursday 16 February 2012 10:00 PM, Cousson, Benoit wrote:
On 2/4/2012 1:16 PM, Aneesh V wrote:

[...]

+/**
+ * struct emif_data - Per device static data for driver's use
+ * @duplicate: Whether the DDR devices attached to this EMIF
+ * instance are exactly same as that on EMIF1. In
+ * this case we can save some memory and processing
+ * @temperature_level: Maximum temperature of LPDDR2 devices attached
+ * to this EMIF - read from MR4 register. If there
+ * are two devices attached to this EMIF, this
+ * value is the maximum of the two temperature
+ * levels.
+ * @irq: IRQ number

Do you really need to store the IRQ number?

Yes, I need it right now because setup_interrupts() is called later,
after the first frequency notification, because that's when I have the
registers to be programmed on a temperature event. But I am re-thinking
on this strategy. I will move it back to probe() because other
interrupts can/should be enabled at probe() time. When I do that I
won't have to store it anymore and I will remove it.

Yes, I saw the code in a later patch. But in that case you should have introduced that attribute in the patch that will use it and not before.

But I do agree, that requesting the interrupt in the probe is probably better.

[...]

+ emif = kzalloc(sizeof(struct emif_data), GFP_KERNEL);

You should use the devm_* version of this API to get the simplify the
error handling / removal.

Please note that most of my allocations are happening through
kmemdup(). kmemdup() doesn't have a devm_* equivalent. So, I have a
cleanup() function and in the interest of uniformity decided to avoid
devm_* variants altogether.

I think it still worth using devm_kzalloc + memcopy here instead of kmemdup to avoid the cleanup() and simplify as well the error handling.

You might even propose a new devm_kmemdup API if you want.

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