From: "Marek Behún" <kabel@kernel.org>
To: linux-leds@vger.kernel.org
Cc: "Dan Murphy" <dmurphy@ti.com>, "Pavel Machek" <pavel@ucw.cz>,
"Marek Behún" <kabel@kernel.org>
Subject: [PATCH leds 1/5] leds: turris-omnia: use constants instead of macros for color command
Date: Fri, 30 Oct 2020 03:39:02 +0100 [thread overview]
Message-ID: <20201030023906.24259-1-kabel@kernel.org> (raw)
Use integer constants directly when building I2C messages for LED color
change command, instead of macros. The command is simple enough to
understand what is going on even without these names.
Signed-off-by: Marek Behún <kabel@kernel.org>
---
drivers/leds/leds-turris-omnia.c | 34 ++++++++++++--------------------
1 file changed, 13 insertions(+), 21 deletions(-)
diff --git a/drivers/leds/leds-turris-omnia.c b/drivers/leds/leds-turris-omnia.c
index 8c5bdc3847ee..80b2d94844f2 100644
--- a/drivers/leds/leds-turris-omnia.c
+++ b/drivers/leds/leds-turris-omnia.c
@@ -27,14 +27,6 @@
#define CMD_LED_SET_BRIGHTNESS 7
#define CMD_LED_GET_BRIGHTNESS 8
-#define OMNIA_CMD 0
-
-#define OMNIA_CMD_LED_COLOR_LED 1
-#define OMNIA_CMD_LED_COLOR_R 2
-#define OMNIA_CMD_LED_COLOR_G 3
-#define OMNIA_CMD_LED_COLOR_B 4
-#define OMNIA_CMD_LED_COLOR_LEN 5
-
struct omnia_led {
struct led_classdev_mc mc_cdev;
struct mc_subled subled_info[OMNIA_LED_NUM_CHANNELS];
@@ -55,21 +47,21 @@ static int omnia_led_brightness_set_blocking(struct led_classdev *cdev,
struct led_classdev_mc *mc_cdev = lcdev_to_mccdev(cdev);
struct omnia_leds *leds = dev_get_drvdata(cdev->dev->parent);
struct omnia_led *led = to_omnia_led(mc_cdev);
- u8 buf[OMNIA_CMD_LED_COLOR_LEN], state;
+ u8 buf[5], state;
int ret;
mutex_lock(&leds->lock);
led_mc_calc_color_components(&led->mc_cdev, brightness);
- buf[OMNIA_CMD] = CMD_LED_COLOR;
- buf[OMNIA_CMD_LED_COLOR_LED] = led->reg;
- buf[OMNIA_CMD_LED_COLOR_R] = mc_cdev->subled_info[0].brightness;
- buf[OMNIA_CMD_LED_COLOR_G] = mc_cdev->subled_info[1].brightness;
- buf[OMNIA_CMD_LED_COLOR_B] = mc_cdev->subled_info[2].brightness;
+ buf[0] = CMD_LED_COLOR;
+ buf[1] = led->reg;
+ buf[2] = mc_cdev->subled_info[0].brightness;
+ buf[3] = mc_cdev->subled_info[1].brightness;
+ buf[4] = mc_cdev->subled_info[2].brightness;
state = CMD_LED_STATE_LED(led->reg);
- if (buf[OMNIA_CMD_LED_COLOR_R] || buf[OMNIA_CMD_LED_COLOR_G] || buf[OMNIA_CMD_LED_COLOR_B])
+ if (buf[2] || buf[3] || buf[4])
state |= CMD_LED_STATE_ON;
ret = i2c_smbus_write_byte_data(leds->client, CMD_LED_STATE, state);
@@ -250,18 +242,18 @@ static int omnia_leds_probe(struct i2c_client *client,
static int omnia_leds_remove(struct i2c_client *client)
{
- u8 buf[OMNIA_CMD_LED_COLOR_LEN];
+ u8 buf[5];
/* put all LEDs into default (HW triggered) mode */
i2c_smbus_write_byte_data(client, CMD_LED_MODE,
CMD_LED_MODE_LED(OMNIA_BOARD_LEDS));
/* set all LEDs color to [255, 255, 255] */
- buf[OMNIA_CMD] = CMD_LED_COLOR;
- buf[OMNIA_CMD_LED_COLOR_LED] = OMNIA_BOARD_LEDS;
- buf[OMNIA_CMD_LED_COLOR_R] = 255;
- buf[OMNIA_CMD_LED_COLOR_G] = 255;
- buf[OMNIA_CMD_LED_COLOR_B] = 255;
+ buf[0] = CMD_LED_COLOR;
+ buf[1] = OMNIA_BOARD_LEDS;
+ buf[2] = 255;
+ buf[3] = 255;
+ buf[4] = 255;
i2c_master_send(client, buf, 5);
base-commit: 041883d044672852fcb8254cfc7b683fd306c943
--
2.26.2
next reply other threads:[~2020-10-30 2:39 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-30 2:39 Marek Behún [this message]
2020-10-30 2:39 ` [PATCH leds 2/5] leds: turris-omnia: wrap to 80 columns Marek Behún
2020-10-30 2:39 ` [PATCH leds 3/5] leds: turris-omnia: fix checkpatch warning Marek Behún
2020-10-30 2:39 ` [PATCH leds 4/5] dt-bindings: leds: leds-class-multicolor: use LED_COLOR_ID_RGB for now Marek Behún
2020-10-30 13:08 ` Dan Murphy
2020-10-30 21:46 ` Marek Behún
2020-11-04 21:55 ` Rob Herring
2020-11-04 21:58 ` Dan Murphy
2020-10-30 2:39 ` [PATCH leds 5/5] leds: turris-omnia: check for LED_COLOR_ID_RGB instead LED_COLOR_ID_MULTI Marek Behún
2020-11-25 12:25 ` Pavel Machek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201030023906.24259-1-kabel@kernel.org \
--to=kabel@kernel.org \
--cc=dmurphy@ti.com \
--cc=linux-leds@vger.kernel.org \
--cc=pavel@ucw.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.