core.c (8ad17c8eb1b57f2395e2a9e43b71665d89de4f34) core.c (25419de1b8dda24f3e02478b12b724a9b0cc4e78)
1/*
2 * Generic OPP Interface
3 *
4 * Copyright (C) 2009-2010 Texas Instruments Incorporated.
5 * Nishanth Menon
6 * Romit Dasgupta
7 * Kevin Hilman
8 *

--- 1143 unchanged lines hidden (view full) ---

1152 * specify the hierarchy of versions it supports. OPP layer will then enable
1153 * OPPs, which are available for those versions, based on its 'opp-supported-hw'
1154 * property.
1155 */
1156struct opp_table *dev_pm_opp_set_supported_hw(struct device *dev,
1157 const u32 *versions, unsigned int count)
1158{
1159 struct opp_table *opp_table;
1/*
2 * Generic OPP Interface
3 *
4 * Copyright (C) 2009-2010 Texas Instruments Incorporated.
5 * Nishanth Menon
6 * Romit Dasgupta
7 * Kevin Hilman
8 *

--- 1143 unchanged lines hidden (view full) ---

1152 * specify the hierarchy of versions it supports. OPP layer will then enable
1153 * OPPs, which are available for those versions, based on its 'opp-supported-hw'
1154 * property.
1155 */
1156struct opp_table *dev_pm_opp_set_supported_hw(struct device *dev,
1157 const u32 *versions, unsigned int count)
1158{
1159 struct opp_table *opp_table;
1160 int ret;
1161
1162 opp_table = dev_pm_opp_get_opp_table(dev);
1163 if (!opp_table)
1164 return ERR_PTR(-ENOMEM);
1165
1166 /* Make sure there are no concurrent readers while updating opp_table */
1167 WARN_ON(!list_empty(&opp_table->opp_list));
1168
1160
1161 opp_table = dev_pm_opp_get_opp_table(dev);
1162 if (!opp_table)
1163 return ERR_PTR(-ENOMEM);
1164
1165 /* Make sure there are no concurrent readers while updating opp_table */
1166 WARN_ON(!list_empty(&opp_table->opp_list));
1167
1169 /* Do we already have a version hierarchy associated with opp_table? */
1170 if (opp_table->supported_hw) {
1171 dev_err(dev, "%s: Already have supported hardware list\n",
1172 __func__);
1173 ret = -EBUSY;
1174 goto err;
1175 }
1168 /* Another CPU that shares the OPP table has set the property ? */
1169 if (opp_table->supported_hw)
1170 return opp_table;
1176
1177 opp_table->supported_hw = kmemdup(versions, count * sizeof(*versions),
1178 GFP_KERNEL);
1179 if (!opp_table->supported_hw) {
1171
1172 opp_table->supported_hw = kmemdup(versions, count * sizeof(*versions),
1173 GFP_KERNEL);
1174 if (!opp_table->supported_hw) {
1180 ret = -ENOMEM;
1181 goto err;
1175 dev_pm_opp_put_opp_table(opp_table);
1176 return ERR_PTR(-ENOMEM);
1182 }
1183
1184 opp_table->supported_hw_count = count;
1185
1186 return opp_table;
1177 }
1178
1179 opp_table->supported_hw_count = count;
1180
1181 return opp_table;
1187
1188err:
1189 dev_pm_opp_put_opp_table(opp_table);
1190
1191 return ERR_PTR(ret);
1192}
1193EXPORT_SYMBOL_GPL(dev_pm_opp_set_supported_hw);
1194
1195/**
1196 * dev_pm_opp_put_supported_hw() - Releases resources blocked for supported hw
1197 * @opp_table: OPP table returned by dev_pm_opp_set_supported_hw().
1198 *
1199 * This is required only for the V2 bindings, and is called for a matching
1200 * dev_pm_opp_set_supported_hw(). Until this is called, the opp_table structure
1201 * will not be freed.
1202 */
1203void dev_pm_opp_put_supported_hw(struct opp_table *opp_table)
1204{
1205 /* Make sure there are no concurrent readers while updating opp_table */
1206 WARN_ON(!list_empty(&opp_table->opp_list));
1207
1182}
1183EXPORT_SYMBOL_GPL(dev_pm_opp_set_supported_hw);
1184
1185/**
1186 * dev_pm_opp_put_supported_hw() - Releases resources blocked for supported hw
1187 * @opp_table: OPP table returned by dev_pm_opp_set_supported_hw().
1188 *
1189 * This is required only for the V2 bindings, and is called for a matching
1190 * dev_pm_opp_set_supported_hw(). Until this is called, the opp_table structure
1191 * will not be freed.
1192 */
1193void dev_pm_opp_put_supported_hw(struct opp_table *opp_table)
1194{
1195 /* Make sure there are no concurrent readers while updating opp_table */
1196 WARN_ON(!list_empty(&opp_table->opp_list));
1197
1208 if (!opp_table->supported_hw) {
1209 pr_err("%s: Doesn't have supported hardware list\n",
1210 __func__);
1211 return;
1212 }
1213
1214 kfree(opp_table->supported_hw);
1215 opp_table->supported_hw = NULL;
1216 opp_table->supported_hw_count = 0;
1217
1218 dev_pm_opp_put_opp_table(opp_table);
1219}
1220EXPORT_SYMBOL_GPL(dev_pm_opp_put_supported_hw);
1221

--- 601 unchanged lines hidden ---
1198 kfree(opp_table->supported_hw);
1199 opp_table->supported_hw = NULL;
1200 opp_table->supported_hw_count = 0;
1201
1202 dev_pm_opp_put_opp_table(opp_table);
1203}
1204EXPORT_SYMBOL_GPL(dev_pm_opp_put_supported_hw);
1205

--- 601 unchanged lines hidden ---