-EPERM or -EINVAL always get converted to -EOPNOTSUPP, so replace them.
This will allow __hw_perf_event_init() to return a different code or not
print that particular message for a different error in the next commit.
Signed-off-by: James Clark <james.clark@arm.com>
Link: https://lore.kernel.org/r/20231211161331.1277825-10-james.clark@arm.com
Signed-off-by: Will Deacon <will@kernel.org>
 {
        unsigned long config_base = 0;
 
-       if (attr->exclude_idle)
-               return -EPERM;
+       if (attr->exclude_idle) {
+               pr_debug("ARM performance counters do not support mode exclusion\n");
+               return -EOPNOTSUPP;
+       }
        if (attr->exclude_user)
                config_base |= ARMV7_EXCLUDE_USER;
        if (attr->exclude_kernel)
 
 {
        unsigned long config_base = 0;
 
-       if (!attr->exclude_guest)
-               return -EINVAL;
+       if (!attr->exclude_guest) {
+               pr_debug("ARM performance counters do not support mode exclusion\n");
+               return -EOPNOTSUPP;
+       }
        if (!attr->exclude_kernel)
                config_base |= M1_PMU_CFG_COUNT_KERNEL;
        if (!attr->exclude_user)
 
 {
        struct arm_pmu *armpmu = to_arm_pmu(event->pmu);
        struct hw_perf_event *hwc = &event->hw;
-       int mapping;
+       int mapping, ret;
 
        hwc->flags = 0;
        mapping = armpmu->map_event(event);
        /*
         * Check whether we need to exclude the counter from certain modes.
         */
-       if (armpmu->set_event_filter &&
-           armpmu->set_event_filter(hwc, &event->attr)) {
-               pr_debug("ARM performance counters do not support "
-                        "mode exclusion\n");
-               return -EOPNOTSUPP;
+       if (armpmu->set_event_filter) {
+               ret = armpmu->set_event_filter(hwc, &event->attr);
+               if (ret)
+                       return ret;
        }
 
        /*
 
 {
        unsigned long config_base = 0;
 
-       if (attr->exclude_idle)
-               return -EPERM;
+       if (attr->exclude_idle) {
+               pr_debug("ARM performance counters do not support mode exclusion\n");
+               return -EOPNOTSUPP;
+       }
 
        /*
         * If we're running in hyp mode, then we *are* the hypervisor.