Hi, On 11/25/20 12:07 PM, Andy Shevchenko wrote: > On Wed, Nov 25, 2020 at 10:37 AM Hans de Goede <hdegoede@xxxxxxxxxx> wrote: >> >> bmc150 accelerometers with an ACPI hardware-id of BOSC0200 have an ACPI >> method providing their mount-matrix, add support for retrieving this. > > ... > >> + if (strcmp(dev_name(dev), "i2c-BOSC0200:base") == 0) >> + alt_name = "ROMK"; >> + else >> + alt_name = "ROMS"; >> + >> + if (acpi_has_method(adev->handle, "ROTM")) >> + name = "ROTM"; > > My gosh, it's a third method of this... > > ... > >> + elements = obj->package.elements; >> + for (i = 0; i < 3; i++) { >> + if (elements[i].type != ACPI_TYPE_STRING) >> + goto unknown_format; >> + >> + str = elements[i].string.pointer; >> + if (sscanf(str, "%d %d %d", &val[0], &val[1], &val[2]) != 3) >> + goto unknown_format; >> + >> + for (j = 0; j < 3; j++) { >> + switch (val[j]) { >> + case -1: str = "-1"; break; >> + case 0: str = "0"; break; >> + case 1: str = "1"; break; >> + default: goto unknown_format; >> + } >> + orientation->rotation[i * 3 + j] = str; >> + } >> + } > > I'm wondering if we can come up with some common code out of this and > existing apply_acpi_orientation(). Honestly they are all different enough that I don't think it is worth the trouble (I did take a look at this, but it did not seem feasible without creating horrible code). Regards, Hans