Re: [RFC 5/5] clk: Add floor and ceiling constraints to clock rates

From: Thierry Reding
Date: Fri Jun 27 2014 - 19:10:37 EST


On Fri, Jun 27, 2014 at 04:57:42PM -0600, Stephen Warren wrote:
> On 06/27/2014 01:57 AM, Tomeu Vizoso wrote:
> > Adds a way for clock consumers to set maximum and minimum rates. This can be
> > used for thermal drivers to set ceiling rates, or by misc. drivers to set
> > floor rates to assure a minimum performance level.
>
> > diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
>
> > +static struct rate_constraint *__ensure_constraint(struct clk *clk_user,
> > + enum constraint_type type)
>
> > + if (!found) {
> > + constraint = kzalloc(sizeof(*constraint), GFP_KERNEL);
> > + if (!constraint) {
> > + pr_err("%s: could not allocate constraint\n", __func__);
>
> Doesn't kzalloc print an error itself if the allocation fails? I've
> certainly seen quite a few patches ripping out custom "allocation
> failed" errors in code.

Yes, these are unnecessary. There's even a checkpatch warning for this
construct nowadays:

f9a5a624f414 checkpatch: attempt to find unnecessary 'out of memory' messages

Thierry

Attachment: pgp_q8xQaaTka.pgp
Description: PGP signature