From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Alan Cox <alan@linux.intel.com>,
Sakari Ailus <sakari.ailus@linux.intel.com>,
linux-media@vger.kernel.org,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
devel@driverdev.osuosl.org, Kristian Beilke <beilke@posteo.de>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH v1 09/10] staging: atomisp: Use standard DMI match table
Date: Tue, 19 Dec 2017 22:59:56 +0200 [thread overview]
Message-ID: <20171219205957.10933-9-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20171219205957.10933-1-andriy.shevchenko@linux.intel.com>
The traditional pattern is to use DMI matching table and provide a
corresponding driver_data in it.
Convert driver to use DMI matching table.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
.../platform/intel-mid/atomisp_gmin_platform.c | 109 +++++++++++++--------
1 file changed, 70 insertions(+), 39 deletions(-)
diff --git a/drivers/staging/media/atomisp/platform/intel-mid/atomisp_gmin_platform.c b/drivers/staging/media/atomisp/platform/intel-mid/atomisp_gmin_platform.c
index 0f859bb714bf..8408a58ed764 100644
--- a/drivers/staging/media/atomisp/platform/intel-mid/atomisp_gmin_platform.c
+++ b/drivers/staging/media/atomisp/platform/intel-mid/atomisp_gmin_platform.c
@@ -209,7 +209,7 @@ struct gmin_cfg_var {
const char *name, *val;
};
-static const struct gmin_cfg_var ffrd8_vars[] = {
+static struct gmin_cfg_var ffrd8_vars[] = {
{ "INTCF1B:00_ImxId", "0x134" },
{ "INTCF1B:00_CsiPort", "1" },
{ "INTCF1B:00_CsiLanes", "4" },
@@ -220,14 +220,14 @@ static const struct gmin_cfg_var ffrd8_vars[] = {
/* Cribbed from MCG defaults in the mt9m114 driver, not actually verified
* vs. T100 hardware
*/
-static const struct gmin_cfg_var t100_vars[] = {
+static struct gmin_cfg_var t100_vars[] = {
{ "INT33F0:00_CsiPort", "0" },
{ "INT33F0:00_CsiLanes", "1" },
{ "INT33F0:00_CamClk", "1" },
{},
};
-static const struct gmin_cfg_var mrd7_vars[] = {
+static struct gmin_cfg_var mrd7_vars[] = {
{"INT33F8:00_CamType", "1"},
{"INT33F8:00_CsiPort", "1"},
{"INT33F8:00_CsiLanes", "2"},
@@ -243,7 +243,7 @@ static const struct gmin_cfg_var mrd7_vars[] = {
{},
};
-static const struct gmin_cfg_var ecs7_vars[] = {
+static struct gmin_cfg_var ecs7_vars[] = {
{"INT33BE:00_CsiPort", "1"},
{"INT33BE:00_CsiLanes", "2"},
{"INT33BE:00_CsiFmt", "13"},
@@ -258,8 +258,7 @@ static const struct gmin_cfg_var ecs7_vars[] = {
{},
};
-
-static const struct gmin_cfg_var i8880_vars[] = {
+static struct gmin_cfg_var i8880_vars[] = {
{"XXOV2680:00_CsiPort", "1"},
{"XXOV2680:00_CsiLanes", "1"},
{"XXOV2680:00_CamClk", "0"},
@@ -269,18 +268,45 @@ static const struct gmin_cfg_var i8880_vars[] = {
{},
};
-static const struct {
- const char *dmi_board_name;
- const struct gmin_cfg_var *vars;
-} hard_vars[] = {
- { "BYT-T FFD8", ffrd8_vars },
- { "T100TA", t100_vars },
- { "MRD7", mrd7_vars },
- { "ST70408", ecs7_vars },
- { "VTA0803", i8880_vars },
+static const struct dmi_system_id gmin_vars[] = {
+ {
+ .ident = "BYT-T FFD8",
+ .matches = {
+ DMI_MATCH(DMI_BOARD_NAME, "BYT-T FFD8"),
+ },
+ .driver_data = ffrd8_vars,
+ },
+ {
+ .ident = "T100TA",
+ .matches = {
+ DMI_MATCH(DMI_BOARD_NAME, "T100TA"),
+ },
+ .driver_data = t100_vars,
+ },
+ {
+ .ident = "MRD7",
+ .matches = {
+ DMI_MATCH(DMI_BOARD_NAME, "MRD7"),
+ },
+ .driver_data = mrd7_vars,
+ },
+ {
+ .ident = "ST70408",
+ .matches = {
+ DMI_MATCH(DMI_BOARD_NAME, "ST70408"),
+ },
+ .driver_data = ecs7_vars,
+ },
+ {
+ .ident = "VTA0803",
+ .matches = {
+ DMI_MATCH(DMI_BOARD_NAME, "VTA0803"),
+ },
+ .driver_data = i8880_vars,
+ },
+ {}
};
-
#define GMIN_CFG_VAR_EFI_GUID EFI_GUID(0xecb54cd9, 0xe5ae, 0x4fdc, \
0xa9, 0x71, 0xe8, 0x77, \
0x75, 0x60, 0x68, 0xf7)
@@ -604,6 +630,29 @@ int atomisp_gmin_register_vcm_control(struct camera_vcm_control *vcmCtrl)
}
EXPORT_SYMBOL_GPL(atomisp_gmin_register_vcm_control);
+static int gmin_get_hardcoded_var(struct gmin_cfg_var *varlist,
+ const char *var8, char *out, size_t *out_len)
+{
+ struct gmin_cfg_var *gv;
+
+ for (gv = varlist; gv->name; gv++) {
+ size_t vl;
+
+ if (strcmp(var8, gv->name))
+ continue;
+
+ vl = strlen(gv->val);
+ if (vl > *out_len - 1)
+ return -ENOSPC;
+
+ strcpy(out, gv->val);
+ *out_len = vl;
+ return 0;
+ }
+
+ return -EINVAL;
+}
+
/* Retrieves a device-specific configuration variable. The dev
* argument should be a device with an ACPI companion, as all
* configuration is based on firmware ID.
@@ -614,7 +663,8 @@ static int gmin_get_config_var(struct device *dev, const char *var,
char var8[CFG_VAR_NAME_MAX];
efi_char16_t var16[CFG_VAR_NAME_MAX];
struct efivar_entry *ev;
- int i, j, ret;
+ const struct dmi_system_id *id;
+ int i, ret;
if (dev && ACPI_COMPANION(dev))
dev = &ACPI_COMPANION(dev)->dev;
@@ -631,28 +681,9 @@ static int gmin_get_config_var(struct device *dev, const char *var,
* Some device firmwares lack the ability to set EFI variables at
* runtime.
*/
- for (i = 0; i < ARRAY_SIZE(hard_vars); i++) {
- if (dmi_match(DMI_BOARD_NAME, hard_vars[i].dmi_board_name)) {
- for (j = 0; hard_vars[i].vars[j].name; j++) {
- size_t vl;
- const struct gmin_cfg_var *gv;
-
- gv = &hard_vars[i].vars[j];
- vl = strlen(gv->val);
-
- if (strcmp(var8, gv->name))
- continue;
- if (vl > *out_len - 1)
- return -ENOSPC;
-
- memcpy(out, gv->val, min(*out_len, vl+1));
- out[*out_len-1] = 0;
- *out_len = vl;
-
- return 0;
- }
- }
- }
+ id = dmi_first_match(gmin_vars);
+ if (id)
+ return gmin_get_hardcoded_var(id->driver_data, var8, out, out_len);
/* Our variable names are ASCII by construction, but EFI names
* are wide chars. Convert and zero-pad.
--
2.15.1
next prev parent reply other threads:[~2017-12-19 21:01 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-19 20:59 [PATCH v1 01/10] staging: atomisp: Don't leak GPIO resources if clk_get() failed Andy Shevchenko
2017-12-19 20:59 ` [PATCH v1 02/10] staging: atomisp: Remove duplicate NULL-check Andy Shevchenko
2017-12-19 20:59 ` [PATCH v1 03/10] staging: atomisp: lm3554: Fix control values Andy Shevchenko
2017-12-19 20:59 ` [PATCH v1 04/10] staging: atomisp: Disable custom format for now Andy Shevchenko
2017-12-19 20:59 ` [PATCH v1 05/10] staging: atomisp: Remove non-ACPI leftovers Andy Shevchenko
2017-12-20 4:54 ` Dan Carpenter
2017-12-20 10:24 ` Andy Shevchenko
2017-12-21 22:34 ` Sakari Ailus
2017-12-20 5:38 ` Dan Carpenter
2017-12-20 5:38 ` Dan Carpenter
2017-12-20 10:30 ` Julia Lawall
2017-12-20 10:30 ` Julia Lawall
2018-01-02 10:26 ` Dan Carpenter
2018-01-02 10:26 ` Dan Carpenter
2018-01-02 10:36 ` Julia Lawall
2018-01-02 10:36 ` Julia Lawall
2017-12-20 12:27 ` walter harms
2017-12-20 12:36 ` Julia Lawall
2017-12-19 20:59 ` [PATCH v1 06/10] staging: atomisp: Switch to use struct device_driver directly Andy Shevchenko
2017-12-19 20:59 ` [PATCH v1 07/10] staging: atomisp: Remove redundant PCI code Andy Shevchenko
2017-12-19 20:59 ` [PATCH v1 08/10] staging: atomisp: Unexport local function Andy Shevchenko
2017-12-19 20:59 ` Andy Shevchenko [this message]
2017-12-19 20:59 ` [PATCH v1 10/10] staging: atomisp: Fix DMI matching entry for MRD7 Andy Shevchenko
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=20171219205957.10933-9-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=alan@linux.intel.com \
--cc=beilke@posteo.de \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-media@vger.kernel.org \
--cc=sakari.ailus@linux.intel.com \
/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.