[PATCH] Make lparcfg.c work when both iseries and pseries are selected
Nathan Lynch
ntl at pobox.com
Wed Jun 28 14:05:40 EST 2006
Stephen Rothwell wrote:
> static ssize_t lparcfg_write(struct file *file, const char __user * buf,
> size_t count, loff_t * off)
> {
> + ssize_t retval = -ENOMEM;
> +#ifdef CONFIG_PPC_PSERIES
> char *kbuf;
> char *tmp;
> u64 new_entitled, *new_entitled_ptr = &new_entitled;
> @@ -479,8 +476,6 @@ static ssize_t lparcfg_write(struct file
> unsigned long resource;
> u8 current_weight;
>
> - ssize_t retval = -ENOMEM;
> -
> kbuf = kmalloc(count, GFP_KERNEL);
> if (!kbuf)
> goto out;
> @@ -546,11 +541,10 @@ static ssize_t lparcfg_write(struct file
>
> out:
> kfree(kbuf);
> +#endif /* CONFIG_PPC_PSERIES */
> return retval;
> }
Erm... this is kind of gross, and will return -ENOMEM on iSeries when
it should really return -ENOSYS (I think).
Would it be over-engineering to have an lparcfg_ops struct, with
lparcfg_read and lparcfg_write methods (and the latter would be null
on iSeries)? All the additional #ifdeffery doesn't really improve
the readability of this code IMO.
More information about the Linuxppc-dev
mailing list