On Thu, Jan 10, 2013 at 04:06:45PM +0000, Marc Zyngier wrote:
> +int kvm_psci_call(struct kvm_vcpu *vcpu)
> +{
> +     unsigned long psci_fn = *vcpu_reg(vcpu, 0) & ~((u32) 0);
> +     unsigned long val;
> +
> +     switch (psci_fn) {
> +     case KVM_PSCI_FN_CPU_OFF:
> +             kvm_psci_vcpu_off(vcpu);
> +             val = KVM_PSCI_RET_SUCCESS;
> +             break;
> +     case KVM_PSCI_FN_CPU_ON:
> +             val = kvm_psci_vcpu_on(vcpu);
> +             break;
> +     case KVM_PSCI_FN_CPU_SUSPEND:
> +     case KVM_PSCI_FN_MIGRATE:
> +             val = KVM_PSCI_RET_NI;
> +             break;
> +
> +     default:
> +             return -1;
> +     }
> +
> +     *vcpu_reg(vcpu, 0) = val;
> +     return 0;
> +}

We were discussing recently on #kernel about kernel APIs and the way that
our integer-returning functions pretty much use 0 for success, and -errno
for failures, whereas our pointer-returning functions are a mess.

And above we have something returning -1 to some other chunk of code outside
this compilation unit.  That doesn't sound particularly clever to me.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to