ACPI: Do not fail acpi_bind_one() if device is already bound correctly

Modify acpi_bind_one() so that it doesn't fail if the device
represented by its first argument has already been bound to the
given ACPI handle (second argument), because that is not a good
enough reason for returning an error code.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Lan Tianyu <tianyu.lan@intel.com>
Acked-by: Toshi Kani <toshi.kani@hp.com>
ACPI: Reduce acpi_bind_one()/acpi_unbind_one() code duplication

Move some duplicated code from acpi_bind_one() and acpi_unbind_one()
into a separate function and make that function use snprintf()
instead of sprintf() for extra safety.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPI: Create symlinks in acpi_bind_one() under physical_node_lock

Put the creation of symlinks in acpi_bind_one() under the
physical_node_lock mutex of the given ACPI device object, because
that is part of the binding operation logically (those links are
already removed under that mutex too).

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPI: acpi_bind_one()/acpi_unbind_one() whitespace cleanups

Clean up some inconsistent use of whitespace in acpi_bind_one() and
acpi_unbind_one().

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPI: Use list_for_each_entry() in acpi_unbind_one()

Since acpi_unbind_one() walks physical_node_list under the ACPI
device object's physical_node_lock mutex and the walk may be
terminated as soon as the matching entry has been found, it is
not necessary to use list_for_each_safe() for that walk, so use
list_for_each_entry() instead and make the code slightly more
straightforward.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPI: Clean up error code path in acpi_unbind_one()

The error code path in acpi_unbind_one() is unnecessarily complicated
(in particular, the err label is not really necessary) and the error
message printed by it is inaccurate (there's nothing called
'acpi_handle' in that function), so clean up those things.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Merge branch 'acpi-bind-next' into bleeding-edge

* acpi-bind-next:
  ACPI: Clean up error code path in acpi_unbind_one()
  ACPI: Use list_for_each_entry() in acpi_unbind_one()
  ACPI: acpi_bind_one()/acpi_unbind_one() whitespace cleanups
  ACPI: Create symlinks in acpi_bind_one() under physical_node_lock
  ACPI: Reduce acpi_bind_one()/acpi_unbind_one() code duplication
  ACPI: Do not fail acpi_bind_one() if device is already bound correctly
cpufreq: loongson2: fix regression related to clock management

Commit 42913c799 (MIPS: Loongson2: Use clk API instead of direct
dereferences) broke the cpufreq functionality on Loongson2 boards:
clk_set_rate() is called before the CPU frequency table is
initialized, and therefore will always fail.

Fix by moving the clk_set_rate() after the table initialization.
Tested on Lemote FuLoong mini-PC.

Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Cc: 3.9+ <stable@vger.kernel.org> # 3.9+
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
cpufreq: rename ignore_nice as ignore_nice_load

This sysfs file was called ignore_nice_load earlier and commit
4d5dcc4 (cpufreq: governor: Implement per policy instances of
governors) changed its name to ignore_nice by mistake.

Lets get it renamed back to its original name.

Reported-by: Martin von Gagern <Martin.vGagern@gmx.net>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Cc: 3.10+ <stable@vger.kernel.org> # 3.10+
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Merge branch 'fixes-next' into bleeding-edge

* fixes-next:
  cpufreq: rename ignore_nice as ignore_nice_load
  cpufreq: loongson2: fix regression related to clock management