From patchwork Tue Apr 2 17:58:34 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Herrmann X-Patchwork-Id: 2379721 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id C9B333FDDA for ; Tue, 2 Apr 2013 17:59:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759195Ab3DBR7I (ORCPT ); Tue, 2 Apr 2013 13:59:08 -0400 Received: from mail-bk0-f43.google.com ([209.85.214.43]:48512 "EHLO mail-bk0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757797Ab3DBR7I (ORCPT ); Tue, 2 Apr 2013 13:59:08 -0400 Received: by mail-bk0-f43.google.com with SMTP id jm2so358081bkc.2 for ; Tue, 02 Apr 2013 10:59:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer; bh=u+EZqW08+rUr+p8XvmDh8MNc1UCYFLsjrhnaRu0ltaI=; b=pepj/f/lq/uyaWpJIKIFIIxLHfTfeb4qXtS1spX+EeQPltTCzGSzCAwbRnmB2KlA7b XZi/dof5FU92DEjA+51zYwpO2FokjfVmENqtl8yZxf4fX66vpQQ90ADNPjyuUgWjQeEL kQ6DhHrE2nVk0enUWaJ93Mohl1atz/lCsdM8tqdqnS73SjJLNrMhwMpJu30ZlnDeOUxj 39CRrIpAwkq2F890Oam1qFcx8XJVs7bugr9SsN2PSh6qUSTBNUs0NA5S4iRbS1C5Zh7s Ki5n6jKsEb5xS6zgy0KuHss1vHBIbncv+TStdWskCze4xGQd2qT5QNNiLWeVSx502Kv1 OXfg== X-Received: by 10.205.23.4 with SMTP id qy4mr7190024bkb.89.1364925546632; Tue, 02 Apr 2013 10:59:06 -0700 (PDT) Received: from localhost.localdomain (stgt-5f71b631.pool.mediaWays.net. [95.113.182.49]) by mx.google.com with ESMTPS id ge12sm1021309bkc.19.2013.04.02.10.59.04 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 02 Apr 2013 10:59:05 -0700 (PDT) From: David Herrmann To: linux-input@vger.kernel.org Cc: Jiri Kosina , David Herrmann Subject: [PATCH 1/3] HID: wiimote: use unique battery names Date: Tue, 2 Apr 2013 19:58:34 +0200 Message-Id: <1364925516-5724-1-git-send-email-dh.herrmann@gmail.com> X-Mailer: git-send-email 1.8.2 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Battery device names must be unique, otherwise registration fails if multiple Wii Remotes are connected. This breaks the sysfs API, but there is no known application that uses the Wii Remote battery that I know of so we should go ahead and apply this. Signed-off-by: David Herrmann --- drivers/hid/hid-wiimote-core.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/hid/hid-wiimote-core.c b/drivers/hid/hid-wiimote-core.c index 84e2fbe..c73bc80 100644 --- a/drivers/hid/hid-wiimote-core.c +++ b/drivers/hid/hid-wiimote-core.c @@ -1160,6 +1160,7 @@ static void wiimote_destroy(struct wiimote_data *wdata) wiimote_leds_destroy(wdata); power_supply_unregister(&wdata->battery); + kfree(wdata->battery.name); input_unregister_device(wdata->accel); input_unregister_device(wdata->ir); input_unregister_device(wdata->input); @@ -1216,9 +1217,14 @@ static int wiimote_hid_probe(struct hid_device *hdev, wdata->battery.properties = wiimote_battery_props; wdata->battery.num_properties = ARRAY_SIZE(wiimote_battery_props); wdata->battery.get_property = wiimote_battery_get_property; - wdata->battery.name = "wiimote_battery"; wdata->battery.type = POWER_SUPPLY_TYPE_BATTERY; wdata->battery.use_for_apm = 0; + wdata->battery.name = kasprintf(GFP_KERNEL, "wiimote_battery_%s", + wdata->hdev->uniq); + if (!wdata->battery.name) { + ret = -ENOMEM; + goto err_battery_name; + } ret = power_supply_register(&wdata->hdev->dev, &wdata->battery); if (ret) { @@ -1254,6 +1260,8 @@ err_free: return ret; err_battery: + kfree(wdata->battery.name); +err_battery_name: input_unregister_device(wdata->input); wdata->input = NULL; err_input: