[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1376030744-22645-3-git-send-email-ricardo.ribalda@gmail.com>
Date: Fri, 9 Aug 2013 08:45:42 +0200
From: Ricardo Ribalda Delgado <ricardo.ribalda@...il.com>
To: Bryan Wu <cooloney@...il.com>,
Peter Meerwald <p.meerwald@...-electronic.com>,
Richard Purdie <rpurdie@...ys.net>,
Linux LED Subsystem <linux-leds@...r.kernel.org>,
LKML <linux-kernel@...r.kernel.org>
Cc: Ricardo Ribalda Delgado <ricardo.ribalda@...il.com>
Subject: [PATCH v3 2/4] leds-pca9633: Unique naming of the LEDs
If there is more than one pca963x chips on the system and there are
some LEDs without platform_data names, the driver wont be able to
provide unique naming to them.
This will cause led_class_dev_register to fail, unregistering all the
LEDs of the chip.
This patch adds the i2c address to the name of the unnamed LEDs, making
them unique.
[ 555.346827] ------------[ cut here ]------------
[ 555.346844] WARNING: at /build/linux-voe0Su/linux-3.9.8/fs/sysfs/dir.c:536 sysfs_add_one+0x8b/0x9d()
[ 555.346847] Hardware name: QT5022
[ 555.346850] sysfs: cannot create duplicate filename '/class/leds/pca9633:6'
[ 555.346853] Modules linked in: qt5038_platform(O+) leds_pca9633(O) hid_generic ledtrig_default_on rfcomm bnep bluetooth binfmt_misc nfsd auth_rpcgss nfs_acl nfs lockd dns_resolver fscache sunrpc nls_utf8 nls_cp437 vfat fat loop fuse joydev hid_multitouch usbhid hid acpi_cpufreq mperf kvm_amd kvm evdev pn533 nfc arc4 microcode pcspkr efivars k10temp ath9k ath9k_common ath9k_hw ath fglrx(PO) mac80211 cfg80211 video rfkill processor thermal_sys sp5100_tco button i2c_piix4 ext4 crc16 jbd2 mbcache sg sd_mod crc_t10dif ahci libahci igb i2c_algo_bit i2c_core dca ptp pps_core ehci_pci ohci_hcd ehci_hcd libata usbcore usb_common scsi_mod [last unloaded: leds_pca963x]
[ 555.346940] Pid: 4766, comm: insmod Tainted: P W O 3.9-1-amd64 #1 Debian 3.9.8-1
[ 555.346943] Call Trace:
[ 555.346956] [<ffffffff8103d153>] ? warn_slowpath_common+0x76/0x8c
[ 555.346962] [<ffffffff8103d202>] ? warn_slowpath_fmt+0x47/0x49
[ 555.346968] [<ffffffff8116005d>] ? sysfs_pathname+0x3b/0x41
[ 555.346973] [<ffffffff81160767>] ? sysfs_add_one+0x8b/0x9d
[ 555.346978] [<ffffffff811610a4>] ? sysfs_do_create_link_sd+0xe8/0x174
[ 555.346985] [<ffffffff81279250>] ? device_add+0x243/0x5ab
[ 555.346991] [<ffffffff81060a16>] ? complete_all+0x31/0x40
[ 555.346998] [<ffffffff8104991a>] ? init_timer_key+0xc/0x56
[ 555.347004] [<ffffffff8127964c>] ? device_create_vargs+0x82/0xb6
[ 555.347009] [<ffffffff812796af>] ? device_create+0x2f/0x31
[ 555.347014] [<ffffffff81060add>] ? should_resched+0x5/0x23
[ 555.347021] [<ffffffff812a3a92>] ? led_classdev_register+0x24/0x103
[ 555.347028] [<ffffffffa09d01c0>] ? pca9633_probe+0x173/0x239 [leds_pca9633]
[ 555.347035] [<ffffffff8127b504>] ? __driver_attach+0x73/0x73
[ 555.347049] [<ffffffffa009dfc9>] ? i2c_device_probe+0x63/0x88 [i2c_core]
[ 555.347057] [<ffffffff8127b373>] ? driver_probe_device+0x92/0x1b0
[ 555.347064] [<ffffffff81279c5c>] ? bus_for_each_drv+0x43/0x7d
[ 555.347070] [<ffffffff8127b2af>] ? device_attach+0x68/0x83
[ 555.347078] [<ffffffff8127a990>] ? bus_probe_device+0x25/0x8d
[ 555.347083] [<ffffffff812793f7>] ? device_add+0x3ea/0x5ab
[ 555.347088] [<ffffffff81060a16>] ? complete_all+0x31/0x40
[ 555.347094] [<ffffffff8104991a>] ? init_timer_key+0xc/0x56
[ 555.347104] [<ffffffffa009d3a1>] ? i2c_new_device+0x10d/0x179 [i2c_core]
[ 555.347112] [<ffffffffa008f036>] ? qt5038_init+0x36/0x1000 [qt5038_platform]
[ 555.347119] [<ffffffffa008f000>] ? 0xffffffffa008efff
[ 555.347125] [<ffffffff8100209e>] ? do_one_initcall+0x74/0x128
[ 555.347131] [<ffffffffa008f000>] ? 0xffffffffa008efff
[ 555.347137] [<ffffffff810836f5>] ? load_module+0x1af7/0x1dfc
[ 555.347144] [<ffffffff810801c5>] ? free_notes_attrs+0x3c/0x3c
[ 555.347150] [<ffffffff81083a98>] ? sys_init_module+0x9e/0xab
[ 555.347157] [<ffffffff8138be29>] ? system_call_fastpath+0x16/0x1b
[ 555.347161] ---[ end trace ad00b85794e0de4d ]---
[ 555.347448] leds-pca9633: probe of 0-006b failed with error -17
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@...il.com>
---
drivers/leds/leds-pca9633.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/leds/leds-pca9633.c b/drivers/leds/leds-pca9633.c
index 070358a..02766fb 100644
--- a/drivers/leds/leds-pca9633.c
+++ b/drivers/leds/leds-pca9633.c
@@ -159,10 +159,12 @@ static int pca9633_probe(struct i2c_client *client,
if (pdata->leds.leds[i].default_trigger)
pca9633[i].led_cdev.default_trigger =
pdata->leds.leds[i].default_trigger;
- } else {
- snprintf(pca9633[i].name, sizeof(pca9633[i].name),
- "pca9633:%d", i);
}
+ if (!pdata || i >= pdata->leds.num_leds ||
+ !pdata->leds.leds[i].name)
+ snprintf(pca9633[i].name, sizeof(pca9633[i].name),
+ "pca9633:%d:%.2x:%d", client->adapter->nr,
+ client->addr, i);
pca9633[i].led_cdev.name = pca9633[i].name;
pca9633[i].led_cdev.brightness_set = pca9633_led_set;
--
1.7.10.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists