Skip to contentSkip to conversation

leds: pca9532: correct shift computation in pca9532_getled

PATCH In review Moll Markus 2 participants 2 messages Sep 15, 2020 – Sep 19, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 leds: pca9532: correct shift computation in pca9532_getled

Each led occupies two bits in the register, so the required shift is LED_NUM(id) * 2, exactly as in pca9532_setled. Furthermore, irrelevant higher bits need to be masked appropriately.

The function is used to implement 'default-status = "keep"', which did not work properly before.

---
 drivers/leds/leds-pca9532.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/leds/leds-pca9532.c +1 -1
index 7d515d5e57b..d822ffcdbae 100644
@@ -260,7 +260,7 @@ static enum pca9532_state pca9532_getled(struct pca9532_led *led)
 
 mutex_lock(&data->update_lock);
 reg = i2c_smbus_read_byte_data(client, LED_REG(maxleds, led->id));
-ret = reg >> LED_NUM(led->id)/2;
+ret = (reg >> LED_NUM(led->id) * 2) & 0x3;
 mutex_unlock(&data->update_lock);
 return ret;
 }

--
2.25.1

i.A. Dr. Markus Moll
Pepperl+Fuchs SE
Geschäftsbereich VT-IVC
Lilienthalstraße 200
68307 Mannheim

Pepperl+Fuchs SE, Mannheim
Vorstände/Board members: Dr.-Ing. Gunther Kegel (Vors.), Werner Guthier (stellv. Vors.), Mehmet Hatiboglu Vorsitzender des Aufsichtsrats/Chairman of the supervisory board: Michael Fuchs sen. Registergericht/Register Court: AG Mannheim HRB 737016 - UST-ID Nr. DE 143877372

Wichtiger Hinweis:
Diese E-Mail einschliesslich ihrer Anhaenge enthaelt vertrauliche und rechtlich geschuetzte Informationen, die nur fuer den Adressaten bestimmt sind. Sollten Sie nicht der bezeichnete Adressat sein, so teilen Sie dies bitte dem Absender umgehend mit und loeschen Sie diese Nachricht und ihre Anhaenge. Die unbefugte Weitergabe, das Anfertigen von Kopien und jede Veraenderung der E-Mail ist untersagt. Der Absender haftet nicht fuer die Inhalte von veraenderten E-Mails.

Important Information:
This e-mail message including its attachments contains confidential and legally protected information solely intended for the addressee. If you are not the intended addressee of this message, please contact the addresser immediately and delete this message including its attachments. The unauthorized dissemination, copying and change of this e-mail are strictly forbidden. The addresser shall not be liable for the content of such changed e-mails.

#1 lore raw

Hi!

Quoted 6 lines

Each led occupies two bits in the register, so the required shift is LED_NUM(id) * 2, exactly as in pca9532_setled. Furthermore, irrelevant higher bits need to be masked appropriately.

The function is used to implement 'default-status = "keep"', which did not work properly before.

Actually, dropping "keep" support if noone uses it would be best.

I can take the patch, too, but it makes sense to merge the two.

Quoted 2 lines

Important Information:
This e-mail message including its attachments contains confidential

...and send it without this trailer.

Best regards,
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html