Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758221Ab3HHWMu (ORCPT ); Thu, 8 Aug 2013 18:12:50 -0400 Received: from mail-la0-f47.google.com ([209.85.215.47]:46580 "EHLO mail-la0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758174Ab3HHWMt convert rfc822-to-8bit (ORCPT ); Thu, 8 Aug 2013 18:12:49 -0400 MIME-Version: 1.0 In-Reply-To: <1375980335-19943-3-git-send-email-ricardo.ribalda@gmail.com> References: <1375980335-19943-1-git-send-email-ricardo.ribalda@gmail.com> <1375980335-19943-3-git-send-email-ricardo.ribalda@gmail.com> From: Bryan Wu Date: Thu, 8 Aug 2013 15:12:27 -0700 Message-ID: Subject: Re: [PATCH v2 2/3] leds-pca9633: Unique naming of the LEDs To: Ricardo Ribalda Delgado Cc: Peter Meerwald , Richard Purdie , Linux LED Subsystem , LKML Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5437 Lines: 92 On Thu, Aug 8, 2013 at 9:45 AM, Ricardo Ribalda Delgado wrote: > 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] [] ? warn_slowpath_common+0x76/0x8c > [ 555.346962] [] ? warn_slowpath_fmt+0x47/0x49 > [ 555.346968] [] ? sysfs_pathname+0x3b/0x41 > [ 555.346973] [] ? sysfs_add_one+0x8b/0x9d > [ 555.346978] [] ? sysfs_do_create_link_sd+0xe8/0x174 > [ 555.346985] [] ? device_add+0x243/0x5ab > [ 555.346991] [] ? complete_all+0x31/0x40 > [ 555.346998] [] ? init_timer_key+0xc/0x56 > [ 555.347004] [] ? device_create_vargs+0x82/0xb6 > [ 555.347009] [] ? device_create+0x2f/0x31 > [ 555.347014] [] ? should_resched+0x5/0x23 > [ 555.347021] [] ? led_classdev_register+0x24/0x103 > [ 555.347028] [] ? pca9633_probe+0x173/0x239 [leds_pca9633] > [ 555.347035] [] ? __driver_attach+0x73/0x73 > [ 555.347049] [] ? i2c_device_probe+0x63/0x88 [i2c_core] > [ 555.347057] [] ? driver_probe_device+0x92/0x1b0 > [ 555.347064] [] ? bus_for_each_drv+0x43/0x7d > [ 555.347070] [] ? device_attach+0x68/0x83 > [ 555.347078] [] ? bus_probe_device+0x25/0x8d > [ 555.347083] [] ? device_add+0x3ea/0x5ab > [ 555.347088] [] ? complete_all+0x31/0x40 > [ 555.347094] [] ? init_timer_key+0xc/0x56 > [ 555.347104] [] ? i2c_new_device+0x10d/0x179 [i2c_core] > [ 555.347112] [] ? qt5038_init+0x36/0x1000 [qt5038_platform] > [ 555.347119] [] ? 0xffffffffa008efff > [ 555.347125] [] ? do_one_initcall+0x74/0x128 > [ 555.347131] [] ? 0xffffffffa008efff > [ 555.347137] [] ? load_module+0x1af7/0x1dfc > [ 555.347144] [] ? free_notes_attrs+0x3c/0x3c > [ 555.347150] [] ? sys_init_module+0x9e/0xab > [ 555.347157] [] ? system_call_fastpath+0x16/0x1b > [ 555.347161] ---[ end trace ad00b85794e0de4d ]--- > [ 555.347448] leds-pca9633: probe of 0-006b failed with error -17 > This one looks good to me. Please rebase this after rework PATCH 1. Thanks, -Bryan > Signed-off-by: Ricardo Ribalda Delgado > --- > 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@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/